summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
diff options
context:
space:
mode:
authorMatej Perina <mperina@cisco.com>2017-09-11 10:11:51 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2017-10-10 16:44:03 +0000
commitac1a7286500c18ac51beb66e4a2b99ea26c8c966 (patch)
tree62a4a0430bd0d5623c5e9945ca5bf671745351f9 /src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
parentd91c1dbdb31f80db7d967f2f57c43d0a81d65297 (diff)
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 <matej.perina@pantheon.tech>
Diffstat (limited to 'src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py')
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py49
1 files changed, 37 insertions, 12 deletions
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;
+
+/**
+ * <p>This class represents $description.
+ * <br>It was generated by dto_gen.py based on $inputfile preparsed data:
+ * <pre>
+$docs
+ * </pre>
+ */
+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()