]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
On-demand Struct.is_immutable
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 7 Jul 2011 10:05:37 +0000 (12:05 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Mon, 1 Aug 2011 16:17:05 +0000 (18:17 +0200)
vala/valastruct.vala

index 40b201620320072fbc98e10187270094bf67e4f9..ea0ccf73cfc7672a443c981d1b54300c78e3898a 100644 (file)
@@ -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") {