summaryrefslogtreecommitdiffstats
path: root/vppapigen/node.c
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-06-15 16:38:33 +0200
committerDave Wallace <dwallacelf@gmail.com>2016-06-24 13:23:16 +0000
commitfa42e25c4e498c57e15ebb0ded56502a61b7dc08 (patch)
treea6a79850ddab1e962c9f639050a09925fe57c9f0 /vppapigen/node.c
parent80ee21386cea217d0e9292d2a8b15ea88bf99d30 (diff)
VPP-118: add support for variable length arrays to jvpp
* extends VPP's message definition language with the following syntax: u32 count: u8 array[count]; which is traslated to: u32 count; u8 array[0]; but now, python API representation generated by vppapigen contains information about where the array length is stored. * modifies existing response messages to use the new syntax Change-Id: I68210bc7a3a755d03d067e9b79a567f40e2d31f3 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vppapigen/node.c')
-rw-r--r--vppapigen/node.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/vppapigen/node.c b/vppapigen/node.c
index 2fb65c2d60b..30a3b017190 100644
--- a/vppapigen/node.c
+++ b/vppapigen/node.c
@@ -1161,7 +1161,11 @@ void node_vector_generate (node_t *this, enum passid which, FILE *fp)
fprintf(fp, "}\n");
break;
case PYTHON_PASS:
- fprintf(fp, "'%s', '%d'),\n", CDATA0, IDATA1);
+ if (CDATA2 != 0) { // variable length vector
+ fprintf(fp, "'%s', '%d', '%s'),\n", CDATA0, IDATA1, CDATA2);
+ } else {
+ fprintf(fp, "'%s', '%d'),\n", CDATA0, IDATA1);
+ }
break;
default:
@@ -1461,6 +1465,21 @@ YYSTYPE add_vector_vbl (YYSTYPE a1, YYSTYPE a2)
}
/*
+ * add_vector_vbl (char *vector_name, char *vector_length_var)
+ */
+
+YYSTYPE add_variable_length_vector_vbl (YYSTYPE vector_name, YYSTYPE vector_length_var)
+{
+ node_t *np;
+
+ np = make_node(NODE_VECTOR);
+ np->data[0] = (void *) vector_name;
+ np->data[1] = (void *) 0; // vector size used for vpe.api.h generation (array of length zero)
+ np->data[2] = (void *) vector_length_var; // name of the variable that stores vector length
+ return ((YYSTYPE) np);
+}
+
+/*
* add_scalar_vbl (char *name)
*/
YYSTYPE add_scalar_vbl (YYSTYPE a1)