GtkSharp/Source/Libs/GLibSharp/GLibSharp.SourceDummyMarshalNative.cs

92 lines
2.1 KiB
C#

// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.
namespace GLibSharp {
using System;
using System.Runtime.InteropServices;
#region Autogenerated code
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void SourceDummyMarshalNative();
internal class SourceDummyMarshalInvoker {
SourceDummyMarshalNative native_cb;
IntPtr __data;
GLib.DestroyNotify __notify;
~SourceDummyMarshalInvoker ()
{
if (__notify == null)
return;
__notify (__data);
}
internal SourceDummyMarshalInvoker (SourceDummyMarshalNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
internal SourceDummyMarshalInvoker (SourceDummyMarshalNative native_cb, IntPtr data) : this (native_cb, data, null) {}
internal SourceDummyMarshalInvoker (SourceDummyMarshalNative native_cb, IntPtr data, GLib.DestroyNotify notify)
{
this.native_cb = native_cb;
__data = data;
__notify = notify;
}
internal GLib.SourceDummyMarshal Handler {
get {
return new GLib.SourceDummyMarshal(InvokeNative);
}
}
void InvokeNative ()
{
native_cb ();
}
}
internal class SourceDummyMarshalWrapper {
public void NativeCallback ()
{
try {
managed ();
if (release_on_call)
gch.Free ();
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
}
bool release_on_call = false;
GCHandle gch;
public void PersistUntilCalled ()
{
release_on_call = true;
gch = GCHandle.Alloc (this);
}
internal SourceDummyMarshalNative NativeDelegate;
GLib.SourceDummyMarshal managed;
public SourceDummyMarshalWrapper (GLib.SourceDummyMarshal managed)
{
this.managed = managed;
if (managed != null)
NativeDelegate = new SourceDummyMarshalNative (NativeCallback);
}
public static GLib.SourceDummyMarshal GetManagedDelegate (SourceDummyMarshalNative native)
{
if (native == null)
return null;
SourceDummyMarshalWrapper wrapper = (SourceDummyMarshalWrapper) native.Target;
if (wrapper == null)
return null;
return wrapper.managed;
}
}
#endregion
}