Back to development
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.MiniObjectCopyFunctionNative.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 IntPtr MiniObjectCopyFunctionNative(IntPtr obj);
12
13         internal class MiniObjectCopyFunctionInvoker {
14
15                 MiniObjectCopyFunctionNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~MiniObjectCopyFunctionInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal MiniObjectCopyFunctionInvoker (MiniObjectCopyFunctionNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal MiniObjectCopyFunctionInvoker (MiniObjectCopyFunctionNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal MiniObjectCopyFunctionInvoker (MiniObjectCopyFunctionNative 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.MiniObjectCopyFunction Handler {
38                         get {
39                                 return new Gst.MiniObjectCopyFunction(InvokeNative);
40                         }
41                 }
42
43                 Gst.MiniObject InvokeNative (Gst.MiniObject obj)
44                 {
45                         Gst.MiniObject __result = native_cb (obj == null ? IntPtr.Zero : obj.Handle) == IntPtr.Zero ? null : (Gst.MiniObject) GLib.Opaque.GetOpaque (native_cb (obj == null ? IntPtr.Zero : obj.Handle), typeof (Gst.MiniObject), false);
46                         return __result;
47                 }
48         }
49
50         internal class MiniObjectCopyFunctionWrapper {
51
52                 public IntPtr NativeCallback (IntPtr obj)
53                 {
54                         try {
55                                 Gst.MiniObject __ret = managed (obj == IntPtr.Zero ? null : (Gst.MiniObject) GLib.Opaque.GetOpaque (obj, typeof (Gst.MiniObject), false));
56                                 if (release_on_call)
57                                         gch.Free ();
58                                 return __ret == null ? IntPtr.Zero : __ret.Handle;
59                         } catch (Exception e) {
60                                 GLib.ExceptionManager.RaiseUnhandledException (e, true);
61                                 // NOTREACHED: Above call does not return.
62                                 throw e;
63                         }
64                 }
65
66                 bool release_on_call = false;
67                 GCHandle gch;
68
69                 public void PersistUntilCalled ()
70                 {
71                         release_on_call = true;
72                         gch = GCHandle.Alloc (this);
73                 }
74
75                 internal MiniObjectCopyFunctionNative NativeDelegate;
76                 Gst.MiniObjectCopyFunction managed;
77
78                 public MiniObjectCopyFunctionWrapper (Gst.MiniObjectCopyFunction managed)
79                 {
80                         this.managed = managed;
81                         if (managed != null)
82                                 NativeDelegate = new MiniObjectCopyFunctionNative (NativeCallback);
83                 }
84
85                 public static Gst.MiniObjectCopyFunction GetManagedDelegate (MiniObjectCopyFunctionNative native)
86                 {
87                         if (native == null)
88                                 return null;
89                         MiniObjectCopyFunctionWrapper wrapper = (MiniObjectCopyFunctionWrapper) native.Target;
90                         if (wrapper == null)
91                                 return null;
92                         return wrapper.managed;
93                 }
94         }
95 #endregion
96 }