2 #pragma warning disable CS1591
4 using System.Runtime.InteropServices;
5 using System.Collections.Generic;
7 using System.Threading;
8 using System.ComponentModel;
9 /// <param name="parent">This object can be used to know when to cancel the future.</param>
10 /// <param name="child">You must reference this object for the duration of your use of it as the caller will not do that for you.</param>
11 [Efl.Eo.BindingEntity]
12 public delegate Eina.Future EflFilterModel(Efl.FilterModel parent, Efl.IModel child);
13 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]public delegate Eina.Future EflFilterModelInternal(IntPtr data, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.FilterModel parent, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.IModel child);
14 internal class EflFilterModelWrapper : IDisposable
17 private EflFilterModelInternal _cb;
18 private IntPtr _cb_data;
19 private EinaFreeCb _cb_free_cb;
21 internal EflFilterModelWrapper (EflFilterModelInternal _cb, IntPtr _cb_data, EinaFreeCb _cb_free_cb)
24 this._cb_data = _cb_data;
25 this._cb_free_cb = _cb_free_cb;
28 ~EflFilterModelWrapper()
33 protected virtual void Dispose(bool disposing)
35 if (this._cb_free_cb != null)
39 this._cb_free_cb(this._cb_data);
43 Efl.Eo.Globals.ThreadSafeFreeCbExec(this._cb_free_cb, this._cb_data);
45 this._cb_free_cb = null;
46 this._cb_data = IntPtr.Zero;
54 GC.SuppressFinalize(this);
57 internal Eina.Future ManagedCb(Efl.FilterModel parent,Efl.IModel child)
59 var _ret_var = _cb(_cb_data, parent, child);
60 Eina.Error.RaiseIfUnhandledException();
64 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] internal static Eina.Future Cb(IntPtr cb_data, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.FilterModel parent, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.IModel child)
66 GCHandle handle = GCHandle.FromIntPtr(cb_data);
67 EflFilterModel cb = (EflFilterModel)handle.Target;
68 Eina.Future _ret_var = default( Eina.Future);
70 _ret_var = cb(parent, child);
71 } catch (Exception e) {
72 Eina.Log.Warning($"Callback error: {e.ToString()}");
73 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
82 /// <summary>Efl model designed to filter its children.</summary>
83 /// <remarks>This is a <b>BETA</b> class. It can be modified or removed in the future. Do not use it for product development.</remarks>
84 [Efl.FilterModel.NativeMethods]
85 [Efl.Eo.BindingEntity]
86 public class FilterModel : Efl.CompositeModel
88 /// <summary>Pointer to the native class description.</summary>
89 public override System.IntPtr NativeClass
93 if (((object)this).GetType() == typeof(FilterModel))
95 return GetEflClassStatic();
99 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
104 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
105 efl_filter_model_class_get();
106 /// <summary>Initializes a new instance of the <see cref="FilterModel"/> class.</summary>
107 /// <param name="parent">Parent instance.</param>
108 /// <param name="filterSet">Set a filter function that will catch children from the composited model. See <see cref="Efl.FilterModel.SetFilter" /></param>
109 /// <param name="model">Model that is/will be See <see cref="Efl.Ui.IView.SetModel" /></param>
110 /// <param name="index">Position of this object in the parent model. See <see cref="Efl.CompositeModel.SetIndex" /></param>
111 public FilterModel(Efl.Object parent
112 , EflFilterModel filterSet, Efl.IModel model, uint? index = null) : base(efl_filter_model_class_get(), parent)
114 if (Efl.Eo.Globals.ParamHelperCheck(filterSet))
116 SetFilter(Efl.Eo.Globals.GetParamHelper(filterSet));
119 if (Efl.Eo.Globals.ParamHelperCheck(model))
121 SetModel(Efl.Eo.Globals.GetParamHelper(model));
124 if (Efl.Eo.Globals.ParamHelperCheck(index))
126 SetIndex(Efl.Eo.Globals.GetParamHelper(index));
129 FinishInstantiation();
132 /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code.
133 /// Do not call this constructor directly.</summary>
134 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
135 protected FilterModel(ConstructingHandle ch) : base(ch)
139 /// <summary>Initializes a new instance of the <see cref="FilterModel"/> class.
140 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
141 /// <param name="wh">The native pointer to be wrapped.</param>
142 protected FilterModel(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
146 /// <summary>Initializes a new instance of the <see cref="FilterModel"/> class.
147 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
148 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
149 /// <param name="parent">The Efl.Object parent of this instance.</param>
150 protected FilterModel(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)
154 /// <summary>Set a filter function that will catch children from the composited model.</summary>
155 /// <param name="filter">Filter callback</param>
156 virtual public void SetFilter(EflFilterModel filter) {
157 GCHandle filter_handle = GCHandle.Alloc(filter);
158 Efl.FilterModel.NativeMethods.efl_filter_model_filter_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),GCHandle.ToIntPtr(filter_handle), EflFilterModelWrapper.Cb, Efl.Eo.Globals.free_gchandle);
159 Eina.Error.RaiseIfUnhandledException();
161 private static IntPtr GetEflClassStatic()
163 return Efl.FilterModel.efl_filter_model_class_get();
165 /// <summary>Wrapper for native methods and virtual method delegates.
166 /// For internal use by generated code only.</summary>
167 public new class NativeMethods : Efl.CompositeModel.NativeMethods
169 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Ecore);
170 /// <summary>Gets the list of Eo operations to override.</summary>
171 /// <returns>The list of Eo operations to be overload.</returns>
172 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
174 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
175 var methods = Efl.Eo.Globals.GetUserMethods(type);
177 if (efl_filter_model_filter_set_static_delegate == null)
179 efl_filter_model_filter_set_static_delegate = new efl_filter_model_filter_set_delegate(filter_set);
182 if (methods.FirstOrDefault(m => m.Name == "SetFilter") != null)
184 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_filter_model_filter_set"), func = Marshal.GetFunctionPointerForDelegate(efl_filter_model_filter_set_static_delegate) });
187 descs.AddRange(base.GetEoOps(type));
190 /// <summary>Returns the Eo class for the native methods of this class.</summary>
191 /// <returns>The native class pointer.</returns>
192 public override IntPtr GetEflClass()
194 return Efl.FilterModel.efl_filter_model_class_get();
197 #pragma warning disable CA1707, CS1591, SA1300, SA1600
200 private delegate void efl_filter_model_filter_set_delegate(System.IntPtr obj, System.IntPtr pd, IntPtr filter_data, EflFilterModelInternal filter, EinaFreeCb filter_free_cb);
203 public delegate void efl_filter_model_filter_set_api_delegate(System.IntPtr obj, IntPtr filter_data, EflFilterModelInternal filter, EinaFreeCb filter_free_cb);
205 public static Efl.Eo.FunctionWrapper<efl_filter_model_filter_set_api_delegate> efl_filter_model_filter_set_ptr = new Efl.Eo.FunctionWrapper<efl_filter_model_filter_set_api_delegate>(Module, "efl_filter_model_filter_set");
207 private static void filter_set(System.IntPtr obj, System.IntPtr pd, IntPtr filter_data, EflFilterModelInternal filter, EinaFreeCb filter_free_cb)
209 Eina.Log.Debug("function efl_filter_model_filter_set was called");
210 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
213 EflFilterModelWrapper filter_wrapper = new EflFilterModelWrapper(filter, filter_data, filter_free_cb);
217 ((FilterModel)ws.Target).SetFilter(filter_wrapper.ManagedCb);
221 Eina.Log.Warning($"Callback error: {e.ToString()}");
222 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
229 efl_filter_model_filter_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), filter_data, filter, filter_free_cb);
233 private static efl_filter_model_filter_set_delegate efl_filter_model_filter_set_static_delegate;
235 #pragma warning restore CA1707, CS1591, SA1300, SA1600
242 #pragma warning disable CS1591
243 public static class EflFilterModel_ExtensionMethods {
245 #pragma warning restore CS1591