summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-11-02 22:05:49 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-11-02 22:05:49 +0200
commitdcdd7f98fdb000859a9e2812174a817431b1af34 (patch)
treeca74462b612bd31da927506e45c981349a088828 /generator
parent287207841db5df93cf7ff9c71a5f1548deb26b09 (diff)
Generate #define tags for extension fields also.
Update issue 93 Status: FixedInGit
Diffstat (limited to 'generator')
-rwxr-xr-xgenerator/nanopb_generator.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 89647c2c..3c248ac3 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -423,6 +423,11 @@ class ExtensionField(Field):
self.skip = False
self.rules = 'OPTEXT'
+ def tags(self):
+ '''Return the #define for the tag number of this field.'''
+ identifier = '%s_tag' % self.fullname
+ return '#define %-40s %d\n' % (identifier, self.tag)
+
def extension_decl(self):
'''Declaration of the extension type in the .pb.h file'''
if self.skip:
@@ -709,6 +714,8 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio
for msg in sort_dependencies(messages):
for field in msg.fields:
yield field.tags()
+ for extension in extensions:
+ yield extension.tags()
yield '\n'
yield '/* Struct field encoding specification for nanopb */\n'