[vala/wip/attributes: 8/31] On-demand Struct.is_boolean_type



commit 6160ba580db193f0d247c51e4c650a61fbcbfcc5
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Jul 7 11:51:30 2011 +0200

    On-demand Struct.is_boolean_type

 vala/valastruct.vala |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index d32996d..b34cd80 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -38,7 +38,7 @@ public class Vala.Struct : TypeSymbol {
 	private string type_id;
 	private string lower_case_cprefix;
 	private string lower_case_csuffix;
-	private bool boolean_type;
+	private bool? boolean_type;
 	private bool integer_type;
 	private bool floating_type;
 	private bool decimal_floating_type;
@@ -342,11 +342,12 @@ public class Vala.Struct : TypeSymbol {
 	 * @return true if this is a boolean type, false otherwise
 	 */
 	public bool is_boolean_type () {
-		if (base_type != null) {
-			var st = base_struct;
-			if (st != null && st.is_boolean_type ()) {
-				return true;
-			}
+		var st = base_struct;
+		if (st != null && st.is_boolean_type ()) {
+			return true;
+		}
+		if (boolean_type == null) {
+			boolean_type = get_attribute ("BooleanType") != null;
 		}
 		return boolean_type;
 	}
@@ -463,10 +464,6 @@ public class Vala.Struct : TypeSymbol {
 		}
 	}
 
-	private void process_boolean_type_attribute (Attribute a) {
-		boolean_type = true;
-	}
-
 	private void process_integer_type_attribute (Attribute a) {
 		integer_type = true;
 		if (a.has_argument ("rank")) {
@@ -500,8 +497,6 @@ public class Vala.Struct : TypeSymbol {
 		foreach (Attribute a in attributes) {
 			if (a.name == "CCode") {
 				process_ccode_attribute (a);
-			} else if (a.name == "BooleanType") {
-				process_boolean_type_attribute (a);
 			} else if (a.name == "IntegerType") {
 				process_integer_type_attribute (a);
 			} else if (a.name == "FloatingType") {
@@ -664,7 +659,7 @@ public class Vala.Struct : TypeSymbol {
 		}
 
 		if (CodeContext.get ().profile == Profile.DOVA) {
-			if (boolean_type) {
+			if (is_boolean_type ()) {
 				return "false";
 			} else if (integer_type || floating_type) {
 				return "0";



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