out_arg_map.set (get_param_pos (get_ccode_array_length_pos (m) + 0.01 * dim), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
append_array_length (expr, temp_ref);
+ } else if (get_ccode_array_length_expr (m) != null) {
+ append_array_length (expr, new CCodeConstant (get_ccode_array_length_expr (m)));
} else {
append_array_length (expr, new CCodeConstant ("-1"));
}
methods/bug774060.vala \
methods/bug775466.test \
methods/bug781061.vala \
+ methods/bug784691.vala \
methods/generics.vala \
methods/printf-invalid.test \
methods/printf-constructor.vala \
public static void change_array ([CCode (array_length = false)] ref uint8 array[2]);
[CCode (cheader_filename = "test.h")]
public static void get_array_out ([CCode (array_length = false)] out uint8 array[8]);
-[CCode (array_length = false, cheader_filename = "test.h")]
+[CCode (array_length = false, array_length_cexpr = "16", cheader_filename = "test.h")]
public static unowned uint8[] get_array_return ();
[CCode (cheader_filename = "test.h")]
public static void set_array ([CCode (array_length = false)] uint8 array[4]);
--- /dev/null
+const int[] FOO = { 0, 1, 2 };
+
+[CCode (array_length = false, array_length_cexpr = "3")]
+unowned int[] get_foo () {
+ assert (FOO.length == 3);
+ return FOO;
+}
+
+void main () {
+ assert (get_foo ().length == 3);
+}
}
type = element_get_type (type, true, ref no_array_length, ref array_null_terminated);
- // FIXME No support for fixed-size array as return-value
- var array_type = type as ArrayType;
- if (array_type != null && array_type.fixed_length) {
- array_type.fixed_length = false;
- array_type.length = null;
- }
-
end_element ("return-value");
return type;
}
s.comment = comment;
s.external = true;
+ // Transform fixed-array properties of return-type into ccode-attribute
+ var array_type = return_type as ArrayType;
+ if (array_type != null && array_type.fixed_length) {
+ s.set_attribute_string ("CCode", "array_length_cexpr", ((IntegerLiteral) array_type.length).value);
+ array_type.fixed_length = false;
+ array_type.length = null;
+ }
+
if (s is Signal) {
if (current.girdata["name"] != name.replace ("_", "-")) {
s.set_attribute_string ("CCode", "cname", current.girdata["name"]);