84f3719c3ebcf39cb3a2f100206cbdc6c7e3e16b
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl / efl_loop_fd.eo.cs
1 #pragma warning disable CS1591
2 using System;
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.ComponentModel;
7 namespace Efl { 
8 /// <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.
9 /// The object will trigger relevant events depending on what&apos;s happening.</summary>
10 [LoopFdNativeInherit]
11 public class LoopFd : Efl.LoopConsumer, Efl.Eo.IWrapper
12 {
13     ///<summary>Pointer to the native class description.</summary>
14     public override System.IntPtr NativeClass {
15         get {
16             if (((object)this).GetType() == typeof (LoopFd))
17                 return Efl.LoopFdNativeInherit.GetEflClassStatic();
18             else
19                 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
20         }
21     }
22     [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
23         efl_loop_fd_class_get();
24     ///<summary>Creates a new instance.</summary>
25     ///<param name="parent">Parent instance.</param>
26     public LoopFd(Efl.Object parent= null
27             ) :
28         base(efl_loop_fd_class_get(), typeof(LoopFd), parent)
29     {
30         FinishInstantiation();
31     }
32     ///<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>
33     protected LoopFd(System.IntPtr raw) : base(raw)
34     {
35                 RegisterEventProxies();
36     }
37     ///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
38     protected LoopFd(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}
39     ///<summary>Verifies if the given object is equal to this one.</summary>
40     public override bool Equals(object obj)
41     {
42         var other = obj as Efl.Object;
43         if (other == null)
44             return false;
45         return this.NativeHandle == other.NativeHandle;
46     }
47     ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
48     public override int GetHashCode()
49     {
50         return this.NativeHandle.ToInt32();
51     }
52     ///<summary>Turns the native pointer into a string representation.</summary>
53     public override String ToString()
54     {
55         return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
56     }
57 private static object ReadEvtKey = new object();
58     /// <summary>Called when a read happened on the file descriptor</summary>
59     public event EventHandler ReadEvt
60     {
61         add {
62             lock (eventLock) {
63                 string key = "_EFL_LOOP_FD_EVENT_READ";
64                 if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_ReadEvt_delegate)) {
65                     eventHandlers.AddHandler(ReadEvtKey , value);
66                 } else
67                     Eina.Log.Error($"Error adding proxy for event {key}");
68             }
69         }
70         remove {
71             lock (eventLock) {
72                 string key = "_EFL_LOOP_FD_EVENT_READ";
73                 if (RemoveNativeEventHandler(key, this.evt_ReadEvt_delegate)) { 
74                     eventHandlers.RemoveHandler(ReadEvtKey , value);
75                 } else
76                     Eina.Log.Error($"Error removing proxy for event {key}");
77             }
78         }
79     }
80     ///<summary>Method to raise event ReadEvt.</summary>
81     public void On_ReadEvt(EventArgs e)
82     {
83         EventHandler evt;
84         lock (eventLock) {
85         evt = (EventHandler)eventHandlers[ReadEvtKey];
86         }
87         evt?.Invoke(this, e);
88     }
89     Efl.EventCb evt_ReadEvt_delegate;
90     private void on_ReadEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
91     {
92         EventArgs args = EventArgs.Empty;
93         try {
94             On_ReadEvt(args);
95         } catch (Exception e) {
96             Eina.Log.Error(e.ToString());
97             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
98         }
99     }
100
101 private static object WriteEvtKey = new object();
102     /// <summary>Called when a write happened on the file descriptor</summary>
103     public event EventHandler WriteEvt
104     {
105         add {
106             lock (eventLock) {
107                 string key = "_EFL_LOOP_FD_EVENT_WRITE";
108                 if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_WriteEvt_delegate)) {
109                     eventHandlers.AddHandler(WriteEvtKey , value);
110                 } else
111                     Eina.Log.Error($"Error adding proxy for event {key}");
112             }
113         }
114         remove {
115             lock (eventLock) {
116                 string key = "_EFL_LOOP_FD_EVENT_WRITE";
117                 if (RemoveNativeEventHandler(key, this.evt_WriteEvt_delegate)) { 
118                     eventHandlers.RemoveHandler(WriteEvtKey , value);
119                 } else
120                     Eina.Log.Error($"Error removing proxy for event {key}");
121             }
122         }
123     }
124     ///<summary>Method to raise event WriteEvt.</summary>
125     public void On_WriteEvt(EventArgs e)
126     {
127         EventHandler evt;
128         lock (eventLock) {
129         evt = (EventHandler)eventHandlers[WriteEvtKey];
130         }
131         evt?.Invoke(this, e);
132     }
133     Efl.EventCb evt_WriteEvt_delegate;
134     private void on_WriteEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
135     {
136         EventArgs args = EventArgs.Empty;
137         try {
138             On_WriteEvt(args);
139         } catch (Exception e) {
140             Eina.Log.Error(e.ToString());
141             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
142         }
143     }
144
145 private static object ErrorEvtKey = new object();
146     /// <summary>Called when a error occurred on the file descriptor</summary>
147     public event EventHandler ErrorEvt
148     {
149         add {
150             lock (eventLock) {
151                 string key = "_EFL_LOOP_FD_EVENT_ERROR";
152                 if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_ErrorEvt_delegate)) {
153                     eventHandlers.AddHandler(ErrorEvtKey , value);
154                 } else
155                     Eina.Log.Error($"Error adding proxy for event {key}");
156             }
157         }
158         remove {
159             lock (eventLock) {
160                 string key = "_EFL_LOOP_FD_EVENT_ERROR";
161                 if (RemoveNativeEventHandler(key, this.evt_ErrorEvt_delegate)) { 
162                     eventHandlers.RemoveHandler(ErrorEvtKey , value);
163                 } else
164                     Eina.Log.Error($"Error removing proxy for event {key}");
165             }
166         }
167     }
168     ///<summary>Method to raise event ErrorEvt.</summary>
169     public void On_ErrorEvt(EventArgs e)
170     {
171         EventHandler evt;
172         lock (eventLock) {
173         evt = (EventHandler)eventHandlers[ErrorEvtKey];
174         }
175         evt?.Invoke(this, e);
176     }
177     Efl.EventCb evt_ErrorEvt_delegate;
178     private void on_ErrorEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
179     {
180         EventArgs args = EventArgs.Empty;
181         try {
182             On_ErrorEvt(args);
183         } catch (Exception e) {
184             Eina.Log.Error(e.ToString());
185             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
186         }
187     }
188
189     ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
190     protected override void RegisterEventProxies()
191     {
192         base.RegisterEventProxies();
193         evt_ReadEvt_delegate = new Efl.EventCb(on_ReadEvt_NativeCallback);
194         evt_WriteEvt_delegate = new Efl.EventCb(on_WriteEvt_NativeCallback);
195         evt_ErrorEvt_delegate = new Efl.EventCb(on_ErrorEvt_NativeCallback);
196     }
197     /// <summary>Defines which file descriptor to watch. If it is a file, use file_fd variant.</summary>
198     /// <returns>The file descriptor.</returns>
199     virtual public int GetFd() {
200          var _ret_var = Efl.LoopFdNativeInherit.efl_loop_fd_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
201         Eina.Error.RaiseIfUnhandledException();
202         return _ret_var;
203  }
204     /// <summary>Defines the fd to watch.</summary>
205     /// <param name="fd">The file descriptor.</param>
206     /// <returns></returns>
207     virtual public void SetFd( int fd) {
208                                  Efl.LoopFdNativeInherit.efl_loop_fd_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), fd);
209         Eina.Error.RaiseIfUnhandledException();
210                          }
211     /// <summary>Defines which file descriptor to watch when watching a file.</summary>
212     /// <returns>The file descriptor.</returns>
213     virtual public int GetFdFile() {
214          var _ret_var = Efl.LoopFdNativeInherit.efl_loop_fd_file_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
215         Eina.Error.RaiseIfUnhandledException();
216         return _ret_var;
217  }
218     /// <summary>Defines the fd to watch on.</summary>
219     /// <param name="fd">The file descriptor.</param>
220     /// <returns></returns>
221     virtual public void SetFdFile( int fd) {
222                                  Efl.LoopFdNativeInherit.efl_loop_fd_file_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), fd);
223         Eina.Error.RaiseIfUnhandledException();
224                          }
225     /// <summary>Defines which file descriptor to watch. If it is a file, use file_fd variant.</summary>
226 /// <value>The file descriptor.</value>
227     public int Fd {
228         get { return GetFd(); }
229         set { SetFd( value); }
230     }
231     /// <summary>Defines which file descriptor to watch when watching a file.</summary>
232 /// <value>The file descriptor.</value>
233     public int FdFile {
234         get { return GetFdFile(); }
235         set { SetFdFile( value); }
236     }
237     private static IntPtr GetEflClassStatic()
238     {
239         return Efl.LoopFd.efl_loop_fd_class_get();
240     }
241 }
242 public class LoopFdNativeInherit : Efl.LoopConsumerNativeInherit{
243     public new  static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Ecore);
244     public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
245     {
246         var descs = new System.Collections.Generic.List<Efl_Op_Description>();
247         var methods = Efl.Eo.Globals.GetUserMethods(type);
248         if (efl_loop_fd_get_static_delegate == null)
249             efl_loop_fd_get_static_delegate = new efl_loop_fd_get_delegate(fd_get);
250         if (methods.FirstOrDefault(m => m.Name == "GetFd") != null)
251             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)});
252         if (efl_loop_fd_set_static_delegate == null)
253             efl_loop_fd_set_static_delegate = new efl_loop_fd_set_delegate(fd_set);
254         if (methods.FirstOrDefault(m => m.Name == "SetFd") != null)
255             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)});
256         if (efl_loop_fd_file_get_static_delegate == null)
257             efl_loop_fd_file_get_static_delegate = new efl_loop_fd_file_get_delegate(fd_file_get);
258         if (methods.FirstOrDefault(m => m.Name == "GetFdFile") != null)
259             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)});
260         if (efl_loop_fd_file_set_static_delegate == null)
261             efl_loop_fd_file_set_static_delegate = new efl_loop_fd_file_set_delegate(fd_file_set);
262         if (methods.FirstOrDefault(m => m.Name == "SetFdFile") != null)
263             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)});
264         descs.AddRange(base.GetEoOps(type));
265         return descs;
266     }
267     public override IntPtr GetEflClass()
268     {
269         return Efl.LoopFd.efl_loop_fd_class_get();
270     }
271     public static new  IntPtr GetEflClassStatic()
272     {
273         return Efl.LoopFd.efl_loop_fd_class_get();
274     }
275
276
277      private delegate int efl_loop_fd_get_delegate(System.IntPtr obj, System.IntPtr pd);
278
279
280      public delegate int efl_loop_fd_get_api_delegate(System.IntPtr obj);
281      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");
282      private static int fd_get(System.IntPtr obj, System.IntPtr pd)
283     {
284         Eina.Log.Debug("function efl_loop_fd_get was called");
285         Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
286         if(wrapper != null) {
287                         int _ret_var = default(int);
288             try {
289                 _ret_var = ((LoopFd)wrapper).GetFd();
290             } catch (Exception e) {
291                 Eina.Log.Warning($"Callback error: {e.ToString()}");
292                 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
293             }
294         return _ret_var;
295         } else {
296             return efl_loop_fd_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
297         }
298     }
299     private static efl_loop_fd_get_delegate efl_loop_fd_get_static_delegate;
300
301
302      private delegate void efl_loop_fd_set_delegate(System.IntPtr obj, System.IntPtr pd,   int fd);
303
304
305      public delegate void efl_loop_fd_set_api_delegate(System.IntPtr obj,   int fd);
306      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");
307      private static void fd_set(System.IntPtr obj, System.IntPtr pd,  int fd)
308     {
309         Eina.Log.Debug("function efl_loop_fd_set was called");
310         Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
311         if(wrapper != null) {
312                                                 
313             try {
314                 ((LoopFd)wrapper).SetFd( fd);
315             } catch (Exception e) {
316                 Eina.Log.Warning($"Callback error: {e.ToString()}");
317                 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
318             }
319                                 } else {
320             efl_loop_fd_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  fd);
321         }
322     }
323     private static efl_loop_fd_set_delegate efl_loop_fd_set_static_delegate;
324
325
326      private delegate int efl_loop_fd_file_get_delegate(System.IntPtr obj, System.IntPtr pd);
327
328
329      public delegate int efl_loop_fd_file_get_api_delegate(System.IntPtr obj);
330      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");
331      private static int fd_file_get(System.IntPtr obj, System.IntPtr pd)
332     {
333         Eina.Log.Debug("function efl_loop_fd_file_get was called");
334         Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
335         if(wrapper != null) {
336                         int _ret_var = default(int);
337             try {
338                 _ret_var = ((LoopFd)wrapper).GetFdFile();
339             } catch (Exception e) {
340                 Eina.Log.Warning($"Callback error: {e.ToString()}");
341                 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
342             }
343         return _ret_var;
344         } else {
345             return efl_loop_fd_file_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
346         }
347     }
348     private static efl_loop_fd_file_get_delegate efl_loop_fd_file_get_static_delegate;
349
350
351      private delegate void efl_loop_fd_file_set_delegate(System.IntPtr obj, System.IntPtr pd,   int fd);
352
353
354      public delegate void efl_loop_fd_file_set_api_delegate(System.IntPtr obj,   int fd);
355      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");
356      private static void fd_file_set(System.IntPtr obj, System.IntPtr pd,  int fd)
357     {
358         Eina.Log.Debug("function efl_loop_fd_file_set was called");
359         Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
360         if(wrapper != null) {
361                                                 
362             try {
363                 ((LoopFd)wrapper).SetFdFile( fd);
364             } catch (Exception e) {
365                 Eina.Log.Warning($"Callback error: {e.ToString()}");
366                 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
367             }
368                                 } else {
369             efl_loop_fd_file_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  fd);
370         }
371     }
372     private static efl_loop_fd_file_set_delegate efl_loop_fd_file_set_static_delegate;
373 }
374