aboutsummaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'generator/nanopb_generator.py')
-rw-r--r--generator/nanopb_generator.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index bffdb35..a583b3f 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -307,6 +307,7 @@ class Message:
def __init__(self, names, desc, message_options):
self.name = names
self.fields = [Field(self.name, f, get_nanopb_suboptions(f, message_options)) for f in desc.field]
+ self.packed = message_options.packed_struct
self.ordered_fields = self.fields[:]
self.ordered_fields.sort()
@@ -317,7 +318,12 @@ class Message:
def __str__(self):
result = 'typedef struct _%s {\n' % self.name
result += '\n'.join([str(f) for f in self.ordered_fields])
- result += '\n} %s;' % self.name
+ result += '\n}'
+
+ if self.packed:
+ result += ' pb_packed'
+
+ result += ' %s;' % self.name
return result
def types(self):