4c3a3b84eda245b0fdd6dee1a1c495530384d9e0
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl / efl_io_writer.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.Threading;
7 using System.ComponentModel;
8 namespace Efl {
9
10 namespace Io {
11
12 /// <summary>Generic interface for objects that can write data from a provided memory.
13 /// This interface allows external objects to transparently write data to this object and be notified whether more data can be written or if it&apos;s reached capacity.
14 /// 
15 /// Calls to <see cref="Efl.Io.IWriter.Write"/> may or may not block: that&apos;s not up to this interface to specify. The user can check with event &quot;can_write,changed&quot; or property <see cref="Efl.Io.IWriter.CanWrite"/> to known whenever a write could push more data.
16 /// (Since EFL 1.22)</summary>
17 [Efl.Io.IWriterConcrete.NativeMethods]
18 public interface IWriter : 
19     Efl.Eo.IWrapper, IDisposable
20 {
21     /// <summary>If <c>true</c> will notify <see cref="Efl.Io.IWriter.Write"/> can be called without blocking or failing.
22 /// (Since EFL 1.22)</summary>
23 /// <returns><c>true</c> if it can be written without blocking or failure, <c>false</c> otherwise</returns>
24 bool GetCanWrite();
25     /// <summary>If <c>true</c> will notify <see cref="Efl.Io.IWriter.Write"/> can be called without blocking or failing.
26 /// (Since EFL 1.22)</summary>
27 /// <param name="can_write"><c>true</c> if it can be written without blocking or failure, <c>false</c> otherwise</param>
28 void SetCanWrite(bool can_write);
29     /// <summary>Writes data from a pre-populated buffer.
30 /// This operation will be executed immediately and may or may not block the caller thread for some time. The details of blocking behavior is defined by the implementation and may be subject to other parameters such as non-blocking flags, maximum timeout or even retry attempts.
31 /// 
32 /// You can understand this method as write(2) libc function.
33 /// (Since EFL 1.22)</summary>
34 /// <param name="slice">Provides a pre-populated memory to be used up to slice.len. The returned slice will be adapted as length will be set to the actually used amount of bytes, which can be smaller than the request.</param>
35 /// <param name="remaining">Convenience to output the remaining parts of slice that was not written. If the full slice was written, this will be a slice of zero-length.</param>
36 /// <returns>0 on succeed, a mapping of errno otherwise</returns>
37 Eina.Error Write(ref Eina.Slice slice, ref Eina.Slice remaining);
38                 /// <summary>Notifies can_write property changed.
39     /// If <see cref="Efl.Io.IWriter.CanWrite"/> is <c>true</c> there is data to <see cref="Efl.Io.IWriter.Write"/> without blocking/error. If <see cref="Efl.Io.IWriter.CanWrite"/> is <c>false</c>, <see cref="Efl.Io.IWriter.Write"/> would either block or fail.
40     /// 
41     /// Note that usually this event is dispatched from inside <see cref="Efl.Io.IWriter.Write"/>, thus before it returns.
42     /// (Since EFL 1.22)</summary>
43     event EventHandler<Efl.Io.IWriterCanWriteChangedEvt_Args> CanWriteChangedEvt;
44     /// <summary>If <c>true</c> will notify <see cref="Efl.Io.IWriter.Write"/> can be called without blocking or failing.
45     /// (Since EFL 1.22)</summary>
46     /// <value><c>true</c> if it can be written without blocking or failure, <c>false</c> otherwise</value>
47     bool CanWrite {
48         get ;
49         set ;
50     }
51 }
52 ///<summary>Event argument wrapper for event <see cref="Efl.Io.IWriter.CanWriteChangedEvt"/>.</summary>
53 public class IWriterCanWriteChangedEvt_Args : EventArgs {
54     ///<summary>Actual event payload.</summary>
55     public bool arg { get; set; }
56 }
57 /// <summary>Generic interface for objects that can write data from a provided memory.
58 /// This interface allows external objects to transparently write data to this object and be notified whether more data can be written or if it&apos;s reached capacity.
59 /// 
60 /// Calls to <see cref="Efl.Io.IWriter.Write"/> may or may not block: that&apos;s not up to this interface to specify. The user can check with event &quot;can_write,changed&quot; or property <see cref="Efl.Io.IWriter.CanWrite"/> to known whenever a write could push more data.
61 /// (Since EFL 1.22)</summary>
62 sealed public class IWriterConcrete :
63     Efl.Eo.EoWrapper
64     , IWriter
65     
66 {
67     ///<summary>Pointer to the native class description.</summary>
68     public override System.IntPtr NativeClass
69     {
70         get
71         {
72             if (((object)this).GetType() == typeof(IWriterConcrete))
73             {
74                 return GetEflClassStatic();
75             }
76             else
77             {
78                 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
79             }
80         }
81     }
82
83     [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
84         efl_io_writer_interface_get();
85     /// <summary>Initializes a new instance of the <see cref="IWriter"/> class.
86     /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
87     private IWriterConcrete(System.IntPtr raw) : base(raw)
88     {
89     }
90
91     /// <summary>Notifies can_write property changed.
92     /// If <see cref="Efl.Io.IWriter.CanWrite"/> is <c>true</c> there is data to <see cref="Efl.Io.IWriter.Write"/> without blocking/error. If <see cref="Efl.Io.IWriter.CanWrite"/> is <c>false</c>, <see cref="Efl.Io.IWriter.Write"/> would either block or fail.
93     /// 
94     /// Note that usually this event is dispatched from inside <see cref="Efl.Io.IWriter.Write"/>, thus before it returns.
95     /// (Since EFL 1.22)</summary>
96     public event EventHandler<Efl.Io.IWriterCanWriteChangedEvt_Args> CanWriteChangedEvt
97     {
98         add
99         {
100             lock (eventLock)
101             {
102                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
103                 {
104                     var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
105                     if (obj != null)
106                     {
107                         Efl.Io.IWriterCanWriteChangedEvt_Args args = new Efl.Io.IWriterCanWriteChangedEvt_Args();
108                         args.arg = Marshal.ReadByte(evt.Info) != 0;
109                         try
110                         {
111                             value?.Invoke(obj, args);
112                         }
113                         catch (Exception e)
114                         {
115                             Eina.Log.Error(e.ToString());
116                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
117                         }
118                     }
119                 };
120
121                 string key = "_EFL_IO_WRITER_EVENT_CAN_WRITE_CHANGED";
122                 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
123             }
124         }
125
126         remove
127         {
128             lock (eventLock)
129             {
130                 string key = "_EFL_IO_WRITER_EVENT_CAN_WRITE_CHANGED";
131                 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
132             }
133         }
134     }
135     ///<summary>Method to raise event CanWriteChangedEvt.</summary>
136     public void OnCanWriteChangedEvt(Efl.Io.IWriterCanWriteChangedEvt_Args e)
137     {
138         var key = "_EFL_IO_WRITER_EVENT_CAN_WRITE_CHANGED";
139         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
140         if (desc == IntPtr.Zero)
141         {
142             Eina.Log.Error($"Failed to get native event {key}");
143             return;
144         }
145
146         IntPtr info = Eina.PrimitiveConversion.ManagedToPointerAlloc(e.arg ? (byte) 1 : (byte) 0);
147         try
148         {
149             Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
150         }
151         finally
152         {
153             Marshal.FreeHGlobal(info);
154         }
155     }
156     /// <summary>If <c>true</c> will notify <see cref="Efl.Io.IWriter.Write"/> can be called without blocking or failing.
157     /// (Since EFL 1.22)</summary>
158     /// <returns><c>true</c> if it can be written without blocking or failure, <c>false</c> otherwise</returns>
159     public bool GetCanWrite() {
160          var _ret_var = Efl.Io.IWriterConcrete.NativeMethods.efl_io_writer_can_write_get_ptr.Value.Delegate(this.NativeHandle);
161         Eina.Error.RaiseIfUnhandledException();
162         return _ret_var;
163  }
164     /// <summary>If <c>true</c> will notify <see cref="Efl.Io.IWriter.Write"/> can be called without blocking or failing.
165     /// (Since EFL 1.22)</summary>
166     /// <param name="can_write"><c>true</c> if it can be written without blocking or failure, <c>false</c> otherwise</param>
167     public void SetCanWrite(bool can_write) {
168                                  Efl.Io.IWriterConcrete.NativeMethods.efl_io_writer_can_write_set_ptr.Value.Delegate(this.NativeHandle,can_write);
169         Eina.Error.RaiseIfUnhandledException();
170                          }
171     /// <summary>Writes data from a pre-populated buffer.
172     /// This operation will be executed immediately and may or may not block the caller thread for some time. The details of blocking behavior is defined by the implementation and may be subject to other parameters such as non-blocking flags, maximum timeout or even retry attempts.
173     /// 
174     /// You can understand this method as write(2) libc function.
175     /// (Since EFL 1.22)</summary>
176     /// <param name="slice">Provides a pre-populated memory to be used up to slice.len. The returned slice will be adapted as length will be set to the actually used amount of bytes, which can be smaller than the request.</param>
177     /// <param name="remaining">Convenience to output the remaining parts of slice that was not written. If the full slice was written, this will be a slice of zero-length.</param>
178     /// <returns>0 on succeed, a mapping of errno otherwise</returns>
179     public Eina.Error Write(ref Eina.Slice slice, ref Eina.Slice remaining) {
180                                                          var _ret_var = Efl.Io.IWriterConcrete.NativeMethods.efl_io_writer_write_ptr.Value.Delegate(this.NativeHandle,ref slice, ref remaining);
181         Eina.Error.RaiseIfUnhandledException();
182                                         return _ret_var;
183  }
184     /// <summary>If <c>true</c> will notify <see cref="Efl.Io.IWriter.Write"/> can be called without blocking or failing.
185     /// (Since EFL 1.22)</summary>
186     /// <value><c>true</c> if it can be written without blocking or failure, <c>false</c> otherwise</value>
187     public bool CanWrite {
188         get { return GetCanWrite(); }
189         set { SetCanWrite(value); }
190     }
191     private static IntPtr GetEflClassStatic()
192     {
193         return Efl.Io.IWriterConcrete.efl_io_writer_interface_get();
194     }
195     /// <summary>Wrapper for native methods and virtual method delegates.
196     /// For internal use by generated code only.</summary>
197     public class NativeMethods  : Efl.Eo.NativeClass
198     {
199         private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule(    efl.Libs.Efl);
200         /// <summary>Gets the list of Eo operations to override.</summary>
201         /// <returns>The list of Eo operations to be overload.</returns>
202         public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
203         {
204             var descs = new System.Collections.Generic.List<Efl_Op_Description>();
205             var methods = Efl.Eo.Globals.GetUserMethods(type);
206
207             if (efl_io_writer_can_write_get_static_delegate == null)
208             {
209                 efl_io_writer_can_write_get_static_delegate = new efl_io_writer_can_write_get_delegate(can_write_get);
210             }
211
212             if (methods.FirstOrDefault(m => m.Name == "GetCanWrite") != null)
213             {
214                 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_io_writer_can_write_get"), func = Marshal.GetFunctionPointerForDelegate(efl_io_writer_can_write_get_static_delegate) });
215             }
216
217             if (efl_io_writer_can_write_set_static_delegate == null)
218             {
219                 efl_io_writer_can_write_set_static_delegate = new efl_io_writer_can_write_set_delegate(can_write_set);
220             }
221
222             if (methods.FirstOrDefault(m => m.Name == "SetCanWrite") != null)
223             {
224                 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_io_writer_can_write_set"), func = Marshal.GetFunctionPointerForDelegate(efl_io_writer_can_write_set_static_delegate) });
225             }
226
227             if (efl_io_writer_write_static_delegate == null)
228             {
229                 efl_io_writer_write_static_delegate = new efl_io_writer_write_delegate(write);
230             }
231
232             if (methods.FirstOrDefault(m => m.Name == "Write") != null)
233             {
234                 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_io_writer_write"), func = Marshal.GetFunctionPointerForDelegate(efl_io_writer_write_static_delegate) });
235             }
236
237             return descs;
238         }
239         /// <summary>Returns the Eo class for the native methods of this class.</summary>
240         /// <returns>The native class pointer.</returns>
241         public override IntPtr GetEflClass()
242         {
243             return Efl.Io.IWriterConcrete.efl_io_writer_interface_get();
244         }
245
246         #pragma warning disable CA1707, CS1591, SA1300, SA1600
247
248         [return: MarshalAs(UnmanagedType.U1)]
249         private delegate bool efl_io_writer_can_write_get_delegate(System.IntPtr obj, System.IntPtr pd);
250
251         [return: MarshalAs(UnmanagedType.U1)]
252         public delegate bool efl_io_writer_can_write_get_api_delegate(System.IntPtr obj);
253
254         public static Efl.Eo.FunctionWrapper<efl_io_writer_can_write_get_api_delegate> efl_io_writer_can_write_get_ptr = new Efl.Eo.FunctionWrapper<efl_io_writer_can_write_get_api_delegate>(Module, "efl_io_writer_can_write_get");
255
256         private static bool can_write_get(System.IntPtr obj, System.IntPtr pd)
257         {
258             Eina.Log.Debug("function efl_io_writer_can_write_get was called");
259             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
260             if (ws != null)
261             {
262             bool _ret_var = default(bool);
263                 try
264                 {
265                     _ret_var = ((IWriter)ws.Target).GetCanWrite();
266                 }
267                 catch (Exception e)
268                 {
269                     Eina.Log.Warning($"Callback error: {e.ToString()}");
270                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
271                 }
272
273         return _ret_var;
274
275             }
276             else
277             {
278                 return efl_io_writer_can_write_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
279             }
280         }
281
282         private static efl_io_writer_can_write_get_delegate efl_io_writer_can_write_get_static_delegate;
283
284         
285         private delegate void efl_io_writer_can_write_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.U1)] bool can_write);
286
287         
288         public delegate void efl_io_writer_can_write_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.U1)] bool can_write);
289
290         public static Efl.Eo.FunctionWrapper<efl_io_writer_can_write_set_api_delegate> efl_io_writer_can_write_set_ptr = new Efl.Eo.FunctionWrapper<efl_io_writer_can_write_set_api_delegate>(Module, "efl_io_writer_can_write_set");
291
292         private static void can_write_set(System.IntPtr obj, System.IntPtr pd, bool can_write)
293         {
294             Eina.Log.Debug("function efl_io_writer_can_write_set was called");
295             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
296             if (ws != null)
297             {
298                                     
299                 try
300                 {
301                     ((IWriter)ws.Target).SetCanWrite(can_write);
302                 }
303                 catch (Exception e)
304                 {
305                     Eina.Log.Warning($"Callback error: {e.ToString()}");
306                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
307                 }
308
309                         
310             }
311             else
312             {
313                 efl_io_writer_can_write_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), can_write);
314             }
315         }
316
317         private static efl_io_writer_can_write_set_delegate efl_io_writer_can_write_set_static_delegate;
318
319         
320         private delegate Eina.Error efl_io_writer_write_delegate(System.IntPtr obj, System.IntPtr pd,  ref Eina.Slice slice,  ref Eina.Slice remaining);
321
322         
323         public delegate Eina.Error efl_io_writer_write_api_delegate(System.IntPtr obj,  ref Eina.Slice slice,  ref Eina.Slice remaining);
324
325         public static Efl.Eo.FunctionWrapper<efl_io_writer_write_api_delegate> efl_io_writer_write_ptr = new Efl.Eo.FunctionWrapper<efl_io_writer_write_api_delegate>(Module, "efl_io_writer_write");
326
327         private static Eina.Error write(System.IntPtr obj, System.IntPtr pd, ref Eina.Slice slice, ref Eina.Slice remaining)
328         {
329             Eina.Log.Debug("function efl_io_writer_write was called");
330             var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
331             if (ws != null)
332             {
333                                 remaining = default(Eina.Slice);                            Eina.Error _ret_var = default(Eina.Error);
334                 try
335                 {
336                     _ret_var = ((IWriter)ws.Target).Write(ref slice, ref remaining);
337                 }
338                 catch (Exception e)
339                 {
340                     Eina.Log.Warning($"Callback error: {e.ToString()}");
341                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
342                 }
343
344                                         return _ret_var;
345
346             }
347             else
348             {
349                 return efl_io_writer_write_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), ref slice, ref remaining);
350             }
351         }
352
353         private static efl_io_writer_write_delegate efl_io_writer_write_static_delegate;
354
355         #pragma warning restore CA1707, CS1591, SA1300, SA1600
356
357 }
358 }
359 }
360
361 }
362