vala r1258 - in trunk: . gobject vapi



Author: juergbi
Date: Fri Apr 18 22:06:11 2008
New Revision: 1258
URL: http://svn.gnome.org/viewvc/vala?rev=1258&view=rev

Log:
2008-04-19  Juerg Billeter  <j bitron ch>

	* gobject/valaccodegenerator.vala: fix casts to GTypeInstance

	* vapi/glib-2.0.vapi: add get_type method to GLib.TypeInstance


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegenerator.vala
   trunk/vapi/glib-2.0.vapi

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Fri Apr 18 22:06:11 2008
@@ -3034,8 +3034,10 @@
 	}
 
 	public override void visit_cast_expression (CastExpression expr) {
-		if (expr.type_reference.data_type != null && expr.type_reference.data_type.is_subtype_of (gtypeinstance_type)) {
-			// GObject cast
+		if (expr.type_reference.data_type != null
+		    && expr.type_reference.data_type.is_subtype_of (gtypeinstance_type)
+		    && expr.type_reference.data_type != gtypeinstance_type) {
+			// checked cast for strict subtypes of GTypeInstance
 			if (expr.is_silent_cast) {
 				var ccomma = new CCodeCommaExpression ();
 				var temp_decl = get_temp_variable (expr.inner.static_type, true, expr);
@@ -3272,7 +3274,10 @@
 			return cexpr;
 		}
 
-		if (context.checking && target_type.data_type != null && target_type.data_type.is_subtype_of (gtypeinstance_type)) {
+		if (context.checking && target_type.data_type != null
+		    && target_type.data_type.is_subtype_of (gtypeinstance_type)
+		    && target_type.data_type != gtypeinstance_type) {
+			// checked cast for strict subtypes of GTypeInstance
 			return new InstanceCast (cexpr, target_type.data_type);
 		} else if (target_type.data_type != null && expression_type.get_cname () != target_type.get_cname ()) {
 			var st = target_type.data_type as Struct;

Modified: trunk/vapi/glib-2.0.vapi
==============================================================================
--- trunk/vapi/glib-2.0.vapi	(original)
+++ trunk/vapi/glib-2.0.vapi	Fri Apr 18 22:06:11 2008
@@ -656,6 +656,8 @@
 
 	[CCode (has_type_id = true)]
 	public class TypeInstance {
+		[CCode (cname = "G_TYPE_FROM_INSTANCE")]
+		public Type get_type ();
 	}
 
 	[CCode (ref_function = "g_type_class_ref", unref_function = "g_type_class_unref")]



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