diff options
author | Ole Troan <ot@cisco.com> | 2018-11-28 11:36:05 +0100 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-12-13 12:11:50 +0000 |
commit | 413f4a5b2123c1625d615315db293a080078482b (patch) | |
tree | 6cfd8376c1d84b93793b062731ec9594487dc95e /src/tools | |
parent | 6f666ad99ae1e384aa851af5e0feed3d2a25e709 (diff) |
API: Use string type instead of u8.
The new string type is modelled after string in proto3.
It is always variable length.
Change-Id: I64884067e28a80072c8dac31b7c7c82d6e306051
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/vppapigen/vppapigen_c.py | 16 | ||||
-rw-r--r-- | src/tools/vppapigen/vppapigen_json.py | 11 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index f0fb00831c3..e189b024454 100644 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -3,7 +3,8 @@ import datetime import os import time -datestring = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) +datestring = datetime.datetime.utcfromtimestamp( + int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) input_filename = 'inputfil' top_boilerplate = '''\ /* @@ -94,6 +95,13 @@ def duplicate_wrapper_tail(): return '#endif\n\n' +def api2c(fieldtype): + mappingtable = {'string': 'vl_api_string_t', } + if fieldtype in mappingtable: + return mappingtable[fieldtype] + return fieldtype + + def typedefs(objs, aliases, filename): name = filename.replace('.', '_') output = '''\ @@ -130,12 +138,12 @@ def typedefs(objs, aliases, filename): output += "typedef VL_API_PACKED(struct _vl_api_%s {\n" % o.name for b in o.block: if b.type == 'Field': - output += " %s %s;\n" % (b.fieldtype, b.fieldname) + output += " %s %s;\n" % (api2c(b.fieldtype), b.fieldname) elif b.type == 'Array': if b.lengthfield: - output += " %s %s[0];\n" % (b.fieldtype, b.fieldname) + output += " %s %s[0];\n" % (api2c(b.fieldtype), b.fieldname) else: - output += " %s %s[%s];\n" % (b.fieldtype, b.fieldname, + output += " %s %s[%s];\n" % (api2c(b.fieldtype), b.fieldname, b.length) else: raise ValueError("Error in processing array type %s" % b) diff --git a/src/tools/vppapigen/vppapigen_json.py b/src/tools/vppapigen/vppapigen_json.py index b57e16c990d..a4707c0cd60 100644 --- a/src/tools/vppapigen/vppapigen_json.py +++ b/src/tools/vppapigen/vppapigen_json.py @@ -32,19 +32,18 @@ def walk_defs(s): d = [] d.append(t.name) for b in t.block: - f = [] if b.type == 'Field': - f = [b.fieldtype, b.fieldname] + d.append([b.fieldtype, b.fieldname]) elif b.type == 'Array': if b.lengthfield: - f = [b.fieldtype, b.fieldname, b.length, b.lengthfield] + d.append([b.fieldtype, b.fieldname, b.length, b.lengthfield]) else: - f = [b.fieldtype, b.fieldname, b.length] + d.append([b.fieldtype, b.fieldname, b.length]) elif b.type == 'Union': - print('UNION') + pass else: raise ValueError("Error in processing array type %s" % b) - d.append(f) + if t.crc: c = {} c['crc'] = "{0:#0{1}x}".format(t.crc, 10) |