// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace GESSharp {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
	internal delegate ulong BaseEffectTimeTranslationFuncNative(IntPtr effect, ulong time, System.IntPtr time_property_values, IntPtr user_data);

	internal class BaseEffectTimeTranslationFuncInvoker {

		BaseEffectTimeTranslationFuncNative native_cb;
		IntPtr __data;
		GLib.DestroyNotify __notify;

		~BaseEffectTimeTranslationFuncInvoker ()
		{
			if (__notify == null)
				return;
			__notify (__data);
		}

		internal BaseEffectTimeTranslationFuncInvoker (BaseEffectTimeTranslationFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}

		internal BaseEffectTimeTranslationFuncInvoker (BaseEffectTimeTranslationFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}

		internal BaseEffectTimeTranslationFuncInvoker (BaseEffectTimeTranslationFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify)
		{
			this.native_cb = native_cb;
			__data = data;
			__notify = notify;
		}

		internal GES.BaseEffectTimeTranslationFunc Handler {
			get {
				return new GES.BaseEffectTimeTranslationFunc(InvokeNative);
			}
		}

		ulong InvokeNative (GES.BaseEffect effect, ulong time, System.IntPtr time_property_values)
		{
			ulong __result = native_cb (effect == null ? IntPtr.Zero : effect.Handle, time, time_property_values, __data);
			return __result;
		}
	}

	internal class BaseEffectTimeTranslationFuncWrapper {

		public ulong NativeCallback (IntPtr effect, ulong time, System.IntPtr time_property_values, IntPtr user_data)
		{
			try {
				ulong __ret = managed (GLib.Object.GetObject(effect) as GES.BaseEffect, time, time_property_values);
				if (release_on_call)
					gch.Free ();
				return __ret;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: Above call does not return.
				throw e;
			}
		}

		bool release_on_call = false;
		GCHandle gch;

		public void PersistUntilCalled ()
		{
			release_on_call = true;
			gch = GCHandle.Alloc (this);
		}

		internal BaseEffectTimeTranslationFuncNative NativeDelegate;
		GES.BaseEffectTimeTranslationFunc managed;

		public BaseEffectTimeTranslationFuncWrapper (GES.BaseEffectTimeTranslationFunc managed)
		{
			this.managed = managed;
			if (managed != null)
				NativeDelegate = new BaseEffectTimeTranslationFuncNative (NativeCallback);
		}

		public static GES.BaseEffectTimeTranslationFunc GetManagedDelegate (BaseEffectTimeTranslationFuncNative native)
		{
			if (native == null)
				return null;
			BaseEffectTimeTranslationFuncWrapper wrapper = (BaseEffectTimeTranslationFuncWrapper) native.Target;
			if (wrapper == null)
				return null;
			return wrapper.managed;
		}
	}
#endregion
}
