aboutsummaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@github.mail.kapsi.fi>2016-10-10 07:20:49 +0300
committerGitHub <noreply@github.com>2016-10-10 07:20:49 +0300
commit060e6a6cc21eaf555cba6d3ee2558527e6790a5f (patch)
tree36020dd4606d4c9eba3c88c8827c5ebf19641393 /generator/nanopb_generator.py
parent91bb64a47b36b112c9b22391ef76fab29cf2cffc (diff)
parentee44d0cee9fa87891fdc5371578f6ff3974a8d59 (diff)
Merge pull request #216 from berni155/proto3_singular_fields_support
Proto3 singular fields support
Diffstat (limited to 'generator/nanopb_generator.py')
-rwxr-xr-xgenerator/nanopb_generator.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 973c7610..185a97bb 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -258,16 +258,18 @@ class Field:
# Check field rules, i.e. required/optional/repeated.
can_be_static = True
- if desc.label == FieldD.LABEL_REQUIRED:
- self.rules = 'REQUIRED'
- elif desc.label == FieldD.LABEL_OPTIONAL:
- self.rules = 'OPTIONAL'
- elif desc.label == FieldD.LABEL_REPEATED:
+ if desc.label == FieldD.LABEL_REPEATED:
self.rules = 'REPEATED'
if self.max_count is None:
can_be_static = False
else:
self.array_decl = '[%d]' % self.max_count
+ elif field_options.HasField("proto3"):
+ self.rules = 'SINGULAR'
+ elif desc.label == FieldD.LABEL_REQUIRED:
+ self.rules = 'REQUIRED'
+ elif desc.label == FieldD.LABEL_OPTIONAL:
+ self.rules = 'OPTIONAL'
else:
raise NotImplementedError(desc.label)