summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen/jvppgen/util.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/util.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/util.py')
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/util.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/util.py b/src/vpp-api/java/jvpp/gen/jvppgen/util.py
index ce34f8549d8..70ddc8ea8e7 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/util.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/util.py
@@ -35,19 +35,30 @@ def remove_folder(folder):
removedirs(folder)
-reply_suffixes = ("reply", "details")
+_REPLY_SUFFIX = "reply"
+_DETAILS_SUFFIX = "details"
+_REPLY_SUFFIXES = (_REPLY_SUFFIX, _DETAILS_SUFFIX)
def is_reply(name):
- return name.lower().endswith(reply_suffixes)
+ return name.lower().endswith(_REPLY_SUFFIXES)
-def is_details(name):
- return name.lower().endswith(reply_suffixes[1])
+def is_request(msg_name_underscore, all_messages):
+ """
+ Checks if reply message is present in all_messages.
+ :param msg_name_underscore name of vpp API message
+ :param all_messages: sequence of vpp message names
+ :returns: True if reply for the msg_name_underscore message is defined.
+ """
+ reply_msg = msg_name_underscore + "_" + _REPLY_SUFFIX
+ return reply_msg in [m['name'] for m in all_messages]
+
+
+def is_details(name):
+ return name.lower().endswith(_DETAILS_SUFFIX)
-def is_retval_field(name):
- return name == 'retval'
dump_suffix = "dump"
@@ -56,8 +67,12 @@ def is_dump(name):
return name.lower().endswith(dump_suffix)
+def is_retval_field(name):
+ return name == 'retval'
+
+
def get_reply_suffix(name):
- for reply_suffix in reply_suffixes:
+ for reply_suffix in _REPLY_SUFFIXES:
if name.lower().endswith(reply_suffix):
return reply_suffix
@@ -149,14 +164,6 @@ jni_field_accessors = {'u8': 'ByteField',
}
-def is_notification(name):
- """ Returns true if the structure is a notification """
- # FIXME no convention in the naming of events (notifications) in vpe.api
- notifications_message_suffixes = ("event", "counters")
-
- return name.lower().endswith(notifications_message_suffixes)
-
-
def remove_reply_suffix(camel_case_name_with_suffix):
return remove_suffix(camel_case_name_with_suffix, get_reply_suffix(camel_case_name_with_suffix))