]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
fix casts to GTypeInstance
authorJuerg Billeter <j@bitron.ch>
Fri, 18 Apr 2008 22:06:11 +0000 (22:06 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 18 Apr 2008 22:06:11 +0000 (22:06 +0000)
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

svn path=/trunk/; revision=1258

ChangeLog
gobject/valaccodegenerator.vala
vapi/glib-2.0.vapi

index 61926a2eb774fe365280eef48f32d387d1812162..50e6d543d37dbd308fca9144f38c14e96f5e74f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-19  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodegenerator.vala: fix casts to GTypeInstance
+
+       * vapi/glib-2.0.vapi: add get_type method to GLib.TypeInstance
+
 2008-04-18  Jürg Billeter  <j@bitron.ch>
 
        * vala/valasemanticanalyzer.vala: check accessiblity of base types
index f9da4d418e6fbc32e54be0456757a7f4de8f2079..f554cf89bf1ed51af78a04c8650c94ca4e934b28 100644 (file)
@@ -3034,8 +3034,10 @@ public class Vala.CCodeGenerator : CodeGenerator {
        }
 
        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 @@ public class Vala.CCodeGenerator : CodeGenerator {
                        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;
index eaa36e065464ec56eaeb626e05166278cc6403a6..d2d7b34b3d7c959abc16eeb2d8697b4c1d8e266c 100644 (file)
@@ -656,6 +656,8 @@ namespace GLib {
 
        [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")]