Add skip_message option to generator.
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>
Sun, 20 Jul 2014 11:56:12 +0000 (14:56 +0300)
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>
Sun, 20 Jul 2014 11:56:12 +0000 (14:56 +0300)
Update issue 121
Status: FixedInGit

generator/nanopb_generator.py
generator/proto/nanopb.proto
tests/options/options.expected
tests/options/options.proto

index 8ef4f18..2d2071e 100755 (executable)
@@ -639,6 +639,10 @@ def parse_file(fdesc, file_options):
     
     for names, message in iterate_messages(fdesc, base_name):
         message_options = get_nanopb_suboptions(message, file_options, names)
+        
+        if message_options.skip_message:
+            continue
+        
         messages.append(Message(names, message, message_options))
         for enum in message.enum_type:
             enum_options = get_nanopb_suboptions(enum, message_options, names + enum.name)
index 2be2f80..9a4d657 100644 (file)
@@ -37,6 +37,9 @@ message NanoPBOptions {
   // Note: this cannot be used on CPUs that break on unaligned
   // accesses to variables.
   optional bool packed_struct = 5 [default = false];
+  
+  // Skip this message
+  optional bool skip_message = 6 [default = false];
 }
 
 // Extensions to protoc 'Descriptor' type in order to define options
index e6179a2..dbd279b 100644 (file)
@@ -5,3 +5,6 @@ pb_callback_t int32_callback;
 \sEnumValue1 = 1
 Message5_EnumValue1
 } pb_packed my_packed_struct;
+! skipped_field
+! SkippedMessage
+
index b5badcf..a8e557b 100644 (file)
@@ -63,11 +63,15 @@ message my_packed_struct
 }
 
 // Message with ignored field
-// Note: doesn't really test if the field is missing in the output,
-// but atleast tests that the output compiles.
 message Message6
 {
     required int32 field1 = 1;
-    optional int32 field2 = 2 [(nanopb).type = FT_IGNORE];
+    optional int32 skipped_field = 2 [(nanopb).type = FT_IGNORE];
 }
 
+// Message that is skipped
+message SkippedMessage
+{
+    option (nanopb_msgopt).skip_message = true;
+    required int32 foo = 1;
+}