vala r1035 - in trunk: . vala vapi



Author: rasa
Date: Sat Feb 23 15:15:46 2008
New Revision: 1035
URL: http://svn.gnome.org/viewvc/vala?rev=1035&view=rev

Log:
2008-02-23  Raffaele Sandrini  <raffaele sandrini ch>

	* vala/valaclass.vala, vala/valaerrortype.vala,
	  vala/valasymbolresolver.vala: allow any error type to be cast
	  implicitly to GLib.Error
	* vapi/glib-2.0.vapi: declare GLib.Error as ErrorBase, random fixes


Modified:
   trunk/ChangeLog
   trunk/vala/valaclass.vala
   trunk/vala/valaerrortype.vala
   trunk/vala/valasymbolresolver.vala
   trunk/vapi/glib-2.0.vapi

Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala	(original)
+++ trunk/vala/valaclass.vala	Sat Feb 23 15:15:46 2008
@@ -97,7 +97,12 @@
 	 * Specifies the instance destructor.
 	 */
 	public Destructor destructor { get; set; }
-	
+
+	/**
+	 * Specifies whether this class denotes an error base.
+	 */
+	public bool is_error_base { get; set ; }
+
 	/**
 	 * Creates a new class.
 	 *
@@ -487,6 +492,8 @@
 		foreach (Attribute a in attributes) {
 			if (a.name == "CCode") {
 				process_ccode_attribute (a);
+			} else if (a.name == "ErrorBase") {
+				is_error_base = true;
 			}
 		}
 	}

Modified: trunk/vala/valaerrortype.vala
==============================================================================
--- trunk/vala/valaerrortype.vala	(original)
+++ trunk/vala/valaerrortype.vala	Sat Feb 23 15:15:46 2008
@@ -35,4 +35,33 @@
 		this.error_domain = error_domain;
 		this.data_type = error_domain;
 	}
+
+	public override bool compatible (DataType! target_type, bool enable_non_null = true) {
+		var et = target_type as ErrorType;
+
+		/* error types are only compatible to error types */
+		if (et == null) {
+			return false;
+		}
+
+		/* every error type is compatible to the base error type */
+		if (et.error_domain == null) {
+			return true;
+		}
+
+		/* otherwhise the error_domain has to be equal */
+		return et.error_domain == error_domain;
+	}
+
+	public override string to_string () {
+		if (error_domain == null) {
+			return "GLib.error";
+		} else {
+			return error_domain.get_full_name ();
+		}
+	}
+
+	public override DataType copy () {
+		return new ErrorType (error_domain);
+	}
 }

Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala	(original)
+++ trunk/vala/valasymbolresolver.vala	Sat Feb 23 15:15:46 2008
@@ -313,6 +313,11 @@
 			}
 		}
 
+		/* check whether this type resolved to a ErrorBase class */
+		if (type.data_type is Class && ((Class)type.data_type).is_error_base) {
+			type = new ErrorType (null);
+		}
+
 		return type;
 	}
 

Modified: trunk/vapi/glib-2.0.vapi
==============================================================================
--- trunk/vapi/glib-2.0.vapi	(original)
+++ trunk/vapi/glib-2.0.vapi	Sat Feb 23 15:15:46 2008
@@ -586,6 +586,8 @@
 	
 	[CCode (cname = "atoi")]
 	public int to_int ();
+	[CCode (cname = "atol")]
+	public long to_long ();
 	[CCode (cname = "strtod")]
 	public double to_double (out string endptr = null);
 	[CCode (cname = "strtoul")]
@@ -1096,6 +1098,7 @@
 		public static bool remove_by_data (pointer data);
 	}
 
+	[SimpleType]
 	[CCode (default_value = "0")]
 	public struct Pid {
 	}
@@ -1188,14 +1191,14 @@
 	public class Thread {
 		public static void init (ThreadFunctions vtable = null);
 		public static bool supported ();
-		public static weak Thread create (ThreadFunc func, pointer data, bool joinable) throws ThreadError;
-		public static weak Thread create_full (ThreadFunc func, pointer data, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError;
+		public static weak Thread create (ThreadFunc func, bool joinable) throws ThreadError;
+		public static weak Thread create_full (ThreadFunc func, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError;
 		public static weak Thread self ();
 		public pointer join ();
 		public void set_priority (ThreadPriority priority);
 		public static void yield ();
 		public static void exit (pointer retval);
-		public static void @foreach (Func thread_func, pointer user_data);
+		public static void @foreach (Func thread_func);
 		
 		[CCode (cname = "g_usleep")]
 		public static void usleep (ulong microseconds);
@@ -1367,6 +1370,7 @@
 
 	/* Error Reporting */
 
+	[ErrorBase]
 	[CCode (copy_function = "g_error_copy", free_function = "g_error_free")]
 	public class Error {
 		public Error (Quark domain, int code, string! format, ...);



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