Code Review
/
apps
/
agl-service-can-low-level.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Verify build with protobuf-3.0.0, fix problems.
[apps/agl-service-can-low-level.git]
/
generator
/
nanopb_generator.py
diff --git
a/generator/nanopb_generator.py
b/generator/nanopb_generator.py
index
80fb93c
..
19771a7
100755
(executable)
--- a/
generator/nanopb_generator.py
+++ b/
generator/nanopb_generator.py
@@
-1,7
+1,7
@@
#!/usr/bin/python
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
#!/usr/bin/python
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
-nanopb_version = "nanopb-0.3.
0
-dev"
+nanopb_version = "nanopb-0.3.
2
-dev"
import sys
import sys
@@
-361,7
+361,7
@@
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.
'''
'''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
2
(%3d, ' % self.tag
+ result = ' PB_FIELD(%3d, ' % self.tag
result += '%-8s, ' % self.pbtype
result += '%s, ' % self.rules
result += '%-8s, ' % self.allocation
result += '%-8s, ' % self.pbtype
result += '%s, ' % self.rules
result += '%-8s, ' % self.allocation
@@
-546,7
+546,7
@@
class Message:
def get_dependencies(self):
'''Get list of type names that this structure refers to.'''
def get_dependencies(self):
'''Get list of type names that this structure refers to.'''
- return [str(field.ctype) for field in self.fields]
+ return [str(field.ctype) for field in self.fields
if field.allocation == 'STATIC'
]
def __str__(self):
result = 'typedef struct _%s {\n' % self.name
def __str__(self):
result = 'typedef struct _%s {\n' % self.name
@@
-596,6
+596,8
@@
class Message:
else:
parts.append(field.get_initializer(null_init))
elif field.allocation == 'POINTER':
else:
parts.append(field.get_initializer(null_init))
elif field.allocation == 'POINTER':
+ if field.rules == 'REPEATED':
+ parts.append('0')
parts.append('NULL')
elif field.allocation == 'CALLBACK':
if field.pbtype == 'EXTENSION':
parts.append('NULL')
elif field.allocation == 'CALLBACK':
if field.pbtype == 'EXTENSION':
@@
-768,8
+770,8
@@
def generate_header(dependencies, headername, enums, messages, extensions, optio
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
symbol = make_identifier(headername)
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
symbol = make_identifier(headername)
- yield '#ifndef
_PB_%s_
\n' % symbol
- yield '#define
_PB_%s_
\n' % symbol
+ yield '#ifndef
PB_%s_INCLUDED
\n' % symbol
+ yield '#define
PB_%s_INCLUDED
\n' % symbol
try:
yield options.libformat % ('pb.h')
except TypeError:
try:
yield options.libformat % ('pb.h')
except TypeError:
@@
-782,6
+784,11
@@
def generate_header(dependencies, headername, enums, messages, extensions, optio
yield options.genformat % (noext + options.extension + '.h')
yield '\n'
yield options.genformat % (noext + options.extension + '.h')
yield '\n'
+ yield '#if PB_PROTO_HEADER_VERSION != 30\n'
+ yield '#error Regenerate this file with the current version of nanopb generator.\n'
+ yield '#endif\n'
+ yield '\n'
+
yield '#ifdef __cplusplus\n'
yield 'extern "C" {\n'
yield '#endif\n\n'
yield '#ifdef __cplusplus\n'
yield 'extern "C" {\n'
yield '#endif\n\n'
@@
-854,6
+861,11
@@
def generate_source(headername, enums, messages, extensions, options):
yield options.genformat % (headername)
yield '\n'
yield options.genformat % (headername)
yield '\n'
+ yield '#if PB_PROTO_HEADER_VERSION != 30\n'
+ yield '#error Regenerate this file with the current version of nanopb generator.\n'
+ yield '#endif\n'
+ yield '\n'
+
for msg in messages:
yield msg.default_decl(False)
for msg in messages:
yield msg.default_decl(False)