VPP-120: include custom types to Python representation of vpe.api 98/3198/3
authorMarek Gradzki <mgradzki@cisco.com>
Thu, 29 Sep 2016 11:20:52 +0000 (13:20 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Fri, 30 Sep 2016 05:36:32 +0000 (07:36 +0200)
Change-Id: Ide97a8bf55d3baf41a1e86af2c67c6b7b26b657a
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
vpp-api/java/jvpp/gen/jvpp_gen.py
vpp-api/python/pneum/api-gen.py
vppapigen/node.c
vppapigen/pyvppapigen.py

index d8ee6a1..4781ea0 100755 (executable)
@@ -109,7 +109,7 @@ def get_definitions():
     # Pass 1
     func_list = []
     func_name = {}
-    for a in cfg.vppapidef:
+    for a in cfg.messages:
         if not is_supported(a[0]):
             continue
 
index 081fb98..6718de4 100755 (executable)
@@ -119,7 +119,7 @@ def get_definitions():
     func_list = []
     func_name = {}
     i = 1
-    for a in cfg.vppapidef:
+    for a in cfg.messages:
         pack, packlen, tup, zeroarray = get_pack(a[1:])
         func_name[a[0]] = dict([('name', a[0]), ('pack', pack), ('packlen', packlen), ('tup', tup), ('args', get_args(a[1:])),
                                 ('zeroarray', zeroarray)])
index 420a128..fa7146a 100644 (file)
@@ -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)
index 7fde21c..901510e 100755 (executable)
@@ -267,7 +267,7 @@ api_func_table = []
 api_name_to_id = {}
     ''')
 
-    for i, a in enumerate(vppapidef):
+    for i, a in enumerate(messages):
         name = a[0]
         encode_print(name, str(i), a[1:])
         decode_print(name, a[1:])