diff options
Diffstat (limited to 'generator')
-rw-r--r-- | generator/nanopb.proto | 1 | ||||
-rw-r--r-- | generator/nanopb_generator.py | 8 | ||||
-rw-r--r-- | generator/nanopb_pb2.py | 9 |
3 files changed, 15 insertions, 3 deletions
diff --git a/generator/nanopb.proto b/generator/nanopb.proto index b9100abd..bc40f290 100644 --- a/generator/nanopb.proto +++ b/generator/nanopb.proto @@ -11,6 +11,7 @@ enum FieldType { FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible. FT_CALLBACK = 1; // Always generate a callback field. FT_STATIC = 2; // Generate a static field or raise an exception if not possible. + FT_IGNORE = 3; // Ignore the field completely. } message NanoPBOptions { diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index a583b3f6..9e85a11d 100644 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -306,7 +306,13 @@ class Field: class Message: def __init__(self, names, desc, message_options): self.name = names - self.fields = [Field(self.name, f, get_nanopb_suboptions(f, message_options)) for f in desc.field] + self.fields = [] + + for f in desc.field: + field_options = get_nanopb_suboptions(f, message_options) + if field_options.type != nanopb_pb2.FT_IGNORE: + self.fields.append(Field(self.name, f, field_options)) + self.packed = message_options.packed_struct self.ordered_fields = self.fields[:] self.ordered_fields.sort() diff --git a/generator/nanopb_pb2.py b/generator/nanopb_pb2.py index d08b82ab..4ba18b26 100644 --- a/generator/nanopb_pb2.py +++ b/generator/nanopb_pb2.py @@ -12,7 +12,7 @@ import google.protobuf.descriptor_pb2 DESCRIPTOR = descriptor.FileDescriptor( name='nanopb.proto', package='', - serialized_pb='\n\x0cnanopb.proto\x1a google/protobuf/descriptor.proto\"\x92\x01\n\rNanoPBOptions\x12\x10\n\x08max_size\x18\x01 \x01(\x05\x12\x11\n\tmax_count\x18\x02 \x01(\x05\x12$\n\x04type\x18\x03 \x01(\x0e\x32\n.FieldType:\nFT_DEFAULT\x12\x18\n\nlong_names\x18\x04 \x01(\x08:\x04true\x12\x1c\n\rpacked_struct\x18\x05 \x01(\x08:\x05\x66\x61lse*;\n\tFieldType\x12\x0e\n\nFT_DEFAULT\x10\x00\x12\x0f\n\x0b\x46T_CALLBACK\x10\x01\x12\r\n\tFT_STATIC\x10\x02:E\n\x0enanopb_fileopt\x12\x1c.google.protobuf.FileOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:G\n\rnanopb_msgopt\x12\x1f.google.protobuf.MessageOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:E\n\x0enanopb_enumopt\x12\x1c.google.protobuf.EnumOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:>\n\x06nanopb\x12\x1d.google.protobuf.FieldOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions') + serialized_pb='\n\x0cnanopb.proto\x1a google/protobuf/descriptor.proto\"\x92\x01\n\rNanoPBOptions\x12\x10\n\x08max_size\x18\x01 \x01(\x05\x12\x11\n\tmax_count\x18\x02 \x01(\x05\x12$\n\x04type\x18\x03 \x01(\x0e\x32\n.FieldType:\nFT_DEFAULT\x12\x18\n\nlong_names\x18\x04 \x01(\x08:\x04true\x12\x1c\n\rpacked_struct\x18\x05 \x01(\x08:\x05\x66\x61lse*J\n\tFieldType\x12\x0e\n\nFT_DEFAULT\x10\x00\x12\x0f\n\x0b\x46T_CALLBACK\x10\x01\x12\r\n\tFT_STATIC\x10\x02\x12\r\n\tFT_IGNORE\x10\x03:E\n\x0enanopb_fileopt\x12\x1c.google.protobuf.FileOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:G\n\rnanopb_msgopt\x12\x1f.google.protobuf.MessageOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:E\n\x0enanopb_enumopt\x12\x1c.google.protobuf.EnumOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:>\n\x06nanopb\x12\x1d.google.protobuf.FieldOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions') _FIELDTYPE = descriptor.EnumDescriptor( name='FieldType', @@ -32,17 +32,22 @@ _FIELDTYPE = descriptor.EnumDescriptor( name='FT_STATIC', index=2, number=2, options=None, type=None), + descriptor.EnumValueDescriptor( + name='FT_IGNORE', index=3, number=3, + options=None, + type=None), ], containing_type=None, options=None, serialized_start=199, - serialized_end=258, + serialized_end=273, ) FT_DEFAULT = 0 FT_CALLBACK = 1 FT_STATIC = 2 +FT_IGNORE = 3 NANOPB_FILEOPT_FIELD_NUMBER = 1010 nanopb_fileopt = descriptor.FieldDescriptor( |