summaryrefslogtreecommitdiff
path: root/buildscripts/idl
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2019-01-08 20:53:42 +0000
committerSara Golemon <sara.golemon@mongodb.com>2019-01-08 22:27:07 +0000
commit3b1c553162427b271266a96b0f80a9b713306788 (patch)
tree28dfcfa54f9771fca0b8268b87669ce9663728d2 /buildscripts/idl
parent8604fe7f230014c4369c98d171cf791a7bc25878 (diff)
downloadmongo-3b1c553162427b271266a96b0f80a9b713306788.tar.gz
SERVER-38899 Pre-initialize declared variables from defaults
Diffstat (limited to 'buildscripts/idl')
-rw-r--r--buildscripts/idl/idl/generator.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py
index bca7da40eba..549de91f22a 100644
--- a/buildscripts/idl/idl/generator.py
+++ b/buildscripts/idl/idl/generator.py
@@ -1842,7 +1842,9 @@ class _CppSourceFileWriter(_CppFileWriterBase):
# Optional storage declarations.
if (param.cpp_vartype is not None) and (param.cpp_varname is not None):
with self._condition(param.condition, preprocessor_only=True):
- self._writer.write_line('%s %s;' % (param.cpp_vartype, param.cpp_varname))
+ init = ('{%s}' % (param.default.expr)) if param.default else ''
+ self._writer.write_line('%s %s%s;' % (param.cpp_vartype, param.cpp_varname,
+ init))
blockname = 'idl_' + uuid.uuid4().hex
with self._block('MONGO_SERVER_PARAMETER_REGISTER(%s)(InitializerContext*) {' % (blockname),
@@ -1934,7 +1936,9 @@ class _CppSourceFileWriter(_CppFileWriterBase):
has_storage_targets = True
if opt.cpp_vartype is not None:
with self._condition(opt.condition, preprocessor_only=True):
- self._writer.write_line('%s %s;' % (opt.cpp_vartype, opt.cpp_varname))
+ init = ('{%s}' % (opt.default.expr)) if opt.default else ''
+ self._writer.write_line('%s %s%s;' % (opt.cpp_vartype, opt.cpp_varname,
+ init))
self.write_empty_line()