summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2016-12-22 17:37:14 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2016-12-22 17:37:14 +0200
commit283258dca59c470e8e209431e206a344839e0cf5 (patch)
tree4dff46a4aaa3b3a496e7e7f1b6b423b542193a14 /generator
parent58af4d1fb733c5348b68dd3980f2a230d95400b4 (diff)
Allow overriding proto3 mode (#228)
Diffstat (limited to 'generator')
-rwxr-xr-xgenerator/nanopb_generator.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 066ef936..a2ee22db 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -285,7 +285,7 @@ class Field:
can_be_static = False
else:
self.array_decl = '[%d]' % self.max_count
- elif field_options.HasField("proto3"):
+ elif field_options.proto3:
self.rules = 'SINGULAR'
elif desc.label == FieldD.LABEL_REQUIRED:
self.rules = 'REQUIRED'
@@ -1373,6 +1373,9 @@ def get_nanopb_suboptions(subdesc, options, name):
new_options = nanopb_pb2.NanoPBOptions()
new_options.CopyFrom(options)
+ if hasattr(subdesc, 'syntax') and subdesc.syntax == "proto3":
+ new_options.proto3 = True
+
# Handle options defined in a separate file
dotname = '.'.join(name.parts)
for namemask, options in Globals.separate_options:
@@ -1380,9 +1383,6 @@ def get_nanopb_suboptions(subdesc, options, name):
Globals.matched_namemasks.add(namemask)
new_options.MergeFrom(options)
- if hasattr(subdesc, 'syntax') and subdesc.syntax == "proto3":
- new_options.proto3 = True
-
# Handle options defined in .proto
if isinstance(subdesc.options, descriptor.FieldOptions):
ext_type = nanopb_pb2.nanopb