[vala] D-Bus: Support DBus.timeout attribute for client methods
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] D-Bus: Support DBus.timeout attribute for client methods
- Date: Sat, 17 Sep 2016 08:09:45 +0000 (UTC)
commit 0431459492f94a9840f29abb143f7e29834e2d54
Author: Michele Dionisio <michele dionisio gmail com>
Date: Sat Sep 17 10:02:15 2016 +0200
D-Bus: Support DBus.timeout attribute for client methods
https://bugzilla.gnome.org/show_bug.cgi?id=737913
codegen/valagdbusclientmodule.vala | 19 ++++++++++++-------
codegen/valagdbusmodule.vala | 4 ++++
vala/valausedattr.vala | 2 +-
3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 59aa20e..7ec2387 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -55,7 +55,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (func);
if (dynamic_method.dynamic_type.data_type == dbus_proxy_type) {
- generate_marshalling (method, CallType.SYNC, null, method.name);
+ generate_marshalling (method, CallType.SYNC, null, method.name, -1);
} else {
Report.error (method.source_reference, "dynamic methods are not supported for
`%s'".printf (dynamic_method.dynamic_type.to_string ()));
}
@@ -554,7 +554,7 @@ public class Vala.GDBusClientModule : GDBusModule {
cfile.add_function (cfunc);
}
- void generate_marshalling (Method m, CallType call_type, string? iface_name, string? method_name) {
+ void generate_marshalling (Method m, CallType call_type, string? iface_name, string? method_name, int
method_timeout) {
var gdbusproxy = new CCodeCastExpression (new CCodeIdentifier ("self"), "GDBusProxy *");
var connection = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_proxy_get_connection"));
@@ -575,8 +575,13 @@ public class Vala.GDBusClientModule : GDBusModule {
var object_path = new CCodeFunctionCall (new CCodeIdentifier
("g_dbus_proxy_get_object_path"));
object_path.add_argument (gdbusproxy);
- var timeout = new CCodeFunctionCall (new CCodeIdentifier
("g_dbus_proxy_get_default_timeout"));
- timeout.add_argument (gdbusproxy);
+ CCodeExpression timeout;
+ if (method_timeout <= 0) {
+ timeout = new CCodeFunctionCall (new CCodeIdentifier
("g_dbus_proxy_get_default_timeout"));
+ ((CCodeFunctionCall) timeout).add_argument (gdbusproxy);
+ } else {
+ timeout = new CCodeConstant ("%d".printf (method_timeout));
+ }
// register errors
foreach (var error_type in m.get_error_types ()) {
@@ -862,7 +867,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (function);
- generate_marshalling (m, no_reply ? CallType.NO_REPLY : CallType.SYNC, dbus_iface_name,
get_dbus_name_for_member (m));
+ generate_marshalling (m, no_reply ? CallType.NO_REPLY : CallType.SYNC, dbus_iface_name,
get_dbus_name_for_member (m), get_dbus_timeout_for_member (m));
pop_function ();
@@ -889,7 +894,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (function);
- generate_marshalling (m, CallType.ASYNC, dbus_iface_name, get_dbus_name_for_member (m));
+ generate_marshalling (m, CallType.ASYNC, dbus_iface_name, get_dbus_name_for_member (m),
get_dbus_timeout_for_member (m));
pop_function ();
@@ -913,7 +918,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (function);
- generate_marshalling (m, CallType.FINISH, null, null);
+ generate_marshalling (m, CallType.FINISH, null, null, -1);
pop_function ();
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index edfc827..8f10daa 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -34,6 +34,10 @@ public class Vala.GDBusModule : GVariantModule {
return Symbol.lower_case_to_camel_case (symbol.name);
}
+ public static int get_dbus_timeout_for_member (Symbol symbol) {
+ return symbol.get_attribute_integer ("DBus", "timeout", -1);
+ }
+
public static bool is_dbus_visible (CodeNode node) {
var dbus_attribute = node.get_attribute ("DBus");
if (dbus_attribute != null
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala
index 588aaf7..6516e5e 100644
--- a/vala/valausedattr.vala
+++ b/vala/valausedattr.vala
@@ -72,7 +72,7 @@ public class Vala.UsedAttr : CodeVisitor {
"GtkTemplate", "ui", "",
"GtkCallback", "name", "",
- "DBus", "name", "no_reply", "result", "use_string_marshalling", "value", "signature",
"visible", "",
+ "DBus", "name", "no_reply", "result", "use_string_marshalling", "value", "signature",
"visible", "timeout", "",
"GIR", "name", ""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]