]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Remove hardcoded "int" length type and use ArrayType.length_type
authorGeorge Barrett <bob@bob131.so>
Tue, 12 Dec 2017 03:37:38 +0000 (14:37 +1100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 2 Nov 2018 13:24:10 +0000 (14:24 +0100)
https://gitlab.gnome.org/GNOME/vala/issues/607

12 files changed:
codegen/valaccode.vala
codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala
codegen/valaccodedelegatemodule.vala
codegen/valaccodememberaccessmodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valaccodemethodmodule.vala
codegen/valaccodestructmodule.vala
codegen/valagasyncmodule.vala
codegen/valagsignalmodule.vala
codegen/valagtypemodule.vala
codegen/valagvariantmodule.vala

index 1bb92171ea1b331dfbbec88ccfa7d5c8b26cc047..bc29b259da0354e42f6a3b9d1680b8628ccc0afa 100644 (file)
@@ -247,7 +247,11 @@ namespace Vala {
        }
 
        public static string? get_ccode_array_length_type (CodeNode node) {
-               return get_ccode_attribute(node).array_length_type;
+               if (node is ArrayType) {
+                       return get_ccode_name (((ArrayType) node).length_type);
+               } else {
+                       return get_ccode_attribute(node).array_length_type;
+               }
        }
 
        public static bool get_ccode_array_null_terminated (CodeNode node) {
index 1730da7f6030f4e037ed5dd280947ee483e30fee..c3ad53fc74621cb910d3c8d3fc4abd21f2d84612 100644 (file)
@@ -744,10 +744,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                }
 
                if (!array_type.fixed_length && get_ccode_array_length (param)) {
-                       string length_ctype = "int";
-                       if (get_ccode_array_length_type (param) != null) {
-                               length_ctype = get_ccode_array_length_type (param);
-                       }
+                       var length_ctype = get_ccode_array_length_type (array_type);
                        if (param.direction != ParameterDirection.IN) {
                                length_ctype = "%s*".printf (length_ctype);
                        }
index 151875fcff5502075c9f4ac63b6b4f9555057859..56a91f347c6df45e1ab6e593696d4f062f0dc1f4 100644 (file)
@@ -1069,10 +1069,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        var array_type = (ArrayType) f.variable_type;
 
                        if (!array_type.fixed_length) {
-                               for (int dim = 1; dim <= array_type.rank; dim++) {
-                                       var len_type = int_type.copy ();
+                               var length_ctype = get_ccode_array_length_type (array_type);
 
-                                       cdecl = new CCodeDeclaration (get_ccode_name (len_type));
+                               for (int dim = 1; dim <= array_type.rank; dim++) {
+                                       cdecl = new CCodeDeclaration (length_ctype);
                                        cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (get_ccode_name (f), dim)));
                                        if (f.is_private_symbol ()) {
                                                cdecl.modifiers = CCodeModifiers.STATIC;
@@ -1282,10 +1282,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        var array_type = (ArrayType) f.variable_type;
 
                                        if (!array_type.fixed_length) {
-                                               for (int dim = 1; dim <= array_type.rank; dim++) {
-                                                       var len_type = int_type.copy ();
+                                               var length_ctype = get_ccode_array_length_type (array_type);
 
-                                                       var len_def = new CCodeDeclaration (get_ccode_name (len_type));
+                                               for (int dim = 1; dim <= array_type.rank; dim++) {
+                                                       var len_def = new CCodeDeclaration (length_ctype);
                                                        len_def.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (get_ccode_name (f), dim), new CCodeConstant ("0")));
                                                        if (!f.is_private_symbol ()) {
                                                                len_def.modifiers = CCodeModifiers.EXTERN;
@@ -1296,9 +1296,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                }
 
                                                if (array_type.rank == 1 && f.is_internal_symbol ()) {
-                                                       var len_type = int_type.copy ();
-
-                                                       var cdecl = new CCodeDeclaration (get_ccode_name (len_type));
+                                                       var cdecl = new CCodeDeclaration (length_ctype);
                                                        cdecl.add_declarator (new CCodeVariableDeclarator (get_array_size_cname (get_ccode_name (f)), new CCodeConstant ("0")));
                                                        cdecl.modifiers = CCodeModifiers.STATIC;
                                                        cfile.add_type_member_declaration (cdecl);
@@ -1563,8 +1561,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                if (acc.value_type is ArrayType) {
                        var array_type = (ArrayType) acc.value_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_array_length_cname (acc.readable ? "result" : "value", dim), acc.readable ? "int*" : "int"));
+                               function.add_parameter (new CCodeParameter (get_array_length_cname (acc.readable ? "result" : "value", dim), acc.readable ? length_ctype + "*" : length_ctype));
                        }
                } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                        function.add_parameter (new CCodeParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
@@ -1665,8 +1664,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        if (acc.value_type is ArrayType) {
                                var array_type = (ArrayType) acc.value_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_array_length_cname (acc.readable ? "result" : "value", dim), acc.readable ? "int*" : "int"));
+                                       function.add_parameter (new CCodeParameter (get_array_length_cname (acc.readable ? "result" : "value", dim), acc.readable ? length_ctype + "*": length_ctype));
                                }
                        } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                                function.add_parameter (new CCodeParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
@@ -1788,8 +1788,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        if (acc.value_type is ArrayType) {
                                var array_type = (ArrayType) acc.value_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_array_length_cname (acc.readable ? "result" : "value", dim), acc.readable ? "int*" : "int"));
+                                       function.add_parameter (new CCodeParameter (get_array_length_cname (acc.readable ? "result" : "value", dim), acc.readable ? length_ctype + "*" : length_ctype));
                                }
                        } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                                function.add_parameter (new CCodeParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
@@ -1844,7 +1845,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        get_call.add_argument (new CCodeIdentifier (is_virtual ? "base" : "self"));
 
                                        if (property_type is ArrayType) {
-                                               ccode.add_declaration ("int", new CCodeVariableDeclarator ("old_value_length"));
+                                               ccode.add_declaration (get_ccode_array_length_type (property_type), new CCodeVariableDeclarator ("old_value_length"));
                                                get_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("old_value_length")));
                                                ccode.open_if (new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_call, new CCodeIdentifier ("value")));
                                        } else if (property_type.compatible (string_type)) {
@@ -1933,8 +1934,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                var deleg_type = param.variable_type as DelegateType;
 
                if (array_type != null && get_ccode_array_length (param)) {
+                       var length_ctype = get_ccode_array_length_type (array_type);
                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                               data.add_field ("gint", get_parameter_array_length_cname (param, dim));
+                               data.add_field (length_ctype, get_parameter_array_length_cname (param, dim));
                        }
                } else if (deleg_type != null && deleg_type.delegate_symbol.has_target) {
                        data.add_field ("gpointer", get_ccode_delegate_target_name (param));
@@ -2000,10 +2002,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                        if (local.variable_type is ArrayType && !((ArrayType) local.variable_type).fixed_length) {
                                                var array_type = (ArrayType) local.variable_type;
+                                               var length_ctype = get_ccode_array_length_type (array_type);
                                                for (int dim = 1; dim <= array_type.rank; dim++) {
-                                                       data.add_field ("gint", get_array_length_cname (get_local_cname (local), dim));
+                                                       data.add_field (length_ctype, get_array_length_cname (get_local_cname (local), dim));
                                                }
-                                               data.add_field ("gint", get_array_size_cname (get_local_cname (local)));
+                                               data.add_field (length_ctype, get_array_size_cname (get_local_cname (local)));
                                        } else if (local.variable_type is DelegateType && ((DelegateType) local.variable_type).delegate_symbol.has_target) {
                                                data.add_field ("gpointer", get_delegate_target_cname (get_local_cname (local)));
                                                if (local.variable_type.is_disposable ()) {
@@ -2448,13 +2451,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                if (!array_type.fixed_length) {
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                               var len_var = new LocalVariable (int_type.copy (), get_array_length_cname (get_local_cname (local), dim));
+                                               var len_var = new LocalVariable (array_type.length_type.copy (), get_array_length_cname (get_local_cname (local), dim));
                                                len_var.init = local.initializer == null;
                                                emit_temp_var (len_var);
                                        }
 
                                        if (array_type.rank == 1) {
-                                               var size_var = new LocalVariable (int_type.copy (), get_array_size_cname (get_local_cname (local)));
+                                               var size_var = new LocalVariable (array_type.length_type.copy (), get_array_size_cname (get_local_cname (local)));
                                                size_var.init = local.initializer == null;
                                                emit_temp_var (size_var);
                                        }
@@ -2506,7 +2509,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                emit_temp_var (local);
                if (array_type != null) {
                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                               var len_var = new LocalVariable (int_type.copy (), get_array_length_cname (local.name, dim), null, node_reference.source_reference);
+                               var len_var = new LocalVariable (array_type.length_type.copy (), get_array_length_cname (local.name, dim), null, node_reference.source_reference);
                                len_var.init = init;
                                emit_temp_var (len_var);
                        }
@@ -5206,10 +5209,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        // return array length if appropriate
                        // tmp = _variant_get (variant, &tmp_length);
                        var array_type = (ArrayType) to;
-
+                       var length_ctype = get_ccode_array_length_type (array_type);
                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_length_cvalue (result, dim)));
-                               cfunc.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), "int*"));
+                               cfunc.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), length_ctype + "*"));
                        }
                }
 
@@ -5978,10 +5981,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        if (type is ArrayType) {
                                // return array length if appropriate
                                var array_type = (ArrayType) type;
-
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                        ccall.add_argument (get_array_length_cvalue (value, dim));
-                                       cfunc.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), "gint"));
+                                       cfunc.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), length_ctype));
                                }
                        }
 
index 4783029695a3d680eb76f27e2a969d2e40575c28..8251e4fa9e60991d2a98ecf908ade9f73d06075c 100644 (file)
@@ -61,9 +61,9 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                        if (get_ccode_array_length (param) && param.variable_type is ArrayType) {
                                var array_type = (ArrayType) param.variable_type;
 
-                               var length_ctype = "int";
+                               var length_ctype = get_ccode_array_length_type (array_type);
                                if (param.direction != ParameterDirection.IN) {
-                                       length_ctype = "int*";
+                                       length_ctype += "*";
                                }
 
                                for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -88,11 +88,10 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                if (get_ccode_array_length (d) && d.return_type is ArrayType) {
                        // return array length if appropriate
                        var array_type = (ArrayType) d.return_type;
-                       var array_length_type = get_ccode_array_length_type (d) != null ? get_ccode_array_length_type (d) : "int";
-                       array_length_type += "*";
+                       var length_ctype = get_ccode_array_length_type (array_type) + "*";
 
                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                               var cparam = new CCodeParameter (get_array_length_cname ("result", dim), array_length_type);
+                               var cparam = new CCodeParameter (get_array_length_cname ("result", dim), length_ctype);
                                cfundecl.add_parameter (cparam);
                        }
                } else if (d.return_type is DelegateType) {
@@ -239,11 +238,10 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                if (get_ccode_array_length (d) && d.return_type is ArrayType) {
                        // return array length if appropriate
                        var array_type = (ArrayType) d.return_type;
-                       var array_length_type = get_ccode_array_length_type (d) != null ? get_ccode_array_length_type (d) : "int";
-                       array_length_type += "*";
+                       var length_ctype = get_ccode_array_length_type (array_type) + "*";
 
                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                               var cparam = new CCodeParameter (get_array_length_cname ("result", dim), array_length_type);
+                               var cparam = new CCodeParameter (get_array_length_cname ("result", dim), length_ctype);
                                cparam_map.set (get_param_pos (get_ccode_array_length_pos (d) + 0.01 * dim), cparam);
                        }
                } else if (d.return_type is DelegateType) {
index 4004486439d1c63de307f42c9b726e2046c95ce6..ca8b6b6df79097d031fc4d1a8db3cbb9a3e32c40 100644 (file)
@@ -727,10 +727,10 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                        result.append_array_length_cvalue (new CCodeConstant ("-1"));
                                }
                                result.lvalue = false;
-                       } else if (get_ccode_array_length_type (variable) != null) {
+                       } else if (get_ccode_array_length_type (variable.variable_type) != get_ccode_array_length_type (array_type)) {
                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                        // cast if variable does not use int for array length
-                                       result.array_length_cvalues[dim - 1] = new CCodeCastExpression (result.array_length_cvalues[dim - 1], "gint");
+                                       result.array_length_cvalues[dim - 1] = new CCodeCastExpression (result.array_length_cvalues[dim - 1], get_ccode_array_length_type (array_type));
                                }
                                result.lvalue = false;
                        }
index 1bca80aee7830ee0b69670d8680efb13faee4b91..8b92c78c2c236fbc3cf4c19c4b6ebe7dfb3054bc 100644 (file)
@@ -366,17 +366,12 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                        if (unary == null || unary.operator != UnaryOperator.OUT) {
                                                if (get_ccode_array_length (param) && param.variable_type is ArrayType && !((ArrayType) param.variable_type).fixed_length) {
                                                        var array_type = (ArrayType) param.variable_type;
+                                                       var length_ctype = get_ccode_array_length_type (array_type);
+                                                       if (unary != null && unary.operator == UnaryOperator.REF) {
+                                                               length_ctype = "%s*".printf (length_ctype);
+                                                       }
                                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                                               CCodeExpression? array_length_expr = null;
-                                                               if (get_ccode_array_length_type (param) != null) {
-                                                                       string length_ctype = get_ccode_array_length_type (param);
-                                                                       if (unary != null && unary.operator == UnaryOperator.REF) {
-                                                                               length_ctype = "%s*".printf (length_ctype);
-                                                                       }
-                                                                       array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), length_ctype);
-                                                               } else {
-                                                                       array_length_expr = get_array_length_cexpression (arg, dim);
-                                                               }
+                                                               var array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), length_ctype);
                                                                carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), array_length_expr);
                                                        }
                                                } else if (param.variable_type is DelegateType) {
@@ -432,12 +427,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                                if (get_ccode_array_length (param) && param.variable_type is ArrayType && !((ArrayType) param.variable_type).fixed_length) {
                                                        var array_type = (ArrayType) param.variable_type;
-                                                       var array_length_type = int_type;
-                                                       if (get_ccode_array_length_type (param) != null) {
-                                                               array_length_type = new CType (get_ccode_array_length_type (param));
-                                                       }
+                                                       var length_ctype = get_ccode_array_length_type (array_type);
                                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                                               var temp_array_length = get_temp_variable (array_length_type);
+                                                               var temp_array_length = get_temp_variable (new CType (length_ctype));
                                                                emit_temp_var (temp_array_length);
                                                                append_array_length (arg, get_variable_cexpression (temp_array_length.name));
                                                                carg_map.set (get_param_pos (get_ccode_array_length_pos (param) + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_lengths (arg).get (dim - 1)));
@@ -512,13 +504,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                        append_array_length (expr, len_call);
                                } else if (get_ccode_array_length (m)) {
-                                       LocalVariable temp_var;
-
-                                       if (get_ccode_array_length_type (m) == null) {
-                                               temp_var = get_temp_variable (int_type, true, null, true);
-                                       } else {
-                                               temp_var = get_temp_variable (new CType (get_ccode_array_length_type (m)), true, null, true);
-                                       }
+                                       var length_ctype = get_ccode_array_length_type (array_type);
+                                       var temp_var = get_temp_variable (new CType (length_ctype), true, null, true);
                                        var temp_ref = get_variable_cexpression (temp_var.name);
 
                                        emit_temp_var (temp_var);
@@ -581,7 +568,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                        append_array_length (expr, len_call);
                                } else if (get_ccode_array_length (deleg)) {
-                                       var temp_var = get_temp_variable (int_type, true, null, true);
+                                       var temp_var = get_temp_variable (new CType (get_ccode_array_length_type (array_type)), true, null, true);
                                        var temp_ref = get_variable_cexpression (temp_var.name);
 
                                        emit_temp_var (temp_var);
index cdedbee6757850a8ee21a781c5126e39a3da5609..b8740002f13cabfdb0a006a3f6acc06ddead76ca 100644 (file)
@@ -80,11 +80,10 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                } else if (get_ccode_array_length (m) && m.return_type is ArrayType) {
                        // return array length if appropriate
                        var array_type = (ArrayType) m.return_type;
-                       var array_length_type = get_ccode_array_length_type (m) != null ? get_ccode_array_length_type (m) : "int";
-                       array_length_type += "*";
+                       var length_ctype = get_ccode_array_length_type (array_type) + "*";
 
                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                               var cparam = new CCodeParameter (get_array_length_cname ("result", dim), array_length_type);
+                               var cparam = new CCodeParameter (get_array_length_cname ("result", dim), length_ctype);
                                cparam_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), cparam);
                                if (carg_map != null) {
                                        carg_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), get_variable_cexpression (cparam.name));
@@ -580,9 +579,10 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                                        var array_type = (ArrayType) param.variable_type;
 
                                                        if (!array_type.fixed_length) {
+                                                               var length_ctype = get_ccode_array_length_type (array_type);
                                                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                                                        vardecl = new CCodeVariableDeclarator.zero (get_array_length_cname (get_variable_cname ("_vala_%s".printf (param.name)), dim), new CCodeConstant ("0"));
-                                                                       ccode.add_declaration ("int", vardecl);
+                                                                       ccode.add_declaration (length_ctype, vardecl);
                                                                }
                                                        }
                                                } else if (param.variable_type is DelegateType) {
index d9237e656f49f4c30bfed59b72b2eaec19f8363e..4460cba11dce1ea3785686971b2fe0e6d82d6566 100644 (file)
@@ -79,7 +79,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                                        var array_type = (ArrayType) f.variable_type;
 
                                        if (!array_type.fixed_length) {
-                                               var len_type = int_type.copy ();
+                                               var length_ctype = get_ccode_array_length_type (array_type);
 
                                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                                        string length_cname;
@@ -88,11 +88,11 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                                                        } else {
                                                                length_cname = get_array_length_cname (get_ccode_name (f), dim);
                                                        }
-                                                       instance_struct.add_field (get_ccode_name (len_type), length_cname);
+                                                       instance_struct.add_field (length_ctype, length_cname);
                                                }
 
                                                if (array_type.rank == 1 && f.is_internal_symbol ()) {
-                                                       instance_struct.add_field (get_ccode_name (len_type), get_array_size_cname (get_ccode_name (f)));
+                                                       instance_struct.add_field (length_ctype, get_array_size_cname (get_ccode_name (f)));
                                                }
                                        }
                                } else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
index 89da47c404f81e7f6b1f38f72f17308eb0b93bab..c63d9fc654fd92f15561a401cad31d8c62c8f69c 100644 (file)
@@ -58,8 +58,9 @@ public class Vala.GAsyncModule : GtkModule {
                        if (param.variable_type is ArrayType) {
                                var array_type = (ArrayType) param.variable_type;
                                if (get_ccode_array_length (param)) {
+                                       var length_ctype = get_ccode_array_length_type (array_type);
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                               data.add_field ("gint", get_parameter_array_length_cname (param, dim));
+                                               data.add_field (length_ctype, get_parameter_array_length_cname (param, dim));
                                        }
                                }
                        } else if (param.variable_type is DelegateType) {
@@ -84,8 +85,9 @@ public class Vala.GAsyncModule : GtkModule {
                        if (m.return_type is ArrayType) {
                                var array_type = (ArrayType) m.return_type;
                                if (get_ccode_array_length (m)) {
+                                       var length_ctype = get_ccode_array_length_type (array_type);
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
-                                               data.add_field ("gint", get_array_length_cname ("result", dim));
+                                               data.add_field (length_ctype, get_array_length_cname ("result", dim));
                                        }
                                }
                        } else if (m.return_type is DelegateType) {
index 0c23ab21b658527e6ad1030050a2e1e49547b3dc..fc8a03bbec4d1f3f06edf867f10172666b54bd09 100644 (file)
@@ -193,8 +193,12 @@ public class Vala.GSignalModule : GObjectModule {
                        callback_decl.add_parameter (new CCodeParameter ("arg_%d".printf (n_params), get_value_type_name_from_parameter (p)));
                        n_params++;
                        if (p.variable_type is ArrayType) {
-                               for (var j = 0; j < ((ArrayType) p.variable_type).rank; j++) {
-                                       callback_decl.add_parameter (new CCodeParameter ("arg_%d".printf (n_params), "gint"));
+                               var array_type = (ArrayType) p.variable_type;
+                               //FIXME Only int length-type
+                               //var length_ctype = get_ccode_array_length_type (array_type);
+                               var length_ctype = get_ccode_name (int_type);
+                               for (var j = 0; j < array_type.rank; j++) {
+                                       callback_decl.add_parameter (new CCodeParameter ("arg_%d".printf (n_params), length_ctype));
                                        n_params++;
                                }
                        }
@@ -265,7 +269,9 @@ public class Vala.GSignalModule : GObjectModule {
                        fc.add_argument (inner_fc);
                        i++;
                        if (p.variable_type is ArrayType) {
-                               for (var j = 0; j < ((ArrayType) p.variable_type).rank; j++) {
+                               var array_type = (ArrayType) p.variable_type;
+                               for (var j = 0; j < array_type.rank; j++) {
+                                       //FIXME Only int length-type
                                        inner_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_int"));
                                        inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
                                        fc.add_argument (inner_fc);
index 4b39cbbee3f03728345e8b3991a4084563cf61dd..19eb85971200d82ca03b5b54fa703c93a7a93a23 100644 (file)
@@ -349,8 +349,9 @@ public class Vala.GTypeModule : GErrorModule {
 
                        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++) {
-                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), "int*"));
+                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), length_ctype));
                                }
                        } else if ((prop.property_type is DelegateType) && ((DelegateType) prop.property_type).delegate_symbol.has_target) {
                                vdeclarator.add_parameter (new CCodeParameter (get_delegate_target_cname ("result"), "gpointer*"));
@@ -379,8 +380,9 @@ public class Vala.GTypeModule : GErrorModule {
 
                        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++) {
-                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), "int"));
+                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), length_ctype));
                                }
                        } else if ((prop.property_type is DelegateType) && ((DelegateType) prop.property_type).delegate_symbol.has_target) {
                                vdeclarator.add_parameter (new CCodeParameter (get_delegate_target_cname ("value"), "gpointer"));
@@ -413,7 +415,7 @@ public class Vala.GTypeModule : GErrorModule {
                                var array_type = (ArrayType) f.variable_type;
 
                                if (!array_type.fixed_length) {
-                                       var len_type = int_type.copy ();
+                                       var length_ctype = get_ccode_array_length_type (array_type);
 
                                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                                string length_cname;
@@ -422,11 +424,11 @@ public class Vala.GTypeModule : GErrorModule {
                                                } else {
                                                        length_cname = get_array_length_cname (get_ccode_name (f), dim);
                                                }
-                                               instance_struct.add_field (get_ccode_name (len_type), length_cname);
+                                               instance_struct.add_field (length_ctype, length_cname);
                                        }
 
                                        if (array_type.rank == 1 && f.is_internal_symbol ()) {
-                                               instance_struct.add_field (get_ccode_name (len_type), get_array_size_cname (get_ccode_name (f)));
+                                               instance_struct.add_field (length_ctype, get_array_size_cname (get_ccode_name (f)));
                                        }
                                }
                        } else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
@@ -513,9 +515,10 @@ public class Vala.GTypeModule : GErrorModule {
                                        if (f.variable_type is ArrayType && get_ccode_array_length (f)) {
                                                // create fields to store array dimensions
                                                var array_type = (ArrayType) f.variable_type;
-                                               var len_type = int_type.copy ();
 
                                                if (!array_type.fixed_length) {
+                                                       var length_ctype = get_ccode_array_length_type (array_type);
+
                                                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                                                string length_cname;
                                                                if (get_ccode_array_length_name (f) != null) {
@@ -523,11 +526,11 @@ public class Vala.GTypeModule : GErrorModule {
                                                                } else {
                                                                        length_cname = get_array_length_cname (get_ccode_name (f), dim);
                                                                }
-                                                               instance_priv_struct.add_field (get_ccode_name (len_type), length_cname);
+                                                               instance_priv_struct.add_field (length_ctype, length_cname);
                                                        }
 
                                                        if (array_type.rank == 1 && f.is_internal_symbol ()) {
-                                                               instance_priv_struct.add_field (get_ccode_name (len_type), get_array_size_cname (get_ccode_name (f)));
+                                                               instance_priv_struct.add_field (length_ctype, get_array_size_cname (get_ccode_name (f)));
                                                        }
                                                }
                                        } else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
@@ -2165,8 +2168,9 @@ public class Vala.GTypeModule : GErrorModule {
 
                                        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++) {
-                                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), "int*"));
+                                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), length_ctype));
                                                }
                                        }
 
@@ -2187,8 +2191,9 @@ public class Vala.GTypeModule : GErrorModule {
 
                                        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++) {
-                                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), "int"));
+                                                       vdeclarator.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), length_ctype));
                                                }
                                        }
 
index b6d36b6eb200c9ec893132de8d460a04d6418278..061b8f5ab539d8163ed5a26eead073a976e8207c 100644 (file)
@@ -280,9 +280,10 @@ public class Vala.GVariantModule : GAsyncModule {
                // add one extra element for NULL-termination
                new_call.add_argument (new CCodeConstant ("5"));
 
+               var length_ctype = get_ccode_array_length_type (array_type);
                ccode.add_declaration (get_ccode_name (array_type), new CCodeVariableDeclarator (temp_name, new_call));
-               ccode.add_declaration ("int", new CCodeVariableDeclarator (temp_name + "_length", new CCodeConstant ("0")));
-               ccode.add_declaration ("int", new CCodeVariableDeclarator (temp_name + "_size", new CCodeConstant ("4")));
+               ccode.add_declaration (length_ctype, new CCodeVariableDeclarator (temp_name + "_length", new CCodeConstant ("0")));
+               ccode.add_declaration (length_ctype, new CCodeVariableDeclarator (temp_name + "_size", new CCodeConstant ("4")));
 
                deserialize_array_dim (array_type, 1, temp_name, variant_expr, expr);
 
@@ -300,7 +301,7 @@ public class Vala.GVariantModule : GAsyncModule {
                string subiter_name = "_tmp%d_".printf (next_temp_var_id++);
                string element_name = "_tmp%d_".printf (next_temp_var_id++);
 
-               ccode.add_declaration ("int", new CCodeVariableDeclarator ("%s_length%d".printf (temp_name, dim), new CCodeConstant ("0")));
+               ccode.add_declaration (get_ccode_array_length_type (array_type), new CCodeVariableDeclarator ("%s_length%d".printf (temp_name, dim), new CCodeConstant ("0")));
                ccode.add_declaration ("GVariantIter", new CCodeVariableDeclarator (subiter_name));
                ccode.add_declaration ("GVariant*", new CCodeVariableDeclarator (element_name));
 
@@ -627,7 +628,7 @@ public class Vala.GVariantModule : GAsyncModule {
                string index_name = "_tmp%d_".printf (next_temp_var_id++);
 
                ccode.add_declaration ("GVariantBuilder", new CCodeVariableDeclarator (builder_name));
-               ccode.add_declaration ("int", new CCodeVariableDeclarator (index_name));
+               ccode.add_declaration (get_ccode_array_length_type (array_type), new CCodeVariableDeclarator (index_name));
 
                var gvariant_type = new CCodeFunctionCall (new CCodeIdentifier ("G_VARIANT_TYPE"));
                ArrayType array_type_copy = (ArrayType) array_type.copy ();