]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gdbus: Remove hardcoded "int" length type and use ArrayType.length_type
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 31 Oct 2018 11:53:29 +0000 (12:53 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 2 Nov 2018 13:24:10 +0000 (14:24 +0100)
codegen/valagdbusclientmodule.vala
codegen/valagdbusservermodule.vala

index 91bdce3637edf694c95a3794356cb8648b639568..a0f15b42b1b283aac64a8c106e74a3b20d5f801c 100644 (file)
@@ -472,11 +472,12 @@ public class Vala.GDBusClientModule : GDBusModule {
 
                        if (param.variable_type is ArrayType) {
                                var array_type = (ArrayType) param.variable_type;
+                               var length_ctype = get_ccode_array_length_type (array_type);
 
                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                        string length_cname = get_parameter_array_length_cname (param, dim);
 
-                                       ccode.add_declaration ("int", new CCodeVariableDeclarator (length_cname, new CCodeConstant ("0")));
+                                       ccode.add_declaration (length_ctype, new CCodeVariableDeclarator (length_cname, new CCodeConstant ("0")));
                                        ccall.add_argument (new CCodeIdentifier (length_cname));
                                }
                        }
@@ -799,10 +800,11 @@ public class Vala.GDBusClientModule : GDBusModule {
                                                ccode.add_declaration (get_ccode_name (param.variable_type), new CCodeVariableDeclarator.zero ("_vala_%s".printf (param.name), default_value_for_type (param.variable_type, true)));
 
                                                var array_type = param.variable_type as ArrayType;
+                                               var length_ctype = get_ccode_array_length_type (array_type);
 
                                                if (array_type != null) {
                                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                                               ccode.add_declaration ("int", new CCodeVariableDeclarator ("_vala_%s_length%d".printf (param.name, dim), new CCodeConstant ("0")));
+                                                               ccode.add_declaration (length_ctype, new CCodeVariableDeclarator ("_vala_%s_length%d".printf (param.name, dim), new CCodeConstant ("0")));
                                                        }
                                                }
 
@@ -839,10 +841,11 @@ public class Vala.GDBusClientModule : GDBusModule {
                                                ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator.zero ("_result", default_value_for_type (m.return_type, true)));
 
                                                var array_type = m.return_type as ArrayType;
+                                               var length_ctype = get_ccode_array_length_type (array_type);
 
                                                if (array_type != null) {
                                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                                               ccode.add_declaration ("int", new CCodeVariableDeclarator ("_result_length%d".printf (dim), new CCodeConstant ("0")));
+                                                               ccode.add_declaration (length_ctype, new CCodeVariableDeclarator ("_result_length%d".printf (dim), new CCodeConstant ("0")));
                                                        }
                                                }
 
@@ -973,8 +976,9 @@ public class Vala.GDBusClientModule : GDBusModule {
                        function.add_parameter (new CCodeParameter ("result", "%s*".printf (get_ccode_name (prop.get_accessor.value_type))));
                } else {
                        if (array_type != null) {
+                               var length_ctype = get_ccode_array_length_type (array_type) + "*";
                                for (int dim = 1; dim <= array_type.rank; dim++) {
-                                       function.add_parameter (new CCodeParameter ("result_length%d".printf (dim), "int*"));
+                                       function.add_parameter (new CCodeParameter ("result_length%d".printf (dim), length_ctype));
                                }
                        }
 
@@ -1052,8 +1056,9 @@ public class Vala.GDBusClientModule : GDBusModule {
                                ccode.add_assignment (new CCodeIdentifier ("_result"), new CCodeIdentifier("_inner_reply"));
                        } else {
                                if (array_type != null) {
+                                       var length_ctype = get_ccode_array_length_type (array_type);
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                               ccode.add_declaration ("int", new CCodeVariableDeclarator ("_result_length%d".printf (dim), new CCodeConstant ("0")));
+                                               ccode.add_declaration (length_ctype, new CCodeVariableDeclarator ("_result_length%d".printf (dim), new CCodeConstant ("0")));
                                        }
                                }
 
@@ -1107,8 +1112,9 @@ public class Vala.GDBusClientModule : GDBusModule {
                        function.add_parameter (new CCodeParameter ("value", get_ccode_name (prop.set_accessor.value_type)));
 
                        if (array_type != null) {
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                for (int dim = 1; dim <= array_type.rank; dim++) {
-                                       function.add_parameter (new CCodeParameter ("value_length%d".printf (dim), "int"));
+                                       function.add_parameter (new CCodeParameter ("value_length%d".printf (dim), length_ctype));
                                }
                        }
                }
index 6b2f31ab45dde78926b8dc6d4c9544f9e9e8a040..c446ffd0e1927fbee615bcf276f898b663274bea 100644 (file)
@@ -149,14 +149,15 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                                }
 
                                var array_type = param.variable_type as ArrayType;
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                if (array_type != null) {
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                                string length_cname = get_parameter_array_length_cname (param, dim);
 
                                                if (ready_data_struct != null) {
-                                                       ready_data_struct.add_field ("int", length_cname);
+                                                       ready_data_struct.add_field (length_ctype, length_cname);
                                                } else {
-                                                       ccode.add_declaration ("int", new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
+                                                       ccode.add_declaration (length_ctype, new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
                                                }
                                        }
                                }
@@ -340,10 +341,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 
                                var array_type = param.variable_type as ArrayType;
                                if (array_type != null) {
+                                       var length_ctype = get_ccode_array_length_type (array_type);
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                                string length_cname = get_parameter_array_length_cname (param, dim);
 
-                                               ccode.add_declaration ("int", new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
+                                               ccode.add_declaration (length_ctype, new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
                                        }
                                }
 
@@ -366,10 +368,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 
                                        var array_type = m.return_type as ArrayType;
                                        if (array_type != null) {
+                                               var length_ctype = get_ccode_array_length_type (array_type);
                                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                                        string length_cname = get_array_length_cname ("result", dim);
 
-                                                       ccode.add_declaration ("int", new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
+                                                       ccode.add_declaration (length_ctype, new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
                                                }
                                        }
 
@@ -504,8 +507,9 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                        function.add_parameter (cparam);
                        if (param.variable_type is ArrayType) {
                                var array_type = (ArrayType) param.variable_type;
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                for (int dim = 1; dim <= array_type.rank; dim++) {
-                                       function.add_parameter (new CCodeParameter (get_parameter_array_length_cname (param, dim), "int"));
+                                       function.add_parameter (new CCodeParameter (get_parameter_array_length_cname (param, dim), length_ctype));
                                }
                        }
                }
@@ -578,10 +582,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 
                        var array_type = prop.get_accessor.value_type as ArrayType;
                        if (array_type != null) {
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                        string length_cname = get_array_length_cname ("result", dim);
 
-                                       ccode.add_declaration ("int", new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
+                                       ccode.add_declaration (length_ctype, new CCodeVariableDeclarator.zero (length_cname, new CCodeConstant ("0")));
                                        ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (length_cname)));
                                }
                        }
@@ -640,8 +645,9 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 
                        var array_type = prop.property_type as ArrayType;
                        if (array_type != null) {
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                for (int dim = 1; dim <= array_type.rank; dim++) {
-                                       ccode.add_declaration ("int", new CCodeVariableDeclarator (get_array_length_cname ("value", dim)));
+                                       ccode.add_declaration (length_ctype, new CCodeVariableDeclarator (get_array_length_cname ("value", dim)));
                                        ccall.add_argument (new CCodeIdentifier (get_array_length_cname ("value", dim)));
                                }
                        }