From 3e4156ad75b4349642b2a56fd4df3bc5440f1b4d Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Fri, 18 Apr 2008 21:26:04 +0000 Subject: [PATCH] make sure that ref_function and unref_function of classes deriving from 2008-04-18 Juerg Billeter * 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 | 6 ++++++ gobject/valaccodegeneratorclass.vala | 3 --- vala/valaclass.vala | 19 ++++++++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e418903..42b2492 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-04-18 Jürg Billeter + * 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 + * vala/valaparser.vala: ensure all classes have a default construction method diff --git a/gobject/valaccodegeneratorclass.vala b/gobject/valaccodegeneratorclass.vala index 31bd5ac..1723c28 100644 --- a/gobject/valaccodegeneratorclass.vala +++ b/gobject/valaccodegeneratorclass.vala @@ -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"); diff --git a/vala/valaclass.vala b/vala/valaclass.vala index c143879..5b504ad 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -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 { -- 2.7.4