aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-09-29 13:20:52 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-09-30 07:36:32 +0200
commit101759c0d67defc91e50221952de6a29071f743c (patch)
tree4f7cc9e28c28e8b92969f13775d8baa2e35521d9
parente85581cd07cf70d19870d8f858420f252ced3405 (diff)
VPP-120: include custom types to Python representation of vpe.api
Change-Id: Ide97a8bf55d3baf41a1e86af2c67c6b7b26b657a Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rwxr-xr-xvpp-api/java/jvpp/gen/jvpp_gen.py2
-rwxr-xr-xvpp-api/python/pneum/api-gen.py2
-rw-r--r--vppapigen/node.c60
-rwxr-xr-xvppapigen/pyvppapigen.py2
4 files changed, 44 insertions, 22 deletions
diff --git a/vpp-api/java/jvpp/gen/jvpp_gen.py b/vpp-api/java/jvpp/gen/jvpp_gen.py
index d8ee6a14c75..4781ea06aa4 100755
--- a/vpp-api/java/jvpp/gen/jvpp_gen.py
+++ b/vpp-api/java/jvpp/gen/jvpp_gen.py
@@ -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
diff --git a/vpp-api/python/pneum/api-gen.py b/vpp-api/python/pneum/api-gen.py
index 081fb983539..6718de42cab 100755
--- a/vpp-api/python/pneum/api-gen.py
+++ b/vpp-api/python/pneum/api-gen.py
@@ -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)])
diff --git a/vppapigen/node.c b/vppapigen/node.c
index 420a128c00e..fa7146ae497 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)
diff --git a/vppapigen/pyvppapigen.py b/vppapigen/pyvppapigen.py
index 7fde21c5ce9..901510e0531 100755
--- a/vppapigen/pyvppapigen.py
+++ b/vppapigen/pyvppapigen.py
@@ -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:])