From 53fffa1db7cb04982db8977acd61b808ef60d5a8 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Tue, 13 Nov 2018 12:36:56 +0100 Subject: 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 Signed-off-by: Klement Sekera --- extras/japi/java/jvpp/gen/jvppgen/jvpp_model.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'extras') 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 -- cgit 1.2.3-korg