From fa42e25c4e498c57e15ebb0ded56502a61b7dc08 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Wed, 15 Jun 2016 16:38:33 +0200 Subject: 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 --- vppapigen/node.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'vppapigen/node.c') diff --git a/vppapigen/node.c b/vppapigen/node.c index 2fb65c2d..30a3b017 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: @@ -1460,6 +1464,21 @@ YYSTYPE add_vector_vbl (YYSTYPE a1, YYSTYPE a2) return ((YYSTYPE) np); } +/* + * 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) */ -- cgit 1.2.3-korg