6faea97c3d0a38acdc7018da66f747d434da8fbc
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl / efl_loop_fd.eo.cs
1 #define EFL_BETA
2 #pragma warning disable CS1591
3 using System;
4 using System.Runtime.InteropServices;
5 using System.Collections.Generic;
6 using System.Linq;
7 using System.Threading;
8 using System.ComponentModel;
9 namespace Efl {
10
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&apos;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
17 {
18     /// <summary>Pointer to the native class description.</summary>
19     public override System.IntPtr NativeClass
20     {
21         get
22         {
23             if (((object)this).GetType() == typeof(LoopFd))
24             {
25                 return GetEflClassStatic();
26             }
27             else
28             {
29                 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
30             }
31         }
32     }
33
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)
40     {
41         FinishInstantiation();
42     }
43
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)
48     {
49     }
50
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)
55     {
56     }
57
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)
63     {
64     }
65
66     /// <summary>Called when a read happened on the file descriptor</summary>
67     public event EventHandler ReadEvt
68     {
69         add
70         {
71             lock (eflBindingEventLock)
72             {
73                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
74                 {
75                     var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
76                     if (obj != null)
77                     {
78                         EventArgs args = EventArgs.Empty;
79                         try
80                         {
81                             value?.Invoke(obj, args);
82                         }
83                         catch (Exception e)
84                         {
85                             Eina.Log.Error(e.ToString());
86                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
87                         }
88                     }
89                 };
90
91                 string key = "_EFL_LOOP_FD_EVENT_READ";
92                 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
93             }
94         }
95
96         remove
97         {
98             lock (eflBindingEventLock)
99             {
100                 string key = "_EFL_LOOP_FD_EVENT_READ";
101                 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
102             }
103         }
104     }
105     /// <summary>Method to raise event ReadEvt.</summary>
106     public void OnReadEvt(EventArgs e)
107     {
108         var key = "_EFL_LOOP_FD_EVENT_READ";
109         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
110         if (desc == IntPtr.Zero)
111         {
112             Eina.Log.Error($"Failed to get native event {key}");
113             return;
114         }
115
116         Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
117     }
118     /// <summary>Called when a write happened on the file descriptor</summary>
119     public event EventHandler WriteEvt
120     {
121         add
122         {
123             lock (eflBindingEventLock)
124             {
125                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
126                 {
127                     var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
128                     if (obj != null)
129                     {
130                         EventArgs args = EventArgs.Empty;
131                         try
132                         {
133                             value?.Invoke(obj, args);
134                         }
135                         catch (Exception e)
136                         {
137                             Eina.Log.Error(e.ToString());
138                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
139                         }
140                     }
141                 };
142
143                 string key = "_EFL_LOOP_FD_EVENT_WRITE";
144                 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
145             }
146         }
147
148         remove
149         {
150             lock (eflBindingEventLock)
151             {
152                 string key = "_EFL_LOOP_FD_EVENT_WRITE";
153                 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
154             }
155         }
156     }
157     /// <summary>Method to raise event WriteEvt.</summary>
158     public void OnWriteEvt(EventArgs e)
159     {
160         var key = "_EFL_LOOP_FD_EVENT_WRITE";
161         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
162         if (desc == IntPtr.Zero)
163         {
164             Eina.Log.Error($"Failed to get native event {key}");
165             return;
166         }
167
168         Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
169     }
170     /// <summary>Called when a error occurred on the file descriptor</summary>
171     public event EventHandler ErrorEvt
172     {
173         add
174         {
175             lock (eflBindingEventLock)
176             {
177                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
178                 {
179                     var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
180                     if (obj != null)
181                     {
182                         EventArgs args = EventArgs.Empty;
183                         try
184                         {
185                             value?.Invoke(obj, args);
186                         }
187                         catch (Exception e)
188                         {
189                             Eina.Log.Error(e.ToString());
190                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
191                         }
192                     }
193                 };
194
195                 string key = "_EFL_LOOP_FD_EVENT_ERROR";
196                 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
197             }
198         }
199
200         remove
201         {
202             lock (eflBindingEventLock)
203             {
204                 string key = "_EFL_LOOP_FD_EVENT_ERROR";
205                 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
206             }
207         }
208     }
209     /// <summary>Method to raise event ErrorEvt.</summary>
210     public void OnErrorEvt(EventArgs e)
211     {
212         var key = "_EFL_LOOP_FD_EVENT_ERROR";
213         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
214         if (desc == IntPtr.Zero)
215         {
216             Eina.Log.Error($"Failed to get native event {key}");
217             return;
218         }
219
220         Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
221     }
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();
227         return _ret_var;
228  }
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();
234                          }
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();
240         return _ret_var;
241  }
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();
247                          }
248     /// <summary>Defines which file descriptor to watch. If it is a file, use file_fd variant.</summary>
249     /// <value>The file descriptor.</value>
250     public int Fd {
251         get { return GetFd(); }
252         set { SetFd(value); }
253     }
254     /// <summary>Defines which file descriptor to watch when watching a file.</summary>
255     /// <value>The file descriptor.</value>
256     public int FdFile {
257         get { return GetFdFile(); }
258         set { SetFdFile(value); }
259     }
260     private static IntPtr GetEflClassStatic()
261     {
262         return Efl.LoopFd.efl_loop_fd_class_get();
263     }
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
267     {
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)
272         {
273             var descs = new System.Collections.Generic.List<Efl_Op_Description>();
274             var methods = Efl.Eo.Globals.GetUserMethods(type);
275
276             if (efl_loop_fd_get_static_delegate == null)
277             {
278                 efl_loop_fd_get_static_delegate = new efl_loop_fd_get_delegate(fd_get);
279             }
280
281             if (methods.FirstOrDefault(m => m.Name == "GetFd") != null)
282             {
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) });
284             }
285
286             if (efl_loop_fd_set_static_delegate == null)
287             {
288                 efl_loop_fd_set_static_delegate = new efl_loop_fd_set_delegate(fd_set);
289             }
290
291             if (methods.FirstOrDefault(m => m.Name == "SetFd") != null)
292             {
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) });
294             }
295
296             if (efl_loop_fd_file_get_static_delegate == null)
297             {
298                 efl_loop_fd_file_get_static_delegate = new efl_loop_fd_file_get_delegate(fd_file_get);
299             }
300
301             if (methods.FirstOrDefault(m => m.Name == "GetFdFile") != null)
302             {
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) });
304             }
305
306             if (efl_loop_fd_file_set_static_delegate == null)
307             {
308                 efl_loop_fd_file_set_static_delegate = new efl_loop_fd_file_set_delegate(fd_file_set);
309             }
310
311             if (methods.FirstOrDefault(m => m.Name == "SetFdFile") != null)
312             {
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) });
314             }
315
316             descs.AddRange(base.GetEoOps(type));
317             return descs;
318         }
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()
322         {
323             return Efl.LoopFd.efl_loop_fd_class_get();
324         }
325
326         #pragma warning disable CA1707, CS1591, SA1300, SA1600
327
328         
329         private delegate int efl_loop_fd_get_delegate(System.IntPtr obj, System.IntPtr pd);
330
331         
332         public delegate int efl_loop_fd_get_api_delegate(System.IntPtr obj);
333
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");
335
336         private static int fd_get(System.IntPtr obj, System.IntPtr pd)
337         {
338             Eina.Log.Debug("function efl_loop_fd_get was called");
339             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
340             if (ws != null)
341             {
342             int _ret_var = default(int);
343                 try
344                 {
345                     _ret_var = ((LoopFd)ws.Target).GetFd();
346                 }
347                 catch (Exception e)
348                 {
349                     Eina.Log.Warning($"Callback error: {e.ToString()}");
350                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
351                 }
352
353         return _ret_var;
354
355             }
356             else
357             {
358                 return efl_loop_fd_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
359             }
360         }
361
362         private static efl_loop_fd_get_delegate efl_loop_fd_get_static_delegate;
363
364         
365         private delegate void efl_loop_fd_set_delegate(System.IntPtr obj, System.IntPtr pd,  int fd);
366
367         
368         public delegate void efl_loop_fd_set_api_delegate(System.IntPtr obj,  int fd);
369
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");
371
372         private static void fd_set(System.IntPtr obj, System.IntPtr pd, int fd)
373         {
374             Eina.Log.Debug("function efl_loop_fd_set was called");
375             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
376             if (ws != null)
377             {
378                                     
379                 try
380                 {
381                     ((LoopFd)ws.Target).SetFd(fd);
382                 }
383                 catch (Exception e)
384                 {
385                     Eina.Log.Warning($"Callback error: {e.ToString()}");
386                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
387                 }
388
389                         
390             }
391             else
392             {
393                 efl_loop_fd_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), fd);
394             }
395         }
396
397         private static efl_loop_fd_set_delegate efl_loop_fd_set_static_delegate;
398
399         
400         private delegate int efl_loop_fd_file_get_delegate(System.IntPtr obj, System.IntPtr pd);
401
402         
403         public delegate int efl_loop_fd_file_get_api_delegate(System.IntPtr obj);
404
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");
406
407         private static int fd_file_get(System.IntPtr obj, System.IntPtr pd)
408         {
409             Eina.Log.Debug("function efl_loop_fd_file_get was called");
410             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
411             if (ws != null)
412             {
413             int _ret_var = default(int);
414                 try
415                 {
416                     _ret_var = ((LoopFd)ws.Target).GetFdFile();
417                 }
418                 catch (Exception e)
419                 {
420                     Eina.Log.Warning($"Callback error: {e.ToString()}");
421                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
422                 }
423
424         return _ret_var;
425
426             }
427             else
428             {
429                 return efl_loop_fd_file_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
430             }
431         }
432
433         private static efl_loop_fd_file_get_delegate efl_loop_fd_file_get_static_delegate;
434
435         
436         private delegate void efl_loop_fd_file_set_delegate(System.IntPtr obj, System.IntPtr pd,  int fd);
437
438         
439         public delegate void efl_loop_fd_file_set_api_delegate(System.IntPtr obj,  int fd);
440
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");
442
443         private static void fd_file_set(System.IntPtr obj, System.IntPtr pd, int fd)
444         {
445             Eina.Log.Debug("function efl_loop_fd_file_set was called");
446             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
447             if (ws != null)
448             {
449                                     
450                 try
451                 {
452                     ((LoopFd)ws.Target).SetFdFile(fd);
453                 }
454                 catch (Exception e)
455                 {
456                     Eina.Log.Warning($"Callback error: {e.ToString()}");
457                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
458                 }
459
460                         
461             }
462             else
463             {
464                 efl_loop_fd_file_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), fd);
465             }
466         }
467
468         private static efl_loop_fd_file_set_delegate efl_loop_fd_file_set_static_delegate;
469
470         #pragma warning restore CA1707, CS1591, SA1300, SA1600
471
472 }
473 }
474 }
475
476 #if EFL_BETA
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);
481     }
482
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);
485     }
486
487 }
488 #pragma warning restore CS1591
489 #endif