diff options
author | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2019-04-22 21:56:48 -0300 |
---|---|---|
committer | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2019-04-22 21:56:48 -0300 |
commit | 4c157bb37d673291989d90d95982d6fd6cc39441 (patch) | |
tree | 01599d2ce6d7c778256f7c7a30e0f0596116f358 | |
parent | 6f1cec4a991c6957388f7102bf42a4624ec81e38 (diff) | |
download | efl-devs/felipealmeida/pin-unpin.tar.gz |
efl-mono: (WIP) Add pin and unpin C# handledevs/felipealmeida/pin-unpin
-rw-r--r-- | src/bindings/mono/eo_mono/iwrapper.cs | 28 | ||||
-rw-r--r-- | src/lib/efl_mono/efl_custom_exports_mono.c | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index cc91d65b34..1c28299e07 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs @@ -60,6 +60,7 @@ public class Globals public static IntPtr efl_key_data_get(IntPtr obj, IntPtr key) => efl_key_data_get_ptr.Value.Delegate(obj, key); [DllImport(efl.Libs.CustomExports)] public static extern IntPtr efl_mono_lifetime_key_get(); + [DllImport(efl.Libs.CustomExports)] public static extern IntPtr efl_mono_lifetime_gchandle_key_get(); [DllImport(efl.Libs.Eo)] public static extern IntPtr _efl_add_internal_start([MarshalAs(UnmanagedType.LPStr)] String file, int line, @@ -486,6 +487,33 @@ public class Globals var getter = new Efl.Eo.WrapperGetter (wrapper); GCHandle gch = GCHandle.Alloc (getter); efl_key_data_set (eo, efl_mono_lifetime_key_get(), GCHandle.ToIntPtr(gch)); + + Efl.EventCb UniqueCb = (IntPtr data, ref Efl.Event.NativeStruct evt) => + { + var obj = getter.Target; + if (obj != null) + { + Console.WriteLine ("UNIQUE"); + IntPtr gchPtr = efl_key_data_get (eo, efl_mono_lifetime_gchandle_key_get()); + GCHandle objGCH = GCHandle.FromIntPtr (gchPtr); + objGCH.Free(); + } + }; + Efl.EventCb SharedCb = (IntPtr data, ref Efl.Event.NativeStruct evt) => + { + var obj = getter.Target; + if (obj != null) + { + Console.WriteLine ("SHARED"); + var objGCH = GCHandle.Alloc (obj); + efl_key_data_set (eo, efl_mono_lifetime_gchandle_key_get(), GCHandle.ToIntPtr(objGCH)); + } + }; + + IntPtr UniqueDesc = Efl.EventDescription.GetNative(efl.Libs.Eo, "_EFL_EVENT_OWNERSHIP_UNIQUE"); + Efl.Eo.Globals.efl_event_callback_priority_add (eo, UniqueDesc, 0, Marshal.GetFunctionPointerForDelegate(UniqueCb), IntPtr.Zero); + IntPtr SharedDesc = Efl.EventDescription.GetNative(efl.Libs.Eo, "_EFL_EVENT_OWNERSHIP_SHARED"); + Efl.Eo.Globals.efl_event_callback_priority_add (eo, SharedDesc, 0, Marshal.GetFunctionPointerForDelegate(SharedCb), IntPtr.Zero); return eo; } diff --git a/src/lib/efl_mono/efl_custom_exports_mono.c b/src/lib/efl_mono/efl_custom_exports_mono.c index b25ca1c548..3cc7324168 100644 --- a/src/lib/efl_mono/efl_custom_exports_mono.c +++ b/src/lib/efl_mono/efl_custom_exports_mono.c @@ -34,6 +34,11 @@ EAPI const char* efl_mono_lifetime_key_get () return "__c#__handle__wrapper__lifetime__"; } +EAPI const char* efl_mono_lifetime_gchandle_key_get () +{ + return "__c#__handle__wrapper__lifetime__gchandle__"; +} + EAPI void efl_mono_gchandle_callbacks_set(Efl_Mono_Free_GCHandle_Cb free_gchandle_cb, Efl_Mono_Remove_Events_Cb remove_events_cb) { _efl_mono_free_gchandle_call = free_gchandle_cb; |