aboutsummaryrefslogtreecommitdiffstats
path: root/vppapigen/lex.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2016-04-09 03:16:30 +0200
committerDave Wallace <dwallacelf@gmail.com>2016-04-20 16:50:29 +0000
commit6855f6cdfee8c479f1e0ae440ce87a91ff41a708 (patch)
treee438e21c8107a675dc3a3141c6af6ba0ab458992 /vppapigen/lex.c
parent633951c3d8dc1640813b4778f3e35463d08f3795 (diff)
Python-API: Inital commit of Python bindings for the VPP API.
See: https://wiki.fd.io/view/VPP/Python_API Change-Id: If135fc32208c7031787e1935b399d930e0e1ea1f Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'vppapigen/lex.c')
-rw-r--r--vppapigen/lex.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/vppapigen/lex.c b/vppapigen/lex.c
index b41eb5ec665..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;
@@ -260,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) {
@@ -364,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) {
@@ -399,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);
@@ -424,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);
@@ -441,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);
@@ -452,7 +481,7 @@ int main (int argc, char **argv)
static void usage (char *progname)
{
fprintf (stderr,
- "usage: %s --input <filename> [--output <filename>]\n%s",
+ "usage: %s --input <filename> [--output <filename>] [--python <filename>]\n%s",
progname,
" [--yydebug] [--dump-tree]\n");
exit (1);