summaryrefslogtreecommitdiffstats
path: root/src/tools/vppapigen/vppapigen_c.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2020-11-24 23:26:06 -0500
committerOle Tr�an <otroan@employees.org>2020-12-04 09:40:27 +0000
commita51f9b3747d3e065b4bc7bb46aea8df11719b6cd (patch)
tree1f95c7a5f3c46f7741c836e183ec3d8dda937da7 /src/tools/vppapigen/vppapigen_c.py
parent86ffb6b232d5ebce03cf53249fa1514384f31cce (diff)
vppapigen: add parser support for enumflags
Type: improvement Change-Id: I0f15862cc8399a4f7c8a81fe44ba8b27d8772278 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com> Signed-off-by: Ole Troan <ot@cisco.com> (cherry picked from commit e15523297bb3905f2e0eef4272fc69a8a92463cc)
Diffstat (limited to 'src/tools/vppapigen/vppapigen_c.py')
-rw-r--r--src/tools/vppapigen/vppapigen_c.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index 4369dd86690..44f86be9222 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -32,6 +32,7 @@ import shutil
process_imports = False
+
###############################################################################
class ToJSON():
'''Class to generate functions converting from VPP binary API to JSON.'''
@@ -89,7 +90,7 @@ class ToJSON():
return 'cJSON_AddBoolToObject', '', False
# Lookup type name check if it's enum
- if vt.type == 'Enum':
+ if vt.type == 'Enum' or vt.type == 'EnumFlag':
return '{t}_tojson'.format(t=t), '', True
return '{t}_tojson'.format(t=t), '&', True
@@ -186,6 +187,7 @@ class ToJSON():
write('}\n')
_dispatch['Enum'] = print_enum
+ _dispatch['EnumFlag'] = print_enum
def print_typedef(self, o):
'''Create cJSON (dictionary) object from VPP API typedef'''
@@ -454,6 +456,7 @@ class FromJSON():
write('}\n')
_dispatch['Enum'] = print_enum
+ _dispatch['EnumFlag'] = print_enum
def print_typedef(self, o):
'''Convert from JSON object to VPP API binary representation'''
@@ -845,6 +848,7 @@ class Printfun():
write(' }\n')
_dispatch['Enum'] = print_enum
+ _dispatch['EnumFlag'] = print_enum
def print_obj(self, o, stream):
'''Entry point'''
@@ -935,7 +939,7 @@ static inline u8 *format_vl_api_{name}_t (u8 *s, va_list * args)
'''
for t in objs:
- if t.__class__.__name__ == 'Enum':
+ if t.__class__.__name__ == 'Enum' or t.__class__.__name__ == 'EnumFlag':
write(signature.format(name=t.name))
pp.print_enum(t.block, stream)
write(' return s;\n')
@@ -1071,7 +1075,7 @@ static inline void vl_api_{name}_t_endian (vl_api_{name}_t *a)
'''
for t in objs:
- if t.__class__.__name__ == 'Enum':
+ if t.__class__.__name__ == 'Enum' or t.__class__.__name__ == 'EnumFlag' :
output += signature.format(name=t.name)
if t.enumtype in ENDIAN_STRINGS:
output += (' *a = {}(*a);\n'
@@ -1191,7 +1195,7 @@ def generate_include_types(s, module, stream):
(o.alias['type'], o.name, o.alias['length']))
else:
write('typedef %s vl_api_%s_t;\n' % (o.alias['type'], o.name))
- elif tname == 'Enum':
+ elif tname == 'Enum' or tname == 'EnumFlag':
if o.enumtype == 'u32':
write("typedef enum {\n")
else: