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