diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2016-11-22 17:24:33 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2016-11-22 17:24:33 +0200 |
commit | 3a01eea8644576d47c2cc05ad3eac900d4b8e4f4 (patch) | |
tree | 905a15ab69a99252d42610ca0fea464d84c176e9 /generator | |
parent | ad6d66010ee072043c61a533730e0691def40061 (diff) |
Small indentation and naming fixes to enum_to_string functionality
Diffstat (limited to 'generator')
-rwxr-xr-x | generator/nanopb_generator.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 36cbbdfa..066ef936 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -208,21 +208,21 @@ class Enum: result += '\n#define %s %s' % (self.value_longnames[i], x[0]) if self.options.enum_to_string: - result += '\nconst char *%s_Name(%s v);\n' % (self.names, self.names) + result += '\nconst char *%s_name(%s v);\n' % (self.names, self.names) return result - def enum_definition(self): + def enum_to_string_definition(self): if not self.options.enum_to_string: return "" - result = 'const char *%s_Name(%s v) {\n' % (self.names, self.names) + result = 'const char *%s_name(%s v) {\n' % (self.names, self.names) result += ' switch (v) {\n' for ((enumname, _), strname) in zip(self.values, self.value_longnames): # Strip off the leading type name from the string value. strval = str(strname)[len(str(self.names)) + 1:] - result += ' case %s: return "%s";\n' % (enumname, strval) + result += ' case %s: return "%s";\n' % (enumname, strval) result += ' }\n' result += ' return "unknown";\n' @@ -1242,7 +1242,7 @@ class ProtoFile: yield ext.extension_def() + '\n' for enum in self.enums: - yield enum.enum_definition() + '\n' + yield enum.enum_to_string_definition() + '\n' # Add checks for numeric limits if self.messages: |