From 662bda610555e026222a2812272e46c31de64da8 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Tue, 7 Oct 2025 21:28:25 +0200 Subject: [PATCH] SERVER-98435 Rename MONGO_MOD_PUB -> MONGO_MOD_PUBLIC (#42272) GitOrigin-RevId: 1588849c60a72fb542ad88d7faefe8458aed5341 --- buildscripts/idl/idl/errors.py | 2 +- buildscripts/idl/idl/parser.py | 2 +- buildscripts/idl/idl_schema.yml | 5 +++-- modules_poc/README.md | 4 ++-- src/mongo/bson/bsonobj.h | 2 +- .../db/repl/replication_consistency_markers.idl | 2 +- src/mongo/util/modules.h | 15 +++++++++------ 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/buildscripts/idl/idl/errors.py b/buildscripts/idl/idl/errors.py index 3e112369b8d..72af26ac940 100644 --- a/buildscripts/idl/idl/errors.py +++ b/buildscripts/idl/idl/errors.py @@ -1335,7 +1335,7 @@ class ParserContext(object): self._add_node_error( node, ERROR_ID_BAD_VISIBILITY, - f"Bad visibility value '{mod_visibility}', only pub, pub_for_technical_reasons, private, file_private, needs_replacement, and use_replacement(...) are accepted", + f"Bad visibility value '{mod_visibility}', only public, public_for_technical_reasons, private, file_private, needs_replacement, and use_replacement(...) are accepted", ) diff --git a/buildscripts/idl/idl/parser.py b/buildscripts/idl/idl/parser.py index f70d36e9f1a..ee3c340342b 100644 --- a/buildscripts/idl/idl/parser.py +++ b/buildscripts/idl/idl/parser.py @@ -225,7 +225,7 @@ def _parse_config_global(ctxt, node): _mod_visibility_pattern = re.compile( - "(pub|pub_for_technical_reasons|private|file_private|needs_replacement|use_replacement\(.+\))" + "(pub|public|public_for_technical_reasons|private|file_private|needs_replacement|use_replacement\(.+\))" ) diff --git a/buildscripts/idl/idl_schema.yml b/buildscripts/idl/idl_schema.yml index a9ea13e94d4..177bf0fef0d 100644 --- a/buildscripts/idl/idl_schema.yml +++ b/buildscripts/idl/idl_schema.yml @@ -108,8 +108,9 @@ description: Schema for IDL files in the mongo codebase. oneOf: - type: string enum: - - pub - - pub_for_technical_reasons + - pub # deprecated alias for public + - public + - public_for_technical_reasons - private - file_private - needs_replacement diff --git a/modules_poc/README.md b/modules_poc/README.md index b93ee15fb79..172539782ec 100644 --- a/modules_poc/README.md +++ b/modules_poc/README.md @@ -92,11 +92,11 @@ To make an API or class available for use by other modules, add a tag to its header declaration. ``` -class MONGO_MOD_PUB Foo { +class MONGO_MOD_PUBLIC Foo { }; -MONGO_MOD_PUB int foo(); +MONGO_MOD_PUBLIC int foo(); ``` Availability specification can also be done at the namespace level. diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h index 57ee21026c3..7b51a45c169 100644 --- a/src/mongo/bson/bsonobj.h +++ b/src/mongo/bson/bsonobj.h @@ -119,7 +119,7 @@ class LegacyStrictGenerator; Code With Scope: \endcode */ -class MONGO_MOD_PUB BSONObj { +class MONGO_MOD_PUBLIC BSONObj { public: struct DefaultSizeTrait { constexpr static int MaxSize = BSONObjMaxInternalSize; diff --git a/src/mongo/db/repl/replication_consistency_markers.idl b/src/mongo/db/repl/replication_consistency_markers.idl index 0da53f5554d..6ad1598c860 100644 --- a/src/mongo/db/repl/replication_consistency_markers.idl +++ b/src/mongo/db/repl/replication_consistency_markers.idl @@ -30,7 +30,7 @@ global: cpp_namespace: "mongo::repl" - mod_visibility: pub_for_technical_reasons + mod_visibility: public_for_technical_reasons imports: - "mongo/db/basic_types.idl" diff --git a/src/mongo/util/modules.h b/src/mongo/util/modules.h index a70e024d496..6518480f07b 100644 --- a/src/mongo/util/modules.h +++ b/src/mongo/util/modules.h @@ -52,7 +52,10 @@ * default all hierarchies are closed within their module unless explicitly marked as open. * See MONGO_MOD_OPEN below. */ -#define MONGO_MOD_PUB MONGO_MOD_ATTR_(public) +#define MONGO_MOD_PUBLIC MONGO_MOD_ATTR_(public) + +/// Deprecated alias for MONGO_MOD_PUBLIC. TODO: All usages will be converted soon. +#define MONGO_MOD_PUB MONGO_MOD_PUBLIC /** * Marks a class as open and everything inside as public to other modules. @@ -61,8 +64,8 @@ * levels. * * If we later decide we do not like this distinction, we can easily just sed this macro away - * and use MONGO_MOD_PUB everywhere. But it will be easier to start with the distinction than to add - * it later. + * and use MONGO_MOD_PUBLIC everywhere. But it will be easier to start with the distinction than to + * add it later. * * NOTE: unlike other markers openness is *not* applied recursively, so each type that should * support external subclasses must be separately marked as open. @@ -72,7 +75,7 @@ /** * Marks a declaration which the module owner would prefer to be * private, but for which there is currently no good alternative - * for out-of-module usage. Allows external usage like MONGO_MOD_PUB, + * for out-of-module usage. Allows external usage like MONGO_MOD_PUBLIC, * but gives a warning to the module owner. */ #define MONGO_MOD_NEEDS_REPLACEMENT MONGO_MOD_ATTR_(needs_replacement) @@ -80,7 +83,7 @@ * Marks a declaration which the module owner would prefer to be * private, but for which there are historical uses outside the * module which haven't been cleaned up yet. Allows external usage - * like MONGO_MOD_PUB, but gives a warning to each caller for usage + * like MONGO_MOD_PUBLIC, but gives a warning to each caller for usage * outside the module. */ #define MONGO_MOD_USE_REPLACEMENT(replacement) MONGO_MOD_ATTR_(use_replacement::replacement) @@ -92,7 +95,7 @@ * currently need to be public, even if they aren't directly used externally. * In almost all cases, MONGO_MOD_NEEDS_REPLACEMENT should be used instead. */ -#define MONGO_MOD_PUB_FOR_TECHNICAL_REASONS MONGO_MOD_ATTR_(public) +#define MONGO_MOD_PUBLIC_FOR_TECHNICAL_REASONS MONGO_MOD_ATTR_(public) /** Marks a declaration and everything inside as private from other modules */ #define MONGO_MOD_PRIVATE MONGO_MOD_ATTR_(private)