#define EFL_BETA #pragma warning disable CS1591 using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Linq; using System.Threading; using System.ComponentModel; namespace Efl { /// Common interface for objects (containers) with multiple contents (sub-objects) which can be added and removed at runtime. [Efl.IPackConcrete.NativeMethods] [Efl.Eo.BindingEntity] public interface IPack : Efl.IContainer , Efl.Eo.IWrapper, IDisposable { /// Removes all packed sub-objects and unreferences them. /// true on success, false otherwise. bool ClearPack(); /// Removes all packed sub-objects without unreferencing them. /// Use with caution. /// true on success, false otherwise. bool UnpackAll(); /// Removes an existing sub-object from the container without deleting it. /// The sub-object to unpack. /// false if subobj wasn't in the container or couldn't be removed. bool Unpack(Efl.Gfx.IEntity subobj); /// Adds a sub-object to this container. /// Depending on the container this will either fill in the default spot, replacing any already existing element or append to the end of the container if there is no default part. /// /// When this container is deleted, it will request deletion of the given subobj. Use to remove subobj from this container without deleting it. /// The object to pack. /// false if subobj could not be packed. bool Pack(Efl.Gfx.IEntity subobj); } /// Common interface for objects (containers) with multiple contents (sub-objects) which can be added and removed at runtime. sealed public class IPackConcrete : Efl.Eo.EoWrapper , IPack , Efl.IContainer { /// Pointer to the native class description. public override System.IntPtr NativeClass { get { if (((object)this).GetType() == typeof(IPackConcrete)) { return GetEflClassStatic(); } else { return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()]; } } } /// Subclasses should override this constructor if they are expected to be instantiated from native code. /// Do not call this constructor directly. /// Tag struct storing the native handle of the object being constructed. private IPackConcrete(ConstructingHandle ch) : base(ch) { } [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr efl_pack_interface_get(); /// Initializes a new instance of the class. /// Internal usage: This is used when interacting with C code and should not be used directly. /// The native pointer to be wrapped. private IPackConcrete(Efl.Eo.Globals.WrappingHandle wh) : base(wh) { } /// Sent after a new sub-object was added. /// (Since EFL 1.22) /// public event EventHandler ContentAddedEvt { add { lock (eflBindingEventLock) { Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) => { var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target; if (obj != null) { Efl.IContainerContentAddedEvt_Args args = new Efl.IContainerContentAddedEvt_Args(); args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete); try { value?.Invoke(obj, args); } catch (Exception e) { Eina.Log.Error(e.ToString()); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } } }; string key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED"; AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value); } } remove { lock (eflBindingEventLock) { string key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED"; RemoveNativeEventHandler(efl.Libs.Efl, key, value); } } } /// Method to raise event ContentAddedEvt. public void OnContentAddedEvt(Efl.IContainerContentAddedEvt_Args e) { var key = "_EFL_CONTAINER_EVENT_CONTENT_ADDED"; IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key); if (desc == IntPtr.Zero) { Eina.Log.Error($"Failed to get native event {key}"); return; } IntPtr info = e.arg.NativeHandle; Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info); } /// Sent after a sub-object was removed, before unref. /// (Since EFL 1.22) /// public event EventHandler ContentRemovedEvt { add { lock (eflBindingEventLock) { Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) => { var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target; if (obj != null) { Efl.IContainerContentRemovedEvt_Args args = new Efl.IContainerContentRemovedEvt_Args(); args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.Gfx.IEntityConcrete); try { value?.Invoke(obj, args); } catch (Exception e) { Eina.Log.Error(e.ToString()); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } } }; string key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED"; AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value); } } remove { lock (eflBindingEventLock) { string key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED"; RemoveNativeEventHandler(efl.Libs.Efl, key, value); } } } /// Method to raise event ContentRemovedEvt. public void OnContentRemovedEvt(Efl.IContainerContentRemovedEvt_Args e) { var key = "_EFL_CONTAINER_EVENT_CONTENT_REMOVED"; IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key); if (desc == IntPtr.Zero) { Eina.Log.Error($"Failed to get native event {key}"); return; } IntPtr info = e.arg.NativeHandle; Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info); } /// Removes all packed sub-objects and unreferences them. /// true on success, false otherwise. public bool ClearPack() { var _ret_var = Efl.IPackConcrete.NativeMethods.efl_pack_clear_ptr.Value.Delegate(this.NativeHandle); Eina.Error.RaiseIfUnhandledException(); return _ret_var; } /// Removes all packed sub-objects without unreferencing them. /// Use with caution. /// true on success, false otherwise. public bool UnpackAll() { var _ret_var = Efl.IPackConcrete.NativeMethods.efl_pack_unpack_all_ptr.Value.Delegate(this.NativeHandle); Eina.Error.RaiseIfUnhandledException(); return _ret_var; } /// Removes an existing sub-object from the container without deleting it. /// The sub-object to unpack. /// false if subobj wasn't in the container or couldn't be removed. public bool Unpack(Efl.Gfx.IEntity subobj) { var _ret_var = Efl.IPackConcrete.NativeMethods.efl_pack_unpack_ptr.Value.Delegate(this.NativeHandle,subobj); Eina.Error.RaiseIfUnhandledException(); return _ret_var; } /// Adds a sub-object to this container. /// Depending on the container this will either fill in the default spot, replacing any already existing element or append to the end of the container if there is no default part. /// /// When this container is deleted, it will request deletion of the given subobj. Use to remove subobj from this container without deleting it. /// The object to pack. /// false if subobj could not be packed. public bool Pack(Efl.Gfx.IEntity subobj) { var _ret_var = Efl.IPackConcrete.NativeMethods.efl_pack_ptr.Value.Delegate(this.NativeHandle,subobj); Eina.Error.RaiseIfUnhandledException(); return _ret_var; } /// Begin iterating over this object's contents. /// (Since EFL 1.22) /// Iterator on object's content. public Eina.Iterator ContentIterate() { var _ret_var = Efl.IContainerConcrete.NativeMethods.efl_content_iterate_ptr.Value.Delegate(this.NativeHandle); Eina.Error.RaiseIfUnhandledException(); return new Eina.Iterator(_ret_var, true); } /// Returns the number of contained sub-objects. /// (Since EFL 1.22) /// Number of sub-objects. public int ContentCount() { var _ret_var = Efl.IContainerConcrete.NativeMethods.efl_content_count_ptr.Value.Delegate(this.NativeHandle); Eina.Error.RaiseIfUnhandledException(); return _ret_var; } private static IntPtr GetEflClassStatic() { return Efl.IPackConcrete.efl_pack_interface_get(); } /// Wrapper for native methods and virtual method delegates. /// For internal use by generated code only. public new class NativeMethods : Efl.Eo.EoWrapper.NativeMethods { private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl); /// Gets the list of Eo operations to override. /// The list of Eo operations to be overload. public override System.Collections.Generic.List GetEoOps(System.Type type) { var descs = new System.Collections.Generic.List(); var methods = Efl.Eo.Globals.GetUserMethods(type); if (efl_pack_clear_static_delegate == null) { efl_pack_clear_static_delegate = new efl_pack_clear_delegate(pack_clear); } if (methods.FirstOrDefault(m => m.Name == "ClearPack") != null) { descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_pack_clear"), func = Marshal.GetFunctionPointerForDelegate(efl_pack_clear_static_delegate) }); } if (efl_pack_unpack_all_static_delegate == null) { efl_pack_unpack_all_static_delegate = new efl_pack_unpack_all_delegate(unpack_all); } if (methods.FirstOrDefault(m => m.Name == "UnpackAll") != null) { descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_pack_unpack_all"), func = Marshal.GetFunctionPointerForDelegate(efl_pack_unpack_all_static_delegate) }); } if (efl_pack_unpack_static_delegate == null) { efl_pack_unpack_static_delegate = new efl_pack_unpack_delegate(unpack); } if (methods.FirstOrDefault(m => m.Name == "Unpack") != null) { descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_pack_unpack"), func = Marshal.GetFunctionPointerForDelegate(efl_pack_unpack_static_delegate) }); } if (efl_pack_static_delegate == null) { efl_pack_static_delegate = new efl_pack_delegate(pack); } if (methods.FirstOrDefault(m => m.Name == "Pack") != null) { descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_pack"), func = Marshal.GetFunctionPointerForDelegate(efl_pack_static_delegate) }); } if (efl_content_iterate_static_delegate == null) { efl_content_iterate_static_delegate = new efl_content_iterate_delegate(content_iterate); } if (methods.FirstOrDefault(m => m.Name == "ContentIterate") != null) { descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_iterate"), func = Marshal.GetFunctionPointerForDelegate(efl_content_iterate_static_delegate) }); } if (efl_content_count_static_delegate == null) { efl_content_count_static_delegate = new efl_content_count_delegate(content_count); } if (methods.FirstOrDefault(m => m.Name == "ContentCount") != null) { descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_content_count"), func = Marshal.GetFunctionPointerForDelegate(efl_content_count_static_delegate) }); } return descs; } /// Returns the Eo class for the native methods of this class. /// The native class pointer. public override IntPtr GetEflClass() { return Efl.IPackConcrete.efl_pack_interface_get(); } #pragma warning disable CA1707, CS1591, SA1300, SA1600 [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_pack_clear_delegate(System.IntPtr obj, System.IntPtr pd); [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_pack_clear_api_delegate(System.IntPtr obj); public static Efl.Eo.FunctionWrapper efl_pack_clear_ptr = new Efl.Eo.FunctionWrapper(Module, "efl_pack_clear"); private static bool pack_clear(System.IntPtr obj, System.IntPtr pd) { Eina.Log.Debug("function efl_pack_clear was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { bool _ret_var = default(bool); try { _ret_var = ((IPack)ws.Target).ClearPack(); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } return _ret_var; } else { return efl_pack_clear_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))); } } private static efl_pack_clear_delegate efl_pack_clear_static_delegate; [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_pack_unpack_all_delegate(System.IntPtr obj, System.IntPtr pd); [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_pack_unpack_all_api_delegate(System.IntPtr obj); public static Efl.Eo.FunctionWrapper efl_pack_unpack_all_ptr = new Efl.Eo.FunctionWrapper(Module, "efl_pack_unpack_all"); private static bool unpack_all(System.IntPtr obj, System.IntPtr pd) { Eina.Log.Debug("function efl_pack_unpack_all was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { bool _ret_var = default(bool); try { _ret_var = ((IPack)ws.Target).UnpackAll(); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } return _ret_var; } else { return efl_pack_unpack_all_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))); } } private static efl_pack_unpack_all_delegate efl_pack_unpack_all_static_delegate; [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_pack_unpack_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo))] Efl.Gfx.IEntity subobj); [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_pack_unpack_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo))] Efl.Gfx.IEntity subobj); public static Efl.Eo.FunctionWrapper efl_pack_unpack_ptr = new Efl.Eo.FunctionWrapper(Module, "efl_pack_unpack"); private static bool unpack(System.IntPtr obj, System.IntPtr pd, Efl.Gfx.IEntity subobj) { Eina.Log.Debug("function efl_pack_unpack was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { bool _ret_var = default(bool); try { _ret_var = ((IPack)ws.Target).Unpack(subobj); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } return _ret_var; } else { return efl_pack_unpack_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), subobj); } } private static efl_pack_unpack_delegate efl_pack_unpack_static_delegate; [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_pack_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo))] Efl.Gfx.IEntity subobj); [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_pack_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo))] Efl.Gfx.IEntity subobj); public static Efl.Eo.FunctionWrapper efl_pack_ptr = new Efl.Eo.FunctionWrapper(Module, "efl_pack"); private static bool pack(System.IntPtr obj, System.IntPtr pd, Efl.Gfx.IEntity subobj) { Eina.Log.Debug("function efl_pack was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { bool _ret_var = default(bool); try { _ret_var = ((IPack)ws.Target).Pack(subobj); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } return _ret_var; } else { return efl_pack_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), subobj); } } private static efl_pack_delegate efl_pack_static_delegate; private delegate System.IntPtr efl_content_iterate_delegate(System.IntPtr obj, System.IntPtr pd); public delegate System.IntPtr efl_content_iterate_api_delegate(System.IntPtr obj); public static Efl.Eo.FunctionWrapper efl_content_iterate_ptr = new Efl.Eo.FunctionWrapper(Module, "efl_content_iterate"); private static System.IntPtr content_iterate(System.IntPtr obj, System.IntPtr pd) { Eina.Log.Debug("function efl_content_iterate was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { Eina.Iterator _ret_var = default(Eina.Iterator); try { _ret_var = ((IPack)ws.Target).ContentIterate(); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } _ret_var.Own = false; return _ret_var.Handle; } else { return efl_content_iterate_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))); } } private static efl_content_iterate_delegate efl_content_iterate_static_delegate; private delegate int efl_content_count_delegate(System.IntPtr obj, System.IntPtr pd); public delegate int efl_content_count_api_delegate(System.IntPtr obj); public static Efl.Eo.FunctionWrapper efl_content_count_ptr = new Efl.Eo.FunctionWrapper(Module, "efl_content_count"); private static int content_count(System.IntPtr obj, System.IntPtr pd) { Eina.Log.Debug("function efl_content_count was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { int _ret_var = default(int); try { _ret_var = ((IPack)ws.Target).ContentCount(); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } return _ret_var; } else { return efl_content_count_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))); } } private static efl_content_count_delegate efl_content_count_static_delegate; #pragma warning restore CA1707, CS1591, SA1300, SA1600 } } } #if EFL_BETA #pragma warning disable CS1591 public static class EflIPackConcrete_ExtensionMethods { } #pragma warning restore CS1591 #endif