From d7a32ebd9948ff37c15d8b6e0e5d9cf243026239 Mon Sep 17 00:00:00 2001 From: Paul Vinciguerra Date: Fri, 1 May 2020 10:09:58 -0400 Subject: vapi: add support for defaults in typedefs refactored out of Neale's change: https://gerrit.fd.io/r/c/vpp/+/26276 Type: refactor Change-Id: Ibb0c019856dc44640e94d6d80a5d119a6296d95c Signed-off-by: Paul Vinciguerra (cherry picked from commit a751d8d61fe5880f6d447e63b81e2df30561e9f9) --- src/vpp-api/vapi/vapi_c_gen.py | 6 +++--- src/vpp-api/vapi/vapi_json_parser.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/vpp-api/vapi/vapi_c_gen.py b/src/vpp-api/vapi/vapi_c_gen.py index 1fae5b3310a..f0a284ccbc1 100755 --- a/src/vpp-api/vapi/vapi_c_gen.py +++ b/src/vpp-api/vapi/vapi_c_gen.py @@ -19,13 +19,13 @@ class CField(Field): else: return "vl_api_string_t %s;" % (self.name) else: - if self.len is not None: + if self.len is not None and type(self.len) != dict: return "%s %s[%d];" % (self.type.get_c_name(), self.name, self.len) else: return "%s %s;" % (self.type.get_c_name(), self.name) def get_swap_to_be_code(self, struct, var): - if self.len is not None: + if self.len is not None and type(self.len) != dict: if self.len > 0: return "do { unsigned i; for (i = 0; i < %d; ++i) { %s } }"\ " while(0);" % ( @@ -46,7 +46,7 @@ class CField(Field): return self.type.get_swap_to_be_code(struct, "%s" % var) def get_swap_to_host_code(self, struct, var): - if self.len is not None: + if self.len is not None and type(self.len) != dict: if self.len > 0: return "do { unsigned i; for (i = 0; i < %d; ++i) { %s } }"\ " while(0);" % ( diff --git a/src/vpp-api/vapi/vapi_json_parser.py b/src/vpp-api/vapi/vapi_json_parser.py index 2a03bd04c03..6d2db422c96 100644 --- a/src/vpp-api/vapi/vapi_json_parser.py +++ b/src/vpp-api/vapi/vapi_json_parser.py @@ -29,6 +29,10 @@ class Field(object): def __str__(self): if self.len is None: return "Field(name: %s, type: %s)" % (self.name, self.type) + elif type(self.len) == dict: + return "Field(name: %s, type: %s, length: %s)" % (self.name, + self.type, + self.len) elif self.len > 0: return "Field(name: %s, type: %s, length: %s)" % (self.name, self.type, -- cgit 1.2.3-korg