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