summaryrefslogtreecommitdiffstats
path: root/vppapigen
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2016-08-30 21:03:51 +0200
committerDave Wallace <dwallacelf@gmail.com>2016-09-13 01:38:14 +0000
commit1732fc1ab851c454a74efda47a383f48691d545a (patch)
treecac536fdb6d59b239a50fe38fae406a3a43b258a /vppapigen
parent01e3caa0955c644a5e4728d6eaa44f6d2f152f61 (diff)
Python API: Re-adding rudimentary variable length array pack support.
Fixed bug in message-id mapping with non-consequtive APIs. Change-Id: Icd6073e4655f7ce5432816861ae58915e5b336af Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'vppapigen')
-rwxr-xr-xvppapigen/pyvppapigen.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/vppapigen/pyvppapigen.py b/vppapigen/pyvppapigen.py
index e216169de3b..c215d15bc5d 100755
--- a/vppapigen/pyvppapigen.py
+++ b/vppapigen/pyvppapigen.py
@@ -68,7 +68,7 @@ def get_pack(f):
bytecount = 0
pack = ''
elements = 1
- if len(f) is 3 or len(f) is 4: # TODO: add support for variable length arrays (VPP-162)
+ if len(f) is 3 or len(f) is 4:
size = type_size[f[0]]
bytecount += size * int(f[2])
# Check if we have a zero length array
@@ -146,14 +146,26 @@ def encode_print(name, id, t):
if multipart == True:
print(u" results_more_set(context)")
- ### TODO deal with zeroarray!!!
- #if zeroarray == True:
- # print(u" vpp_api.write(pack('" + pack + "', " + id + ", 0, context, " + ', '.join(args[3:-1]) + ") + " + args[-1] + ")")
- #else:
- print(u" vpp_api.write(pack('" + pack + "', base + " + id + ", 0, context, " + ', '.join(args[3:]) + "))")
+ pack = '>'
+ start = 0
+ end = 0
+ offset = 0
+ t = list(t)
+ i = 0
+
+ while t:
+ t, i, pack, offset, array = get_normal_pack(t, i, pack, offset)
+ if array:
+ print(u" vpp_api.write(pack('" + pack + "', base + " +
+ id + ", 0, context, " + ', '.join(args[3:-1]) + ") + "
+ + args[-1] + ")")
+ else:
+ print(u" vpp_api.write(pack('" + pack + "', base + " + id +
+ ", 0, context, " + ', '.join(args[3:]) + "))")
if multipart == True:
- print(u" vpp_api.write(pack('>HII', VL_API_CONTROL_PING, 0, context))")
+ print(
+ u" vpp_api.write(pack('>HII', VL_API_CONTROL_PING, 0, context))")
print('''
if not async: