[vala] D-Bus: Add DBusModule.get_type_signature method
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] D-Bus: Add DBusModule.get_type_signature method
- Date: Fri, 3 Jul 2009 14:32:44 +0000 (UTC)
commit ab0905ea9d3fafa533141e8ea09ddf530f7c09ca
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Thu Apr 30 14:34:42 2009 +0200
D-Bus: Add DBusModule.get_type_signature method
Replace DataType.get_type_signature() calls.
Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
codegen/valadbusclientmodule.vala | 10 +++++-----
codegen/valadbusmodule.vala | 12 ++++++++----
codegen/valadbusservermodule.vala | 18 +++++++++---------
codegen/valagsignalmodule.vala | 6 +++---
4 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/codegen/valadbusclientmodule.vala b/codegen/valadbusclientmodule.vala
index 30f82c5..06e67d4 100644
--- a/codegen/valadbusclientmodule.vala
+++ b/codegen/valadbusclientmodule.vala
@@ -261,7 +261,7 @@ internal class Vala.DBusClientModule : DBusModule {
ccall.add_argument (new CCodeIdentifier ("G_TYPE_STRV"));
ccall.add_argument (new CCodeIdentifier (param.name));
}
- } else if (param.parameter_type.get_type_signature ().has_prefix ("(")) {
+ } else if (get_type_signature (param.parameter_type).has_prefix ("(")) {
// struct parameter
var st = (Struct) param.parameter_type.data_type;
@@ -327,7 +327,7 @@ internal class Vala.DBusClientModule : DBusModule {
continue;
}
- if (param.parameter_type.get_type_signature ().has_prefix ("(")) {
+ if (get_type_signature (param.parameter_type).has_prefix ("(")) {
// struct output parameter
var st = (Struct) param.parameter_type.data_type;
@@ -488,7 +488,7 @@ internal class Vala.DBusClientModule : DBusModule {
}
return cmap_type;
- } else if (data_type.data_type.get_type_signature ().has_prefix ("(")) {
+ } else if (get_type_signature (data_type).has_prefix ("(")) {
// struct parameter
var st = (Struct) data_type.data_type;
@@ -1153,7 +1153,7 @@ internal class Vala.DBusClientModule : DBusModule {
cdecl.add_declarator (new CCodeVariableDeclarator (param.name, default_value_for_type (param.parameter_type, true)));
prefragment.append (cdecl);
- if (param.parameter_type.get_type_signature () == null) {
+ if (get_type_signature (param.parameter_type) == null) {
Report.error (param.parameter_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (param.parameter_type.to_string ()));
continue;
}
@@ -1178,7 +1178,7 @@ internal class Vala.DBusClientModule : DBusModule {
}
}
- type_signature += param.parameter_type.get_type_signature ();
+ type_signature += get_type_signature (param.parameter_type);
var target = new CCodeIdentifier (param.name);
var expr = read_expression (prefragment, param.parameter_type, new CCodeIdentifier ("iter"), target);
diff --git a/codegen/valadbusmodule.vala b/codegen/valadbusmodule.vala
index 5e7fe11..87f60b5 100644
--- a/codegen/valadbusmodule.vala
+++ b/codegen/valadbusmodule.vala
@@ -59,6 +59,10 @@ internal class Vala.DBusModule : GAsyncModule {
return false;
}
+ public static string get_type_signature (DataType datatype) {
+ return datatype.get_type_signature ();
+ }
+
CCodeExpression? get_array_length (CCodeExpression expr, int dim) {
var id = expr as CCodeIdentifier;
var ma = expr as CCodeMemberAccess;
@@ -366,7 +370,7 @@ internal class Vala.DBusModule : GAsyncModule {
public CCodeExpression? read_expression (CCodeFragment fragment, DataType type, CCodeExpression iter_expr, CCodeExpression? expr) {
BasicTypeInfo basic_type;
CCodeExpression result = null;
- if (get_basic_type_info (type.get_type_signature (), out basic_type)) {
+ if (get_basic_type_info (get_type_signature (type), out basic_type)) {
result = read_basic (fragment, basic_type, iter_expr);
} else if (type is ArrayType) {
result = read_array (fragment, (ArrayType) type, iter_expr, expr);
@@ -444,7 +448,7 @@ internal class Vala.DBusModule : GAsyncModule {
var iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_open_container"));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, iter_expr));
iter_call.add_argument (new CCodeIdentifier ("DBUS_TYPE_ARRAY"));
- iter_call.add_argument (new CCodeConstant ("\"%s%s\"".printf (string.nfill (array_type.rank - dim, 'a'), array_type.element_type.get_type_signature ())));
+ iter_call.add_argument (new CCodeConstant ("\"%s%s\"".printf (string.nfill (array_type.rank - dim, 'a'), get_type_signature (array_type.element_type))));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (subiter_name)));
fragment.append (new CCodeExpressionStatement (iter_call));
@@ -566,7 +570,7 @@ internal class Vala.DBusModule : GAsyncModule {
var iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_open_container"));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, iter_expr));
iter_call.add_argument (new CCodeIdentifier ("DBUS_TYPE_ARRAY"));
- iter_call.add_argument (new CCodeConstant ("\"{%s%s}\"".printf (key_type.get_type_signature (), value_type.get_type_signature ())));
+ iter_call.add_argument (new CCodeConstant ("\"{%s%s}\"".printf (get_type_signature (key_type), get_type_signature (value_type))));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (subiter_name)));
fragment.append (new CCodeExpressionStatement (iter_call));
@@ -635,7 +639,7 @@ internal class Vala.DBusModule : GAsyncModule {
public void write_expression (CCodeFragment fragment, DataType type, CCodeExpression iter_expr, CCodeExpression expr) {
BasicTypeInfo basic_type;
- if (get_basic_type_info (type.get_type_signature (), out basic_type)) {
+ if (get_basic_type_info (get_type_signature (type), out basic_type)) {
write_basic (fragment, basic_type, iter_expr, expr);
} else if (type is ArrayType) {
write_array (fragment, (ArrayType) type, iter_expr, expr);
diff --git a/codegen/valadbusservermodule.vala b/codegen/valadbusservermodule.vala
index 225ab2a..49cde63 100644
--- a/codegen/valadbusservermodule.vala
+++ b/codegen/valadbusservermodule.vala
@@ -129,7 +129,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
continue;
}
- if (param.parameter_type.get_type_signature () == null) {
+ if (get_type_signature (param.parameter_type) == null) {
Report.error (param.parameter_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (param.parameter_type.to_string ()));
continue;
}
@@ -160,7 +160,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
}
if (param.direction == ParameterDirection.IN) {
- type_signature += param.parameter_type.get_type_signature ();
+ type_signature += get_type_signature (param.parameter_type);
var target = new CCodeIdentifier (param.name);
var expr = read_expression (prefragment, param.parameter_type, new CCodeIdentifier ("iter"), target);
@@ -181,7 +181,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
signature_check.add_argument (new CCodeConstant ("\"%s\"".printf (type_signature)));
if (!(m.return_type is VoidType)) {
- if (m.return_type.get_type_signature () == null) {
+ if (get_type_signature (m.return_type) == null) {
Report.error (m.return_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (m.return_type.to_string ()));
} else {
cdecl = new CCodeDeclaration (m.return_type.get_cname ());
@@ -560,7 +560,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_open_container"));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("reply_iter")));
iter_call.add_argument (new CCodeIdentifier ("DBUS_TYPE_VARIANT"));
- iter_call.add_argument (new CCodeConstant ("\"%s\"".printf (prop.property_type.get_type_signature ())));
+ iter_call.add_argument (new CCodeConstant ("\"%s\"".printf (get_type_signature (prop.property_type))));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("subiter")));
postfragment.append (new CCodeExpressionStatement (iter_call));
@@ -768,7 +768,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_open_container"));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("entry_iter")));
iter_call.add_argument (new CCodeIdentifier ("DBUS_TYPE_VARIANT"));
- iter_call.add_argument (new CCodeConstant ("\"%s\"".printf (prop.property_type.get_type_signature ())));
+ iter_call.add_argument (new CCodeConstant ("\"%s\"".printf (get_type_signature (prop.property_type))));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("value_iter")));
postfragment.append (new CCodeExpressionStatement (iter_call));
@@ -1059,10 +1059,10 @@ internal class Vala.DBusServerModule : DBusClientModule {
}
string direction = param.direction == ParameterDirection.IN ? "in" : "out";
- result += " <arg name=\"%s\" type=\"%s\" direction=\"%s\"/>\n".printf (param.name, param.parameter_type.get_type_signature (), direction);
+ result += " <arg name=\"%s\" type=\"%s\" direction=\"%s\"/>\n".printf (param.name, get_type_signature (param.parameter_type), direction);
}
if (!(m.return_type is VoidType)) {
- result += " <arg name=\"%s\" type=\"%s\" direction=\"out\"/>\n".printf (dbus_result_name (m), m.return_type.get_type_signature ());
+ result += " <arg name=\"%s\" type=\"%s\" direction=\"out\"/>\n".printf (dbus_result_name (m), get_type_signature (m.return_type));
}
result += " </method>\n";
@@ -1078,7 +1078,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
}
string access = (prop.get_accessor != null ? "read" : "") + (prop.set_accessor != null ? "write" : "");
- result += " <property name=\"%s\" type=\"%s\" access=\"%s\"/>\n".printf (Symbol.lower_case_to_camel_case (prop.name), prop.property_type.get_type_signature (), access);
+ result += " <property name=\"%s\" type=\"%s\" access=\"%s\"/>\n".printf (Symbol.lower_case_to_camel_case (prop.name), get_type_signature (prop.property_type), access);
}
foreach (var sig in sym.get_signals ()) {
@@ -1092,7 +1092,7 @@ internal class Vala.DBusServerModule : DBusClientModule {
result += " <signal name=\"%s\">\n".printf (Symbol.lower_case_to_camel_case (sig.name));
foreach (var param in sig.get_parameters ()) {
- result += " <arg name=\"%s\" type=\"%s\"/>\n".printf (param.name, param.parameter_type.get_type_signature ());
+ result += " <arg name=\"%s\" type=\"%s\"/>\n".printf (param.name, get_type_signature (param.parameter_type));
}
result += " </signal>\n";
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 5fb41eb..f4ed94d 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -46,7 +46,7 @@ internal class Vala.GSignalModule : GObjectModule {
}
} else if (t is VoidType) {
return ("VOID");
- } else if (dbus && t.get_type_signature ().has_prefix ("(")) {
+ } else if (dbus && DBusModule.get_type_signature (t).has_prefix ("(")) {
return ("BOXED");
} else if (t.data_type is Enum) {
var en = (Enum) t.data_type;
@@ -280,7 +280,7 @@ internal class Vala.GSignalModule : GObjectModule {
get_value_function = "g_value_get_pointer";
} else if (p.parameter_type is ErrorType) {
get_value_function = "g_value_get_pointer";
- } else if (dbus && p.parameter_type.get_type_signature ().has_prefix ("(")) {
+ } else if (dbus && DBusModule.get_type_signature (p.parameter_type).has_prefix ("(")) {
get_value_function = "g_value_get_boxed";
} else if (dbus && p.parameter_type.data_type is Enum) {
var en = (Enum) p.parameter_type.data_type;
@@ -327,7 +327,7 @@ internal class Vala.GSignalModule : GObjectModule {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_string"));
} else if (return_type.data_type is Class || return_type.data_type is Interface) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_object"));
- } else if (dbus && return_type.get_type_signature ().has_prefix ("(")) {
+ } else if (dbus && DBusModule.get_type_signature (return_type).has_prefix ("(")) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_boxed"));
} else if (dbus && return_type.data_type is Enum) {
var en = (Enum) return_type.data_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]