[vala] girparser: Allow specifying the error thrown from a function in metadata



commit 0d5af7406b390f937acc1a7cff8bc926483587ff
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed May 18 11:15:28 2011 +0200

    girparser: Allow specifying the error thrown from a function in metadata

 vala/valagirparser.vala |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 48b736e..47c7c0a 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -61,7 +61,8 @@ public class Vala.GirParser : CodeVisitor {
 		VIRTUAL,
 		ABSTRACT,
 		SCOPE,
-		STRUCT;
+		STRUCT,
+		THROWS;
 
 		public static ArgumentType? from_string (string name) {
 			var enum_class = (EnumClass) typeof(ArgumentType).class_ref ();
@@ -2425,8 +2426,15 @@ public class Vala.GirParser : CodeVisitor {
 			}
 		}
 
-		if (throws_string == "1") {
-			s.add_error_type (new ErrorType (null, null));
+		if (!(metadata.get_expression (ArgumentType.THROWS) is NullLiteral)) {
+			if (metadata.has_argument (ArgumentType.THROWS)) {
+				var error_types = metadata.get_string(ArgumentType.THROWS).split(",");
+				foreach (var error_type in error_types) {
+					s.add_error_type (parse_type_from_string (error_type, true, metadata.get_source_reference (ArgumentType.THROWS)));
+				}
+			} else {
+				s.add_error_type (new ErrorType (null, null));
+			}
 		}
 
 		current.symbol = s;



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