diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2018-03-06 10:05:44 +0100 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2018-03-06 10:09:12 +0100 |
commit | 51e59688359ddac32ed58f3add3ea9ac358c9132 (patch) | |
tree | 98308da8c6eeb9ed1da7c960f78658541c4c3aff /src/vpp-api/vapi | |
parent | 2de1f15355f9e183e46ee4ea94523a7dd4921ec0 (diff) |
API: Add service definitions for events and singleton messages (second attempt)
Based on https://gerrit.fd.io/r/#/c/10920/
Updates service definition in stats.api with correct reply message names.
Change-Id: I3282bee5304e667e23bc1fab3f43d967a50d880d
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'src/vpp-api/vapi')
-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(): |