summaryrefslogtreecommitdiffstats
path: root/vppapigen
diff options
context:
space:
mode:
Diffstat (limited to 'vppapigen')
-rw-r--r--vppapigen/gram.y2
-rw-r--r--vppapigen/node.c21
-rw-r--r--vppapigen/node.h3
3 files changed, 24 insertions, 2 deletions
diff --git a/vppapigen/gram.y b/vppapigen/gram.y
index 09e20067128..ccdcc8f2573 100644
--- a/vppapigen/gram.y
+++ b/vppapigen/gram.y
@@ -31,6 +31,7 @@ void generate (YYSTYPE);
YYSTYPE add_union(YYSTYPE, YYSTYPE);
YYSTYPE add_scalar_vbl(YYSTYPE);
YYSTYPE add_vector_vbl(YYSTYPE, YYSTYPE);
+ YYSTYPE add_variable_length_vector_vbl(YYSTYPE, YYSTYPE);
YYSTYPE set_flags(YYSTYPE, YYSTYPE);
%}
@@ -86,4 +87,5 @@ onedef: PRIMTYPE vbl SEMI {$$ = add_primtype($1, $2, 0);}
vbl: NAME {$$ = add_scalar_vbl($1);}
| NAME LBRACK NUMBER RBRACK {$$ = add_vector_vbl($1, $3);}
+ | NAME LBRACK NAME RBRACK {$$ = add_variable_length_vector_vbl($1, $3);}
;
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)
diff --git a/vppapigen/node.h b/vppapigen/node.h
index 1f5a153c24f..fc331507485 100644
--- a/vppapigen/node.h
+++ b/vppapigen/node.h
@@ -73,12 +73,13 @@ typedef struct node_ {
struct node_ *peer;
struct node_ *deeper;
int flags;
- void *data[2];
+ void *data[3];
} node_t;
/* To shut up gcc-4.2.x warnings */
#define CDATA0 ((char *)(this->data[0]))
#define IDATA1 ((int)(uword)(this->data[1]))
+#define CDATA2 ((char *)(this->data[2]))
#define NODE_FLAG_MANUAL_PRINT (1<<0)
#define NODE_FLAG_MANUAL_ENDIAN (1<<1)