vala r2267 - in trunk: . gobject vala vapi



Author: juergbi
Date: Sun Jan  4 16:15:41 2009
New Revision: 2267
URL: http://svn.gnome.org/viewvc/vala?rev=2267&view=rev

Log:
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


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodearraymodule.vala
   trunk/gobject/valaccodemethodcallmodule.vala
   trunk/vala/valadelegate.vala
   trunk/vala/valafield.vala
   trunk/vala/valaformalparameter.vala
   trunk/vala/valamethod.vala
   trunk/vapi/glib-2.0.vapi

Modified: trunk/gobject/valaccodearraymodule.vala
==============================================================================
--- trunk/gobject/valaccodearraymodule.vala	(original)
+++ trunk/gobject/valaccodearraymodule.vala	Sun Jan  4 16:15:41 2009
@@ -141,7 +141,12 @@
 		} 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
@@ -164,7 +169,12 @@
 				}
 			} 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;

Modified: trunk/gobject/valaccodemethodcallmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodcallmodule.vala	(original)
+++ trunk/gobject/valaccodemethodcallmodule.vala	Sun Jan  4 16:15:41 2009
@@ -1,6 +1,7 @@
 /* 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
@@ -361,7 +362,20 @@
 		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);
 

Modified: trunk/vala/valadelegate.vala
==============================================================================
--- trunk/vala/valadelegate.vala	(original)
+++ trunk/vala/valadelegate.vala	Sun Jan  4 16:15:41 2009
@@ -68,6 +68,11 @@
 	 */
 	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> ();
@@ -216,6 +221,9 @@
 		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");
 		}

Modified: trunk/vala/valafield.vala
==============================================================================
--- trunk/vala/valafield.vala	(original)
+++ trunk/vala/valafield.vala	Sun Jan  4 16:15:41 2009
@@ -70,6 +70,11 @@
 	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.
 	 */
 	public bool has_array_length_cname {
@@ -181,6 +186,9 @@
 		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"));
 		}

Modified: trunk/vala/valaformalparameter.vala
==============================================================================
--- trunk/vala/valaformalparameter.vala	(original)
+++ trunk/vala/valaformalparameter.vala	Sun Jan  4 16:15:41 2009
@@ -67,6 +67,11 @@
 	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.
 	 */
 	public double cparameter_position { get; set; }
@@ -143,6 +148,9 @@
 		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");
 		}

Modified: trunk/vala/valamethod.vala
==============================================================================
--- trunk/vala/valamethod.vala	(original)
+++ trunk/vala/valamethod.vala	Sun Jan  4 16:15:41 2009
@@ -183,6 +183,11 @@
 	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.
 	 */
 	public bool printf_format { get; set; }
@@ -365,6 +370,9 @@
 		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");
 		}

Modified: trunk/vapi/glib-2.0.vapi
==============================================================================
--- trunk/vapi/glib-2.0.vapi	(original)
+++ trunk/vapi/glib-2.0.vapi	Sun Jan  4 16:15:41 2009
@@ -717,7 +717,7 @@
 	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)]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]