[vala/wip/attributes: 15/32] On-demand Struct.is_immutable



commit a42eaa6efff673a6e89296513b4ee6f5af4038be
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Jul 7 12:05:37 2011 +0200

    On-demand Struct.is_immutable

 vala/valastruct.vala |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 40b2016..ea0ccf7 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -89,7 +89,18 @@ 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;
+			}
+			return _is_immutable;
+		}
+		set {
+			_is_immutable = value;
+			set_attribute ("Immutable", value);
+		}
+	}
 
 	/**
 	 * Specifies whether this struct has a registered GType.
@@ -519,8 +530,6 @@ public class Vala.Struct : TypeSymbol {
 		foreach (Attribute a in attributes) {
 			if (a.name == "CCode") {
 				process_ccode_attribute (a);
-			} else if (a.name == "Immutable") {
-				is_immutable = true;
 			} else if (a.name == "Deprecated") {
 				process_deprecated_attribute (a);
 			} else if (a.name == "GIR") {



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