[vala/wip/attributes: 58/119] Drop Struct.copy_function



commit 75a0e49df3c450c6479ba29851c81bcd01daab8b
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed Jun 29 20:08:37 2011 +0200

    Drop Struct.copy_function

 codegen/valadovabasemodule.vala  |   10 +++++++---
 codegen/valadovavaluemodule.vala |    6 +++---
 vala/valastruct.vala             |   19 -------------------
 vala/valatypesymbol.vala         |   12 ------------
 4 files changed, 10 insertions(+), 37 deletions(-)
---
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index f1a1054..91bb309 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -1037,10 +1037,10 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 					}
 				} else {
 					var st = (Struct) type.data_type;
-					unref_function = st.get_copy_function ();
+					unref_function = get_ccode_copy_function (st);
 				}
 			}
-			if (unref_function == null) {
+			if (unref_function == null || unref_function == "") {
 				return new CCodeConstant ("NULL");
 			}
 			return new CCodeIdentifier (unref_function);
@@ -1464,7 +1464,7 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 
 			var vt = (ValueType) expression_type;
 			var st = (Struct) vt.type_symbol;
-			var copy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_copy_function ()));
+			var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
 			copy_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
 			copy_call.add_argument (new CCodeConstant ("0"));
 			copy_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cexpr));
@@ -2293,6 +2293,10 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		return CCodeBaseModule.get_ccode_const_name (node);
 	}
 
+	public string get_ccode_copy_function (CodeNode node) {
+		return CCodeBaseModule.get_ccode_copy_function (node);
+	}
+
 	public DataType? get_this_type () {
 		if (current_method != null && current_method.binding == MemberBinding.INSTANCE) {
 			return current_method.this_parameter.variable_type;
diff --git a/codegen/valadovavaluemodule.vala b/codegen/valadovavaluemodule.vala
index 9df833d..9ddb11e 100644
--- a/codegen/valadovavaluemodule.vala
+++ b/codegen/valadovavaluemodule.vala
@@ -35,7 +35,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 	public override void generate_struct_declaration (Struct st, CCodeFile decl_space) {
 		base.generate_struct_declaration (st, decl_space);
 
-		if (add_symbol_declaration (decl_space, st, st.get_copy_function ())) {
+		if (add_symbol_declaration (decl_space, st, get_ccode_copy_function (st))) {
 			return;
 		}
 
@@ -54,7 +54,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		}
 		decl_space.add_function_declaration (type_init_fun);
 
-		var function = new CCodeFunction (st.get_copy_function (), "void");
+		var function = new CCodeFunction (get_ccode_copy_function (st), "void");
 		if (st.is_internal_symbol ()) {
 			function.modifiers = CCodeModifiers.STATIC;
 		}
@@ -276,7 +276,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 	}
 
 	void add_struct_copy_function (Struct st) {
-		var function = new CCodeFunction (st.get_copy_function (), "void");
+		var function = new CCodeFunction (get_ccode_copy_function (st), "void");
 		if (st.is_internal_symbol ()) {
 			function.modifiers = CCodeModifiers.STATIC;
 		}
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 764726f..d64b0f6 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -49,7 +49,6 @@ public class Vala.Struct : TypeSymbol {
 	private string set_value_function;
 	private string take_value_function;
 	private string default_value = null;
-	private string copy_function;
 	private string destroy_function;
 
 	/**
@@ -456,9 +455,6 @@ public class Vala.Struct : TypeSymbol {
 		if (a.has_argument ("default_value")) {
 			set_default_value (a.get_string ("default_value"));
 		}
-		if (a.has_argument ("copy_function")) {
-			set_copy_function (a.get_string ("copy_function"));
-		}
 		if (a.has_argument ("destroy_function")) {
 			set_destroy_function (a.get_string ("destroy_function"));
 		}
@@ -749,21 +745,6 @@ public class Vala.Struct : TypeSymbol {
 		}
 	}
 
-	public string get_default_copy_function () {
-		return get_lower_case_cprefix () + "copy";
-	}
-
-	public override string? get_copy_function () {
-		if (copy_function == null) {
-			copy_function = get_default_copy_function ();
-		}
-		return copy_function;
-	}
-
-	public void set_copy_function (string name) {
-		this.copy_function = name;
-	}
-
 	public string get_default_destroy_function () {
 		return get_lower_case_cprefix () + "destroy";
 	}
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index 956939b..ea2da2e 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -73,18 +73,6 @@ public abstract class Vala.TypeSymbol : Symbol {
 	}
 
 	/**
-	 * Returns the C function name that copies contents of instances of
-	 * this data type. This is only applicable to structs. The specified
-	 * C function must accept two arguments, the first is the source value
-	 * and the second is the destination value.
-	 *
-	 * @return the name of the C function if supported or null otherwise
-	 */
-	public virtual string? get_copy_function () {
-		return null;
-	}
-
-	/**
 	 * Returns the C function name that destroys the contents of instances
 	 * of this data type. This is only applicable to structs. The specified
 	 * C function must accept one argument pointing to the instance to be



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