]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Keep respecting CCode array_length_type of Parameter/Method/Delegate
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 31 Oct 2018 10:09:21 +0000 (11:09 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 2 Nov 2018 13:24:10 +0000 (14:24 +0100)
codegen/valaccode.vala
codegen/valaccodearraymodule.vala
codegen/valaccodedelegatemodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valaccodemethodmodule.vala

index bc29b259da0354e42f6a3b9d1680b8628ccc0afa..ac9b5ead653d14556dadc6b5f9b1b11c64c94d9e 100644 (file)
@@ -250,6 +250,7 @@ namespace Vala {
                if (node is ArrayType) {
                        return get_ccode_name (((ArrayType) node).length_type);
                } else {
+                       assert (node is Method || node is Parameter || node is Delegate);
                        return get_ccode_attribute(node).array_length_type;
                }
        }
index c3ad53fc74621cb910d3c8d3fc4abd21f2d84612..38a4d773a9d33ca0022e5d5a6e5fccbf364c4365 100644 (file)
@@ -744,7 +744,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                }
 
                if (!array_type.fixed_length && get_ccode_array_length (param)) {
-                       var length_ctype = get_ccode_array_length_type (array_type);
+                       var length_ctype = get_ccode_array_length_type (param) ?? get_ccode_array_length_type (array_type);
                        if (param.direction != ParameterDirection.IN) {
                                length_ctype = "%s*".printf (length_ctype);
                        }
index 8251e4fa9e60991d2a98ecf908ade9f73d06075c..7ef39e395f431c18552d0f617e18e2152d2c2db0 100644 (file)
@@ -88,7 +88,7 @@ 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 length_ctype = get_ccode_array_length_type (array_type) + "*";
+                       var length_ctype = (get_ccode_array_length_type (d) ?? 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), length_ctype);
@@ -238,7 +238,7 @@ 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 length_ctype = get_ccode_array_length_type (array_type) + "*";
+                       var length_ctype = (get_ccode_array_length_type (d) ?? 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), length_ctype);
index 8b92c78c2c236fbc3cf4c19c4b6ebe7dfb3054bc..82411bf177b56395d30839f317e875fa52ec8521 100644 (file)
@@ -366,7 +366,7 @@ 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);
+                                                       var length_ctype = get_ccode_array_length_type (param) ?? get_ccode_array_length_type (array_type);
                                                        if (unary != null && unary.operator == UnaryOperator.REF) {
                                                                length_ctype = "%s*".printf (length_ctype);
                                                        }
@@ -427,7 +427,7 @@ 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 length_ctype = get_ccode_array_length_type (array_type);
+                                                       var length_ctype = get_ccode_array_length_type (param) ?? get_ccode_array_length_type (array_type);
                                                        for (int dim = 1; dim <= array_type.rank; dim++) {
                                                                var temp_array_length = get_temp_variable (new CType (length_ctype));
                                                                emit_temp_var (temp_array_length);
@@ -504,7 +504,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                        append_array_length (expr, len_call);
                                } else if (get_ccode_array_length (m)) {
-                                       var length_ctype = get_ccode_array_length_type (array_type);
+                                       var length_ctype = get_ccode_array_length_type (m) ?? 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);
 
index b8740002f13cabfdb0a006a3f6acc06ddead76ca..5aba1446ee3157c7cfc7ecf24f93447b7ad291c5 100644 (file)
@@ -80,7 +80,7 @@ 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 length_ctype = get_ccode_array_length_type (array_type) + "*";
+                       var length_ctype = (get_ccode_array_length_type (m) ?? 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), length_ctype);