[vala/switch-to-gir: 5/34] girparser: Fix mapping gsize to size_t and gssize to ssize_t.



commit fcffc9c7e073634f41974f7a7175da065a279a21
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Nov 9 11:54:13 2010 +0100

    girparser: Fix mapping gsize to size_t and gssize to ssize_t.

 vala/valagirparser.vala |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index ed37757..fd3c689 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1731,7 +1731,7 @@ public class Vala.GirParser : CodeVisitor {
 			type_name = "GLib.GenericArray";
 		}
 
-		DataType type = parse_type_from_gir_name (type_name, out no_array_length, out array_null_terminated);
+		DataType type = parse_type_from_gir_name (type_name, out no_array_length, out array_null_terminated, ctype);
 
 		// type arguments / element types
 		while (current_token == MarkupTokenType.START_ELEMENT) {
@@ -1744,7 +1744,7 @@ public class Vala.GirParser : CodeVisitor {
 		return type;
 	}
 
-	DataType parse_type_from_gir_name (string type_name, out bool no_array_length = null, out bool array_null_terminated = null) {
+	DataType parse_type_from_gir_name (string type_name, out bool no_array_length = null, out bool array_null_terminated = null, string? ctype = null) {
 		if (&no_array_length != null) {
 			no_array_length = false;
 		}
@@ -1782,9 +1782,17 @@ public class Vala.GirParser : CodeVisitor {
 			} else if (type_name == "guint") {
 				type_name = "uint";
 			} else if (type_name == "glong") {
-				type_name = "long";
+				if (ctype == "gssize") {
+					type_name = "ssize_t";
+				} else {
+					type_name = "long";
+				}
 			} else if (type_name == "gulong") {
-				type_name = "ulong";
+				if (ctype == "gsize") {
+					type_name = "size_t";
+				} else {
+					type_name = "ulong";
+				}
 			} else if (type_name == "gint8") {
 				type_name = "int8";
 			} else if (type_name == "guint8") {



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