summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-04-03 19:44:23 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-04-03 19:44:23 +0300
commit02652148fc9648e258f091298d7fae6159069823 (patch)
tree9105a76258654e78195f3d9a80d090792771e739
parent62a7e4ff2b3487ec259de90db9215c4ad8838dd6 (diff)
Generate #defines for plain message ids
-rwxr-xr-xgenerator/nanopb_generator.py10
-rw-r--r--tests/options/options.expected1
2 files changed, 8 insertions, 3 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 4673ac67..fc32e2c5 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -1005,9 +1005,8 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio
yield '#define %-40s %s\n' % (identifier, msize)
yield '\n'
- yield '/* helper macros for message type ids if set with */\n'
- yield '/* option (nanopb_msgopt).msgid = <id>; */\n\n'
-
+ yield '/* Message IDs (where set with "msgid" option) */\n'
+
yield '#ifdef PB_MSGID\n'
for msg in messages:
if hasattr(msg,'msgid'):
@@ -1026,6 +1025,11 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio
yield '\tPB_MSG(%d,%s,%s) \\\n' % (msg.msgid, m, msg.name)
yield '\n'
+ for msg in messages:
+ if hasattr(msg,'msgid'):
+ yield '#define %s_msgid %d\n' % (msg.name, msg.msgid)
+ yield '\n'
+
yield '#endif\n\n'
diff --git a/tests/options/options.expected b/tests/options/options.expected
index ad74a525..63ba0fd8 100644
--- a/tests/options/options.expected
+++ b/tests/options/options.expected
@@ -14,4 +14,5 @@ Message5_EnumValue1
\s+PB_MSG\(103,[0-9]*,Message3\) \\
\s+PB_MSG\(104,-1,Message4\) \\
\s+PB_MSG\(105,[0-9]*,Message5\) \\
+#define Message5_msgid 105