[vala/wip/attributes: 106/121] Drop process_attributes from Struct



commit 0a23776a4ce6a98f4fa9bb8ae4291dd5270e10e4
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Jul 3 13:02:22 2011 +0200

    Drop process_attributes from Struct

 vala/valaparameter.vala |    2 -
 vala/valastruct.vala    |   59 ++++++++++++++++------------------------------
 2 files changed, 21 insertions(+), 40 deletions(-)
---
diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala
index 7ad3891..ff7775f 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -116,8 +116,6 @@ public class Vala.Parameter : Variable {
 
 		checked = true;
 
-		process_attributes ();
-
 		var old_source_file = context.analyzer.current_source_file;
 		var old_symbol = context.analyzer.current_symbol;
 
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 8c3b014..a8558cb 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -74,11 +74,29 @@ public class Vala.Struct : TypeSymbol {
 	 * Specifies if 'const' should be emitted for input parameters
 	 * of this type.
 	 */
-	public bool is_immutable { get; set; }
+	public bool is_immutable {
+		get {
+			if (_is_immutable == null) {
+				_is_immutable = get_attribute ("Immutable") != null;
+			}
+		}
+	}
 
-	public int width { get; set; default = 32; }
+	public int width {
+		get {
+			if (is_integer_type ()) {
+				return get_attribute_integer ("IntegerType", "width", 32);
+			} else {
+				return get_attribute_integer ("FloatingType", "width", 32);
+			}
+		}
+	}
 
-	public bool signed { get; set; default = true; }
+	public bool signed {
+		get {
+			return get_attribute_bool ("IntegerType", "signed", true);
+		}
+	}
 
 	/**
 	 * Creates a new struct.
@@ -343,40 +361,7 @@ public class Vala.Struct : TypeSymbol {
 			set_attribute_integer ("FloatingType", "rank", rank);
 		}
 	}
-
-	private void process_integer_type_attribute (Attribute a) {
-		if (a.has_argument ("width")) {
-			width = a.get_integer ("width");
-		}
-		if (a.has_argument ("signed")) {
-			signed = a.get_bool ("signed");
-		}
-	}
-
-	private void process_floating_type_attribute (Attribute a) {
-		if (a.has_argument ("decimal")) {
-			decimal_floating_type = a.get_bool ("decimal");
-		}
-		if (a.has_argument ("width")) {
-			width = a.get_integer ("width");
-		}
-	}
 	
-	/**
-	 * Process all associated attributes.
-	 */
-	public void process_attributes () {
-		foreach (Attribute a in attributes) {
-			if (a.name == "IntegerType") {
-				process_integer_type_attribute (a);
-			} else if (a.name == "FloatingType") {
-				process_floating_type_attribute (a);
-			} else if (a.name == "Immutable") {
-				is_immutable = true;
-			}
-		}
-	}
-
 	public override int get_type_parameter_index (string name) {
 		int i = 0;
 		
@@ -476,8 +461,6 @@ public class Vala.Struct : TypeSymbol {
 
 		checked = true;
 
-		process_attributes ();
-
 		var old_source_file = context.analyzer.current_source_file;
 		var old_symbol = context.analyzer.current_symbol;
 



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