diff options
author | Ole Troan <ot@cisco.com> | 2018-11-13 12:36:56 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2018-11-29 07:39:22 +0000 |
commit | 53fffa1db7cb04982db8977acd61b808ef60d5a8 (patch) | |
tree | 7f8c8b25b51d722cc6353c028ddad4e0ad6fcd31 /src/tools/vppapigen/vppapigen_c.py | |
parent | 4f10db317382832068d67b5d19be4a696d80c19a (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 'src/tools/vppapigen/vppapigen_c.py')
-rw-r--r-- | src/tools/vppapigen/vppapigen_c.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index b56e0722122..2a66ff3159e 100644 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -94,7 +94,7 @@ def duplicate_wrapper_tail(): return '#endif\n\n' -def typedefs(objs, filename): +def typedefs(objs, aliases, filename): name = filename.replace('.', '_') output = '''\ @@ -106,6 +106,15 @@ def typedefs(objs, filename): #define included_{module} ''' output = output.format(module=name) + + for k, v in aliases.items(): + output += duplicate_wrapper_head(k) + if 'length' in v: + output += 'typedef %s vl_api_%s_t[%s];\n' % (v['type'], k, v['length']) + else: + output += 'typedef %s vl_api_%s_t;\n' % (v['type'], k) + output += duplicate_wrapper_tail() + for o in objs: tname = o.__class__.__name__ output += duplicate_wrapper_head(o.name) @@ -276,7 +285,7 @@ def run(input_filename, s, file_crc): output += msg_ids(s) output += msg_names(s) output += msg_name_crc_list(s, filename) - output += typedefs(s['types'] + s['Define'], filename + file_extension) + output += typedefs(s['types'] + s['Define'], s['Alias'], filename + file_extension) output += printfun(s['types'] + s['Define']) output += endianfun(s['types'] + s['Define']) output += version_tuple(s, basename) |