From 26161e9fbe3c8529a478743d6b834635c1512940 Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Tue, 29 Oct 2019 11:56:38 -0300 Subject: [PATCH] mono: encapsulate internal iwrapper members Summary: Depends on D10339 Test Plan: meson setup -Dbindings=mono,cxx -Dmono-beta=true Reviewers: segfaultxavi, Jaehyun_Cho, YOhoho Reviewed By: YOhoho Subscribers: cedric, #reviewers, #committers, woohyun Tags: #efl Differential Revision: https://phab.enlightenment.org/D10345 --- .../mono/eo_mono/WrapperSupervisor.cs | 12 +-- src/bindings/mono/eo_mono/iwrapper.cs | 92 +++++++++---------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/bindings/mono/eo_mono/WrapperSupervisor.cs b/src/bindings/mono/eo_mono/WrapperSupervisor.cs index d50cd76a66..31cdaa9c3c 100644 --- a/src/bindings/mono/eo_mono/WrapperSupervisor.cs +++ b/src/bindings/mono/eo_mono/WrapperSupervisor.cs @@ -20,7 +20,7 @@ namespace Efl.Eo { /// Observe the ownership state of an Eo wrapper and control its life-cycle. -public class WrapperSupervisor +internal class WrapperSupervisor { private System.WeakReference weakRef; #pragma warning disable CS0414 @@ -30,7 +30,7 @@ public class WrapperSupervisor /// Create a new supervisor for the given. /// Efl object to be supervised. - public WrapperSupervisor(Efl.Eo.IWrapper obj) + internal WrapperSupervisor(Efl.Eo.IWrapper obj) { weakRef = new WeakReference(obj); sharedRef = null; @@ -38,7 +38,7 @@ public class WrapperSupervisor } /// Efl object being supervised. - public Efl.Eo.IWrapper Target + internal Efl.Eo.IWrapper Target { get { @@ -47,7 +47,7 @@ public class WrapperSupervisor } /// Dictionary that holds the events related with the supervised object. - public EventDictionary EoEvents + internal EventDictionary EoEvents { get { @@ -56,13 +56,13 @@ public class WrapperSupervisor } /// To be called when the object is uniquely owned by C#, removing its strong reference and making it available to garbage collection. - public void MakeUnique() + internal void MakeUnique() { sharedRef = null; } /// To be called when the object is owned in the native library too, adding a strong reference to it and making it unavailable for garbage collection. - public void MakeShared() + internal void MakeShared() { if (this.Target == null) throw new InvalidOperationException("Tried to make a null reference shared."); diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index 691a59fb12..db4213d3ec 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs @@ -36,7 +36,7 @@ namespace Eo public static class Globals { /// Represents the type of the native Efl_Class. - public enum EflClassType + internal enum EflClassType { /// Regular EFL classes. Regular = 0, @@ -51,14 +51,14 @@ public static class Globals } [return: MarshalAs(UnmanagedType.U1)] - public delegate bool efl_object_init_delegate(); + internal delegate bool efl_object_init_delegate(); static readonly FunctionWrapper efl_object_init_ptr = new FunctionWrapper(efl.Libs.EoModule, "efl_object_init"); - public static bool efl_object_init() => efl_object_init_ptr.Value.Delegate(); + internal static bool efl_object_init() => efl_object_init_ptr.Value.Delegate(); - public delegate void efl_object_shutdown_delegate(); + internal delegate void efl_object_shutdown_delegate(); static readonly FunctionWrapper efl_object_shutdown_ptr = new FunctionWrapper(efl.Libs.EoModule, "efl_object_shutdown"); - public static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate(); + internal static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate(); // [DllImport(efl.Libs.Eo)] internal static extern void efl_object_shutdown(); [DllImport(efl.Libs.CustomExports)] internal static extern IntPtr efl_mono_wrapper_supervisor_get(IntPtr eo); @@ -70,19 +70,19 @@ public static class Globals [DllImport(efl.Libs.Eo)] internal static extern IntPtr _efl_add_internal_start_bindings([MarshalAs(UnmanagedType.LPStr)] String file, int line, IntPtr klass, IntPtr parent, byte is_ref, byte is_fallback, IntPtr substitute_ctor, IntPtr data); - public delegate IntPtr + internal delegate IntPtr _efl_add_end_delegate(IntPtr eo, byte is_ref, byte is_fallback); [DllImport(efl.Libs.Eo)] internal static extern IntPtr _efl_add_end(IntPtr eo, byte is_ref, byte is_fallback); - public delegate IntPtr + internal delegate IntPtr efl_ref_delegate(IntPtr eo); [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_ref(IntPtr eo); - public delegate void + internal delegate void efl_unref_delegate(IntPtr eo); [DllImport(efl.Libs.CustomExports)] internal static extern void efl_unref(IntPtr eo); - public delegate int + internal delegate int efl_ref_count_delegate(IntPtr eo); [DllImport(efl.Libs.Eo)] internal static extern int efl_ref_count(IntPtr eo); @@ -199,11 +199,11 @@ public static class Globals [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_class_new(IntPtr class_description, IntPtr parent, IntPtr extn1, IntPtr extn2, IntPtr extn3, IntPtr extn4, IntPtr extn5, IntPtr extn6, IntPtr extn7, IntPtr extn8, IntPtr extn9, IntPtr extn10, IntPtr extn11, IntPtr extn12, IntPtr extn13, IntPtr extn14, IntPtr extn15, IntPtr extn16, IntPtr extn17, IntPtr extn18, IntPtr extn19, IntPtr extn20, IntPtr extn21, IntPtr extn22, IntPtr extn23, IntPtr extn24, IntPtr extn25, IntPtr extn26, IntPtr extn27, IntPtr extn28, IntPtr extn29, IntPtr extn30, IntPtr extn31, IntPtr extn32, IntPtr extn33, IntPtr extn34, IntPtr extn35, IntPtr extn36, IntPtr extn37, IntPtr extn38, IntPtr extn39, IntPtr extn40, IntPtr extn41, IntPtr extn42, IntPtr extn43, IntPtr extn44, IntPtr extn45, IntPtr extn46, IntPtr extn47, IntPtr extn48, IntPtr term); - public delegate byte efl_class_functions_set_delegate(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops); + internal delegate byte efl_class_functions_set_delegate(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops); [DllImport(efl.Libs.Eo)] internal static extern byte efl_class_functions_set(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops); - public delegate IntPtr efl_data_scope_get_delegate(IntPtr obj, IntPtr klass); + internal delegate IntPtr efl_data_scope_get_delegate(IntPtr obj, IntPtr klass); [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_data_scope_get(IntPtr obj, IntPtr klass); - public delegate IntPtr efl_super_delegate(IntPtr obj, IntPtr klass); + internal delegate IntPtr efl_super_delegate(IntPtr obj, IntPtr klass); /// Gets a native pointer to obj that forwards the method call to its parent /// implementation. @@ -214,13 +214,13 @@ public static class Globals /// The native pointer to be prepared. /// The current class. /// The native pointer to obj prepared to call the parent implementation of klass. - public static IntPtr Super(IntPtr obj, IntPtr klass) + internal static IntPtr Super(IntPtr obj, IntPtr klass) { return efl_super(obj, klass); } [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_super(IntPtr obj, IntPtr klass); - public delegate IntPtr efl_class_get_delegate(IntPtr obj); + internal delegate IntPtr efl_class_get_delegate(IntPtr obj); [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_class_get(IntPtr obj); /// Gets the native EO class pointer for the given object. @@ -230,13 +230,13 @@ public static class Globals /// The native pointer to the instance to get the native class /// from. /// The native class pointer or if no such class existis. - public static IntPtr GetClass(IntPtr obj) + internal static IntPtr GetClass(IntPtr obj) { return efl_class_get(obj); } [DllImport(efl.Libs.Eo)] internal static extern EflClassType efl_class_type_get(IntPtr klass); - public delegate IntPtr dlerror_delegate(); + internal delegate IntPtr dlerror_delegate(); [DllImport(efl.Libs.Evil)] internal static extern IntPtr dlerror(); [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_constructor(IntPtr obj); @@ -261,36 +261,36 @@ public static class Globals /// The native event description. /// The native payload of the event. /// false if one of the callbacks aborted the call. true otherwise. - public static bool CallEventCallback(IntPtr obj, IntPtr desc, IntPtr event_info) + internal static bool CallEventCallback(IntPtr obj, IntPtr desc, IntPtr event_info) { return efl_event_callback_call(obj, desc, event_info); } - public const int RTLD_NOW = 2; + internal const int RTLD_NOW = 2; - public delegate byte class_initializer(IntPtr klass); + internal delegate byte class_initializer(IntPtr klass); - public static T GetParamHelper(Nullable v) where T : struct + internal static T GetParamHelper(Nullable v) where T : struct { return v.Value; } - public static U GetParamHelper(U v) + internal static U GetParamHelper(U v) { return v; } - public static bool ParamHelperCheck(Nullable v) where T : struct + internal static bool ParamHelperCheck(Nullable v) where T : struct { return v.HasValue; } - public static bool ParamHelperCheck(U v) + internal static bool ParamHelperCheck(U v) { return v != null; } - public static IntPtr register_class(String class_name, IntPtr base_klass, System.Type type) + internal static IntPtr register_class(String class_name, IntPtr base_klass, System.Type type) { ClassDescription description; description.version = 2; // EO_VERSION @@ -329,7 +329,7 @@ public static class Globals return klass; } - public static List get_efl_interfaces(System.Type type) + internal static List get_efl_interfaces(System.Type type) { System.Type base_type = type.BaseType; @@ -369,7 +369,7 @@ public static class Globals return null; } - public static System.Collections.Generic.List + internal static System.Collections.Generic.List GetUserMethods(System.Type type) { var r = new System.Collections.Generic.List(); @@ -397,7 +397,7 @@ public static class Globals return r; } - public static byte class_initializer_call(IntPtr klass, System.Type type) + internal static byte class_initializer_call(IntPtr klass, System.Type type) { Eina.Log.Debug($"called with 0x{klass.ToInt64():x} {type}"); var derived = type.BaseType; @@ -446,7 +446,7 @@ public static class Globals return 1; } - public static IntPtr call_efl_class_new(IntPtr desc, IntPtr bk, List il = null) + internal static IntPtr call_efl_class_new(IntPtr desc, IntPtr bk, List il = null) { IntPtr nul = IntPtr.Zero; int iface_list_count = (il == null ? 0 : il.Count); @@ -505,12 +505,12 @@ public static class Globals } } - public static Efl.Eo.WrapperSupervisor WrapperSupervisorPtrToManaged(IntPtr wsPtr) + internal static Efl.Eo.WrapperSupervisor WrapperSupervisorPtrToManaged(IntPtr wsPtr) { return (Efl.Eo.WrapperSupervisor) GCHandle.FromIntPtr(wsPtr).Target; } - public static Efl.Eo.WrapperSupervisor GetWrapperSupervisor(IntPtr eo) + internal static Efl.Eo.WrapperSupervisor GetWrapperSupervisor(IntPtr eo) { var wsPtr = Efl.Eo.Globals.efl_mono_wrapper_supervisor_get(eo); if (wsPtr == IntPtr.Zero) @@ -521,13 +521,13 @@ public static class Globals return WrapperSupervisorPtrToManaged(wsPtr); } - public static void SetWrapperSupervisor(IntPtr eo, Efl.Eo.WrapperSupervisor ws) + internal static void SetWrapperSupervisor(IntPtr eo, Efl.Eo.WrapperSupervisor ws) { GCHandle gch = GCHandle.Alloc(ws); Efl.Eo.Globals.efl_mono_wrapper_supervisor_set(eo, GCHandle.ToIntPtr(gch)); } - public static void free_dict_values(Dictionary dict) + internal static void free_dict_values(Dictionary dict) { foreach (IntPtr ptr in dict.Values) { @@ -535,7 +535,7 @@ public static class Globals } } - public static void free_stringshare_values(Dictionary dict) + internal static void free_stringshare_values(Dictionary dict) { foreach (IntPtr ptr in dict.Values) { @@ -543,13 +543,13 @@ public static class Globals } } - public static void free_gchandle(IntPtr ptr) + internal static void free_gchandle(IntPtr ptr) { GCHandle handle = GCHandle.FromIntPtr(ptr); handle.Free(); } - public static System.Threading.Tasks.Task WrapAsync(Eina.Future future, CancellationToken token) + internal static System.Threading.Tasks.Task WrapAsync(Eina.Future future, CancellationToken token) { // Creates a task that will wait for SetResult for completion. // TaskCompletionSource is used to create tasks for 'external' Task sources. @@ -621,7 +621,7 @@ public static class Globals /// The Eo id to be wrapped. /// Whether we should increase the refcount of the Eo instance. /// The C# wrapper for this instance. - public static Efl.Eo.IWrapper CreateWrapperFor(System.IntPtr handle, bool shouldIncRef=true) + internal static Efl.Eo.IWrapper CreateWrapperFor(System.IntPtr handle, bool shouldIncRef=true) { if (handle == IntPtr.Zero) @@ -695,7 +695,7 @@ public static class Globals } private static Efl.FreeWrapperSupervisorCb FreeWrapperSupervisorCallbackDelegate = new Efl.FreeWrapperSupervisorCb(FreeWrapperSupervisorCallback); - public static void FreeWrapperSupervisorCallback(IntPtr eo) + internal static void FreeWrapperSupervisorCallback(IntPtr eo) { try { @@ -733,12 +733,12 @@ public static class Globals } } - public static void SetNativeDisposeCallbacks() + internal static void SetNativeDisposeCallbacks() { efl_mono_wrapper_supervisor_callbacks_set(FreeWrapperSupervisorCallbackDelegate); } - public static void ThreadSafeFreeCbExec(EinaFreeCb cbFreeCb, IntPtr cbData) + internal static void ThreadSafeFreeCbExec(EinaFreeCb cbFreeCb, IntPtr cbData) { EinaFreeCb cb = (IntPtr gcHandlePtr) => { cbFreeCb(cbData); @@ -848,9 +848,9 @@ public interface IWrapper } } -public static class ClassRegister +internal static class ClassRegister { - public static System.Type GetManagedType(IntPtr klass) + internal static System.Type GetManagedType(IntPtr klass) { System.Type t; if (Efl.Eo.ClassRegister.typeFromKlass.TryGetValue(klass, out t)) @@ -914,7 +914,7 @@ public static class ClassRegister return t; } - public static IntPtr GetKlass(System.Type objectType) + internal static IntPtr GetKlass(System.Type objectType) { IntPtr klass; if (klassFromType.TryGetValue(objectType, out klass)) @@ -941,7 +941,7 @@ public static class ClassRegister return RegisterKlass(baseKlass, objectType); } - public static IntPtr GetInheritKlassOrRegister(IntPtr baseKlass, System.Type objectType) + internal static IntPtr GetInheritKlassOrRegister(IntPtr baseKlass, System.Type objectType) { IntPtr klass; if (klassFromType.TryGetValue(objectType, out klass)) @@ -1011,16 +1011,16 @@ public static class ClassRegister return (IntPtr)(method.Invoke(null, null)); } - public static void AddToKlassTypeBiDictionary(IntPtr klassPtr, System.Type objectType) + internal static void AddToKlassTypeBiDictionary(IntPtr klassPtr, System.Type objectType) { klassFromType[objectType] = klassPtr; typeFromKlass[klassPtr] = objectType; } - public static readonly System.Collections.Concurrent.ConcurrentDictionary klassFromType + internal static readonly System.Collections.Concurrent.ConcurrentDictionary klassFromType = new System.Collections.Concurrent.ConcurrentDictionary(); - public static readonly System.Collections.Concurrent.ConcurrentDictionary typeFromKlass + internal static readonly System.Collections.Concurrent.ConcurrentDictionary typeFromKlass = new System.Collections.Concurrent.ConcurrentDictionary(); private static readonly object klassAllocLock = new object();