1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>An <see cref="Efl.LoopConsumer"/> is a class which requires one of the parents to provide an <see cref="Efl.Loop"/> interface when performing <see cref="Efl.Object.FindProvider"/>. It will enforce this by only allowing parents which provide such an interface or <c>NULL</c>.
11 /// (Since EFL 1.22)</summary>
12 [Efl.LoopConsumer.NativeMethods]
13 [Efl.Eo.BindingEntity]
14 public abstract class LoopConsumer : Efl.Object
16 ///<summary>Pointer to the native class description.</summary>
17 public override System.IntPtr NativeClass
21 if (((object)this).GetType() == typeof(LoopConsumer))
23 return GetEflClassStatic();
27 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
32 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
33 efl_loop_consumer_class_get();
34 /// <summary>Initializes a new instance of the <see cref="LoopConsumer"/> class.</summary>
35 /// <param name="parent">Parent instance.</param>
36 public LoopConsumer(Efl.Object parent= null
37 ) : base(efl_loop_consumer_class_get(), parent)
39 FinishInstantiation();
42 /// <summary>Constructor to be used when objects are expected to be constructed from native code.</summary>
43 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
44 protected LoopConsumer(ConstructingHandle ch) : base(ch)
48 /// <summary>Initializes a new instance of the <see cref="LoopConsumer"/> class.
49 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
50 /// <param name="wh">The native pointer to be wrapped.</param>
51 protected LoopConsumer(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
55 [Efl.Eo.PrivateNativeClass]
56 private class LoopConsumerRealized : LoopConsumer
58 private LoopConsumerRealized(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
62 /// <summary>Initializes a new instance of the <see cref="LoopConsumer"/> class.
63 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
64 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
65 /// <param name="parent">The Efl.Object parent of this instance.</param>
66 protected LoopConsumer(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)
70 /// <summary>Gets a handle to the loop.
71 /// (Since EFL 1.22)</summary>
72 /// <returns>Efl loop</returns>
73 virtual public Efl.Loop GetLoop() {
74 var _ret_var = Efl.LoopConsumer.NativeMethods.efl_loop_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
75 Eina.Error.RaiseIfUnhandledException();
78 /// <summary>Creates a new future that is already resolved to a value.
79 /// This function creates a new future with an already known value, that will be resolved and dispatched by the loop scheduler as usual.
81 /// This is a helper that behaves the same as eina_future_resolved.
82 /// (Since EFL 1.22)</summary>
83 /// <param name="result">The value to be delivered.
84 /// Note that the value contents must survive this function scope, that is, do not use stack allocated blobs, arrays, structures or types that keep references to memory you give. Values will be automatically cleaned up using @ref eina_value_flush() once they are unused (no more future or futures returned a new value)</param>
85 /// <returns>The future or <c>NULL</c> on error.</returns>
86 virtual public Eina.Future FutureResolved(Eina.Value result) {
87 var _in_result = result.GetNative();
88 var _ret_var = Efl.LoopConsumer.NativeMethods.efl_loop_future_resolved_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),_in_result);
89 Eina.Error.RaiseIfUnhandledException();
92 /// <summary>Creates a new future that is already rejected to a specified error using the <see cref="Efl.LoopConsumer.GetLoop"/>.
93 /// This function creates a new future with an already known error, that will be resolved and dispatched by the loop scheduler as usual.
95 /// This is a helper that behaves the same as @ref eina_future_rejected.
96 /// (Since EFL 1.22)</summary>
97 /// <param name="error">An Eina_Error value</param>
98 /// <returns>The future or <c>NULL</c> on error.</returns>
99 virtual public Eina.Future FutureRejected(Eina.Error error) {
100 var _ret_var = Efl.LoopConsumer.NativeMethods.efl_loop_future_rejected_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),error);
101 Eina.Error.RaiseIfUnhandledException();
104 /// <summary>Create a new promise with the scheduler coming from the loop provided by this object.
105 /// Note: You should not use eina_promise_data_set as this function rely on controlling the promise data.
106 /// (Since EFL 1.22)</summary>
107 /// <returns>The new promise.</returns>
108 virtual public Eina.Promise NewPromise() {
109 var _ret_var = Efl.LoopConsumer.NativeMethods.efl_loop_promise_new_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
110 Eina.Error.RaiseIfUnhandledException();
113 /// <summary>Async wrapper for <see cref="FutureResolved" />.</summary>
114 /// <param name="result">The value to be delivered.
115 /// Note that the value contents must survive this function scope, that is, do not use stack allocated blobs, arrays, structures or types that keep references to memory you give. Values will be automatically cleaned up using @ref eina_value_flush() once they are unused (no more future or futures returned a new value)</param>
116 /// <param name="token">Token to notify the async operation of external request to cancel.</param>
117 /// <returns>An async task wrapping the result of the operation.</returns>
118 public System.Threading.Tasks.Task<Eina.Value> FutureResolvedAsync(Eina.Value result, System.Threading.CancellationToken token = default(System.Threading.CancellationToken))
120 Eina.Future future = FutureResolved( result);
121 return Efl.Eo.Globals.WrapAsync(future, token);
124 /// <summary>Async wrapper for <see cref="FutureRejected" />.</summary>
125 /// <param name="error">An Eina_Error value</param>
126 /// <param name="token">Token to notify the async operation of external request to cancel.</param>
127 /// <returns>An async task wrapping the result of the operation.</returns>
128 public System.Threading.Tasks.Task<Eina.Value> FutureRejectedAsync(Eina.Error error, System.Threading.CancellationToken token = default(System.Threading.CancellationToken))
130 Eina.Future future = FutureRejected( error);
131 return Efl.Eo.Globals.WrapAsync(future, token);
134 /// <summary>The loop to which this object belongs to.
135 /// (Since EFL 1.22)</summary>
136 /// <value>Efl loop</value>
137 public Efl.Loop Loop {
138 get { return GetLoop(); }
140 private static IntPtr GetEflClassStatic()
142 return Efl.LoopConsumer.efl_loop_consumer_class_get();
144 /// <summary>Wrapper for native methods and virtual method delegates.
145 /// For internal use by generated code only.</summary>
146 public new class NativeMethods : Efl.Object.NativeMethods
148 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Ecore);
149 /// <summary>Gets the list of Eo operations to override.</summary>
150 /// <returns>The list of Eo operations to be overload.</returns>
151 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
153 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
154 var methods = Efl.Eo.Globals.GetUserMethods(type);
156 if (efl_loop_get_static_delegate == null)
158 efl_loop_get_static_delegate = new efl_loop_get_delegate(loop_get);
161 if (methods.FirstOrDefault(m => m.Name == "GetLoop") != null)
163 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_get"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_get_static_delegate) });
166 if (efl_loop_future_resolved_static_delegate == null)
168 efl_loop_future_resolved_static_delegate = new efl_loop_future_resolved_delegate(future_resolved);
171 if (methods.FirstOrDefault(m => m.Name == "FutureResolved") != null)
173 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_future_resolved"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_future_resolved_static_delegate) });
176 if (efl_loop_future_rejected_static_delegate == null)
178 efl_loop_future_rejected_static_delegate = new efl_loop_future_rejected_delegate(future_rejected);
181 if (methods.FirstOrDefault(m => m.Name == "FutureRejected") != null)
183 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_future_rejected"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_future_rejected_static_delegate) });
186 if (efl_loop_promise_new_static_delegate == null)
188 efl_loop_promise_new_static_delegate = new efl_loop_promise_new_delegate(promise_new);
191 if (methods.FirstOrDefault(m => m.Name == "NewPromise") != null)
193 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_promise_new"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_promise_new_static_delegate) });
196 descs.AddRange(base.GetEoOps(type));
199 /// <summary>Returns the Eo class for the native methods of this class.</summary>
200 /// <returns>The native class pointer.</returns>
201 public override IntPtr GetEflClass()
203 return Efl.LoopConsumer.efl_loop_consumer_class_get();
206 #pragma warning disable CA1707, CS1591, SA1300, SA1600
208 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
209 private delegate Efl.Loop efl_loop_get_delegate(System.IntPtr obj, System.IntPtr pd);
211 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
212 public delegate Efl.Loop efl_loop_get_api_delegate(System.IntPtr obj);
214 public static Efl.Eo.FunctionWrapper<efl_loop_get_api_delegate> efl_loop_get_ptr = new Efl.Eo.FunctionWrapper<efl_loop_get_api_delegate>(Module, "efl_loop_get");
216 private static Efl.Loop loop_get(System.IntPtr obj, System.IntPtr pd)
218 Eina.Log.Debug("function efl_loop_get was called");
219 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
222 Efl.Loop _ret_var = default(Efl.Loop);
225 _ret_var = ((LoopConsumer)ws.Target).GetLoop();
229 Eina.Log.Warning($"Callback error: {e.ToString()}");
230 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
238 return efl_loop_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
242 private static efl_loop_get_delegate efl_loop_get_static_delegate;
244 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]
245 private delegate Eina.Future efl_loop_future_resolved_delegate(System.IntPtr obj, System.IntPtr pd, Eina.ValueNative result);
247 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]
248 public delegate Eina.Future efl_loop_future_resolved_api_delegate(System.IntPtr obj, Eina.ValueNative result);
250 public static Efl.Eo.FunctionWrapper<efl_loop_future_resolved_api_delegate> efl_loop_future_resolved_ptr = new Efl.Eo.FunctionWrapper<efl_loop_future_resolved_api_delegate>(Module, "efl_loop_future_resolved");
252 private static Eina.Future future_resolved(System.IntPtr obj, System.IntPtr pd, Eina.ValueNative result)
254 Eina.Log.Debug("function efl_loop_future_resolved was called");
255 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
258 var _in_result = new Eina.Value(result);
259 Eina.Future _ret_var = default( Eina.Future);
262 _ret_var = ((LoopConsumer)ws.Target).FutureResolved(_in_result);
266 Eina.Log.Warning($"Callback error: {e.ToString()}");
267 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
275 return efl_loop_future_resolved_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), result);
279 private static efl_loop_future_resolved_delegate efl_loop_future_resolved_static_delegate;
281 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]
282 private delegate Eina.Future efl_loop_future_rejected_delegate(System.IntPtr obj, System.IntPtr pd, Eina.Error error);
284 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]
285 public delegate Eina.Future efl_loop_future_rejected_api_delegate(System.IntPtr obj, Eina.Error error);
287 public static Efl.Eo.FunctionWrapper<efl_loop_future_rejected_api_delegate> efl_loop_future_rejected_ptr = new Efl.Eo.FunctionWrapper<efl_loop_future_rejected_api_delegate>(Module, "efl_loop_future_rejected");
289 private static Eina.Future future_rejected(System.IntPtr obj, System.IntPtr pd, Eina.Error error)
291 Eina.Log.Debug("function efl_loop_future_rejected was called");
292 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
295 Eina.Future _ret_var = default( Eina.Future);
298 _ret_var = ((LoopConsumer)ws.Target).FutureRejected(error);
302 Eina.Log.Warning($"Callback error: {e.ToString()}");
303 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
311 return efl_loop_future_rejected_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), error);
315 private static efl_loop_future_rejected_delegate efl_loop_future_rejected_static_delegate;
318 private delegate Eina.Promise efl_loop_promise_new_delegate(System.IntPtr obj, System.IntPtr pd);
321 public delegate Eina.Promise efl_loop_promise_new_api_delegate(System.IntPtr obj);
323 public static Efl.Eo.FunctionWrapper<efl_loop_promise_new_api_delegate> efl_loop_promise_new_ptr = new Efl.Eo.FunctionWrapper<efl_loop_promise_new_api_delegate>(Module, "efl_loop_promise_new");
325 private static Eina.Promise promise_new(System.IntPtr obj, System.IntPtr pd)
327 Eina.Log.Debug("function efl_loop_promise_new was called");
328 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
331 Eina.Promise _ret_var = default(Eina.Promise);
334 _ret_var = ((LoopConsumer)ws.Target).NewPromise();
338 Eina.Log.Warning($"Callback error: {e.ToString()}");
339 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
347 return efl_loop_promise_new_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
351 private static efl_loop_promise_new_delegate efl_loop_promise_new_static_delegate;
353 #pragma warning restore CA1707, CS1591, SA1300, SA1600