[vala/wip/array-length-type: 6/10] gdbus: Remove hardcoded "int" length type and use ArrayType.length_type



commit 4cdbde3f7dd0b71645c55d6ba5d0084de0ead4d3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Oct 31 12:53:29 2018 +0100

    gdbus: Remove hardcoded "int" length type and use ArrayType.length_type

 codegen/valagdbusclientmodule.vala | 18 ++++++++++++------
 codegen/valagdbusservermodule.vala | 20 +++++++++++++-------
 2 files changed, 25 insertions(+), 13 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 91bdce363..a0f15b42b 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -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));
                                }
                        }
                }
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 6b2f31ab4..c446ffd0e 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -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)));
                                }
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]