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