summaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-09-11 09:53:51 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-09-11 09:53:51 +0300
commit840e213b9fa244bce4c67789971c02ce16e66295 (patch)
tree375827f43fbf1d0899a6e341320a695874ce1d17 /generator/nanopb_generator.py
parent5b9ad17dc2014d7506a7dde92281d8c36a1433e4 (diff)
Get rid of the ternary operator in the pb_field_t initialization.
Some compilers where unable to detect that the ternary operator can be evaluated at the compile time. This commit does the evaluation on the Python side, which should fix the problem. The new .pb.c files are generated using PB_FIELD2() macro. The old PB_FIELD() macro remains, so that previously generated files keep working.
Diffstat (limited to 'generator/nanopb_generator.py')
-rwxr-xr-xgenerator/nanopb_generator.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index d70938a1..e463b6ca 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -246,13 +246,14 @@ class Field:
'''Return the pb_field_t initializer to use in the constant array.
prev_field_name is the name of the previous field or None.
'''
- result = ' PB_FIELD(%3d, ' % self.tag
+ result = ' PB_FIELD2(%3d, ' % self.tag
result += '%-8s, ' % self.pbtype
result += '%s, ' % self.rules
result += '%s, ' % self.allocation
result += '%s, ' % self.struct_name
result += '%s, ' % self.name
result += '%s, ' % (prev_field_name or self.name)
+ result += '%s, ' % ("first" if not prev_field_name else "other")
if self.pbtype == 'MESSAGE':
result += '&%s_fields)' % self.submsgname