summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-11-14 00:43:51 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-11-14 00:43:51 +0200
commit0abb764b1816e6a986c10c30444530e11d112cb1 (patch)
tree9f3ffc343095595b3f6391e7cf9cc8c3c7a01ca2
parent02ecee2de89f3225a6cd4bf87b0e4285bb1d06eb (diff)
Fix naming of nested Enums with short names
-rw-r--r--generator/nanopb_generator.py7
-rw-r--r--tests/options.expected1
-rw-r--r--tests/options.proto11
3 files changed, 16 insertions, 3 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 68cc800c..6aac1b8c 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -92,9 +92,9 @@ class Enum:
if enum_options.long_names:
self.values = [(self.names + x.name, x.number) for x in desc.value]
else:
- self.values = [(x.name, x.number) for x in desc.value]
+ self.values = [(names + x.name, x.number) for x in desc.value]
- self.value_longnames = [names + desc.name + x.name for x in desc.value]
+ self.value_longnames = [self.names + x.name for x in desc.value]
def __str__(self):
result = 'typedef enum _%s {\n' % self.names
@@ -395,7 +395,8 @@ def parse_file(fdesc, file_options):
message_options = get_nanopb_suboptions(message, file_options)
messages.append(Message(names, message, message_options))
for enum in message.enum_type:
- enums.append(Enum(names, enum, message_options))
+ enum_options = get_nanopb_suboptions(enum, message_options)
+ enums.append(Enum(names, enum, enum_options))
# Fix field default values where enum short names are used.
for enum in enums:
diff --git a/tests/options.expected b/tests/options.expected
index 61d9805e..93501430 100644
--- a/tests/options.expected
+++ b/tests/options.expected
@@ -3,3 +3,4 @@ char msgsize\[30\];
char fieldsize\[40\];
pb_callback_t int32_callback;
\sEnumValue1 = 1
+Message5_EnumValue1
diff --git a/tests/options.proto b/tests/options.proto
index 7eb2eb30..413d21b5 100644
--- a/tests/options.proto
+++ b/tests/options.proto
@@ -43,3 +43,14 @@ message EnumTest
{
required Enum1 field = 1 [default = EnumValue2];
}
+
+// Short enum names inside message
+message Message5
+{
+ enum Enum2
+ {
+ option (nanopb_enumopt).long_names = false;
+ EnumValue1 = 1;
+ }
+ required Enum2 field = 1 [default = EnumValue1];
+}