From: Evan Nemerson Date: Wed, 3 Nov 2010 05:42:54 +0000 (-0700) Subject: glib-2.0: make Func, ThreadFunc, HFunc, Thread, and ThreadPool generic X-Git-Tag: 0.11.2~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c24afbe5ed2e311c82f08dc19ccfce6fbbc4b90;p=thirdparty%2Fvala.git glib-2.0: make Func, ThreadFunc, HFunc, Thread, and ThreadPool generic --- diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index a4df04512..801924860 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -1605,8 +1605,8 @@ namespace GLib { /* Thread support */ - public delegate void* ThreadFunc (); - public delegate void Func (void* data); + public delegate G ThreadFunc (); + public delegate void Func (G data); [CCode (has_type_id = false)] public enum ThreadPriority { @@ -1617,17 +1617,19 @@ namespace GLib { } [Compact] - public class Thread { + public class Thread { public static bool supported (); - public static unowned Thread create (ThreadFunc func, bool joinable) throws ThreadError; - public static unowned Thread create_full (ThreadFunc func, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError; - public static unowned Thread self (); - public void* join (); + [CCode (simple_generics = true)] + public static unowned Thread create (ThreadFunc func, bool joinable) throws ThreadError; + [CCode (simple_generics = true)] + public static unowned Thread create_full (ThreadFunc func, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError; + public static unowned Thread self (); + public T join (); public void set_priority (ThreadPriority priority); public static void yield (); - public static void exit (void* retval); - public static void @foreach (Func thread_func); - + public static void exit (T retval); + public static void @foreach (Func thread_func); + [CCode (cname = "g_usleep")] public static void usleep (ulong microseconds); } @@ -1699,9 +1701,9 @@ namespace GLib { [Compact] [CCode (free_function = "g_thread_pool_free")] - public class ThreadPool { - public ThreadPool (Func func, int max_threads, bool exclusive) throws ThreadError; - public void push (void* data) throws ThreadError; + public class ThreadPool { + public ThreadPool (Func func, int max_threads, bool exclusive) throws ThreadError; + public void push (T data) throws ThreadError; public void set_max_threads (int max_threads) throws ThreadError; public int get_max_threads (); public uint get_num_threads (); @@ -3500,7 +3502,7 @@ namespace GLib { public void sort_with_data (CompareDataFunc compare_func); [ReturnsModifiedPointer ()] public void concat (owned List list2); - public void @foreach (Func func); + public void @foreach (Func func); public unowned List first (); public unowned List last (); @@ -3556,7 +3558,7 @@ namespace GLib { public void sort_with_data (CompareDataFunc compare_func); [ReturnsModifiedPointer ()] public void concat (owned SList list2); - public void @foreach (Func func); + public void @foreach (Func func); public unowned SList last (); public unowned SList nth (uint n); @@ -3610,6 +3612,8 @@ namespace GLib { public int index (G data); public void remove (G data); public void remove_all (G data); + public void delete_link (List link); + public void unlink (List link); public void insert_before (List sibling, owned G data); public void insert_after (List sibling, owned G data); public void insert_sorted (owned G data, CompareDataFunc func); @@ -3622,8 +3626,8 @@ namespace GLib { public class Sequence { public Sequence (DestroyNotify? data_destroy); public int get_length (); - public void @foreach (Func func); - public static void foreach_range (SequenceIter begin, SequenceIter end, Func func); + public void @foreach (Func func); + public static void foreach_range (SequenceIter begin, SequenceIter end, Func func); public void sort (CompareDataFunc cmp_func); public void sort_iter (SequenceIterCompareFunc func); public SequenceIter get_begin_iter (); @@ -3682,9 +3686,9 @@ namespace GLib { public void remove_all (); public List get_keys (); public List get_values (); - public void @foreach (HFunc func); + public void @foreach (HFunc func); [CCode (cname = "g_hash_table_foreach")] - public void for_each (HFunc func); + public void for_each (HFunc func); public uint size (); public bool steal (K key); public void steal_all (); @@ -3702,7 +3706,7 @@ namespace GLib { public delegate uint HashFunc (K key); [CCode (has_target = false)] public delegate bool EqualFunc (G a, G b); - public delegate void HFunc (void* key, void* value); + public delegate void HFunc (K key, V value); [CCode (has_target = false)] public delegate void DestroyNotify (void* data); @@ -3792,7 +3796,7 @@ namespace GLib { [CCode (cname = "g_ptr_array_sized_new")] public PtrArray.sized (uint reserved_size); public void add (void* data); - public void foreach (GLib.Func func); + public void foreach (GLib.Func func); [CCode (cname = "g_ptr_array_index")] public void* index(uint index); public bool remove (void* data); @@ -3815,7 +3819,7 @@ namespace GLib { [CCode (cname = "g_ptr_array_new_with_free_func", simple_generics = true)] public GenericArray (); public void add (owned G data); - public void foreach (GLib.Func func); + public void foreach (GLib.Func func); [CCode (cname = "g_ptr_array_index")] public unowned G get (uint index); public bool remove (G data);