diff options
Diffstat (limited to 'src/vpp-api')
-rwxr-xr-x | src/vpp-api/vapi/vapi_c_gen.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vpp-api/vapi/vapi_c_gen.py b/src/vpp-api/vapi/vapi_c_gen.py index 4b7da6a1f15..60c54e4f031 100755 --- a/src/vpp-api/vapi/vapi_c_gen.py +++ b/src/vpp-api/vapi/vapi_c_gen.py @@ -70,6 +70,13 @@ class CStruct(Struct): def __init__(self, name, fields): super(CStruct, self).__init__(name, fields) + def duplicate_barrier(func): + def func_wrapper(self): + name = self.get_c_name() + return "#ifndef defined_{}\n#define defined_{}\n{}\n#endif".format(name, name, func(self)) + return func_wrapper + + @duplicate_barrier def get_c_def(self): return "\n".join([ "typedef struct __attribute__((__packed__)) {", @@ -271,6 +278,13 @@ class CMessage (Message): "}", ]) + def duplicate_barrier(func): + def func_wrapper(self): + name = self.get_payload_struct_name() + return "#ifndef defined_{}\n#define defined_{}\n{}\n#endif".format(name, name, func(self)) + return func_wrapper + + @duplicate_barrier def get_c_def(self): if self.has_payload(): return "\n".join([ @@ -585,9 +599,12 @@ def gen_json_unified_header(parser, logger, j, io, name): print("") function_attrs = "static inline " for t in parser.types_by_json[j].values(): + print("#ifndef defined_inline_%s" % t.get_c_name()) + print("#define defined_inline_%s" % t.get_c_name()) print("%s%s" % (function_attrs, t.get_swap_to_be_func_def())) print("") print("%s%s" % (function_attrs, t.get_swap_to_host_func_def())) + print("#endif") print("") for m in parser.messages_by_json[j].values(): if m.has_payload(): |