From 1f13e8cd2c5bb091677f35e53ae5757774e7d1ba Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Mon, 22 Jul 2013 18:59:15 +0300 Subject: Fix bugs in extension support when multiple extension fields are present. --- generator/nanopb_generator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'generator') diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 3bac9a92..f39614b3 100644 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -313,16 +313,19 @@ class ExtensionField(Field): raise NotImplementedError("Only 'optional' is supported for extension fields. " + "(%s.rules == %s)" % (self.fullname, self.rules)) + self.rules = 'OPTEXT' + def extension_decl(self): '''Declaration of the extension type in the .pb.h file''' - return 'extern const pb_extension_type_t %s;' % self.fullname + return 'extern const pb_extension_type_t %s;\n' % self.fullname def extension_def(self): '''Definition of the extension type in the .pb.c file''' + result = 'typedef struct {\n' result += str(self) - result += '} %s;\n' % self.struct_name - result += ('static const pb_field_t %s_field = %s;\n' % + result += '\n} %s;\n\n' % self.struct_name + result += ('static const pb_field_t %s_field = \n %s;\n\n' % (self.fullname, self.pb_field_t(None))) result += 'const pb_extension_type_t %s = {\n' % self.fullname result += ' NULL,\n' -- cgit 1.2.3-korg