Move STATIC_ASSERTs to .pb.c file.
This way the .pb.h will remain cleaner and easier to read.
This commit is contained in:
@@ -478,6 +478,28 @@ def generate_header(dependencies, headername, enums, messages):
|
|||||||
for msg in messages:
|
for msg in messages:
|
||||||
yield msg.fields_declaration() + '\n'
|
yield msg.fields_declaration() + '\n'
|
||||||
|
|
||||||
|
yield '\n#ifdef __cplusplus\n'
|
||||||
|
yield '} /* extern "C" */\n'
|
||||||
|
yield '#endif\n'
|
||||||
|
|
||||||
|
# End of header
|
||||||
|
yield '\n#endif\n'
|
||||||
|
|
||||||
|
def generate_source(headername, enums, messages):
|
||||||
|
'''Generate content for a source file.'''
|
||||||
|
|
||||||
|
yield '/* Automatically generated nanopb constant definitions */\n'
|
||||||
|
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
|
||||||
|
yield '#include "%s"\n\n' % headername
|
||||||
|
|
||||||
|
for msg in messages:
|
||||||
|
yield msg.default_decl(False)
|
||||||
|
|
||||||
|
yield '\n\n'
|
||||||
|
|
||||||
|
for msg in messages:
|
||||||
|
yield msg.fields_definition() + '\n\n'
|
||||||
|
|
||||||
if messages:
|
if messages:
|
||||||
count_required_fields = lambda m: len([f for f in msg.fields if f.rules == 'REQUIRED'])
|
count_required_fields = lambda m: len([f for f in msg.fields if f.rules == 'REQUIRED'])
|
||||||
largest_msg = max(messages, key = count_required_fields)
|
largest_msg = max(messages, key = count_required_fields)
|
||||||
@@ -538,31 +560,11 @@ def generate_header(dependencies, headername, enums, messages):
|
|||||||
yield '\n'
|
yield '\n'
|
||||||
yield '/* On some platforms (such as AVR), double is really float.\n'
|
yield '/* On some platforms (such as AVR), double is really float.\n'
|
||||||
yield ' * These are not directly supported by nanopb, but see example_avr_double.\n'
|
yield ' * These are not directly supported by nanopb, but see example_avr_double.\n'
|
||||||
|
yield ' * To get rid of this error, remove any double fields from your .proto.\n'
|
||||||
yield ' */\n'
|
yield ' */\n'
|
||||||
yield 'STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)\n'
|
yield 'STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)\n'
|
||||||
|
|
||||||
yield '\n#ifdef __cplusplus\n'
|
yield '\n'
|
||||||
yield '} /* extern "C" */\n'
|
|
||||||
yield '#endif\n'
|
|
||||||
|
|
||||||
# End of header
|
|
||||||
yield '\n#endif\n'
|
|
||||||
|
|
||||||
def generate_source(headername, enums, messages):
|
|
||||||
'''Generate content for a source file.'''
|
|
||||||
|
|
||||||
yield '/* Automatically generated nanopb constant definitions */\n'
|
|
||||||
yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
|
|
||||||
yield '#include "%s"\n\n' % headername
|
|
||||||
|
|
||||||
for msg in messages:
|
|
||||||
yield msg.default_decl(False)
|
|
||||||
|
|
||||||
yield '\n\n'
|
|
||||||
|
|
||||||
for msg in messages:
|
|
||||||
yield msg.fields_definition() + '\n\n'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user