[vala/wip/attributes: 67/100] Drop TypeSymbol ref_function and unref_function



commit b3de8d136e198c5d08e973f472817b464ba3ba4e
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed Jun 29 21:10:52 2011 +0200

    Drop TypeSymbol ref_function and unref_function

 codegen/valadovabasemodule.vala |   16 ++++++++++++----
 vala/valaclass.vala             |   36 ------------------------------------
 vala/valainterface.vala         |   20 --------------------
 vala/valatypesymbol.vala        |   27 ---------------------------
 4 files changed, 12 insertions(+), 87 deletions(-)
---
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index a33b7f6..7b9bb68 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -997,7 +997,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		if (type.data_type != null) {
 			string dup_function = "";
 			if (is_reference_counting (type.data_type)) {
-				dup_function = type.data_type.get_ref_function ();
+				dup_function = get_ccode_ref_function (type.data_type);
 			} else if (type is ValueType) {
 				dup_function = get_ccode_dup_function (type.data_type);
 			}
@@ -1022,7 +1022,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 			string unref_function;
 			if (type is ReferenceType) {
 				if (is_reference_counting (type.data_type)) {
-					unref_function = type.data_type.get_unref_function ();
+					unref_function = get_ccode_unref_function (type.data_type);
 				} else {
 					unref_function = get_ccode_free_function (type.data_type);
 				}
@@ -1404,7 +1404,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 
 		var cl = type.data_type as Class;
 		if (cl != null && is_reference_counting (cl)
-		    && cl.get_ref_function () == "") {
+		    && get_ccode_ref_function (cl) == "") {
 			// empty ref_function => no ref necessary
 			return false;
 		}
@@ -1428,7 +1428,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 
 		var cl = type.data_type as Class;
 		if (cl != null && is_reference_counting (cl)
-		    && cl.get_unref_function () == "") {
+		    && get_ccode_unref_function (cl) == "") {
 			// empty unref_function => no unref necessary
 			return false;
 		}
@@ -2298,6 +2298,14 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		return CCodeBaseModule.get_ccode_dup_function (node);
 	}
 
+	public string get_ccode_ref_function (CodeNode node) {
+		return CCodeBaseModule.get_ccode_ref_function (node);
+	}
+
+	public string get_ccode_unref_function (CodeNode node) {
+		return CCodeBaseModule.get_ccode_unref_function (node);
+	}
+
 	public bool is_reference_counting (CodeNode node) {
 		return CCodeBaseModule.is_reference_counting (node);
 	}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index b28cda0..722256c 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -84,7 +84,6 @@ public class Vala.Class : ObjectTypeSymbol {
 	private string lower_case_cprefix;
 	private string lower_case_csuffix;
 	private string type_id;
-	private string unref_function;
 	private string ref_sink_function;
 	private bool _is_compact;
 	private bool _is_immutable;
@@ -632,9 +631,6 @@ public class Vala.Class : ObjectTypeSymbol {
 	}
 	
 	private void process_ccode_attribute (Attribute a) {
-		if (a.has_argument ("unref_function")) {
-			set_unref_function (a.get_string ("unref_function"));
-		}
 		if (a.has_argument ("ref_sink_function")) {
 			set_ref_sink_function (a.get_string ("ref_sink_function"));
 		}
@@ -702,38 +698,6 @@ public class Vala.Class : ObjectTypeSymbol {
 		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 {
-			return ref_function;
-		}
-	}
-
-	public void set_ref_function (string? name) {
-		this.ref_function = name;
-	}
-
-	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 {
-			return unref_function;
-		}
-	}
-
-	public void set_unref_function (string? name) {
-		this.unref_function = name;
-	}
-
 	public override string? get_ref_sink_function () {
 		if (ref_sink_function == null && base_class != null) {
 			return base_class.get_ref_sink_function ();
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 6c3f2cd..d5975ff 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -418,26 +418,6 @@ public class Vala.Interface : ObjectTypeSymbol {
 		return true;
 	}
 	
-	public override string? get_ref_function () {
-		foreach (DataType prerequisite in prerequisites) {
-			string ref_func = prerequisite.data_type.get_ref_function ();
-			if (ref_func != null) {
-				return ref_func;
-			}
-		}
-		return null;
-	}
-	
-	public override string? get_unref_function () {
-		foreach (DataType prerequisite in prerequisites) {
-			string unref_func = prerequisite.data_type.get_unref_function ();
-			if (unref_func != null) {
-				return unref_func;
-			}
-		}
-		return null;
-	}
-
 	public override string? get_ref_sink_function () {
 		foreach (DataType prerequisite in prerequisites) {
 			string ref_sink_func = prerequisite.data_type.get_ref_sink_function ();
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index acb85f6..0f1f966 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -74,33 +74,6 @@ public abstract class Vala.TypeSymbol : Symbol {
 	}
 	
 	/**
-	 * Returns the C function name that increments the reference count of
-	 * instances of this data type. This is only valid for data types
-	 * supporting reference counting. The specified C function must accept
-	 * one argument referencing the instance of this data type and return
-	 * the reference.
-	 *
-	 * @return the name of the C function or null if this data type does not
-	 *         support reference counting
-	 */
-	public virtual string? get_ref_function () {
-		return null;
-	}
-	
-	/**
-	 * Returns the C function name that decrements the reference count of
-	 * instances of this data type. This is only valid for data types
-	 * supporting reference counting. The specified C function must accept
-	 * one argument referencing the instance of this data type.
-	 *
-	 * @return the name of the C function or null if this data type does not
-	 *         support reference counting
-	 */
-	public virtual string? get_unref_function () {
-		return null;
-	}
-
-	/**
 	 * Returns the C function name that sinks the reference count of
 	 * "floating" instances of this data type. This is only valid for data
 	 * types supporting floating references. The specified C function must



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