mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 14:55:40 +00:00
generator,glib: Added Mutex, RecMutex, Cond types
Bind these types manually and added generator support for them.
This commit is contained in:
parent
747a4ad871
commit
112e2b9598
|
@ -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})"));
|
||||
|
|
70
glib/Cond.cs
Normal file
70
glib/Cond.cs
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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 \
|
||||
|
|
110
glib/Mutex.cs
Normal file
110
glib/Mutex.cs
Normal file
|
@ -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<Mutex> {
|
||||
|
||||
[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
|
||||
}
|
||||
}
|
57
glib/RecMutex.cs
Normal file
57
glib/RecMutex.cs
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -87,6 +87,9 @@
|
|||
<Compile Include="Variant.cs" />
|
||||
<Compile Include="VariantType.cs" />
|
||||
<Compile Include="GLibSynchronizationContext.cs" />
|
||||
<Compile Include="Mutex.cs" />
|
||||
<Compile Include="RecMutex.cs" />
|
||||
<Compile Include="Cond.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Core" />
|
||||
|
|
Loading…
Reference in a new issue