2 #pragma warning disable CS1591
4 using System.Runtime.InteropServices;
5 using System.Collections.Generic;
7 using System.Threading;
8 using System.ComponentModel;
11 /// <summary>Fds are objects that watch the activity on a given file descriptor. This file descriptor can be a network, a file, provided by a library.
12 /// The object will trigger relevant events depending on what's happening.</summary>
13 /// <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>
14 [Efl.LoopFd.NativeMethods]
15 [Efl.Eo.BindingEntity]
16 public class LoopFd : Efl.LoopConsumer
18 /// <summary>Pointer to the native class description.</summary>
19 public override System.IntPtr NativeClass
23 if (((object)this).GetType() == typeof(LoopFd))
25 return GetEflClassStatic();
29 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
34 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
35 efl_loop_fd_class_get();
36 /// <summary>Initializes a new instance of the <see cref="LoopFd"/> class.</summary>
37 /// <param name="parent">Parent instance.</param>
38 public LoopFd(Efl.Object parent= null
39 ) : base(efl_loop_fd_class_get(), parent)
41 FinishInstantiation();
44 /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code.
45 /// Do not call this constructor directly.</summary>
46 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
47 protected LoopFd(ConstructingHandle ch) : base(ch)
51 /// <summary>Initializes a new instance of the <see cref="LoopFd"/> class.
52 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
53 /// <param name="wh">The native pointer to be wrapped.</param>
54 protected LoopFd(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
58 /// <summary>Initializes a new instance of the <see cref="LoopFd"/> class.
59 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
60 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
61 /// <param name="parent">The Efl.Object parent of this instance.</param>
62 protected LoopFd(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)
66 /// <summary>Called when a read happened on the file descriptor</summary>
67 public event EventHandler ReadEvt
71 lock (eflBindingEventLock)
73 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
75 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
78 EventArgs args = EventArgs.Empty;
81 value?.Invoke(obj, args);
85 Eina.Log.Error(e.ToString());
86 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
91 string key = "_EFL_LOOP_FD_EVENT_READ";
92 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
98 lock (eflBindingEventLock)
100 string key = "_EFL_LOOP_FD_EVENT_READ";
101 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
105 /// <summary>Method to raise event ReadEvt.</summary>
106 public void OnReadEvt(EventArgs e)
108 var key = "_EFL_LOOP_FD_EVENT_READ";
109 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
110 if (desc == IntPtr.Zero)
112 Eina.Log.Error($"Failed to get native event {key}");
116 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
118 /// <summary>Called when a write happened on the file descriptor</summary>
119 public event EventHandler WriteEvt
123 lock (eflBindingEventLock)
125 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
127 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
130 EventArgs args = EventArgs.Empty;
133 value?.Invoke(obj, args);
137 Eina.Log.Error(e.ToString());
138 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
143 string key = "_EFL_LOOP_FD_EVENT_WRITE";
144 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
150 lock (eflBindingEventLock)
152 string key = "_EFL_LOOP_FD_EVENT_WRITE";
153 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
157 /// <summary>Method to raise event WriteEvt.</summary>
158 public void OnWriteEvt(EventArgs e)
160 var key = "_EFL_LOOP_FD_EVENT_WRITE";
161 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
162 if (desc == IntPtr.Zero)
164 Eina.Log.Error($"Failed to get native event {key}");
168 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
170 /// <summary>Called when a error occurred on the file descriptor</summary>
171 public event EventHandler ErrorEvt
175 lock (eflBindingEventLock)
177 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
179 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
182 EventArgs args = EventArgs.Empty;
185 value?.Invoke(obj, args);
189 Eina.Log.Error(e.ToString());
190 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
195 string key = "_EFL_LOOP_FD_EVENT_ERROR";
196 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
202 lock (eflBindingEventLock)
204 string key = "_EFL_LOOP_FD_EVENT_ERROR";
205 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
209 /// <summary>Method to raise event ErrorEvt.</summary>
210 public void OnErrorEvt(EventArgs e)
212 var key = "_EFL_LOOP_FD_EVENT_ERROR";
213 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
214 if (desc == IntPtr.Zero)
216 Eina.Log.Error($"Failed to get native event {key}");
220 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
222 /// <summary>Defines which file descriptor to watch. If it is a file, use file_fd variant.</summary>
223 /// <returns>The file descriptor.</returns>
224 virtual public int GetFd() {
225 var _ret_var = Efl.LoopFd.NativeMethods.efl_loop_fd_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
226 Eina.Error.RaiseIfUnhandledException();
229 /// <summary>Defines the fd to watch.</summary>
230 /// <param name="fd">The file descriptor.</param>
231 virtual public void SetFd(int fd) {
232 Efl.LoopFd.NativeMethods.efl_loop_fd_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),fd);
233 Eina.Error.RaiseIfUnhandledException();
235 /// <summary>Defines which file descriptor to watch when watching a file.</summary>
236 /// <returns>The file descriptor.</returns>
237 virtual public int GetFdFile() {
238 var _ret_var = Efl.LoopFd.NativeMethods.efl_loop_fd_file_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
239 Eina.Error.RaiseIfUnhandledException();
242 /// <summary>Defines the fd to watch on.</summary>
243 /// <param name="fd">The file descriptor.</param>
244 virtual public void SetFdFile(int fd) {
245 Efl.LoopFd.NativeMethods.efl_loop_fd_file_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),fd);
246 Eina.Error.RaiseIfUnhandledException();
248 /// <summary>Defines which file descriptor to watch. If it is a file, use file_fd variant.</summary>
249 /// <value>The file descriptor.</value>
251 get { return GetFd(); }
252 set { SetFd(value); }
254 /// <summary>Defines which file descriptor to watch when watching a file.</summary>
255 /// <value>The file descriptor.</value>
257 get { return GetFdFile(); }
258 set { SetFdFile(value); }
260 private static IntPtr GetEflClassStatic()
262 return Efl.LoopFd.efl_loop_fd_class_get();
264 /// <summary>Wrapper for native methods and virtual method delegates.
265 /// For internal use by generated code only.</summary>
266 public new class NativeMethods : Efl.LoopConsumer.NativeMethods
268 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Ecore);
269 /// <summary>Gets the list of Eo operations to override.</summary>
270 /// <returns>The list of Eo operations to be overload.</returns>
271 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
273 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
274 var methods = Efl.Eo.Globals.GetUserMethods(type);
276 if (efl_loop_fd_get_static_delegate == null)
278 efl_loop_fd_get_static_delegate = new efl_loop_fd_get_delegate(fd_get);
281 if (methods.FirstOrDefault(m => m.Name == "GetFd") != null)
283 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_fd_get"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_fd_get_static_delegate) });
286 if (efl_loop_fd_set_static_delegate == null)
288 efl_loop_fd_set_static_delegate = new efl_loop_fd_set_delegate(fd_set);
291 if (methods.FirstOrDefault(m => m.Name == "SetFd") != null)
293 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_fd_set"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_fd_set_static_delegate) });
296 if (efl_loop_fd_file_get_static_delegate == null)
298 efl_loop_fd_file_get_static_delegate = new efl_loop_fd_file_get_delegate(fd_file_get);
301 if (methods.FirstOrDefault(m => m.Name == "GetFdFile") != null)
303 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_fd_file_get"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_fd_file_get_static_delegate) });
306 if (efl_loop_fd_file_set_static_delegate == null)
308 efl_loop_fd_file_set_static_delegate = new efl_loop_fd_file_set_delegate(fd_file_set);
311 if (methods.FirstOrDefault(m => m.Name == "SetFdFile") != null)
313 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_fd_file_set"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_fd_file_set_static_delegate) });
316 descs.AddRange(base.GetEoOps(type));
319 /// <summary>Returns the Eo class for the native methods of this class.</summary>
320 /// <returns>The native class pointer.</returns>
321 public override IntPtr GetEflClass()
323 return Efl.LoopFd.efl_loop_fd_class_get();
326 #pragma warning disable CA1707, CS1591, SA1300, SA1600
329 private delegate int efl_loop_fd_get_delegate(System.IntPtr obj, System.IntPtr pd);
332 public delegate int efl_loop_fd_get_api_delegate(System.IntPtr obj);
334 public static Efl.Eo.FunctionWrapper<efl_loop_fd_get_api_delegate> efl_loop_fd_get_ptr = new Efl.Eo.FunctionWrapper<efl_loop_fd_get_api_delegate>(Module, "efl_loop_fd_get");
336 private static int fd_get(System.IntPtr obj, System.IntPtr pd)
338 Eina.Log.Debug("function efl_loop_fd_get was called");
339 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
342 int _ret_var = default(int);
345 _ret_var = ((LoopFd)ws.Target).GetFd();
349 Eina.Log.Warning($"Callback error: {e.ToString()}");
350 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
358 return efl_loop_fd_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
362 private static efl_loop_fd_get_delegate efl_loop_fd_get_static_delegate;
365 private delegate void efl_loop_fd_set_delegate(System.IntPtr obj, System.IntPtr pd, int fd);
368 public delegate void efl_loop_fd_set_api_delegate(System.IntPtr obj, int fd);
370 public static Efl.Eo.FunctionWrapper<efl_loop_fd_set_api_delegate> efl_loop_fd_set_ptr = new Efl.Eo.FunctionWrapper<efl_loop_fd_set_api_delegate>(Module, "efl_loop_fd_set");
372 private static void fd_set(System.IntPtr obj, System.IntPtr pd, int fd)
374 Eina.Log.Debug("function efl_loop_fd_set was called");
375 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
381 ((LoopFd)ws.Target).SetFd(fd);
385 Eina.Log.Warning($"Callback error: {e.ToString()}");
386 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
393 efl_loop_fd_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), fd);
397 private static efl_loop_fd_set_delegate efl_loop_fd_set_static_delegate;
400 private delegate int efl_loop_fd_file_get_delegate(System.IntPtr obj, System.IntPtr pd);
403 public delegate int efl_loop_fd_file_get_api_delegate(System.IntPtr obj);
405 public static Efl.Eo.FunctionWrapper<efl_loop_fd_file_get_api_delegate> efl_loop_fd_file_get_ptr = new Efl.Eo.FunctionWrapper<efl_loop_fd_file_get_api_delegate>(Module, "efl_loop_fd_file_get");
407 private static int fd_file_get(System.IntPtr obj, System.IntPtr pd)
409 Eina.Log.Debug("function efl_loop_fd_file_get was called");
410 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
413 int _ret_var = default(int);
416 _ret_var = ((LoopFd)ws.Target).GetFdFile();
420 Eina.Log.Warning($"Callback error: {e.ToString()}");
421 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
429 return efl_loop_fd_file_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
433 private static efl_loop_fd_file_get_delegate efl_loop_fd_file_get_static_delegate;
436 private delegate void efl_loop_fd_file_set_delegate(System.IntPtr obj, System.IntPtr pd, int fd);
439 public delegate void efl_loop_fd_file_set_api_delegate(System.IntPtr obj, int fd);
441 public static Efl.Eo.FunctionWrapper<efl_loop_fd_file_set_api_delegate> efl_loop_fd_file_set_ptr = new Efl.Eo.FunctionWrapper<efl_loop_fd_file_set_api_delegate>(Module, "efl_loop_fd_file_set");
443 private static void fd_file_set(System.IntPtr obj, System.IntPtr pd, int fd)
445 Eina.Log.Debug("function efl_loop_fd_file_set was called");
446 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
452 ((LoopFd)ws.Target).SetFdFile(fd);
456 Eina.Log.Warning($"Callback error: {e.ToString()}");
457 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
464 efl_loop_fd_file_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), fd);
468 private static efl_loop_fd_file_set_delegate efl_loop_fd_file_set_static_delegate;
470 #pragma warning restore CA1707, CS1591, SA1300, SA1600
477 #pragma warning disable CS1591
478 public static class EflLoopFd_ExtensionMethods {
479 public static Efl.BindableProperty<int> Fd<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<Efl.LoopFd, T>magic = null) where T : Efl.LoopFd {
480 return new Efl.BindableProperty<int>("fd", fac);
483 public static Efl.BindableProperty<int> FdFile<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<Efl.LoopFd, T>magic = null) where T : Efl.LoopFd {
484 return new Efl.BindableProperty<int>("fd_file", fac);
488 #pragma warning restore CS1591