make sure that ref_function and unref_function of classes deriving from
authorJuerg Billeter <j@bitron.ch>
Fri, 18 Apr 2008 21:26:04 +0000 (21:26 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 18 Apr 2008 21:26:04 +0000 (21:26 +0000)
2008-04-18  Juerg Billeter  <j@bitron.ch>

* vala/valaclass.vala, gobject/valaccodegeneratorclass.vala: make
  sure that ref_function and unref_function of classes deriving
  from GTypeInstance are always initialized

svn path=/trunk/; revision=1255

ChangeLog
gobject/valaccodegeneratorclass.vala
vala/valaclass.vala

index e418903..42b2492 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-04-18  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valaclass.vala, gobject/valaccodegeneratorclass.vala: make
+         sure that ref_function and unref_function of classes deriving
+         from GTypeInstance are always initialized
+
+2008-04-18  Jürg Billeter  <j@bitron.ch>
+
        * vala/valaparser.vala: ensure all classes have a default
          construction method
 
index 31bd5ac..1723c28 100644 (file)
@@ -238,9 +238,6 @@ public class Vala.CCodeGenerator {
 
                                source_type_member_definition.append (ref_fun);
                                source_type_member_definition.append (unref_fun);
-
-                               cl.set_ref_function (ref_fun.name);
-                               cl.set_unref_function (unref_fun.name);
                        }
                } else if (!cl.is_static) {
                        var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
index c143879..5b504ad 100644 (file)
@@ -598,8 +598,21 @@ public class Vala.Class : Typesymbol {
        public override bool is_reference_counting () {
                return get_ref_function () != null;
        }
-       
+
+       bool is_fundamental () {
+               if (base_class != null
+                   && base_class.name == "TypeInstance"
+                   && base_class.parent_symbol.name == "GLib") {
+                       return true;
+               }
+               return false;
+       }
+
        public override string? get_ref_function () {
+               if (ref_function == null && is_fundamental ()) {
+                       ref_function = get_lower_case_cprefix () + "ref";
+               }
+
                if (ref_function == null && base_class != null) {
                        return base_class.get_ref_function ();
                } else {
@@ -612,6 +625,10 @@ public class Vala.Class : Typesymbol {
        }
 
        public override string? get_unref_function () {
+               if (unref_function == null && is_fundamental ()) {
+                       unref_function = get_lower_case_cprefix () + "unref";
+               }
+
                if (unref_function == null && base_class != null) {
                        return base_class.get_unref_function ();
                } else {