summaryrefslogtreecommitdiffstats
path: root/extras/japi
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-11-13 12:36:56 +0100
committerFlorin Coras <florin.coras@gmail.com>2018-11-29 07:39:22 +0000
commit53fffa1db7cb04982db8977acd61b808ef60d5a8 (patch)
tree7f8c8b25b51d722cc6353c028ddad4e0ad6fcd31 /extras/japi
parent4f10db317382832068d67b5d19be4a696d80c19a (diff)
API: Add support for type aliases
Previously all types are compound. This adds support for aliases, so one can do things like: typedef u32 interface_index; or typedef u8 ip4_address[4]; Change-Id: I0455cad0123fc88acb491d2a3ea2725426bdb246 Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'extras/japi')
-rwxr-xr-xextras/japi/java/jvpp/gen/jvppgen/jvpp_model.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/extras/japi/java/jvpp/gen/jvppgen/jvpp_model.py b/extras/japi/java/jvpp/gen/jvppgen/jvpp_model.py
index 299796b908b..3c2db15d176 100755
--- a/extras/japi/java/jvpp/gen/jvppgen/jvpp_model.py
+++ b/extras/japi/java/jvpp/gen/jvppgen/jvpp_model.py
@@ -320,6 +320,7 @@ class JVppModel(object):
types = {}
self._messages = []
self._services = {}
+ self._aliases = {}
for file_name in json_api_files:
with open(file_name) as f:
j = json.load(f)
@@ -328,6 +329,8 @@ class JVppModel(object):
types.update({d[0]: {'type': 'union', 'data': d} for d in j['unions']})
self._messages.extend(j['messages'])
self._services.update(j['services'])
+ self._aliases.update(j['aliases'])
+
self._parse_types(types)
def _parse_types(self, types):
@@ -481,6 +484,10 @@ class JVppModel(object):
def _parse_field(self, field, fields):
type_name = _extract_type_name(field[0])
+ if type_name in self._aliases and type_name not in self._types_by_name:
+ aliased_type = self._types_by_name.get(self._aliases.get(type_name).get("type"))
+ self._types_by_name[type_name] = aliased_type
+
if type_name in self._types_by_name:
if len(field) > 2:
# Array field