[vala/wip/attributes: 75/100] Drop TypeSymbol.get_default_value



commit 3645a54206e3bdf5dae96441c8dc564875188383
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Jun 30 09:21:23 2011 +0200

    Drop TypeSymbol.get_default_value

 codegen/valadovabasemodule.vala |    8 ++++++--
 vala/valaenum.vala              |    4 ----
 vala/valastruct.vala            |   32 --------------------------------
 vala/valatypesymbol.vala        |   10 ----------
 4 files changed, 6 insertions(+), 48 deletions(-)
---
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 7b9bb68..8f0e3fb 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -2269,8 +2269,8 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		           || type.nullable
 		           || type is PointerType || type is DelegateType) {
 			return new CCodeConstant ("NULL");
-		} else if (type.data_type != null && type.data_type.get_default_value () != null) {
-			return new CCodeConstant (type.data_type.get_default_value ());
+		} else if (type.data_type != null && get_ccode_default_value (type.data_type) != "") {
+			return new CCodeConstant (get_ccode_default_value (type.data_type));
 		}
 		return null;
 	}
@@ -2314,6 +2314,10 @@ public abstract class Vala.DovaBaseModule : CodeGenerator {
 		return CCodeBaseModule.get_ccode_ref_function_void (node);
 	}
 
+	public string get_ccode_default_value (CodeNode node) {
+		return CCodeBaseModule.get_ccode_default_value (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/vala/valaenum.vala b/vala/valaenum.vala
index d8e6999..033a0e4 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -248,10 +248,6 @@ public class Vala.Enum : TypeSymbol {
 		}
 	}
 
-	public override string? get_default_value () {
-		return "0";
-	}
-
 	public override bool check (CodeContext context) {
 		if (checked) {
 			return !error;
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 0eba280..3a5eab6 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -43,7 +43,6 @@ public class Vala.Struct : TypeSymbol {
 	private bool? decimal_floating_type;
 	private bool? simple_type;
 	private int? rank;
-	private string default_value = null;
 
 	/**
 	 * Specifies the base type.
@@ -427,9 +426,6 @@ public class Vala.Struct : TypeSymbol {
 		if (a.has_argument ("has_type_id")) {
 			has_type_id = a.get_bool ("has_type_id");
 		}
-		if (a.has_argument ("default_value")) {
-			set_default_value (a.get_string ("default_value"));
-		}
 	}
 
 	private void process_boolean_type_attribute (Attribute a) {
@@ -477,34 +473,6 @@ public class Vala.Struct : TypeSymbol {
 		}
 	}
 
-	public override string? get_default_value () {
-		if (default_value != null) {
-			return default_value;
-		}
-
-		// inherit default value from base type
-		if (base_type != null) {
-			var st = base_struct;
-			if (st != null) {
-				return st.get_default_value ();
-			}
-		}
-
-		if (CodeContext.get ().profile == Profile.DOVA) {
-			if (boolean_type) {
-				return "false";
-			} else if (integer_type || floating_type) {
-				return "0";
-			}
-		}
-
-		return null;
-	}
-
-	private void set_default_value (string? value) {
-		default_value = value;
-	}
-
 	public override int get_type_parameter_index (string name) {
 		int i = 0;
 		
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index 393bd15..bbb9688 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -55,16 +55,6 @@ public abstract class Vala.TypeSymbol : Symbol {
 	}
 
 	/**
-	 * Returns the default value for the given type. Returning null means
-	 * there is no default value (i.e. not that the default name is NULL).
-	 *
-	 * @return the name of the default value
-	 */
-	public virtual string? get_default_value () {
-		return null;
-	}
-
-	/**
 	 * Checks whether this data type is equal to or a subtype of the
 	 * specified data type.
 	 *



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