diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2015-04-03 19:44:23 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2015-04-03 19:44:23 +0300 |
commit | 02652148fc9648e258f091298d7fae6159069823 (patch) | |
tree | 9105a76258654e78195f3d9a80d090792771e739 /generator | |
parent | 62a7e4ff2b3487ec259de90db9215c4ad8838dd6 (diff) |
Generate #defines for plain message ids
Diffstat (limited to 'generator')
-rwxr-xr-x | generator/nanopb_generator.py | 10 |
1 files changed, 7 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' |