1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 /// <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>.</summary>
9 [LoopConsumerNativeInherit]
10 public class LoopConsumer : Efl.Object, Efl.Eo.IWrapper
12 public new static System.IntPtr klass = System.IntPtr.Zero;
13 public new static Efl.LoopConsumerNativeInherit nativeInherit = new Efl.LoopConsumerNativeInherit();
14 ///<summary>Pointer to the native class description.</summary>
15 public override System.IntPtr NativeClass {
17 if (((object)this).GetType() == typeof (LoopConsumer))
18 return Efl.LoopConsumerNativeInherit.GetEflClassStatic();
20 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
23 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
24 efl_loop_consumer_class_get();
25 ///<summary>Creates a new instance.</summary>
26 ///<param name="parent">Parent instance.</param>
27 public LoopConsumer(Efl.Object parent= null
29 base(efl_loop_consumer_class_get(), typeof(LoopConsumer), parent)
31 FinishInstantiation();
33 ///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
34 public LoopConsumer(System.IntPtr raw) : base(raw)
36 register_event_proxies();
38 ///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
39 protected LoopConsumer(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}
40 ///<summary>Casts obj into an instance of this type.</summary>
41 public new static LoopConsumer static_cast(Efl.Object obj)
44 throw new System.ArgumentNullException("obj");
45 return new LoopConsumer(obj.NativeHandle);
47 ///<summary>Verifies if the given object is equal to this one.</summary>
48 public override bool Equals(object obj)
50 var other = obj as Efl.Object;
53 return this.NativeHandle == other.NativeHandle;
55 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
56 public override int GetHashCode()
58 return this.NativeHandle.ToInt32();
60 ///<summary>Turns the native pointer into a string representation.</summary>
61 public override String ToString()
63 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
65 protected override void register_event_proxies()
67 base.register_event_proxies();
69 /// <summary>Gets a handle to the loop.</summary>
70 /// <returns>Efl loop</returns>
71 virtual public Efl.Loop GetLoop() {
72 var _ret_var = Efl.LoopConsumerNativeInherit.efl_loop_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
73 Eina.Error.RaiseIfUnhandledException();
76 /// <summary>Creates a new future that is already resolved to a value.
77 /// This function creates a new future with an already known value, that will be resolved and dispatched by the loop scheduler as usual.
79 /// This is a helper that behaves the same as eina_future_resolved.</summary>
80 /// <param name="result">The value to be delivered.
81 /// 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>
82 /// <returns>The future or <c>NULL</c> on error.</returns>
83 virtual public Eina.Future FutureResolved( Eina.Value result) {
84 var _in_result = result.GetNative();
85 var _ret_var = Efl.LoopConsumerNativeInherit.efl_loop_future_resolved_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), _in_result);
86 Eina.Error.RaiseIfUnhandledException();
89 /// <summary>Creates a new future that is already rejected to a specified error using the <see cref="Efl.LoopConsumer.GetLoop"/>.
90 /// This function creates a new future with an already known error, that will be resolved and dispatched by the loop scheduler as usual.
92 /// This is a helper that behaves the same as @ref eina_future_rejected.</summary>
93 /// <param name="error">An Eina_Error value</param>
94 /// <returns>The future or <c>NULL</c> on error.</returns>
95 virtual public Eina.Future FutureRejected( Eina.Error error) {
96 var _ret_var = Efl.LoopConsumerNativeInherit.efl_loop_future_rejected_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), error);
97 Eina.Error.RaiseIfUnhandledException();
100 /// <summary>Create a new promise with the scheduler coming from the loop provided by this object.
101 /// Note: You should not use eina_promise_data_set as this function rely on controlling the promise data.</summary>
102 /// <returns>The new promise.</returns>
103 virtual public Eina.Promise NewPromise() {
104 var _ret_var = Efl.LoopConsumerNativeInherit.efl_loop_promise_new_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
105 Eina.Error.RaiseIfUnhandledException();
108 public System.Threading.Tasks.Task<Eina.Value> FutureResolvedAsync( Eina.Value result, System.Threading.CancellationToken token=default(System.Threading.CancellationToken))
110 Eina.Future future = FutureResolved( result);
111 return Efl.Eo.Globals.WrapAsync(future, token);
113 public System.Threading.Tasks.Task<Eina.Value> FutureRejectedAsync( Eina.Error error, System.Threading.CancellationToken token=default(System.Threading.CancellationToken))
115 Eina.Future future = FutureRejected( error);
116 return Efl.Eo.Globals.WrapAsync(future, token);
118 /// <summary>The loop to which this object belongs to.</summary>
119 /// <value>Efl loop</value>
120 public Efl.Loop Loop {
121 get { return GetLoop(); }
123 private static new IntPtr GetEflClassStatic()
125 return Efl.LoopConsumer.efl_loop_consumer_class_get();
128 public class LoopConsumerNativeInherit : Efl.ObjectNativeInherit{
129 public new static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Ecore);
130 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
132 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
133 if (efl_loop_get_static_delegate == null)
134 efl_loop_get_static_delegate = new efl_loop_get_delegate(loop_get);
135 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)});
136 if (efl_loop_future_resolved_static_delegate == null)
137 efl_loop_future_resolved_static_delegate = new efl_loop_future_resolved_delegate(future_resolved);
138 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)});
139 if (efl_loop_future_rejected_static_delegate == null)
140 efl_loop_future_rejected_static_delegate = new efl_loop_future_rejected_delegate(future_rejected);
141 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)});
142 if (efl_loop_promise_new_static_delegate == null)
143 efl_loop_promise_new_static_delegate = new efl_loop_promise_new_delegate(promise_new);
144 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)});
145 descs.AddRange(base.GetEoOps(type));
148 public override IntPtr GetEflClass()
150 return Efl.LoopConsumer.efl_loop_consumer_class_get();
152 public static new IntPtr GetEflClassStatic()
154 return Efl.LoopConsumer.efl_loop_consumer_class_get();
158 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Loop, Efl.Eo.NonOwnTag>))] private delegate Efl.Loop efl_loop_get_delegate(System.IntPtr obj, System.IntPtr pd);
161 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.Loop, Efl.Eo.NonOwnTag>))] public delegate Efl.Loop efl_loop_get_api_delegate(System.IntPtr obj);
162 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");
163 private static Efl.Loop loop_get(System.IntPtr obj, System.IntPtr pd)
165 Eina.Log.Debug("function efl_loop_get was called");
166 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
167 if(wrapper != null) {
168 Efl.Loop _ret_var = default(Efl.Loop);
170 _ret_var = ((LoopConsumer)wrapper).GetLoop();
171 } catch (Exception e) {
172 Eina.Log.Warning($"Callback error: {e.ToString()}");
173 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
177 return efl_loop_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
180 private static efl_loop_get_delegate efl_loop_get_static_delegate;
183 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] private delegate Eina.Future efl_loop_future_resolved_delegate(System.IntPtr obj, System.IntPtr pd, Eina.ValueNative result);
186 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] public delegate Eina.Future efl_loop_future_resolved_api_delegate(System.IntPtr obj, Eina.ValueNative result);
187 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");
188 private static Eina.Future future_resolved(System.IntPtr obj, System.IntPtr pd, Eina.ValueNative result)
190 Eina.Log.Debug("function efl_loop_future_resolved was called");
191 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
192 if(wrapper != null) {
193 var _in_result = new Eina.Value(result);
194 Eina.Future _ret_var = default( Eina.Future);
196 _ret_var = ((LoopConsumer)wrapper).FutureResolved( _in_result);
197 } catch (Exception e) {
198 Eina.Log.Warning($"Callback error: {e.ToString()}");
199 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
203 return efl_loop_future_resolved_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), result);
206 private static efl_loop_future_resolved_delegate efl_loop_future_resolved_static_delegate;
209 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] private delegate Eina.Future efl_loop_future_rejected_delegate(System.IntPtr obj, System.IntPtr pd, Eina.Error error);
212 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))] public delegate Eina.Future efl_loop_future_rejected_api_delegate(System.IntPtr obj, Eina.Error error);
213 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");
214 private static Eina.Future future_rejected(System.IntPtr obj, System.IntPtr pd, Eina.Error error)
216 Eina.Log.Debug("function efl_loop_future_rejected was called");
217 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
218 if(wrapper != null) {
219 Eina.Future _ret_var = default( Eina.Future);
221 _ret_var = ((LoopConsumer)wrapper).FutureRejected( error);
222 } catch (Exception e) {
223 Eina.Log.Warning($"Callback error: {e.ToString()}");
224 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
228 return efl_loop_future_rejected_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), error);
231 private static efl_loop_future_rejected_delegate efl_loop_future_rejected_static_delegate;
234 private delegate Eina.Promise efl_loop_promise_new_delegate(System.IntPtr obj, System.IntPtr pd);
237 public delegate Eina.Promise efl_loop_promise_new_api_delegate(System.IntPtr obj);
238 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");
239 private static Eina.Promise promise_new(System.IntPtr obj, System.IntPtr pd)
241 Eina.Log.Debug("function efl_loop_promise_new was called");
242 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
243 if(wrapper != null) {
244 Eina.Promise _ret_var = default(Eina.Promise);
246 _ret_var = ((LoopConsumer)wrapper).NewPromise();
247 } catch (Exception e) {
248 Eina.Log.Warning($"Callback error: {e.ToString()}");
249 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
253 return efl_loop_promise_new_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
256 private static efl_loop_promise_new_delegate efl_loop_promise_new_static_delegate;