From: Jürg Billeter Date: Sat, 23 Dec 2006 20:24:38 +0000 (+0000) Subject: add get_bool method for boolean values print message when detecting option X-Git-Tag: VALA_0_0_6~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4391dfe01b5748ed2a4e462cc3b079e8fde4bb8a;p=thirdparty%2Fvala.git add get_bool method for boolean values print message when detecting option 2006-12-23 Jürg Billeter * vala/valaattribute.vala: add get_bool method for boolean values * compiler/valacompiler.vala: print message when detecting option errors svn path=/trunk/; revision=184 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index d2ffe6751..bf0b1baa6 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,8 @@ +2006-12-23 Jürg Billeter + + * 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 * vapi/glib-2.0.vala: add message logging functions diff --git a/vala/compiler/valacompiler.vala b/vala/compiler/valacompiler.vala index de8bf5619..b36090c51 100644 --- a/vala/compiler/valacompiler.vala +++ b/vala/compiler/valacompiler.vala @@ -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; } diff --git a/vala/vala/valaattribute.vala b/vala/vala/valaattribute.vala index fdd4cf041..4734468b9 100644 --- a/vala/vala/valaattribute.vala +++ b/vala/vala/valaattribute.vala @@ -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; + } }