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
Include package name in include guard (issue #207).
[apps/agl-service-can-low-level.git]
/
generator
/
nanopb_generator.py
diff --git
a/generator/nanopb_generator.py
b/generator/nanopb_generator.py
index
60dc7e8
..
9cf2de5
100755
(executable)
--- a/
generator/nanopb_generator.py
+++ b/
generator/nanopb_generator.py
@@
-3,7
+3,7
@@
from __future__ import unicode_literals
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
from __future__ import unicode_literals
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
-nanopb_version = "nanopb-0.3.
6
-dev"
+nanopb_version = "nanopb-0.3.
7
-dev"
import sys
import re
import sys
import re
@@
-197,6
+197,10
@@
class Enum:
result += ' %s;' % self.names
result += ' %s;' % self.names
+ result += '\n#define _%s_MIN %s' % (self.names, self.values[0][0])
+ result += '\n#define _%s_MAX %s' % (self.names, self.values[-1][0])
+ result += '\n#define _%s_ARRAYSIZE ((%s)(%s+1))' % (self.names, self.names, self.values[-1][0])
+
if not self.options.long_names:
# Define the long names always so that enum value references
# from other files work properly.
if not self.options.long_names:
# Define the long names always so that enum value references
# from other files work properly.
@@
-213,7
+217,7
@@
class FieldMaxSize:
self.worst = worst
self.worst_field = field_name
self.worst = worst
self.worst_field = field_name
- self.checks =
checks
+ self.checks =
list(checks)
def extend(self, extend, field_name = None):
self.worst = max(self.worst, extend.worst)
def extend(self, extend, field_name = None):
self.worst = max(self.worst, extend.worst)
@@
-1041,7
+1045,10
@@
class ProtoFile:
else:
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
else:
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
- symbol = make_identifier(headername)
+ if self.fdesc.package:
+ symbol = make_identifier(self.fdesc.package + '_' + headername)
+ else:
+ symbol = make_identifier(headername)
yield '#ifndef PB_%s_INCLUDED\n' % symbol
yield '#define PB_%s_INCLUDED\n' % symbol
try:
yield '#ifndef PB_%s_INCLUDED\n' % symbol
yield '#define PB_%s_INCLUDED\n' % symbol
try:
@@
-1115,9
+1122,11
@@
class ProtoFile:
yield '/* Maximum encoded size of messages (where known) */\n'
for msg in self.messages:
msize = msg.encoded_size(self.dependencies)
yield '/* Maximum encoded size of messages (where known) */\n'
for msg in self.messages:
msize = msg.encoded_size(self.dependencies)
+ identifier = '%s_size' % msg.name
if msize is not None:
if msize is not None:
- identifier = '%s_size' % msg.name
yield '#define %-40s %s\n' % (identifier, msize)
yield '#define %-40s %s\n' % (identifier, msize)
+ else:
+ yield '/* %s depends on runtime parameters */\n' % identifier
yield '\n'
yield '/* Message IDs (where set with "msgid" option) */\n'
yield '\n'
yield '/* Message IDs (where set with "msgid" option) */\n'