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