[vala/wip/attributes: 66/121] Drop TypeSymbol.is_reference_counting



commit 25a2e94e3430b7581095f0717c81f2101316b6e6
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed Jun 29 21:08:05 2011 +0200

    Drop TypeSymbol.is_reference_counting

 codegen/valaccodebasemodule.vala         |   18 +++++++++++-------
 codegen/valaccodedelegatemodule.vala     |    2 +-
 codegen/valaccodememberaccessmodule.vala |    2 +-
 codegen/valadovabasemodule.vala          |   12 ++++++++----
 vala/valaclass.vala                      |    8 --------
 vala/valainterface.vala                  |    4 ----
 vala/valatypesymbol.vala                 |   10 ----------
 7 files changed, 21 insertions(+), 35 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index a142474..6c4f47c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2234,7 +2234,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		} else if (type.data_type != null) {
 			string dup_function;
 			var cl = type.data_type as Class;
-			if (type.data_type.is_reference_counting ()) {
+			if (is_reference_counting (type.data_type)) {
 				dup_function = get_ccode_ref_function ((ObjectTypeSymbol) type.data_type);
 				if (type.data_type is Interface && dup_function == "") {
 					Report.error (source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.data_type.get_full_name ()));
@@ -2662,7 +2662,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		} else if (type.data_type != null) {
 			string unref_function;
 			if (type is ReferenceType) {
-				if (type.data_type.is_reference_counting ()) {
+				if (is_reference_counting (type.data_type)) {
 					unref_function = get_ccode_unref_function ((ObjectTypeSymbol) type.data_type);
 					if (type.data_type is Interface && unref_function == "") {
 						Report.error (type.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (type.data_type.get_full_name ()));
@@ -2901,7 +2901,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		var ccomma = new CCodeCommaExpression ();
 
 		if (context.profile == Profile.GOBJECT) {
-			if (type.data_type != null && !type.data_type.is_reference_counting () &&
+			if (type.data_type != null && !is_reference_counting (type.data_type) &&
 			    (type.data_type == gstringbuilder_type
 			     || type.data_type == garray_type
 			     || type.data_type == gbytearray_type
@@ -2947,7 +2947,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		var cassign = new CCodeAssignment (cvar, ccomma);
 
 		// g_free (NULL) is allowed
-		bool uses_gfree = (type.data_type != null && !type.data_type.is_reference_counting () && get_ccode_free_function (type.data_type) == "g_free");
+		bool uses_gfree = (type.data_type != null && !is_reference_counting (type.data_type) && get_ccode_free_function (type.data_type) == "g_free");
 		uses_gfree = uses_gfree || type is ArrayType;
 		if (uses_gfree) {
 			return cassign;
@@ -3661,7 +3661,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		}
 
 		var cl = type.data_type as Class;
-		if (cl != null && cl.is_reference_counting ()
+		if (cl != null && is_reference_counting (cl)
 		    && get_ccode_ref_function (cl) == "") {
 			// empty ref_function => no ref necessary
 			return false;
@@ -3687,7 +3687,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		}
 
 		var cl = type.data_type as Class;
-		if (cl != null && cl.is_reference_counting ()
+		if (cl != null && is_reference_counting (cl)
 		    && get_ccode_unref_function (cl) == "") {
 			// empty unref_function => no unref necessary
 			return false;
@@ -5609,10 +5609,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return get_ccode_attribute(sym).lower_case_suffix;
 	}
 
-	public static string get_ccode_ref_function (ObjectTypeSymbol sym) {
+	public static string get_ccode_ref_function (TypeSymbol sym) {
 		return get_ccode_attribute(sym).ref_function;
 	}
 
+	public static bool is_reference_counting (TypeSymbol sym) {
+		return get_ccode_ref_function (sym) != "";
+	}
+
 	public static bool get_ccode_ref_function_void (Class cl) {
 		return get_ccode_attribute(cl).ref_function_void;
 	}
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index cdce4e2..91d5f00 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -414,7 +414,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 			if (m.closure) {
 				int block_id = get_block_id (current_closure_block);
 				destroy_notify = new CCodeIdentifier ("block%d_data_unref".printf (block_id));
-			} else if (get_this_type () != null && m.binding != MemberBinding.STATIC && !m.is_async_callback && m.this_parameter.variable_type.data_type.is_reference_counting ()) {
+			} else if (get_this_type () != null && m.binding != MemberBinding.STATIC && !m.is_async_callback && is_reference_counting (m.this_parameter.variable_type.data_type)) {
 				destroy_notify = get_destroy_func_expression (m.this_parameter.variable_type);
 			} else if (in_constructor) {
 				destroy_notify = new CCodeIdentifier ("g_object_unref");
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index af9cd8d..28480a3 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -106,7 +106,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				// expr.inner is null in the special case of referencing the method in a constant initializer
 				var delegate_target = (CCodeExpression) get_ccodenode (expr.inner);
 				delegate_type = expr.target_type as DelegateType;
-				if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.data_type != null && expr.inner.value_type.data_type.is_reference_counting ()) {
+				if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.data_type != null && is_reference_counting (expr.inner.value_type.data_type)) {
 					var ref_call = new CCodeFunctionCall (get_dup_func_expression (expr.inner.value_type, expr.source_reference));
 					ref_call.add_argument (delegate_target);
 					delegate_target = ref_call;
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 1dc85cc..a33b7f6 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -996,7 +996,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 	public virtual CCodeExpression? get_dup_func_expression (DataType type, SourceReference? source_reference, bool is_chainup = false) {
 		if (type.data_type != null) {
 			string dup_function = "";
-			if (type.data_type.is_reference_counting ()) {
+			if (is_reference_counting (type.data_type)) {
 				dup_function = type.data_type.get_ref_function ();
 			} else if (type is ValueType) {
 				dup_function = get_ccode_dup_function (type.data_type);
@@ -1021,7 +1021,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		if (type.data_type != null) {
 			string unref_function;
 			if (type is ReferenceType) {
-				if (type.data_type.is_reference_counting ()) {
+				if (is_reference_counting (type.data_type)) {
 					unref_function = type.data_type.get_unref_function ();
 				} else {
 					unref_function = get_ccode_free_function (type.data_type);
@@ -1403,7 +1403,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		}
 
 		var cl = type.data_type as Class;
-		if (cl != null && cl.is_reference_counting ()
+		if (cl != null && is_reference_counting (cl)
 		    && cl.get_ref_function () == "") {
 			// empty ref_function => no ref necessary
 			return false;
@@ -1427,7 +1427,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		}
 
 		var cl = type.data_type as Class;
-		if (cl != null && cl.is_reference_counting ()
+		if (cl != null && is_reference_counting (cl)
 		    && cl.get_unref_function () == "") {
 			// empty unref_function => no unref necessary
 			return false;
@@ -2298,6 +2298,10 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		return CCodeBaseModule.get_ccode_dup_function (node);
 	}
 
+	public bool is_reference_counting (CodeNode node) {
+		return CCodeBaseModule.is_reference_counting (node);
+	}
+
 	public bool get_ccode_ref_function_void (CodeNode node) {
 		return CCodeBaseModule.get_ccode_ref_function_void (node);
 	}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 8a36b0e..b28cda0 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 ref_function;
 	private string unref_function;
 	private string ref_sink_function;
 	private bool _is_compact;
@@ -633,9 +632,6 @@ public class Vala.Class : ObjectTypeSymbol {
 	}
 	
 	private void process_ccode_attribute (Attribute a) {
-		if (a.has_argument ("ref_function")) {
-			set_ref_function (a.get_string ("ref_function"));
-		}
 		if (a.has_argument ("unref_function")) {
 			set_unref_function (a.get_string ("unref_function"));
 		}
@@ -697,10 +693,6 @@ public class Vala.Class : ObjectTypeSymbol {
 		this.type_id = type_id;
 	}
 
-	public override bool is_reference_counting () {
-		return get_ref_function () != null;
-	}
-
 	public bool is_fundamental () {
 		if (!is_compact && base_class == null) {
 			return true;
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index f9ce4b9..6c3f2cd 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -417,10 +417,6 @@ public class Vala.Interface : ObjectTypeSymbol {
 	public override bool is_reference_type () {
 		return true;
 	}
-
-	public override bool is_reference_counting () {
-		return true;
-	}
 	
 	public override string? get_ref_function () {
 		foreach (DataType prerequisite in prerequisites) {
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index de82df6..acb85f6 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -72,16 +72,6 @@ public abstract class Vala.TypeSymbol : Symbol {
 	public virtual string? get_destroy_function () {
 		return null;
 	}
-
-	/**
-	 * Checks whether this data type supports reference counting. This is
-	 * only valid for reference types.
-	 *
-	 * @return true if this data type supports reference counting
-	 */
-	public virtual bool is_reference_counting () {
-		return false;
-	}
 	
 	/**
 	 * Returns the C function name that increments the reference count of



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