diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2017-05-17 10:52:53 -0400 |
---|---|---|
committer | Gabriel Russell <gabriel.russell@mongodb.com> | 2017-05-17 11:55:17 -0400 |
commit | d99b57425c5c29e8f5f834146994509939c2d2f7 (patch) | |
tree | d9f5f0694d850a974c58f21eb4c02bf947ec18f5 /buildscripts | |
parent | 2482a5807dfa624f358569c727ff3b96ccfd8922 (diff) | |
download | mongo-d99b57425c5c29e8f5f834146994509939c2d2f7.tar.gz |
SERVER-29046 IDL constants should use cpp_name instead of field name
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/idl/idl/generator.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py index df7b75df4bb..2d8937be02c 100644 --- a/buildscripts/idl/idl/generator.py +++ b/buildscripts/idl/idl/generator.py @@ -325,14 +325,15 @@ class _CppHeaderFileWriter(_CppFileWriterBase): # type: (ast.Struct) -> None # pylint: disable=invalid-name """Generate a StringData constant for field name.""" - field_names = sorted([field.name for field in struct.fields if not field.ignore]) + sorted_fields = sorted( + [field for field in struct.fields if not field.ignore], key=lambda f: f.cpp_name) - for field_name in field_names: + for field in sorted_fields: self._writer.write_line( common.template_args( 'static constexpr auto k${constant_name}FieldName = "${field_name}"_sd;', - constant_name=common.title_case(field_name), - field_name=field_name)) + constant_name=common.title_case(field.cpp_name), + field_name=field.name)) def gen_enum_functions(self, idl_enum): # type: (ast.Enum) -> None @@ -839,14 +840,15 @@ class _CppSourceFileWriter(_CppFileWriterBase): # Generate a sorted list of string constants - field_names = sorted([field.name for field in struct.fields if not field.ignore]) + sorted_fields = sorted( + [field for field in struct.fields if not field.ignore], key=lambda f: f.cpp_name) - for field_name in field_names: + for field in sorted_fields: self._writer.write_line( common.template_args( 'constexpr StringData ${class_name}::k${constant_name}FieldName;', class_name=common.title_case(struct.name), - constant_name=common.title_case(field_name))) + constant_name=common.title_case(field.cpp_name))) def gen_enum_definition(self, idl_enum): # type: (ast.Enum) -> None |