Generate #define tags for extension fields also.
Update issue 93 Status: FixedInGit
This commit is contained in:
@@ -423,6 +423,11 @@ class ExtensionField(Field):
|
|||||||
self.skip = False
|
self.skip = False
|
||||||
self.rules = 'OPTEXT'
|
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):
|
def extension_decl(self):
|
||||||
'''Declaration of the extension type in the .pb.h file'''
|
'''Declaration of the extension type in the .pb.h file'''
|
||||||
if self.skip:
|
if self.skip:
|
||||||
@@ -709,6 +714,8 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio
|
|||||||
for msg in sort_dependencies(messages):
|
for msg in sort_dependencies(messages):
|
||||||
for field in msg.fields:
|
for field in msg.fields:
|
||||||
yield field.tags()
|
yield field.tags()
|
||||||
|
for extension in extensions:
|
||||||
|
yield extension.tags()
|
||||||
yield '\n'
|
yield '\n'
|
||||||
|
|
||||||
yield '/* Struct field encoding specification for nanopb */\n'
|
yield '/* Struct field encoding specification for nanopb */\n'
|
||||||
|
|||||||
@@ -46,5 +46,9 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream));
|
fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream));
|
||||||
return 1; /* Failure */
|
return 1; /* Failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check that the field tags are properly generated */
|
||||||
|
(void)AllTypes_extensionfield1_tag;
|
||||||
|
(void)ExtensionMessage_AllTypes_extensionfield2_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user