]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
On-demand Struct.is_simple_type
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 7 Jul 2011 09:50:15 +0000 (11:50 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Mon, 1 Aug 2011 16:17:04 +0000 (18:17 +0200)
vala/valastruct.vala

index a492233fbb234caa5c767e5cd8d02be1cd443312..d32996d6764dc3e9a2ce674c97ad93c067d40d5b 100644 (file)
@@ -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) {