Back to development
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.PadActivateFunctionNative.cs
1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
3
4 namespace GstSharp {
5
6         using System;
7         using System.Runtime.InteropServices;
8
9 #region Autogenerated code
10         [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
11         internal delegate bool PadActivateFunctionNative(IntPtr pad, IntPtr parent);
12
13         internal class PadActivateFunctionInvoker {
14
15                 PadActivateFunctionNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~PadActivateFunctionInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal PadActivateFunctionInvoker (PadActivateFunctionNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal PadActivateFunctionInvoker (PadActivateFunctionNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal PadActivateFunctionInvoker (PadActivateFunctionNative native_cb, IntPtr data, GLib.DestroyNotify notify)
31                 {
32                         this.native_cb = native_cb;
33                         __data = data;
34                         __notify = notify;
35                 }
36
37                 internal Gst.PadActivateFunction Handler {
38                         get {
39                                 return new Gst.PadActivateFunction(InvokeNative);
40                         }
41                 }
42
43                 bool InvokeNative (Gst.Pad pad, Gst.Object parent)
44                 {
45                         bool __result = native_cb (pad == null ? IntPtr.Zero : pad.Handle, parent == null ? IntPtr.Zero : parent.Handle);
46                         return __result;
47                 }
48         }
49
50         internal class PadActivateFunctionWrapper {
51
52                 public bool NativeCallback (IntPtr pad, IntPtr parent)
53                 {
54                         try {
55                                 bool __ret = managed (GLib.Object.GetObject(pad) as Gst.Pad, GLib.Object.GetObject(parent) as Gst.Object);
56                                 if (release_on_call)
57                                         gch.Free ();
58                                 return __ret;
59                         } catch (Exception e) {
60                                 GLib.ExceptionManager.RaiseUnhandledException (e, false);
61                                 return false;
62                         }
63                 }
64
65                 bool release_on_call = false;
66                 GCHandle gch;
67
68                 public void PersistUntilCalled ()
69                 {
70                         release_on_call = true;
71                         gch = GCHandle.Alloc (this);
72                 }
73
74                 internal PadActivateFunctionNative NativeDelegate;
75                 Gst.PadActivateFunction managed;
76
77                 public PadActivateFunctionWrapper (Gst.PadActivateFunction managed)
78                 {
79                         this.managed = managed;
80                         if (managed != null)
81                                 NativeDelegate = new PadActivateFunctionNative (NativeCallback);
82                 }
83
84                 public static Gst.PadActivateFunction GetManagedDelegate (PadActivateFunctionNative native)
85                 {
86                         if (native == null)
87                                 return null;
88                         PadActivateFunctionWrapper wrapper = (PadActivateFunctionWrapper) native.Target;
89                         if (wrapper == null)
90                                 return null;
91                         return wrapper.managed;
92                 }
93         }
94 #endregion
95 }