+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
+
2008-02-23 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: visit child nodes of object
* 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.
*
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "ErrorBase") {
+ is_error_base = true;
}
}
}
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);
+ }
}
[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")]
public static bool remove_by_data (pointer data);
}
+ [SimpleType]
[CCode (default_value = "0")]
public struct Pid {
}
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);
/* 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, ...);