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