Fixes part of bug 529866.
} else {
length_expr = new CCodeMemberAccess (inst, length_cname);
}
+
+ if (field.array_length_type != null) {
+ length_expr = new CCodeCastExpression (length_expr, "gint");
+ }
} else {
length_expr = new CCodeIdentifier (get_array_length_cname (field.get_cname (), dim));
}
bool custom_ctype = (f.get_ctype () != null);
bool custom_cheaders = (f.parent_symbol is Namespace);
bool custom_array_length_cname = (f.get_array_length_cname () != null);
- if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname || (f.no_array_length && f.field_type is ArrayType)) {
+ bool custom_array_length_type = (f.array_length_type != null);
+ if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname || custom_array_length_type || (f.no_array_length && f.field_type is ArrayType)) {
write_indent ();
write_string ("[CCode (");
if (f.array_null_terminated) {
write_string (", array_null_terminated = true");
}
- } else if (custom_array_length_cname) {
- if (custom_cname || custom_ctype || custom_cheaders) {
- write_string (", ");
+ } else {
+ if (custom_array_length_cname) {
+ if (custom_cname || custom_ctype || custom_cheaders) {
+ write_string (", ");
+ }
+
+ write_string ("array_length_cname = \"%s\"".printf (f.get_array_length_cname ()));
}
- write_string ("array_length_cname = \"%s\"".printf (f.get_array_length_cname ()));
+ if (custom_array_length_type) {
+ if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname) {
+ write_string (", ");
+ }
+
+ write_string ("array_length_type = \"%s\"".printf (f.array_length_type));
+ }
}
}
get { return (array_length_cexpr != null); }
}
+ /**
+ * Specifies a custom type for the array length.
+ */
+ public string? array_length_type { get; set; default = null; }
+
private string? array_length_cname;
private string? array_length_cexpr;
if (a.has_argument ("array_length_cexpr")) {
set_array_length_cexpr (a.get_string ("array_length_cexpr"));
}
+ if (a.has_argument ("array_length_type")) {
+ array_length_type = a.get_string ("array_length_type");
+ }
if (a.has_argument ("delegate_target")) {
no_delegate_target = !a.get_bool ("delegate_target");
}
string cheader_filename = null;
string ctype = null;
string array_length_cname = null;
+ string array_length_type = null;
bool array_null_terminated = false;
var attributes = get_attributes ("%s.%s".printf (current_data_type.get_cname (), node.name));
}
} else if (nv[0] == "array_length_cname") {
array_length_cname = eval (nv[1]);
+ } else if (nv[0] == "array_length_type") {
+ array_length_type = eval (nv[1]);
}
}
}
field.array_null_terminated = true;
}
- if (array_length_cname != null) {
- field.set_array_length_cname (array_length_cname);
+ if (array_length_cname != null || array_length_type != null) {
+ if (array_length_cname != null) {
+ field.set_array_length_cname (array_length_cname);
+ }
+ if (array_length_type != null) {
+ field.array_length_type = array_length_type;
+ }
} else {
field.no_array_length = true;
}