From ac1a7286500c18ac51beb66e4a2b99ea26c8c966 Mon Sep 17 00:00:00 2001 From: Matej Perina Date: Mon, 11 Sep 2017 10:11:51 +0200 Subject: jvpp: adding callbacks for all messages (VPP-914) 1) In the previous version callbacks were generated based on request-replay naming conventions. It turned out they were too strict in case of events (e.g. BFD sends Details messages as notifications). So now we generate callback for all messages, allowing to receive any message as notification.(callback_gen.py) 2) "notification" suffix is no longer added because all messages are treated same (dto_gen.py, jvpp_c_gen_.py) 3) name of property that holds notification/events changed in callback facade and future apis 4) JVppNotification.java is no longer used since all events are treated equally Change-Id: I13f6438affc3473040d63cd4acb3984d03e97482 Signed-off-by: Matej --- src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py | 49 +++++++++++++++++++++------- 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py') diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py index e831557c15a..e94bbc5cb28 100644 --- a/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py +++ b/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py @@ -35,6 +35,23 @@ $methods } """) +dto_template_typeless = Template(""" +package $plugin_package.$dto_package; + +/** + *

This class represents $description. + *
It was generated by dto_gen.py based on $inputfile preparsed data: + *

+$docs
+ * 
+ */ +public final class $cls_name { + +$fields +$methods +} +""") + field_template = Template(""" public $type $name;\n""") send_template = Template(""" @Override @@ -93,9 +110,7 @@ def generate_dtos(func_list, base_package, plugin_package, plugin_name, dto_pack # for structures that are also used as notifications, generate dedicated notification DTO if util.is_notification(func["name"]): - base_type = "JVppNotification" description = "notification DTO" - camel_case_dto_name = util.add_notification_suffix(camel_case_dto_name) dto_path = os.path.join(dto_package, camel_case_dto_name + ".java") methods = generate_dto_base_methods(camel_case_dto_name, func) write_dto_file(base_package, plugin_package, base_type, camel_case_dto_name, description, dto_package, @@ -229,16 +244,26 @@ def generate_dto_hash(func): def write_dto_file(base_package, plugin_package, base_type, camel_case_dto_name, description, dto_package, dto_path, fields, func, inputfile, methods): dto_file = open(dto_path, 'w') - dto_file.write(dto_template.substitute(inputfile=inputfile, - description=description, - docs=util.api_message_to_javadoc(func), - cls_name=camel_case_dto_name, - fields=fields, - methods=methods, - base_package=base_package, - plugin_package=plugin_package, - base_type=base_type, - dto_package=dto_package)) + if base_type != "": + dto_file.write(dto_template.substitute(inputfile=inputfile, + description=description, + docs=util.api_message_to_javadoc(func), + cls_name=camel_case_dto_name, + fields=fields, + methods=methods, + base_package=base_package, + plugin_package=plugin_package, + base_type=base_type, + dto_package=dto_package)) + else: + dto_file.write(dto_template_typeless.substitute(inputfile=inputfile, + description=description, + docs=util.api_message_to_javadoc(func), + cls_name=camel_case_dto_name, + fields=fields, + methods=methods, + plugin_package=plugin_package, + dto_package=dto_package)) dto_file.flush() dto_file.close() -- cgit 1.2.3-korg