+2009-01-04 Jürg Billeter <j@bitron.ch>
+
+ * vala/valadelegate.vala:
+ * vala/valafield.vala:
+ * vala/valaformalparameter.vala:
+ * vala/valamethod.vala:
+ * gobject/valaccodearraymodule.vala:
+ * gobject/valaccodemethodcallmodule.vala:
+
+ Support [CCode (array_null_terminated = true)] attribute to fix
+ length handling of null terminated arrays, fixes bug 514186
+
+ * vapi/glib-2.0.vapi:
+
+ Fix g_strsplit binding
+
2009-01-04 Jürg Billeter <j@bitron.ch>
* vapi/cairo.vapi:
} else if (array_expr.symbol_reference != null) {
if (array_expr.symbol_reference is FormalParameter) {
var param = (FormalParameter) array_expr.symbol_reference;
- if (!param.no_array_length) {
+ if (param.array_null_terminated) {
+ var carray_expr = get_variable_cexpression (param.name);
+ var len_call = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
+ len_call.add_argument (carray_expr);
+ return len_call;
+ } else if (!param.no_array_length) {
CCodeExpression length_expr = get_variable_cexpression (get_array_length_cname (param.name, dim));
if (param.direction != ParameterDirection.IN) {
// accessing argument of out/ref param
}
} else if (array_expr.symbol_reference is Field) {
var field = (Field) array_expr.symbol_reference;
- if (!field.no_array_length) {
+ if (field.array_null_terminated) {
+ var carray_expr = (CCodeExpression) array_expr.ccodenode;
+ var len_call = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
+ len_call.add_argument (carray_expr);
+ return len_call;
+ } else if (!field.no_array_length) {
var ma = (MemberAccess) array_expr;
CCodeExpression length_expr = null;
/* valaccodemethodcallmodule.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2008 Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
if (m != null && m.return_type is ArrayType) {
var array_type = (ArrayType) m.return_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
- if (!m.no_array_length) {
+ if (m.array_null_terminated) {
+ // handle calls to methods returning null-terminated arrays
+ var temp_var = get_temp_variable (itype.get_return_type ());
+ var temp_ref = get_variable_cexpression (temp_var.name);
+
+ temp_vars.insert (0, temp_var);
+
+ ccall_expr = new CCodeAssignment (temp_ref, ccall_expr);
+
+ var len_call = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
+ len_call.add_argument (temp_ref);
+
+ expr.append_array_size (len_call);
+ } else if (!m.no_array_length) {
var temp_var = get_temp_variable (int_type);
var temp_ref = get_variable_cexpression (temp_var.name);
*/
public bool no_array_length { get; set; }
+ /**
+ * Specifies whether the array is null terminated.
+ */
+ public bool array_null_terminated { get; set; }
+
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
private Gee.List<FormalParameter> parameters = new ArrayList<FormalParameter> ();
if (a.has_argument ("array_length")) {
no_array_length = !a.get_bool ("array_length");
}
+ if (a.has_argument ("array_null_terminated")) {
+ array_null_terminated = a.get_bool ("array_null_terminated");
+ }
if (a.has_argument ("array_length_pos")) {
carray_length_parameter_position = a.get_double ("array_length_pos");
}
*/
public bool no_array_length { get; set; }
+ /**
+ * Specifies whether the array is null terminated.
+ */
+ public bool array_null_terminated { get; set; }
+
/**
* Specifies whether the array length field uses a custom name in C.
*/
if (a.has_argument ("array_length")) {
no_array_length = !a.get_bool ("array_length");
}
+ if (a.has_argument ("array_null_terminated")) {
+ array_null_terminated = a.get_bool ("array_null_terminated");
+ }
if (a.has_argument ("array_length_cname")) {
set_array_length_cname (a.get_string ("array_length_cname"));
}
*/
public bool no_array_length { get; set; }
+ /**
+ * Specifies whether the array is null terminated.
+ */
+ public bool array_null_terminated { get; set; }
+
/**
* Specifies the position of the parameter in the C function.
*/
if (a.has_argument ("array_length")) {
no_array_length = !a.get_bool ("array_length");
}
+ if (a.has_argument ("array_null_terminated")) {
+ array_null_terminated = a.get_bool ("array_null_terminated");
+ }
if (a.has_argument ("array_length_pos")) {
carray_length_parameter_position = a.get_double ("array_length_pos");
}
*/
public bool no_array_length { get; set; }
+ /**
+ * Specifies whether the array is null terminated.
+ */
+ public bool array_null_terminated { get; set; }
+
/**
* Specifies whether this method expects printf-style format arguments.
*/
if (a.has_argument ("array_length")) {
no_array_length = !a.get_bool ("array_length");
}
+ if (a.has_argument ("array_null_terminated")) {
+ array_null_terminated = a.get_bool ("array_null_terminated");
+ }
if (a.has_argument ("array_length_pos")) {
carray_length_parameter_position = a.get_double ("array_length_pos");
}
public string escape (string exceptions);
[CCode (cname = "g_strcompress")]
public string compress ();
- [CCode (cname = "g_strsplit", array_length = false)]
+ [CCode (cname = "g_strsplit", array_length = false, array_null_terminated = true)]
[NoArrayLength]
public string[] split (string delimiter, int max_tokens = 0);
[CCode (cname = "g_strsplit_set", array_length = false)]