summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-12-07 15:40:11 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-09 13:23:15 +0000
commit6e73f7f6055a9ba1c4e604060934a0aa5e555f57 (patch)
tree84ad8d53635552c1a158d48d783b794f34e1d762 /src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
parentc42fc05bfbb26fd11fe92ac9d11587660a817ac1 (diff)
jvpp: do not hardcode event sufixes (VPP-940)
JVpp maps request messages with replies for Java API user convenience, e.g.: - do not polute send APIs with messages other than requests/dumps, - allow callback registration only for replies/details and events. Since there are no conventions for event message naming (https://wiki.fd.io/view/VPP/API_Concepts#API_Conventions), jvpp should not limit events to messages that end with 'event' or 'counters' suffix. Instead jvpp should treat all messages except for requests/dumps as potential events. Such behaviour was introduced on Java API level by https://gerrit.fd.io/r/#/c/8377/ in order support reusing details messages as events (e.g. BFD events). This patch goes one step forward by relaxing rules at jvpp generation level. Change-Id: I2a35e9eb2a288b2cf02d36ca95e6cb13e76e19e3 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
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.py57
1 files changed, 25 insertions, 32 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 8126912230b..158e26ef59f 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
@@ -79,41 +79,34 @@ def generate_dtos(func_list, base_package, plugin_package, plugin_name, dto_pack
methods = generate_dto_base_methods(camel_case_dto_name, func)
base_type = ""
- # Generate request/reply or dump/dumpReply even if structure can be used as notification
- if not util.is_notification(func["name"]):
- if util.is_reply(camel_case_dto_name):
- description = "reply DTO"
- request_dto_name = util.remove_reply_suffix(camel_case_dto_name)
- if util.is_details(camel_case_dto_name):
- # FIXME assumption that dump calls end with "Dump" suffix. Not enforced in vpe.api
- base_type += "JVppReply<%s.%s.%s>" % (plugin_package, dto_package, request_dto_name + "Dump")
- generate_dump_reply_dto(request_dto_name, base_package, plugin_package, dto_package,
- camel_case_dto_name, camel_case_method_name, func)
- else:
- base_type += "JVppReply<%s.%s.%s>" % (plugin_package, dto_package, request_dto_name)
+ if util.is_reply(camel_case_dto_name):
+ description = "reply DTO"
+ request_dto_name = util.remove_reply_suffix(camel_case_dto_name)
+ if util.is_details(camel_case_dto_name):
+ base_type += "JVppReply<%s.%s.%s>" % (plugin_package, dto_package, request_dto_name + "Dump")
+ generate_dump_reply_dto(request_dto_name, base_package, plugin_package, dto_package,
+ camel_case_dto_name, camel_case_method_name, func)
else:
- args = "" if fields is "" else "this"
- methods += send_template.substitute(method_name=camel_case_method_name,
- base_package=base_package,
- plugin_package=plugin_package,
- plugin_name=plugin_name,
- args=args)
- if util.is_dump(camel_case_dto_name):
- base_type += "JVppDump"
- description = "dump request DTO"
- else:
- base_type += "JVppRequest"
- description = "request DTO"
-
- write_dto_file(base_package, plugin_package, base_type, camel_case_dto_name, description, dto_package,
- dto_path, fields, func, inputfile, methods)
+ base_type += "JVppReply<%s.%s.%s>" % (plugin_package, dto_package, request_dto_name)
+ elif util.is_dump(camel_case_dto_name) or util.is_request(func['name'], func_list):
+ args = "" if fields is "" else "this"
+ methods += send_template.substitute(method_name=camel_case_method_name,
+ base_package=base_package,
+ plugin_package=plugin_package,
+ plugin_name=plugin_name,
+ args=args)
+ if util.is_dump(camel_case_dto_name):
+ base_type += "JVppDump"
+ description = "dump request DTO"
+ else:
+ base_type += "JVppRequest"
+ description = "request DTO"
else:
- # for structures that are also used as notifications, generate dedicated notification DTO
- description = "notification DTO"
+ description = "event DTO"
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,
- dto_path, fields, func, inputfile, methods)
+
+ write_dto_file(base_package, plugin_package, base_type, camel_case_dto_name, description, dto_package,
+ dto_path, fields, func, inputfile, methods)
flush_dump_reply_dtos(inputfile)