diff options
author | Arun Banala <arun.banala@mongodb.com> | 2020-11-02 18:09:28 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-07 20:04:53 +0000 |
commit | c8ddb496f147e5a977eb668247b81da313d06e1d (patch) | |
tree | 34ba0cc443ec6294c5585d0951d5430cc69349e2 /buildscripts/idl/idl | |
parent | d0cfd1d0c0fcfd75525a8d8f3a050876bc9d1e40 (diff) | |
download | mongo-c8ddb496f147e5a977eb668247b81da313d06e1d.tar.gz |
SERVER-51619 Convert find command input to IDL
Diffstat (limited to 'buildscripts/idl/idl')
-rw-r--r-- | buildscripts/idl/idl/ast.py | 1 | ||||
-rw-r--r-- | buildscripts/idl/idl/binder.py | 1 | ||||
-rw-r--r-- | buildscripts/idl/idl/parser.py | 2 | ||||
-rw-r--r-- | buildscripts/idl/idl/struct_types.py | 14 | ||||
-rw-r--r-- | buildscripts/idl/idl/syntax.py | 1 |
5 files changed, 11 insertions, 8 deletions
diff --git a/buildscripts/idl/idl/ast.py b/buildscripts/idl/idl/ast.py index 600117685b5..7f3d998842c 100644 --- a/buildscripts/idl/idl/ast.py +++ b/buildscripts/idl/idl/ast.py @@ -108,6 +108,7 @@ class Struct(common.SourceLocation): self.generate_comparison_operators = False # type: bool self.fields = [] # type: List[Field] self.allow_global_collection_name = False # type: bool + self.non_const_getter = False # type: bool super(Struct, self).__init__(file_name, line, column) diff --git a/buildscripts/idl/idl/binder.py b/buildscripts/idl/idl/binder.py index b02186cf383..0c42b7b85e6 100644 --- a/buildscripts/idl/idl/binder.py +++ b/buildscripts/idl/idl/binder.py @@ -261,6 +261,7 @@ def _bind_struct_common(ctxt, parsed_spec, struct, ast_struct): ast_struct.generate_comparison_operators = struct.generate_comparison_operators ast_struct.cpp_name = struct.name ast_struct.allow_global_collection_name = struct.allow_global_collection_name + ast_struct.non_const_getter = struct.non_const_getter if struct.cpp_name: ast_struct.cpp_name = struct.cpp_name diff --git a/buildscripts/idl/idl/parser.py b/buildscripts/idl/idl/parser.py index a144a7d6f94..319173a69d0 100644 --- a/buildscripts/idl/idl/parser.py +++ b/buildscripts/idl/idl/parser.py @@ -457,6 +457,7 @@ def _parse_struct(ctxt, spec, name, node): "inline_chained_structs": _RuleDesc("bool_scalar"), "immutable": _RuleDesc('bool_scalar'), "generate_comparison_operators": _RuleDesc("bool_scalar"), + "non_const_getter": _RuleDesc('bool_scalar'), }) spec.symbols.add_struct(ctxt, struct) @@ -637,6 +638,7 @@ def _parse_command(ctxt, spec, name, node): "immutable": _RuleDesc('bool_scalar'), "generate_comparison_operators": _RuleDesc("bool_scalar"), "allow_global_collection_name": _RuleDesc('bool_scalar'), + "non_const_getter": _RuleDesc('bool_scalar'), }) valid_commands = [ diff --git a/buildscripts/idl/idl/struct_types.py b/buildscripts/idl/idl/struct_types.py index e32f5b88e1b..1e0081b4f4c 100644 --- a/buildscripts/idl/idl/struct_types.py +++ b/buildscripts/idl/idl/struct_types.py @@ -484,6 +484,8 @@ class _CommandWithNamespaceTypeInfo(_CommandBaseTypeInfo): def gen_getter_method(self, indented_writer): # type: (writer.IndentedTextWriter) -> None indented_writer.write_line('const NamespaceString& getNamespace() const { return _nss; }') + if self._struct.non_const_getter: + indented_writer.write_line('NamespaceString& getNamespace() { return _nss; }') def gen_member(self, indented_writer): # type: (writer.IndentedTextWriter) -> None @@ -558,6 +560,9 @@ class _CommandWithUUIDNamespaceTypeInfo(_CommandBaseTypeInfo): # type: (writer.IndentedTextWriter) -> None indented_writer.write_line( 'const NamespaceStringOrUUID& getNamespaceOrUUID() const { return _nssOrUUID; }') + if self._struct.non_const_getter: + indented_writer.write_line( + 'NamespaceStringOrUUID& getNamespaceOrUUID() { return _nssOrUUID; }') def gen_member(self, indented_writer): # type: (writer.IndentedTextWriter) -> None @@ -565,14 +570,7 @@ class _CommandWithUUIDNamespaceTypeInfo(_CommandBaseTypeInfo): def gen_serializer(self, indented_writer): # type: (writer.IndentedTextWriter) -> None - indented_writer.write_line('invariant(_nssOrUUID.nss() || _nssOrUUID.uuid());') - # Prefer the uuid over the nss for serialization - with writer.IndentedScopedBlock(indented_writer, "if( _nssOrUUID.uuid() ) {", "}"): - indented_writer.write_line( - '_nssOrUUID.uuid().get().appendToBuilder(builder, "%s"_sd);' % (self._command.name)) - with writer.IndentedScopedBlock(indented_writer, "else {", "}"): - indented_writer.write_line( - 'builder->append("%s"_sd, _nssOrUUID.nss().get().coll());' % (self._command.name)) + indented_writer.write_line('_nssOrUUID.serialize(builder, "%s"_sd);' % (self._command.name)) indented_writer.write_empty_line() def gen_namespace_check(self, indented_writer, db_name, element): diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py index 26f5218f768..d441c2b4c06 100644 --- a/buildscripts/idl/idl/syntax.py +++ b/buildscripts/idl/idl/syntax.py @@ -411,6 +411,7 @@ class Struct(common.SourceLocation): self.chained_structs = None # type: List[ChainedStruct] self.fields = None # type: List[Field] self.allow_global_collection_name = False # type: bool + self.non_const_getter = False # type: bool # Command only property self.cpp_name = None # type: str |