]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
D-Bus: Add DBusModule.get_type_signature method
authorDidier 'Ptitjes <ptitjes@free.fr>
Thu, 30 Apr 2009 12:34:42 +0000 (14:34 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 3 Jul 2009 14:15:14 +0000 (15:15 +0100)
Replace DataType.get_type_signature() calls.

Signed-off-by: Didier 'Ptitjes <ptitjes@free.fr>
codegen/valadbusclientmodule.vala
codegen/valadbusmodule.vala
codegen/valadbusservermodule.vala
codegen/valagsignalmodule.vala

index 30f82c554fed3010c73a9faaca9d524b93bd2544..06e67d4534606343bf305fb928e1df3b97e06169 100644 (file)
@@ -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);
index 5e7fe11d270f9b94f1622c5a58335c3dc32cb341..87f60b5f609ec64cd3c7aba55f3e0f1f0848f9a3 100644 (file)
@@ -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);
index 225ab2afcc4979e3805efe6429000d854fe6b8fd..49cde6340f2c92c33870cb94dc8bea54ba7d0438 100644 (file)
@@ -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";
index 5fb41ebd45698cbb9d5e6d4b77cc76ba6b114ca1..f4ed94d709270653633d1f010ec94cf8131039f4 100644 (file)
@@ -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;