aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/vppapigen/JSON.py
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-04-24 00:02:37 -0400
committerFlorin Coras <florin.coras@gmail.com>2018-05-23 16:29:47 +0000
commit2c2feab7d89239c92df4622c96e853230393deb9 (patch)
tree132f56800f7c78f236fc41f025f53ba2f4835df6 /src/tools/vppapigen/JSON.py
parent886bb1ae9b7cfef181e279f3f3b48586ea8d9ad0 (diff)
VPPAPIGEN: Add union and enum support and IP4/IP6 address type.
Note: The Python, Java and C/C++ bindings must be updated before ip/ip_types.api can be used. ip_types.api: typedef ip4_address { u8 address[4]; }; typedef ip6_address { u8 address[16]; }; enum address_family { ADDRESS_IP4 = 0, ADDRESS_IP6, }; union address_union { vl_api_ip4_address_t ip4; vl_api_ip6_address_t ip6; }; typedef address { vl_api_address_family_t af; vl_api_address_union_t un; }; Change-Id: I22f67092f24db5bd650a03c6f446a84cd9fd1074 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/tools/vppapigen/JSON.py')
-rw-r--r--src/tools/vppapigen/JSON.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/tools/vppapigen/JSON.py b/src/tools/vppapigen/JSON.py
index 73bff76cbb7..2991bec57ac 100644
--- a/src/tools/vppapigen/JSON.py
+++ b/src/tools/vppapigen/JSON.py
@@ -40,6 +40,8 @@ def walk_defs(s):
f = [b.fieldtype, b.fieldname, b.length, b.lengthfield]
else:
f = [b.fieldtype, b.fieldname, b.length]
+ elif b.type == 'Union':
+ print('UNION')
else:
raise ValueError("Error in processing array type %s" % b)
d.append(f)
@@ -58,9 +60,10 @@ def walk_defs(s):
def run(filename, s, file_crc):
j = {}
- j['types'] = walk_defs(s['typedefs'])
- j['messages'] = walk_defs(s['defines'])
- j['enums'] = walk_enums(s['enums'])
- j['services'] = walk_services(s['services'])
+ j['types'] = walk_defs([o for o in s['types'] if o.__class__.__name__ == 'Typedef'])
+ j['messages'] = walk_defs(s['Define'])
+ j['unions'] = walk_defs([o for o in s['types'] if o.__class__.__name__ == 'Union'])
+ j['enums'] = walk_enums([o for o in s['types'] if o.__class__.__name__ == 'Enum'])
+ j['services'] = walk_services(s['Service'])
j['vl_api_version'] = hex(file_crc)
return json.dumps(j, indent=4, separators=(',', ': '))