]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
add get_bool method for boolean values print message when detecting option
authorJürg Billeter <j@bitron.ch>
Sat, 23 Dec 2006 20:24:38 +0000 (20:24 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sat, 23 Dec 2006 20:24:38 +0000 (20:24 +0000)
2006-12-23  Jürg Billeter  <j@bitron.ch>

* vala/valaattribute.vala: add get_bool method for boolean values
* compiler/valacompiler.vala: print message when detecting option errors

svn path=/trunk/; revision=184

vala/ChangeLog
vala/compiler/valacompiler.vala
vala/vala/valaattribute.vala

index d2ffe67511c2c15a241bcb0136723372607db3bb..bf0b1baa6b76ad230f4479da7a7f0df066c1d057 100644 (file)
@@ -1,3 +1,8 @@
+2006-12-23  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaattribute.vala: add get_bool method for boolean values
+       * compiler/valacompiler.vala: print message when detecting option errors
+
 2006-12-10  Jürg Billeter  <j@bitron.ch>
 
        * vapi/glib-2.0.vala: add message logging functions
index de8bf5619999a554df3749cee43c4bf3d203eb09..b36090c5154ad311c8b50bd84a4810690e6f1a5c 100644 (file)
@@ -221,6 +221,8 @@ class Vala.Compiler {
                opt_context.parse (out args, out err);
                
                if (err != null) {
+                       stdout.printf ("%s\n", err.message);
+                       stdout.printf ("Run '%s --help' to see a full list of available command line options.\n", args[0]);
                        return 1;
                }
                
index fdd4cf0417b26142b46fc8b3a5a45b56787dbcf2..4734468b9d69fce23d5670842c03277d1297ccc5 100644 (file)
@@ -117,4 +117,26 @@ public class Vala.Attribute : CodeNode {
                
                return 0;
        }
+       
+       /**
+        * Returns the boolean value of the specified named argument.
+        *
+        * @param name argument name
+        * @return     boolean value
+        */
+       public bool get_bool (string! name) {
+               // FIXME: use hash table
+               foreach (NamedArgument arg in args) {
+                       if (arg.name == name) {
+                               if (arg.argument is LiteralExpression) {
+                                       var lit = ((LiteralExpression) arg.argument).literal;
+                                       if (lit is BooleanLiteral) {
+                                               return ((BooleanLiteral) lit).value;
+                                       }
+                               }
+                       }
+               }
+               
+               return false;
+       }
 }