summaryrefslogtreecommitdiff
path: root/buildscripts/idl
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2021-04-13 20:52:44 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-22 00:00:27 +0000
commit8f4dbd6889eb9534da7af27729aa0c2edea532f0 (patch)
tree9849d0d59ba36bb78f8bed91d9ee23512ea116a7 /buildscripts/idl
parentccca20406141099cf6f778cd01e633ecd1fd8f11 (diff)
downloadmongo-8f4dbd6889eb9534da7af27729aa0c2edea532f0.tar.gz
SERVER-43964 UUID etc need not befriend IDL types
Diffstat (limited to 'buildscripts/idl')
-rw-r--r--buildscripts/idl/idl/cpp_types.py18
-rw-r--r--buildscripts/idl/idl/generator.py24
2 files changed, 12 insertions, 30 deletions
diff --git a/buildscripts/idl/idl/cpp_types.py b/buildscripts/idl/idl/cpp_types.py
index d4066af197f..bb7ec7d0a22 100644
--- a/buildscripts/idl/idl/cpp_types.py
+++ b/buildscripts/idl/idl/cpp_types.py
@@ -56,24 +56,6 @@ def is_primitive_scalar_type(cpp_type):
]
-def get_primitive_scalar_type_default_value(cpp_type):
- # type: (str) -> str
- """
- Return a default value for a primitive scalar type.
-
- Assumes the IDL generated code verifies the user sets the value before serialization.
- """
- # pylint: disable=invalid-name
- assert is_primitive_scalar_type(cpp_type)
- if cpp_type == 'bool':
- return 'false'
- # TODO (SERVER-50101): Remove 'FeatureCompatibility::Version' once IDL supports a command
- # cpp_type of C++ enum.
- if cpp_type == 'ServerGlobalParams::FeatureCompatibility::Version':
- return 'ServerGlobalParams::FeatureCompatibility::Version::kUnsetDefault44Behavior'
- return '-1'
-
-
def is_primitive_type(cpp_type):
# type: (str) -> bool
"""Return True if a cpp_type is a primitive type and should not be returned as reference."""
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py
index 34747fd6d24..3dc643b5075 100644
--- a/buildscripts/idl/idl/generator.py
+++ b/buildscripts/idl/idl/generator.py
@@ -1580,13 +1580,12 @@ class _CppSourceFileWriter(_CppFileWriterBase):
if default_init:
for field in struct.fields:
needs_init = (field.type and field.type.cpp_type and not field.type.is_array
- and cpp_types.is_primitive_scalar_type(field.type.cpp_type))
-
- if _is_required_serializer_field(field) and needs_init:
+ and _is_required_serializer_field(field)
+ and field.cpp_name != 'dbName')
+ if needs_init:
initializers.append(
- '%s(%s)' % (_get_field_member_name(field),
- cpp_types.get_primitive_scalar_type_default_value(
- field.type.cpp_type)))
+ '%s(mongo::idl::preparsedValue<decltype(%s)>())' %
+ (_get_field_member_name(field), _get_field_member_name(field)))
# Serialize the _dbName field second
initializes_db_name = False
@@ -1760,13 +1759,13 @@ class _CppSourceFileWriter(_CppFileWriterBase):
if struct.command_field.type.cpp_type and cpp_types.is_primitive_scalar_type(
struct.command_field.type.cpp_type):
- self._writer.write_line('%s localCmdType(%s);' %
- (cpp_type_info.get_storage_type(),
- cpp_types.get_primitive_scalar_type_default_value(
- struct.command_field.type.cpp_type)))
+ self._writer.write_line(
+ 'auto localCmdType = mongo::idl::preparsedValue<%s>();' %
+ (cpp_type_info.get_storage_type()))
else:
self._writer.write_line(
- '%s localCmdType;' % (cpp_type_info.get_storage_type()))
+ 'auto localCmdType = mongo::idl::preparsedValue<%s>();' %
+ (cpp_type_info.get_storage_type()))
self._writer.write_line(
'%s object(localCmdType);' % (common.title_case(struct.cpp_name)))
elif struct.namespace in (common.COMMAND_NAMESPACE_CONCATENATE_WITH_DB,
@@ -1777,7 +1776,8 @@ class _CppSourceFileWriter(_CppFileWriterBase):
else:
assert False, "Missing case"
else:
- self._writer.write_line('%s object;' % common.title_case(struct.cpp_name))
+ self._writer.write_line('auto object = mongo::idl::preparsedValue<%s>();' %
+ common.title_case(struct.cpp_name))
self._writer.write_line(method_info.get_call('object'))
self._writer.write_line('return object;')