vala r2061 - in trunk: . ccode gobject vala vapi



Author: juergbi
Date: Mon Nov 24 15:10:25 2008
New Revision: 2061
URL: http://svn.gnome.org/viewvc/vala?rev=2061&view=rev

Log:
2008-11-24  JÃrg Billeter  <j bitron ch>

	* ccode/valaccodefunctioncall.vala:
	* gobject/valaccodearraymodule.vala:
	* gobject/valaccodebasemodule.vala:
	* gobject/valaccodemethodcallmodule.vala:
	* vala/valasemanticanalyzer.vala:
	* vapi/glib-2.0.vapi:

	Add g_array_index binding and fix g_array_free calls,
	fixes bug 519978


Modified:
   trunk/ChangeLog
   trunk/ccode/valaccodefunctioncall.vala
   trunk/gobject/valaccodearraymodule.vala
   trunk/gobject/valaccodebasemodule.vala
   trunk/gobject/valaccodemethodcallmodule.vala
   trunk/vala/valasemanticanalyzer.vala
   trunk/vapi/glib-2.0.vapi

Modified: trunk/ccode/valaccodefunctioncall.vala
==============================================================================
--- trunk/ccode/valaccodefunctioncall.vala	(original)
+++ trunk/ccode/valaccodefunctioncall.vala	Mon Nov 24 15:10:25 2008
@@ -47,6 +47,10 @@
 		arguments.add (expr);
 	}
 
+	public void insert_argument (int index, CCodeExpression expr) {
+		arguments.insert (index, expr);
+	}
+
 	/**
 	 * Returns a copy of the list of arguments.
 	 *

Modified: trunk/gobject/valaccodearraymodule.vala
==============================================================================
--- trunk/gobject/valaccodearraymodule.vala	(original)
+++ trunk/gobject/valaccodearraymodule.vala	Mon Nov 24 15:10:25 2008
@@ -476,4 +476,25 @@
 
 		return dup_func;
 	}
+
+	public override void visit_method_call (MethodCall expr) {
+		base.visit_method_call (expr);
+
+		var ccall = expr.ccodenode as CCodeFunctionCall;
+		if (ccall == null) {
+			return;
+		}
+
+		var cid = ccall.call as CCodeIdentifier;
+		if (cid == null || cid.name != "g_array_index") {
+			return;
+		}
+
+		// insert type argument in calls to g_array_index macro
+
+		var ma = (MemberAccess) expr.call;
+		var element_type = ma.inner.value_type.get_type_arguments ().get (0);
+
+		ccall.insert_argument (1, new CCodeIdentifier (element_type.get_cname ()));
+	}
 }

Modified: trunk/gobject/valaccodebasemodule.vala
==============================================================================
--- trunk/gobject/valaccodebasemodule.vala	(original)
+++ trunk/gobject/valaccodebasemodule.vala	Mon Nov 24 15:10:25 2008
@@ -1659,7 +1659,7 @@
 		/* set freed references to NULL to prevent further use */
 		var ccomma = new CCodeCommaExpression ();
 
-		if (type.data_type == gstringbuilder_type) {
+		if (type.data_type == gstringbuilder_type || type.data_type == garray_type) {
 			ccall.add_argument (new CCodeConstant ("TRUE"));
 		} else if (type is ArrayType) {
 			var array_type = (ArrayType) type;

Modified: trunk/gobject/valaccodemethodcallmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodcallmodule.vala	(original)
+++ trunk/gobject/valaccodemethodcallmodule.vala	Mon Nov 24 15:10:25 2008
@@ -426,12 +426,7 @@
 		if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) {
 			expr.ccodenode = new CCodeAssignment (instance, ccall_expr);
 		} else {
-			/* cast pointer to actual type if this is a generic method return value */
-			if (m != null && m.return_type.type_parameter != null && expr.value_type.data_type != null) {
-				expr.ccodenode = convert_from_generic_pointer (ccall_expr, expr.value_type);
-			} else {
-				expr.ccodenode = ccall_expr;
-			}
+			expr.ccodenode = ccall_expr;
 		}
 		
 		if (m is ArrayResizeMethod) {

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Mon Nov 24 15:10:25 2008
@@ -56,6 +56,7 @@
 	public TypeSymbol initially_unowned_type;
 	public DataType glist_type;
 	public DataType gslist_type;
+	public DataType garray_type;
 	public Class gerror_type;
 	public DataType iterable_type;
 	public Interface iterator_type;
@@ -108,6 +109,7 @@
 
 			glist_type = new ObjectType ((Class) glib_ns.scope.lookup ("List"));
 			gslist_type = new ObjectType ((Class) glib_ns.scope.lookup ("SList"));
+			garray_type = new ObjectType ((Class) glib_ns.scope.lookup ("Array"));
 
 			gerror_type = (Class) glib_ns.scope.lookup ("Error");
 		}
@@ -571,7 +573,10 @@
 			return generic_type;
 		}
 		actual_type = actual_type.copy ();
-		actual_type.is_type_argument = true;
+		if (!(derived_instance_type.data_type != null && derived_instance_type.data_type.get_full_name () == "GLib.Array")) {
+			// GArray doesn't use pointer-based generics
+			actual_type.is_type_argument = true;
+		}
 		actual_type.value_owned = actual_type.value_owned && generic_type.value_owned;
 		return actual_type;
 	}

Modified: trunk/vapi/glib-2.0.vapi
==============================================================================
--- trunk/vapi/glib-2.0.vapi	(original)
+++ trunk/vapi/glib-2.0.vapi	Mon Nov 24 15:10:25 2008
@@ -3009,32 +3009,25 @@
 
 	[Compact]
 	public class Array<G> {
+		[CCode (cname = "len")]
+		public uint length;
+
 		public Array (bool zero_terminated, bool clear, uint element_size);
 		[CCode (cname = "g_array_sized_new")]
 		public Array.sized (bool zero_terminated, bool clear, uint element_size, uint reserved_size);
-		[ReturnsModifiedPointer ()]
 		public void append_val (G value);
-		[ReturnsModifiedPointer ()]
 		public void append_vals (constpointer data, uint len);
-		[ReturnsModifiedPointer ()]
 		public void prepend_val (G value);
-		[ReturnsModifiedPointer ()]
 		public void prepend_vals (constpointer data, uint len);
-		[ReturnsModifiedPointer ()]
 		public void insert_val (uint index, G value);
-		[ReturnsModifiedPointer ()]
 		public void insert_vals (uint index, constpointer data, uint len);
-		[ReturnsModifiedPointer ()]
 		public void remove_index (uint index);
-		[ReturnsModifiedPointer ()]
 		public void remove_index_fast (uint index);
-		[ReturnsModifiedPointer ()]
 		public void remove_range (uint index, uint length);
 		public void sort (CompareFunc compare_func);
 		public void sort_with_data (CompareDataFunc compare_func, void* user_data);
-		[ReturnsModifiedPointer ()]
+		public G index (uint index);
 		public void set_size (uint length);
-		public string free (bool free_segment);
 	}
 	
 	/* GTree */



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