[vala/wip/attributes: 6/38] Specify default values in Attribute methods



commit 5cf76e87f02b43c745aac902f70514bcb30eacd3
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed Jul 6 09:52:40 2011 +0200

    Specify default values in Attribute methods

 vala/valaattribute.vala |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/vala/valaattribute.vala b/vala/valaattribute.vala
index 68d7539..63258e1 100644
--- a/vala/valaattribute.vala
+++ b/vala/valaattribute.vala
@@ -92,11 +92,11 @@ public class Vala.Attribute : CodeNode {
 	 * @param name argument name
 	 * @return     integer value
 	 */
-	public int get_integer (string name) {
+	public int get_integer (string name, int default_value = 0) {
 		string value = args.get (name);
 
 		if (value == null) {
-			return 0;
+			return default_value;
 		}
 
 		return int.parse (value);
@@ -108,11 +108,11 @@ public class Vala.Attribute : CodeNode {
 	 * @param name argument name
 	 * @return     double value
 	 */
-	public double get_double (string name) {
+	public double get_double (string name, double default_value = 0) {
 		string value = args.get (name);
 
 		if (value == null) {
-			return 0;
+			return default_value;
 		}
 
 		return double.parse (value);
@@ -124,7 +124,13 @@ public class Vala.Attribute : CodeNode {
 	 * @param name argument name
 	 * @return     boolean value
 	 */
-	public bool get_bool (string name) {
-		return bool.parse (args.get (name));
+	public bool get_bool (string name, bool default_value = false) {
+		string value = args.get (name);
+
+		if (value == null) {
+			return default_value;
+		}
+
+		return bool.parse (value);
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]