diff options
Diffstat (limited to 'src/tools/vppapigen')
-rwxr-xr-x | src/tools/vppapigen/vppapigen.py | 2 | ||||
-rw-r--r-- | src/tools/vppapigen/vppapigen_c.py | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py index 7c596967cfb..33510b86fa8 100755 --- a/src/tools/vppapigen/vppapigen.py +++ b/src/tools/vppapigen/vppapigen.py @@ -635,7 +635,7 @@ class VPPAPIParser(object): '''counter_elements : counter_element | counter_elements counter_element''' if len(p) == 2: - p[0] = p[1] + p[0] = [p[1]] else: if type(p[1]) is dict: p[0] = [p[1], p[2]] diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index 0ded2af7a52..0798e9aca26 100644 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -73,9 +73,7 @@ class ToJSON(): write = self.stream.write write('#endif\n') - def get_json_func(self, t): - '''Given the type, returns the function to use to create a - cJSON object''' + def get_base_type(self, t): vt_type = None try: vt = self.types_hash[t] @@ -83,6 +81,12 @@ class ToJSON(): vt_type = vt.alias['type'] except KeyError: vt = t + return vt, vt_type + + def get_json_func(self, t): + '''Given the type, returns the function to use to create a + cJSON object''' + vt, vt_type = self.get_base_type(t) if t in self.is_number or vt_type in self.is_number: return 'cJSON_AddNumberToObject', '', False @@ -101,6 +105,9 @@ class ToJSON(): return 'cJSON_CreateNumber', '' if t == 'bool': return 'cJSON_CreateBool', '' + vt, vt_type = self.get_base_type(t) + if vt.type == 'Enum' or vt.type == 'EnumFlag': + return '{t}_tojson'.format(t=t), '' return '{t}_tojson'.format(t=t), '&' def print_string(self, o): @@ -1039,7 +1046,7 @@ def endianfun_array(o): ''' output = '' - if o.fieldtype == 'u8' or o.fieldtype == 'string': + if o.fieldtype == 'u8' or o.fieldtype == 'string' or o.fieldtype == 'bool': output += ' /* a->{n} = a->{n} (no-op) */\n'.format(n=o.fieldname) else: lfield = 'a->' + o.lengthfield if o.lengthfield else o.length |