node_vft_t node_u8_vft = {
node_u8_print,
node_u8_generate,
- ""
+ NULL
};
void node_u16_print (node_t *this)
CDATA0, current_endianfun,
union_prefix, CDATA0);
} else {
- fprintf(fp, "/* a->%s%s = a->%s%s */\n",
+ fprintf(fp, "/* a->%s%s = a->%s%s (no-op) */\n",
union_prefix, CDATA0,
union_prefix, CDATA0);
}
/* Don't bother about "u8 data [0];" et al. */
if (IDATA1 == 0)
break;
+ /* If this is a simple endian swap, but the endian swap method is a no-op,
+ * then indicate this is a no-op in a comment.
+ */
+ if (!current_is_complex && current_endianfun == NULL) {
+ indent_me(fp);
+ fprintf(fp, "/* a->%s%s[0..%d] = a->%s%s[0..%d] (no-op) */\n",
+ union_prefix, CDATA0, IDATA1 - 1,
+ union_prefix, CDATA0, IDATA1 - 1);
+ break;
+ }
indent_me(fp);
fprintf(fp, "{\n");
if (*cp == '/')
cp++;
- strcpy (tmpbuf, cp);
+ strncpy (tmpbuf, cp, sizeof(tmpbuf)-1);
cp = tmpbuf;
}
}
-void generate_python (YYSTYPE a1, FILE *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;
+ }
+ 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, "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);
+ 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;
}
- np = np->peer;
- }
- fprintf (fp, "\n]\n");
+ 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)