Back to development
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.StructureFilterMapFuncNative.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 StructureFilterMapFuncNative(uint field_id, IntPtr value, IntPtr user_data);
12
13         internal class StructureFilterMapFuncInvoker {
14
15                 StructureFilterMapFuncNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~StructureFilterMapFuncInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal StructureFilterMapFuncInvoker (StructureFilterMapFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal StructureFilterMapFuncInvoker (StructureFilterMapFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal StructureFilterMapFuncInvoker (StructureFilterMapFuncNative 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.StructureFilterMapFunc Handler {
38                         get {
39                                 return new Gst.StructureFilterMapFunc(InvokeNative);
40                         }
41                 }
42
43                 bool InvokeNative (uint field_id, GLib.Value value)
44                 {
45                         IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
46                         bool __result = native_cb (field_id, native_value, __data);
47                         Marshal.FreeHGlobal (native_value);
48                         return __result;
49                 }
50         }
51
52         internal class StructureFilterMapFuncWrapper {
53
54                 public bool NativeCallback (uint field_id, IntPtr value, IntPtr user_data)
55                 {
56                         try {
57                                 bool __ret = managed (field_id, (GLib.Value) Marshal.PtrToStructure (value, typeof (GLib.Value)));
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 StructureFilterMapFuncNative NativeDelegate;
77                 Gst.StructureFilterMapFunc managed;
78
79                 public StructureFilterMapFuncWrapper (Gst.StructureFilterMapFunc managed)
80                 {
81                         this.managed = managed;
82                         if (managed != null)
83                                 NativeDelegate = new StructureFilterMapFuncNative (NativeCallback);
84                 }
85
86                 public static Gst.StructureFilterMapFunc GetManagedDelegate (StructureFilterMapFuncNative native)
87                 {
88                         if (native == null)
89                                 return null;
90                         StructureFilterMapFuncWrapper wrapper = (StructureFilterMapFuncWrapper) native.Target;
91                         if (wrapper == null)
92                                 return null;
93                         return wrapper.managed;
94                 }
95         }
96 #endregion
97 }