VAPI: support enums & unions
Change-Id: I76ac7e4eeb6a300538d52a0e355d66937764a4d1
Signed-off-by: Klement Sekera <ksekera@cisco.com>
diff --git a/src/vpp-api/vapi/vapi_cpp_gen.py b/src/vpp-api/vapi/vapi_cpp_gen.py
index 3260268..6b62bc4 100755
--- a/src/vpp-api/vapi/vapi_cpp_gen.py
+++ b/src/vpp-api/vapi/vapi_cpp_gen.py
@@ -4,8 +4,8 @@
import os
import sys
import logging
-from vapi_c_gen import CField, CStruct, CSimpleType, CStructType, CMessage, \
- json_to_c_header_name
+from vapi_c_gen import CField, CEnum, CStruct, CSimpleType, CStructType,\
+ CMessage, json_to_c_header_name
from vapi_json_parser import JsonParser
@@ -17,6 +17,10 @@
pass
+class CppEnum(CEnum):
+ pass
+
+
class CppSimpleType (CSimpleType):
pass
@@ -69,7 +73,7 @@
return "%s%s" % (self.name[0].upper(), self.name[1:])
def get_req_template_name(self):
- if self.is_dump():
+ if self.reply_is_stream:
template = "Dump"
else:
template = "Request"
@@ -159,7 +163,7 @@
print("/* m.get_cpp_constructor() */")
print("%s" % m.get_cpp_constructor())
print("")
- if not m.is_reply():
+ if not m.is_reply and not m.is_event:
if add_debug_comments:
print("/* m.get_alloc_template_instantiation() */")
print("%s" % m.get_alloc_template_instantiation())
@@ -168,7 +172,7 @@
print("/* m.get_msg_class_instantiation() */")
print("%s" % m.get_msg_class_instantiation())
print("")
- if m.is_reply():
+ if m.is_reply or m.is_event:
if add_debug_comments:
print("/* m.get_reply_type_alias() */")
print("%s" % m.get_reply_type_alias())
@@ -246,6 +250,7 @@
simple_type_class=CppSimpleType,
struct_type_class=CppStructType,
field_class=CppField,
+ enum_class=CppEnum,
message_class=CppMessage)
gen_cpp_headers(jsonparser, logger, args.prefix, args.gen_h_prefix,