aboutsummaryrefslogtreecommitdiffstats
path: root/vppapigen
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@qosmos.com>2016-09-22 21:00:17 +0200
committerOle Trøan <otroan@employees.org>2016-10-26 13:02:41 +0000
commit513da53d96731002bb24285413c7646e25210ac8 (patch)
tree68b631ee93bbc0d701efdcc592bccdfec84e7dff /vppapigen
parent5d4759b0c98e96a7aafc14876d58a7eb85feacc5 (diff)
python api - vla - allow the user to pass in a normal python list
Only add support for named variable-length-arrays as some api fo not follow the expected order of length preceding the value. Change-Id: I4c22c9b3c05f23edb3edc1cbc445be87b0a69162 Signed-off-by: Gabriel Ganne <gabriel.ganne@qosmos.com>
Diffstat (limited to 'vppapigen')
-rwxr-xr-xvppapigen/pyvppapigen.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/vppapigen/pyvppapigen.py b/vppapigen/pyvppapigen.py
index 75d6a1416fa..675712ab616 100755
--- a/vppapigen/pyvppapigen.py
+++ b/vppapigen/pyvppapigen.py
@@ -150,11 +150,20 @@ def encode_print(name, id, t):
# first, deal with all the other fields
pack = '>' + ''.join([get_pack(f)[0] for f in t[:-1]])
- # now see if the last field is a vla
- if len(t[-1]) >= 3 and t[-1][2] == '0':
+ # named variable-length-array
+ if len(t[-1]) == 4 and t[-1][2] == '0' and t[-1][3] == t[-2][1]:
+ print(u" vpp_api.write(pack('" + pack + "', base + "
+ + id + ", 0, context, " + ', '.join(args[3:-2] + ["len(" + args[-1] + ")"])
+ + ") + " + args[-1] + ")")
+
+ # unnamed variable-length-array
+ elif len(t[-1]) >= 3 and t[-1][2] == '0':
print(u" vpp_api.write(pack('" + pack + "', base + " +
id + ", 0, context, " + ', '.join(args[3:-1]) + ") + "
+ args[-1] + ")")
+
+
+ # not a variable-length-array
else:
pack += get_pack(t[-1])[0]
print(u" vpp_api.write(pack('" + pack + "', base + " + id +