[vala/wip/attributes-clean: 7/32] On-demand Struct.is_simple_type



commit 6a17ba66ce937e446f67963f6d2eee89a6675e5e
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Jul 7 11:50:15 2011 +0200

    On-demand Struct.is_simple_type

 vala/valastruct.vala |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index a492233..d32996d 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -42,6 +42,7 @@ public class Vala.Struct : TypeSymbol {
 	private bool integer_type;
 	private bool floating_type;
 	private bool decimal_floating_type;
+	private bool? simple_type;
 	private int rank;
 	private string marshaller_type_name;
 	private string get_value_function;
@@ -695,17 +696,17 @@ public class Vala.Struct : TypeSymbol {
 	 * instances are passed by value.
 	 */
 	public bool is_simple_type () {
-		if (base_type != null) {
-			var st = base_struct;
-			if (st != null && st.is_simple_type ()) {
-				return true;
-			}
-		}
 		if (CodeContext.get ().profile == Profile.DOVA) {
 			return true;
 		}
-		return (boolean_type || integer_type || floating_type
-		        || get_attribute ("SimpleType") != null);
+		var st = base_struct;
+		if (st != null && st.is_simple_type ()) {
+			return true;
+		}
+		if (simple_type == null) {
+			simple_type = get_attribute ("SimpleType") != null || get_attribute ("BooleanType") != null || get_attribute ("IntegerType") != null || get_attribute ("FloatingType") != null;
+		}
+		return simple_type;
 	}
 
 	/**
@@ -713,7 +714,8 @@ public class Vala.Struct : TypeSymbol {
 	 * value.
 	 */
 	public void set_simple_type (bool simple_type) {
-		attributes.append (new Attribute ("SimpleType"));
+		this.simple_type = simple_type;
+		set_attribute ("SimpleType", simple_type);
 	}
 
 	public override void replace_type (DataType old_type, DataType new_type) {



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