[vala] girparser: add special case for GPtrArray and GArray



commit ffba491cadd4e1515d182dba92d1fadc4e94b15d
Author: Evan Nemerson <evan coeus-group com>
Date:   Fri Jun 18 15:08:49 2010 -0700

    girparser: add special case for GPtrArray and GArray
    
    Fixes bug 618660.

 vala/valagirparser.vala |   55 +++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 20 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 8cd241d..a2020f4 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -414,37 +414,52 @@ public class Vala.GirParser : CodeVisitor {
 	}
 
 	DataType parse_type (out string? ctype = null, out int array_length_index = null, bool transfer_elements = false) {
+		bool is_array = false;
+		string type_name = reader.get_attribute ("name");
+
 		if (reader.name == "array") {
+			is_array = true;
 			start_element ("array");
-			if (reader.get_attribute ("length") != null
-			    && &array_length_index != null) {
-				array_length_index = reader.get_attribute ("length").to_int ();
+
+			if (!(type_name == "GLib.Array" || type_name == "GLib.PtrArray")) {
+				if (reader.get_attribute ("length") != null
+				    && &array_length_index != null) {
+					array_length_index = reader.get_attribute ("length").to_int ();
+				}
+				next ();
+				var element_type = parse_type ();
+				end_element ("array");
+				return new ArrayType (element_type, 1, null);
 			}
-			next ();
-			var element_type = parse_type ();
-			end_element ("array");
-			return new ArrayType (element_type, 1, null);
 		} else if (reader.name == "callback"){
 			var callback = parse_callback ();
 			return new DelegateType (callback);
 		} else {
 			start_element ("type");
-			DataType type = parse_type_from_name (reader.get_attribute ("name"));
-			if (&ctype != null) {
-				ctype = reader.get_attribute("c:type");
-			}
-			next ();
+		}
 
-			// type arguments / element types
-			while (current_token == MarkupTokenType.START_ELEMENT) {
-				var element_type = parse_type ();
-				element_type.value_owned = transfer_elements;
-				type.add_type_argument (element_type);
-			}
+		if (&ctype != null) {
+			ctype = reader.get_attribute("c:type");
+		}
+
+		next ();
 
-			end_element ("type");
-			return type;
+		if (type_name == "GLib.PtrArray"
+		    && current_token == MarkupTokenType.START_ELEMENT) {
+			type_name = "GLib.GenericArray";
 		}
+
+		DataType type = parse_type_from_name (type_name);
+
+		// type arguments / element types
+		while (current_token == MarkupTokenType.START_ELEMENT) {
+			var element_type = parse_type ();
+			element_type.value_owned = transfer_elements;
+			type.add_type_argument (element_type);
+		}
+
+		end_element (is_array ? "array" : "type");
+		return type;
 	}
 
 	DataType parse_type_from_name (string type_name) {



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