[vala] girparser: Box structs when used in type arguments



commit 095725c51ea7752fc69f39bdb9847e271fff4242
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Nov 3 10:39:09 2011 +0100

    girparser: Box structs when used in type arguments
    
    Fixes bug 663058.

 vala/valagirparser.vala |   19 +++++++++++++++++++
 vapi/libsoup-2.4.vapi   |   18 +++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 21b63d7..1908a05 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1073,6 +1073,7 @@ public class Vala.GirParser : CodeVisitor {
 	Set<string> provided_namespaces = new HashSet<string> (str_hash, str_equal);
 	HashMap<UnresolvedSymbol,Symbol> unresolved_symbols_map = new HashMap<UnresolvedSymbol,Symbol> (unresolved_symbol_hash, unresolved_symbol_equal);
 	ArrayList<UnresolvedSymbol> unresolved_gir_symbols = new ArrayList<UnresolvedSymbol> ();
+	ArrayList<DataType> unresolved_type_arguments = new ArrayList<DataType> ();
 
 	/**
 	 * Parses all .gir source files in the specified code
@@ -1095,6 +1096,7 @@ public class Vala.GirParser : CodeVisitor {
 
 		resolve_gir_symbols ();
 		create_new_namespaces ();
+		resolve_type_arguments ();
 
 		root.process (this);
 
@@ -2221,6 +2223,7 @@ public class Vala.GirParser : CodeVisitor {
 			var element_type = parse_type ();
 			element_type.value_owned = transfer_elements;
 			type.add_type_argument (element_type);
+			unresolved_type_arguments.add (element_type);
 		}
 
 		end_element (is_array ? "array" : "type");
@@ -2964,6 +2967,22 @@ public class Vala.GirParser : CodeVisitor {
 		}
 	}
 
+	void resolve_type_arguments () {
+		// box structs in type arguments
+		foreach (var element_type in unresolved_type_arguments) {
+			TypeSymbol sym = null;
+			if (element_type is UnresolvedType) {
+				sym = (TypeSymbol) resolve_symbol (root, ((UnresolvedType) element_type).unresolved_symbol);
+			} else if (element_type.data_type != null) {
+				sym = element_type.data_type;
+			}
+			var st = sym as Struct;
+			if (st != null && !st.is_integer_type () && !st.is_floating_type ()) {
+				element_type.nullable = true;
+			}
+		}
+	}
+
 	void process_interface (Node iface_node) {
 		/* Temporarily workaround G-I bug not adding GLib.Object prerequisite:
 		   ensure we have at least one instantiable prerequisite */
diff --git a/vapi/libsoup-2.4.vapi b/vapi/libsoup-2.4.vapi
index 6ae2581..9991f3b 100644
--- a/vapi/libsoup-2.4.vapi
+++ b/vapi/libsoup-2.4.vapi
@@ -363,7 +363,7 @@ namespace Soup {
 		public uint status_code { get; set; }
 		public Soup.URI uri { get; set; }
 		[HasEmitter]
-		public signal void content_sniffed (string object, GLib.HashTable<void*,void*> p0);
+		public signal void content_sniffed (string content_type, GLib.HashTable<void*,void*> @params);
 		[HasEmitter]
 		public virtual signal void finished ();
 		[HasEmitter]
@@ -379,7 +379,7 @@ namespace Soup {
 		[HasEmitter]
 		public virtual signal void wrote_body ();
 		[HasEmitter]
-		public signal void wrote_body_data (Soup.Buffer object);
+		public signal void wrote_body_data (Soup.Buffer chunk);
 		[HasEmitter]
 		public virtual signal void wrote_chunk ();
 		[HasEmitter]
@@ -1198,19 +1198,19 @@ namespace Soup {
 	[CCode (cheader_filename = "libsoup/soup.h")]
 	public static bool value_array_to_args (GLib.ValueArray array, va_list args);
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static void value_hash_insert (GLib.HashTable<string,GLib.Value> hash, string key, GLib.Type type, ...);
+	public static void value_hash_insert (GLib.HashTable<string,GLib.Value?> hash, string key, GLib.Type type, ...);
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static void value_hash_insert_vals (GLib.HashTable<string,GLib.Value> hash, ...);
+	public static void value_hash_insert_vals (GLib.HashTable<string,GLib.Value?> hash, ...);
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static void value_hash_insert_value (GLib.HashTable<string,GLib.Value> hash, string key, GLib.Value value);
+	public static void value_hash_insert_value (GLib.HashTable<string,GLib.Value?> hash, string key, GLib.Value value);
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static bool value_hash_lookup (GLib.HashTable<string,GLib.Value> hash, string key, GLib.Type type, ...);
+	public static bool value_hash_lookup (GLib.HashTable<string,GLib.Value?> hash, string key, GLib.Type type, ...);
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static bool value_hash_lookup_vals (GLib.HashTable<string,GLib.Value> hash, ...);
+	public static bool value_hash_lookup_vals (GLib.HashTable<string,GLib.Value?> hash, ...);
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static GLib.HashTable<string,GLib.Value> value_hash_new ();
+	public static GLib.HashTable<string,GLib.Value?> value_hash_new ();
 	[CCode (cheader_filename = "libsoup/soup.h")]
-	public static GLib.HashTable<string,GLib.Value> value_hash_new_with_vals (...);
+	public static GLib.HashTable<string,GLib.Value?> value_hash_new_with_vals (...);
 	[CCode (cheader_filename = "libsoup/soup.h")]
 	[Deprecated (replacement = "XMLRPC.build_fault", since = "vala-0.12")]
 	[PrintfFormat]



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