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