diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2015-09-12 12:15:27 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2015-09-12 12:15:27 +0300 |
commit | 612a51c608504f59fcd86c74eedac2903f088a0a (patch) | |
tree | 6646ab479a95ecc6280696edb3fe5730d0fcd555 /generator/nanopb_generator.py | |
parent | 5497a1dfc91a86965383cdd1652e348345400435 (diff) |
Add packed_enum option to generator.
This can be generally useful for saving RAM, but also makes
it easier to test for issue #164.
Diffstat (limited to 'generator/nanopb_generator.py')
-rwxr-xr-x | generator/nanopb_generator.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 8fd45372..aaa0d2f1 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -160,11 +160,17 @@ class Enum: self.values = [(names + x.name, x.number) for x in desc.value] self.value_longnames = [self.names + x.name for x in desc.value] + self.packed = enum_options.packed_enum def __str__(self): result = 'typedef enum _%s {\n' % self.names result += ',\n'.join([" %s = %d" % x for x in self.values]) - result += '\n} %s;' % self.names + result += '\n}' + + if self.packed: + result += ' pb_packed' + + result += ' %s;' % self.names if not self.options.long_names: # Define the long names always so that enum value references |