From 101759c0d67defc91e50221952de6a29071f743c Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Thu, 29 Sep 2016 13:20:52 +0200 Subject: VPP-120: include custom types to Python representation of vpe.api Change-Id: Ide97a8bf55d3baf41a1e86af2c67c6b7b26b657a Signed-off-by: Marek Gradzki --- vppapigen/node.c | 60 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'vppapigen/node.c') diff --git a/vppapigen/node.c b/vppapigen/node.c index 420a128c..fa7146ae 100644 --- a/vppapigen/node.c +++ b/vppapigen/node.c @@ -1324,26 +1324,48 @@ void add_msg_ids(YYSTYPE a1) } } -void generate_python (YYSTYPE a1, FILE *fp) -{ - node_t *np = (node_t *)a1; - node_vft_t *vftp; - fprintf (fp, "vppapidef = [\n"); - /* Walk the top-level node-list */ - while (np) { - if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { - /* Yeah, this is pedantic */ - vftp = the_vft[np->type]; - vftp->generate(np, PYTHON_PASS, fp); +void generate_python_msg_definitions(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "messages = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; } - np = np->peer; - } - fprintf (fp, "\n]\n"); - - /* - * API CRC signature - */ - fprintf (fp, "vl_api_version = 0x%08x\n\n", (unsigned int)input_crc); + fprintf (fp, "\n]\n"); +} + +void generate_python_typeonly_definitions(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "types = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && (np->flags & NODE_FLAG_TYPEONLY)) { + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; + } + fprintf (fp, "\n]\n"); +} + +void generate_python(YYSTYPE a1, FILE *fp) +{ + generate_python_typeonly_definitions(a1, fp); + generate_python_msg_definitions(a1, fp); + + /* + * API CRC signature + */ + fprintf (fp, "vl_api_version = 0x%08x\n\n", (unsigned int)input_crc); } void generate(YYSTYPE a1) -- cgit 1.2.3-korg