aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-08-17 19:03:06 +0000
committerPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-08-17 19:03:06 +0000
commit7f53c3f7484679c1e38607f59542d43be1387650 (patch)
tree396198a24a1661eb7af87d0364a936d8df98a5ae /generator
parent2cefaeaf61f38f1566293e53b4708e9ceff2d945 (diff)
Example
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@957 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'generator')
-rw-r--r--generator/nanopb_generator.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index e62d04f..a6d38c0 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -124,7 +124,7 @@ class Field:
self.ctype = self.struct_name + self.name + 't'
elif desc.type == FieldD.TYPE_MESSAGE:
self.ltype = 'PB_LTYPE_SUBMESSAGE'
- self.ctype = names_from_type_name(desc.type_name)
+ self.ctype = self.submsgname = names_from_type_name(desc.type_name)
else:
raise NotImplementedError(desc.type)
@@ -167,8 +167,8 @@ class Field:
if self.max_size is None:
return None # Not implemented
else:
- array_decl = '[%d]' % self.max_size
- default = self.default.encode('string_escape')
+ array_decl = '[%d]' % (self.max_size + 1)
+ default = str(self.default).encode('string_escape')
default = default.replace('"', '\\"')
default = '"' + default + '"'
elif self.ltype == 'PB_LTYPE_BYTES':
@@ -223,7 +223,7 @@ class Field:
result += ' 0,'
if self.ltype == 'PB_LTYPE_SUBMESSAGE':
- result += '\n &%s_fields}' % self.ctype
+ result += '\n &%s_fields}' % self.submsgname
elif self.default is None or self.htype == 'PB_HTYPE_CALLBACK':
result += ' 0}'
else: