[vala/switch-to-gir] girparser: Strv properties have no length and are null terminated



commit ef01a12bf773701849fa40da592395e09c0372a5
Author: Luca Bruno <lethalman88 gmail com>
Date:   Thu Aug 26 11:10:14 2010 +0200

    girparser: Strv properties have no length and are null terminated

 vala/valagirparser.vala |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 2fbde9d..f647dea 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1131,7 +1131,7 @@ public class Vala.GirParser : CodeVisitor {
 		return param;
 	}
 
-	DataType parse_type (out string? ctype = null, out int array_length_index = null, bool transfer_elements = false) {
+	DataType parse_type (out string? ctype = null, out int array_length_index = null, bool transfer_elements = false, out bool no_array_length = null, out bool array_null_terminated = null) {
 		bool is_array = false;
 		string type_name = reader.get_attribute ("name");
 
@@ -1167,7 +1167,7 @@ public class Vala.GirParser : CodeVisitor {
 			type_name = "GLib.GenericArray";
 		}
 
-		DataType type = parse_type_from_gir_name (type_name);
+		DataType type = parse_type_from_gir_name (type_name, out no_array_length, out array_null_terminated);
 
 		// type arguments / element types
 		while (current_token == MarkupTokenType.START_ELEMENT) {
@@ -1180,7 +1180,14 @@ public class Vala.GirParser : CodeVisitor {
 		return type;
 	}
 
-	DataType? parse_type_from_gir_name (string type_name) {
+	DataType? parse_type_from_gir_name (string type_name, out bool no_array_length = null, out bool array_null_terminated = null) {
+		if (&no_array_length != null) {
+			no_array_length = false;
+		}
+		if (&array_null_terminated != null) {
+			array_null_terminated = false;
+		}
+
 		DataType type;
 		if (type_name == "none") {
 			type = new VoidType (get_current_src ());
@@ -1188,6 +1195,12 @@ public class Vala.GirParser : CodeVisitor {
 			type = new PointerType (new VoidType (get_current_src ()), get_current_src ());
 		} else if (type_name == "GObject.Strv") {
 			type = new ArrayType (new UnresolvedType.from_symbol (new UnresolvedSymbol (null, "string")), 1, get_current_src ());
+			if (&no_array_length != null) {
+				no_array_length = true;
+			}
+			if (&array_null_terminated != null) {
+				array_null_terminated = true;
+			}
 		} else {
 			if (type_name == "utf8") {
 				type_name = "string";
@@ -1636,8 +1649,12 @@ public class Vala.GirParser : CodeVisitor {
 		string construct_ = reader.get_attribute ("construct");
 		string construct_only = reader.get_attribute ("construct-only");
 		next ();
-		var type = parse_type ();
+		bool no_array_length;
+		bool array_null_terminated;
+		var type = parse_type (null, null, false, out no_array_length, out array_null_terminated);
 		var prop = new Property (name, type, null, null, get_current_src ());
+		prop.no_array_length = no_array_length;
+		prop.array_null_terminated = array_null_terminated;
 		prop.access = SymbolAccessibility.PUBLIC;
 		if (readable != "0") {
 			prop.get_accessor = new PropertyAccessor (true, false, false, prop.property_type.copy (), null, null);



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