diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 823494a97..d490a02d4 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -127,6 +127,9 @@ namespace GtkSharp.Generation { AddType (new ManualGen ("GVariant", "GLib.Variant")); AddType (new ManualGen ("GVariantType", "GLib.VariantType")); AddType (new ManualGen ("GValueArray", "GLib.ValueArray")); + AddType (new ManualGen ("GMutex", "GLib.Mutex")); + AddType (new ManualGen ("GRecMutex", "GLib.RecMutex")); + AddType (new ManualGen ("GCond", "GLib.Cond")); AddType (new MarshalGen ("gunichar", "char", "uint", "GLib.Marshaller.CharToGUnichar ({0})", "GLib.Marshaller.GUnicharToChar ({0})")); AddType (new MarshalGen ("time_t", "System.DateTime", "IntPtr", "GLib.Marshaller.DateTimeTotime_t ({0})", "GLib.Marshaller.time_tToDateTime ({0})")); AddType (new MarshalGen ("GString", "string", "IntPtr", "new GLib.GString ({0}).Handle", "GLib.GString.PtrToString ({0})")); diff --git a/glib/Cond.cs b/glib/Cond.cs new file mode 100644 index 000000000..ee7c2e100 --- /dev/null +++ b/glib/Cond.cs @@ -0,0 +1,70 @@ +// This file was generated by the Gtk# code generator. +// Any changes made will be lost if regenerated. + +// TODO: generate this as part of the build instead of committing it to the repo + +namespace GLib { + + using System; + using System.Collections; + using System.Collections.Generic; + using System.Runtime.InteropServices; + +#region Autogenerated code + public partial class Cond : GLib.Opaque { + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_cond_broadcast(IntPtr raw); + + public void Broadcast() { + g_cond_broadcast(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_cond_clear(IntPtr raw); + + public void Clear() { + g_cond_clear(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_cond_init(IntPtr raw); + + public void Init() { + g_cond_init(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_cond_signal(IntPtr raw); + + public void Signal() { + g_cond_signal(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_cond_wait(IntPtr raw, IntPtr mutex); + + public void Wait(GLib.Mutex mutex) { + IntPtr native_mutex = GLib.Marshaller.StructureToPtrAlloc (mutex); + g_cond_wait(Handle, native_mutex); + mutex = GLib.Mutex.New (native_mutex); + Marshal.FreeHGlobal (native_mutex); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern bool g_cond_wait_until(IntPtr raw, IntPtr mutex, long end_time); + + public bool WaitUntil(GLib.Mutex mutex, long end_time) { + IntPtr native_mutex = GLib.Marshaller.StructureToPtrAlloc (mutex); + bool raw_ret = g_cond_wait_until(Handle, native_mutex, end_time); + bool ret = raw_ret; + mutex = GLib.Mutex.New (native_mutex); + Marshal.FreeHGlobal (native_mutex); + return ret; + } + + public Cond(IntPtr raw) : base(raw) {} + +#endregion + } +} diff --git a/glib/Makefile.am b/glib/Makefile.am index b23c11ad6..c73edaf87 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -22,6 +22,7 @@ references = sources = \ Argv.cs \ ConnectBeforeAttribute.cs \ + Cond.cs \ DefaultSignalHandlerAttribute.cs \ DestroyNotify.cs \ ExceptionManager.cs \ @@ -48,6 +49,7 @@ sources = \ Markup.cs \ Marshaller.cs \ MissingIntPtrCtorException.cs \ + Mutex.cs \ NotifyHandler.cs \ Object.cs \ ObjectManager.cs \ @@ -56,6 +58,7 @@ sources = \ Priority.cs \ PropertyAttribute.cs \ PtrArray.cs \ + RecMutex.cs \ Signal.cs \ SignalArgs.cs \ SignalAttribute.cs \ diff --git a/glib/Mutex.cs b/glib/Mutex.cs new file mode 100644 index 000000000..9a6d2e6db --- /dev/null +++ b/glib/Mutex.cs @@ -0,0 +1,110 @@ +// This file was generated by the Gtk# code generator. +// Any changes made will be lost if regenerated. + +// TODO: generate this as part of the build instead of committing it to the repo + +namespace GLib { + + using System; + using System.Collections; + using System.Collections.Generic; + using System.Runtime.InteropServices; + +#region Autogenerated code + [StructLayout(LayoutKind.Explicit)] + public partial struct Mutex : IEquatable { + + [FieldOffset(0)] + private IntPtr _p; + [FieldOffset(0)] + [MarshalAs (UnmanagedType.ByValArray, SizeConst=2)] + public uint[] I; + + public static GLib.Mutex Zero = new GLib.Mutex (); + + public static GLib.Mutex New(IntPtr raw) { + if (raw == IntPtr.Zero) + return GLib.Mutex.Zero; + return (GLib.Mutex) Marshal.PtrToStructure (raw, typeof (GLib.Mutex)); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_mutex_clear(IntPtr raw); + + public void Clear() { + IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this)); + System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false); + g_mutex_clear(this_as_native); + ReadNative (this_as_native, ref this); + System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_mutex_init(IntPtr raw); + + public void Init() { + IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this)); + System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false); + g_mutex_init(this_as_native); + ReadNative (this_as_native, ref this); + System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_mutex_lock(IntPtr raw); + + public void Lock() { + IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this)); + System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false); + g_mutex_lock(this_as_native); + ReadNative (this_as_native, ref this); + System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern bool g_mutex_trylock(IntPtr raw); + + public bool Trylock() { + IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this)); + System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false); + bool raw_ret = g_mutex_trylock(this_as_native); + bool ret = raw_ret; + ReadNative (this_as_native, ref this); + System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native); + return ret; + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_mutex_unlock(IntPtr raw); + + public void Unlock() { + IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this)); + System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false); + g_mutex_unlock(this_as_native); + ReadNative (this_as_native, ref this); + System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native); + } + + static void ReadNative (IntPtr native, ref GLib.Mutex target) + { + target = New (native); + } + + public bool Equals (Mutex other) + { + return true && _p.Equals (other._p) && I.Equals (other.I); + } + + public override bool Equals (object other) + { + return other is Mutex && Equals ((Mutex) other); + } + + public override int GetHashCode () + { + return this.GetType().FullName.GetHashCode() ^ _p.GetHashCode () ^ I.GetHashCode (); + } + +#endregion + } +} diff --git a/glib/RecMutex.cs b/glib/RecMutex.cs new file mode 100644 index 000000000..a1e3bdbc5 --- /dev/null +++ b/glib/RecMutex.cs @@ -0,0 +1,57 @@ +// This file was generated by the Gtk# code generator. +// Any changes made will be lost if regenerated. + +// TODO: generate this as part of the build instead of committing it to the repo + +namespace GLib { + + using System; + using System.Collections; + using System.Collections.Generic; + using System.Runtime.InteropServices; + +#region Autogenerated code + public partial class RecMutex : GLib.Opaque { + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_rec_mutex_clear(IntPtr raw); + + public void Clear() { + g_rec_mutex_clear(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_rec_mutex_init(IntPtr raw); + + public void Init() { + g_rec_mutex_init(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_rec_mutex_lock(IntPtr raw); + + public void Lock() { + g_rec_mutex_lock(Handle); + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern bool g_rec_mutex_trylock(IntPtr raw); + + public bool Trylock() { + bool raw_ret = g_rec_mutex_trylock(Handle); + bool ret = raw_ret; + return ret; + } + + [DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern void g_rec_mutex_unlock(IntPtr raw); + + public void Unlock() { + g_rec_mutex_unlock(Handle); + } + + public RecMutex(IntPtr raw) : base(raw) {} + +#endregion + } +} diff --git a/glib/glib.csproj b/glib/glib.csproj index 0f7bf4384..7e3f086ab 100644 --- a/glib/glib.csproj +++ b/glib/glib.csproj @@ -87,6 +87,9 @@ + + +