X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vppapigen%2Flex.c;h=f1d49a877e8abe2c9a6e64081432747e4e99fb0a;hb=e0965d4e05c3d43cec43c1fd31d6bc774ca79310;hp=b9dc833ad232a5c73add091d7e1eb72d257f7aeb;hpb=cb9cadad578297ffd78fa8a33670bdf1ab669e7e;p=vpp.git diff --git a/vppapigen/lex.c b/vppapigen/lex.c index b9dc833ad23..f1d49a877e8 100644 --- a/vppapigen/lex.c +++ b/vppapigen/lex.c @@ -28,7 +28,7 @@ #include "node.h" #include "gram.h" -FILE *ifp, *ofp, *javafp, *jnifp; +FILE *ifp, *ofp, *javafp, *jnifp, *pythonfp; char *java_class = "vppApi"; char *vlib_app_name = "vpp"; int dump_tree; @@ -54,6 +54,7 @@ static void usage (char *); static int name_check (const char *, YYSTYPE *); static int name_compare (const char *, const char *); extern int yydebug; +extern YYSTYPE yylval; unsigned int crc32c_table[256] = { 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, @@ -259,6 +260,7 @@ int main (int argc, char **argv) char *ofile=0; char *jofile=0; char *jnifile=0; + char *pythonfile=0; char *show_name=0; while (curarg < argc) { @@ -363,6 +365,23 @@ int main (int argc, char **argv) } continue; } + if (!strncmp (argv [curarg], "--python", 8)) { + curarg++; + if (curarg < argc) { + pythonfp = fopen (argv[curarg], "w"); + if (pythonfp == NULL) { + fprintf (stderr, "Couldn't open python output file %s\n", + argv[curarg]); + exit (1); + } + pythonfile = argv[curarg]; + curarg++; + } else { + fprintf(stderr, "Missing filename after --python\n"); + exit(1); + } + continue; + } if (!strncmp (argv [curarg], "--app", 4)) { curarg++; if (curarg < argc) { @@ -398,6 +417,9 @@ int main (int argc, char **argv) if (jnifp == NULL) { jnifile = 0; } + if (pythonfp == NULL) { + pythonfile = 0; + } if (ifp == NULL) { fprintf(stderr, "No input file specified...\n"); exit(1); @@ -423,6 +445,10 @@ int main (int argc, char **argv) printf ("Java native bindings written to %s\n", jnifile); fclose (jnifp); } + if (pythonfile) { + printf ("Python bindings written to %s\n", pythonfile); + fclose (pythonfp); + } } else { fclose (ifp); @@ -440,6 +466,10 @@ int main (int argc, char **argv) printf ("Removing %s\n", jnifile); unlink (jnifile); } + if (pythonfile) { + printf ("Removing %s\n", pythonfile); + unlink (pythonfile); + } exit (1); } exit (0); @@ -451,7 +481,7 @@ int main (int argc, char **argv) static void usage (char *progname) { fprintf (stderr, - "usage: %s --input [--output ]\n%s", + "usage: %s --input [--output ] [--python ]\n%s", progname, " [--yydebug] [--dump-tree]\n"); exit (1);