summaryrefslogtreecommitdiffstats
path: root/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py')
-rw-r--r--vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py52
1 files changed, 36 insertions, 16 deletions
diff --git a/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py b/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py
index acf29eb85b8..7df17486a60 100644
--- a/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py
+++ b/vpp-api/java/jvpp/gen/jvpp_callback_facade_gen.py
@@ -27,7 +27,7 @@ package $base_package.$callback_facade_package;
* <br>It was generated by jvpp_callback_facade_gen.py based on $inputfile
* <br>(python representation of vpe.api generated by vppapigen).
*/
-public interface CallbackJVpp extends java.lang.AutoCloseable {
+public interface CallbackJVpp extends $base_package.$notification_package.NotificationRegistryProvider, java.lang.AutoCloseable {
@Override
void close();
@@ -46,7 +46,7 @@ package $base_package.$callback_facade_package;
* <br>It was generated by jvpp_callback_facade_gen.py based on $inputfile
* <br>(python representation of vpe.api generated by vppapigen).
*/
-public final class CallbackJVppFacade implements $base_package.$callback_facade_package.CallbackJVpp {
+public final class CallbackJVppFacade extends $base_package.$notification_package.NotificationRegistryProviderContext implements $base_package.$callback_facade_package.CallbackJVpp {
private final $base_package.JVpp jvpp;
private final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> callbacks;
@@ -63,7 +63,7 @@ public final class CallbackJVppFacade implements $base_package.$callback_facade_
public CallbackJVppFacade(final $base_package.JVpp jvpp) throws java.io.IOException {
this.jvpp = java.util.Objects.requireNonNull(jvpp,"jvpp is null");
this.callbacks = new java.util.HashMap<>();
- this.jvpp.connect(new CallbackJVppFacadeCallback(this.callbacks));
+ this.jvpp.connect(new CallbackJVppFacadeCallback(this.callbacks, getNotificationCallback()));
}
@Override
@@ -95,7 +95,7 @@ no_arg_method_impl_template = Template(""" public final void $name($base_pack
""")
-def generate_jvpp(func_list, base_package, dto_package, callback_package, callback_facade_package, inputfile):
+def generate_jvpp(func_list, base_package, dto_package, callback_package, notification_package, callback_facade_package, inputfile):
""" Generates callback facade """
print "Generating JVpp callback facade"
@@ -152,6 +152,7 @@ def generate_jvpp(func_list, base_package, dto_package, callback_package, callba
methods="\n".join(methods),
base_package=base_package,
dto_package=dto_package,
+ notification_package=notification_package,
callback_facade_package=callback_facade_package))
jvpp_file.flush()
jvpp_file.close()
@@ -161,12 +162,13 @@ def generate_jvpp(func_list, base_package, dto_package, callback_package, callba
methods="\n".join(methods_impl),
base_package=base_package,
dto_package=dto_package,
+ notification_package=notification_package,
callback_package=callback_package,
callback_facade_package=callback_facade_package))
jvpp_file.flush()
jvpp_file.close()
- generate_callback(func_list, base_package, dto_package, callback_package, callback_facade_package, inputfile)
+ generate_callback(func_list, base_package, dto_package, callback_package, notification_package, callback_facade_package, inputfile)
jvpp_facade_callback_template = Template("""
@@ -180,10 +182,13 @@ package $base_package.$callback_facade_package;
public final class CallbackJVppFacadeCallback implements $base_package.$callback_package.JVppGlobalCallback {
private final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> requests;
+ private final $base_package.$notification_package.GlobalNotificationCallback notificationCallback;
private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(CallbackJVppFacadeCallback.class.getName());
- public CallbackJVppFacadeCallback(final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> requestMap) {
+ public CallbackJVppFacadeCallback(final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> requestMap,
+ final $base_package.$notification_package.GlobalNotificationCallback notificationCallback) {
this.requests = requestMap;
+ this.notificationCallback = notificationCallback;
}
@Override
@@ -224,29 +229,44 @@ jvpp_facade_callback_method_template = Template("""
}
""")
+jvpp_facade_callback_notification_method_template = Template("""
+ @Override
+ @SuppressWarnings("unchecked")
+ public void on$callback_dto($base_package.$dto_package.$callback_dto notification) {
+ notificationCallback.on$callback_dto(notification);
+ }
+""")
-def generate_callback(func_list, base_package, dto_package, callback_package, callback_facade_package, inputfile):
+
+def generate_callback(func_list, base_package, dto_package, callback_package, notification_package, callback_facade_package, inputfile):
callbacks = []
for func in func_list:
- if util.is_notification(func['name']) or util.is_ignored(func['name']):
- # TODO handle notifications
+ if util.is_ignored(func['name']):
continue
camel_case_name_with_suffix = util.underscore_to_camelcase_upper(func['name'])
- if not util.is_reply(camel_case_name_with_suffix):
- continue
- callbacks.append(jvpp_facade_callback_method_template.substitute(base_package=base_package,
- dto_package=dto_package,
- callback_package=callback_package,
- callback=util.remove_reply_suffix(camel_case_name_with_suffix) + callback_gen.callback_suffix,
- callback_dto=camel_case_name_with_suffix))
+ if util.is_reply(camel_case_name_with_suffix):
+ callbacks.append(jvpp_facade_callback_method_template.substitute(base_package=base_package,
+ dto_package=dto_package,
+ callback_package=callback_package,
+ callback=util.remove_reply_suffix(camel_case_name_with_suffix) + callback_gen.callback_suffix,
+ callback_dto=camel_case_name_with_suffix))
+
+ if util.is_notification(func["name"]):
+ with_notification_suffix = util.add_notification_suffix(camel_case_name_with_suffix)
+ callbacks.append(jvpp_facade_callback_notification_method_template.substitute(base_package=base_package,
+ dto_package=dto_package,
+ callback_package=callback_package,
+ callback=with_notification_suffix + callback_gen.callback_suffix,
+ callback_dto=with_notification_suffix))
jvpp_file = open(os.path.join(callback_facade_package, "CallbackJVppFacadeCallback.java"), 'w')
jvpp_file.write(jvpp_facade_callback_template.substitute(inputfile=inputfile,
base_package=base_package,
dto_package=dto_package,
+ notification_package=notification_package,
callback_package=callback_package,
methods="".join(callbacks),
callback_facade_package=callback_facade_package))