From 1dd9f1900fca0c137324c05a9421f1ba180b2470 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Mon, 18 Aug 2014 20:09:52 +0300 Subject: Change the _count fields to use pb_size_t datatype. Update issue 82 Status: FixedInGit --- generator/nanopb_generator.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'generator') diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 1d12ae3..88e9798 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -261,7 +261,7 @@ class Field: result = '' if self.allocation == 'POINTER': if self.rules == 'REPEATED': - result += ' size_t ' + self.name + '_count;\n' + result += ' pb_size_t ' + self.name + '_count;\n' if self.pbtype == 'MESSAGE': # Use struct definition, so recursive submessages are possible @@ -277,17 +277,14 @@ class Field: if self.rules == 'OPTIONAL' and self.allocation == 'STATIC': result += ' bool has_' + self.name + ';\n' elif self.rules == 'REPEATED' and self.allocation == 'STATIC': - result += ' size_t ' + self.name + '_count;\n' + result += ' pb_size_t ' + self.name + '_count;\n' result += ' %s %s%s;' % (self.ctype, self.name, self.array_decl) return result def types(self): '''Return definitions for any special types this field might need.''' if self.pbtype == 'BYTES' and self.allocation == 'STATIC': - result = 'typedef struct {\n' - result += ' size_t size;\n' - result += ' uint8_t bytes[%d];\n' % self.max_size - result += '} %s;\n' % self.ctype + result = 'typedef PB_BYTES_ARRAY_T(%d) %s;\n' % (self.max_size, self.ctype) else: result = None return result -- cgit 1.2.3-korg