diff options
author | Ole Troan <ot@cisco.com> | 2018-03-01 14:53:12 +0100 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-03-05 16:44:28 +0000 |
commit | f7b7fa53b7eaec81d8c00c1023fb7d01f1f9761f (patch) | |
tree | 4367f86fbb2c335c0e6d893a3eb6981ea7a63927 /src/vpp-api | |
parent | f313b747ad4313a5cadfdb6aa7eb66ce8bf7958f (diff) |
API: Add service definitions for events and singleton messages.
Change-Id: I7de987c30b263d43521e6280c5273f30b5f6e11c
Signed-off-by: Ole Troan <ot@cisco.com>
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(): |