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'
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:
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
env.NanopbProto("options")
env.Object('options.pb.c')
-
env.Match(['options.pb.h', 'options.expected'])
+env.NanopbProto("proto3_options")
+env.Object('proto3_options.pb.c')
+env.Match(['proto3_options.pb.h', 'proto3_options.expected'])
+
--- /dev/null
+syntax = "proto3";
+
+import "nanopb.proto";
+
+message Message1
+{
+ int32 proto3_default = 1;
+ int32 proto3_off = 2 [(nanopb).proto3 = false];
+ int32 proto3_on = 3 [(nanopb).proto3 = true];
+}
+