summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-04-22 21:56:48 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-04-22 21:56:48 -0300
commit4c157bb37d673291989d90d95982d6fd6cc39441 (patch)
tree01599d2ce6d7c778256f7c7a30e0f0596116f358
parent6f1cec4a991c6957388f7102bf42a4624ec81e38 (diff)
efl-mono: (WIP) Add pin and unpin C# handledevs/felipealmeida/pin-unpin
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs28
-rw-r--r--src/lib/efl_mono/efl_custom_exports_mono.c5
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
60 public static IntPtr efl_key_data_get(IntPtr obj, IntPtr key) => efl_key_data_get_ptr.Value.Delegate(obj, key); 60 public static IntPtr efl_key_data_get(IntPtr obj, IntPtr key) => efl_key_data_get_ptr.Value.Delegate(obj, key);
61 61
62 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr efl_mono_lifetime_key_get(); 62 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr efl_mono_lifetime_key_get();
63 [DllImport(efl.Libs.CustomExports)] public static extern IntPtr efl_mono_lifetime_gchandle_key_get();
63 64
64 [DllImport(efl.Libs.Eo)] public static extern IntPtr 65 [DllImport(efl.Libs.Eo)] public static extern IntPtr
65 _efl_add_internal_start([MarshalAs(UnmanagedType.LPStr)] String file, int line, 66 _efl_add_internal_start([MarshalAs(UnmanagedType.LPStr)] String file, int line,
@@ -486,6 +487,33 @@ public class Globals
486 var getter = new Efl.Eo.WrapperGetter (wrapper); 487 var getter = new Efl.Eo.WrapperGetter (wrapper);
487 GCHandle gch = GCHandle.Alloc (getter); 488 GCHandle gch = GCHandle.Alloc (getter);
488 efl_key_data_set (eo, efl_mono_lifetime_key_get(), GCHandle.ToIntPtr(gch)); 489 efl_key_data_set (eo, efl_mono_lifetime_key_get(), GCHandle.ToIntPtr(gch));
490
491 Efl.EventCb UniqueCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
492 {
493 var obj = getter.Target;
494 if (obj != null)
495 {
496 Console.WriteLine ("UNIQUE");
497 IntPtr gchPtr = efl_key_data_get (eo, efl_mono_lifetime_gchandle_key_get());
498 GCHandle objGCH = GCHandle.FromIntPtr (gchPtr);
499 objGCH.Free();
500 }
501 };
502 Efl.EventCb SharedCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
503 {
504 var obj = getter.Target;
505 if (obj != null)
506 {
507 Console.WriteLine ("SHARED");
508 var objGCH = GCHandle.Alloc (obj);
509 efl_key_data_set (eo, efl_mono_lifetime_gchandle_key_get(), GCHandle.ToIntPtr(objGCH));
510 }
511 };
512
513 IntPtr UniqueDesc = Efl.EventDescription.GetNative(efl.Libs.Eo, "_EFL_EVENT_OWNERSHIP_UNIQUE");
514 Efl.Eo.Globals.efl_event_callback_priority_add (eo, UniqueDesc, 0, Marshal.GetFunctionPointerForDelegate(UniqueCb), IntPtr.Zero);
515 IntPtr SharedDesc = Efl.EventDescription.GetNative(efl.Libs.Eo, "_EFL_EVENT_OWNERSHIP_SHARED");
516 Efl.Eo.Globals.efl_event_callback_priority_add (eo, SharedDesc, 0, Marshal.GetFunctionPointerForDelegate(SharedCb), IntPtr.Zero);
489 517
490 return eo; 518 return eo;
491 } 519 }
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 ()
34 return "__c#__handle__wrapper__lifetime__"; 34 return "__c#__handle__wrapper__lifetime__";
35} 35}
36 36
37EAPI const char* efl_mono_lifetime_gchandle_key_get ()
38{
39 return "__c#__handle__wrapper__lifetime__gchandle__";
40}
41
37EAPI void efl_mono_gchandle_callbacks_set(Efl_Mono_Free_GCHandle_Cb free_gchandle_cb, Efl_Mono_Remove_Events_Cb remove_events_cb) 42EAPI void efl_mono_gchandle_callbacks_set(Efl_Mono_Free_GCHandle_Cb free_gchandle_cb, Efl_Mono_Remove_Events_Cb remove_events_cb)
38{ 43{
39 _efl_mono_free_gchandle_call = free_gchandle_cb; 44 _efl_mono_free_gchandle_call = free_gchandle_cb;