]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Allow specifying default value to Metadata.get_bool
authorLuca Bruno <lucabru@src.gnome.org>
Sat, 16 Jul 2011 16:39:58 +0000 (18:39 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sat, 16 Jul 2011 17:05:00 +0000 (19:05 +0200)
vala/valagirparser.vala

index 2d110963e64a7ff97b90bd01eca5361674e73d9c..335a203864ed6aa1d6d85034a1db9cd58f50cfd5 100644 (file)
@@ -204,12 +204,12 @@ public class Vala.GirParser : CodeVisitor {
                        return 0;
                }
 
-               public bool get_bool (ArgumentType arg) {
+               public bool get_bool (ArgumentType arg, bool default_value = false) {
                        var lit = get_expression (arg) as BooleanLiteral;
                        if (lit != null) {
                                return lit.value;
                        }
-                       return false;
+                       return default_value;
                }
 
                public SourceReference? get_source_reference (ArgumentType arg) {
@@ -1400,9 +1400,7 @@ public class Vala.GirParser : CodeVisitor {
                                        type.value_owned = metadata.get_bool (ArgumentType.OWNED);
                                }
                        }
-                       if (metadata.has_argument (ArgumentType.NULLABLE)) {
-                               type.nullable = metadata.get_bool (ArgumentType.NULLABLE);
-                       }
+                       type.nullable = metadata.get_bool (ArgumentType.NULLABLE, type.nullable);
                }
 
                if (type is ArrayType && !(orig_type is ArrayType)) {