[vala/switch-to-gir] girparser: Add nullable argument and pattern fixes



commit 50a6cf92466c8a4b9835ce3a5b332f7d7c4edd0b
Author: Luca Bruno <lethalman88 gmail com>
Date:   Thu Aug 26 23:42:32 2010 +0200

    girparser: Add nullable argument and pattern fixes

 vala/valagirparser.vala |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index d4b7eee..e7ad581 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -48,7 +48,8 @@ public class Vala.GirParser : CodeVisitor {
 		NAME,
 		OWNED,
 		UNOWNED,
-		PARENT;
+		PARENT,
+		NULLABLE;
 
 		public static ArgumentType? from_string (string name) {
 			var enum_class = (EnumClass) typeof(ArgumentType).class_ref ();
@@ -277,6 +278,10 @@ public class Vala.GirParser : CodeVisitor {
 						builder.append (get_string ());
 					} else if (current == TokenType.UNOWNED) {
 						builder.append ("unowned");
+					} else if (current == TokenType.GET) {
+						builder.append ("get");
+					} else if (current == TokenType.NEW) {
+						builder.append ("new");
 					} else {
 						break;
 					}
@@ -767,6 +772,9 @@ public class Vala.GirParser : CodeVisitor {
 					}
 				}
 			}
+			if (metadata.has_argument (ArgumentType.NULLABLE)) {
+				type.nullable = metadata.get_bool (ArgumentType.NULLABLE);
+			}
 		}
 		return type;
 	}
@@ -888,6 +896,9 @@ public class Vala.GirParser : CodeVisitor {
 		current_source_file.gir_version = gir_version;
 
 		var ns_metadata = metadata.match_child (gir_namespace);
+		if (ns_metadata.has_argument (ArgumentType.NAME)) {
+			namespace_name = ns_metadata.get_string (ArgumentType.NAME);
+		}
 
 		var ns = context.root.scope.lookup (namespace_name) as Namespace;
 		if (ns == null) {
@@ -1737,7 +1748,13 @@ public class Vala.GirParser : CodeVisitor {
 			start_element ("parameters");
 			next ();
 			while (current_token == MarkupTokenType.START_ELEMENT) {
+				if (!push_metadata ()) {
+					skip_element ();
+				}
+
 				m.add_parameter (parse_parameter ());
+
+				pop_metadata ();
 			}
 			end_element ("parameters");
 		}



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