[EflSharp] Introduce EflSharp project (#749)
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl_io_positioner.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 { namespace Io { 
8 /// <summary>Generic interface for objects that can change or report position.
9 /// 1.19</summary>
10 [PositionerNativeInherit]
11 public interface Positioner : 
12    Efl.Eo.IWrapper, IDisposable
13 {
14    /// <summary>Position property
15 /// 1.19</summary>
16 /// <returns>Position in file or buffer
17 /// 1.19</returns>
18  ulong GetPosition();
19    /// <summary>Try to set position object, relative to start of file. See <see cref="Efl.Io.Positioner.Seek"/>
20 /// 1.19</summary>
21 /// <param name="position">Position in file or buffer
22 /// 1.19</param>
23 /// <returns><c>true</c> if could reposition, <c>false</c> if errors.
24 /// 1.19</returns>
25 bool SetPosition(  ulong position);
26    /// <summary>Seek in data
27 /// 1.19</summary>
28 /// <param name="offset">Offset in byte relative to whence
29 /// 1.19</param>
30 /// <param name="whence">Whence
31 /// 1.19</param>
32 /// <returns>0 on succeed, a mapping of errno otherwise
33 /// 1.19</returns>
34  Eina.Error Seek(  long offset,  Efl.Io.PositionerWhence whence);
35             /// <summary>Notifies position changed
36    /// 1.19</summary>
37    event EventHandler PositionChangedEvt;
38    /// <summary>Position property
39 /// 1.19</summary>
40 /// <value>Position in file or buffer
41 /// 1.19</value>
42     ulong Position {
43       get ;
44       set ;
45    }
46 }
47 /// <summary>Generic interface for objects that can change or report position.
48 /// 1.19</summary>
49 sealed public class PositionerConcrete : 
50
51 Positioner
52    
53 {
54    ///<summary>Pointer to the native class description.</summary>
55    public System.IntPtr NativeClass {
56       get {
57          if (((object)this).GetType() == typeof (PositionerConcrete))
58             return Efl.Io.PositionerNativeInherit.GetEflClassStatic();
59          else
60             return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
61       }
62    }
63    private EventHandlerList eventHandlers = new EventHandlerList();
64    private  System.IntPtr handle;
65    ///<summary>Pointer to the native instance.</summary>
66    public System.IntPtr NativeHandle {
67       get { return handle; }
68    }
69    [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
70       efl_io_positioner_mixin_get();
71    ///<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>
72    public PositionerConcrete(System.IntPtr raw)
73    {
74       handle = raw;
75       register_event_proxies();
76    }
77    ///<summary>Destructor.</summary>
78    ~PositionerConcrete()
79    {
80       Dispose(false);
81    }
82    ///<summary>Releases the underlying native instance.</summary>
83    void Dispose(bool disposing)
84    {
85       if (handle != System.IntPtr.Zero) {
86          Efl.Eo.Globals.efl_unref(handle);
87          handle = System.IntPtr.Zero;
88       }
89    }
90    ///<summary>Releases the underlying native instance.</summary>
91    public void Dispose()
92    {
93       Dispose(true);
94       GC.SuppressFinalize(this);
95    }
96    ///<summary>Casts obj into an instance of this type.</summary>
97    public static PositionerConcrete static_cast(Efl.Object obj)
98    {
99       if (obj == null)
100          throw new System.ArgumentNullException("obj");
101       return new PositionerConcrete(obj.NativeHandle);
102    }
103    ///<summary>Verifies if the given object is equal to this one.</summary>
104    public override bool Equals(object obj)
105    {
106       var other = obj as Efl.Object;
107       if (other == null)
108          return false;
109       return this.NativeHandle == other.NativeHandle;
110    }
111    ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
112    public override int GetHashCode()
113    {
114       return this.NativeHandle.ToInt32();
115    }
116    ///<summary>Turns the native pointer into a string representation.</summary>
117    public override String ToString()
118    {
119       return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
120    }
121    private readonly object eventLock = new object();
122    private Dictionary<string, int> event_cb_count = new Dictionary<string, int>();
123    private bool add_cpp_event_handler(string lib, string key, Efl.EventCb evt_delegate) {
124       int event_count = 0;
125       if (!event_cb_count.TryGetValue(key, out event_count))
126          event_cb_count[key] = event_count;
127       if (event_count == 0) {
128          IntPtr desc = Efl.EventDescription.GetNative(lib, key);
129          if (desc == IntPtr.Zero) {
130             Eina.Log.Error($"Failed to get native event {key}");
131             return false;
132          }
133           bool result = Efl.Eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);
134          if (!result) {
135             Eina.Log.Error($"Failed to add event proxy for event {key}");
136             return false;
137          }
138          Eina.Error.RaiseIfUnhandledException();
139       } 
140       event_cb_count[key]++;
141       return true;
142    }
143    private bool remove_cpp_event_handler(string key, Efl.EventCb evt_delegate) {
144       int event_count = 0;
145       if (!event_cb_count.TryGetValue(key, out event_count))
146          event_cb_count[key] = event_count;
147       if (event_count == 1) {
148          IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
149          if (desc == IntPtr.Zero) {
150             Eina.Log.Error($"Failed to get native event {key}");
151             return false;
152          }
153          bool result = Efl.Eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);
154          if (!result) {
155             Eina.Log.Error($"Failed to remove event proxy for event {key}");
156             return false;
157          }
158          Eina.Error.RaiseIfUnhandledException();
159       } else if (event_count == 0) {
160          Eina.Log.Error($"Trying to remove proxy for event {key} when there is nothing registered.");
161          return false;
162       } 
163       event_cb_count[key]--;
164       return true;
165    }
166 private static object PositionChangedEvtKey = new object();
167    /// <summary>Notifies position changed
168    /// 1.19</summary>
169    public event EventHandler PositionChangedEvt
170    {
171       add {
172          lock (eventLock) {
173             string key = "_EFL_IO_POSITIONER_EVENT_POSITION_CHANGED";
174             if (add_cpp_event_handler(efl.Libs.Efl, key, this.evt_PositionChangedEvt_delegate)) {
175                eventHandlers.AddHandler(PositionChangedEvtKey , value);
176             } else
177                Eina.Log.Error($"Error adding proxy for event {key}");
178          }
179       }
180       remove {
181          lock (eventLock) {
182             string key = "_EFL_IO_POSITIONER_EVENT_POSITION_CHANGED";
183             if (remove_cpp_event_handler(key, this.evt_PositionChangedEvt_delegate)) { 
184                eventHandlers.RemoveHandler(PositionChangedEvtKey , value);
185             } else
186                Eina.Log.Error($"Error removing proxy for event {key}");
187          }
188       }
189    }
190    ///<summary>Method to raise event PositionChangedEvt.</summary>
191    public void On_PositionChangedEvt(EventArgs e)
192    {
193       EventHandler evt;
194       lock (eventLock) {
195       evt = (EventHandler)eventHandlers[PositionChangedEvtKey];
196       }
197       evt?.Invoke(this, e);
198    }
199    Efl.EventCb evt_PositionChangedEvt_delegate;
200    private void on_PositionChangedEvt_NativeCallback(System.IntPtr data, ref Efl.Event_StructInternal evt)
201    {
202       EventArgs args = EventArgs.Empty;
203       try {
204          On_PositionChangedEvt(args);
205       } catch (Exception e) {
206          Eina.Log.Error(e.ToString());
207          Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
208       }
209    }
210
211     void register_event_proxies()
212    {
213       evt_PositionChangedEvt_delegate = new Efl.EventCb(on_PositionChangedEvt_NativeCallback);
214    }
215    /// <summary>Position property
216    /// 1.19</summary>
217    /// <returns>Position in file or buffer
218    /// 1.19</returns>
219    public  ulong GetPosition() {
220        var _ret_var = Efl.Io.PositionerNativeInherit.efl_io_positioner_position_get_ptr.Value.Delegate(this.NativeHandle);
221       Eina.Error.RaiseIfUnhandledException();
222       return _ret_var;
223  }
224    /// <summary>Try to set position object, relative to start of file. See <see cref="Efl.Io.Positioner.Seek"/>
225    /// 1.19</summary>
226    /// <param name="position">Position in file or buffer
227    /// 1.19</param>
228    /// <returns><c>true</c> if could reposition, <c>false</c> if errors.
229    /// 1.19</returns>
230    public bool SetPosition(  ulong position) {
231                          var _ret_var = Efl.Io.PositionerNativeInherit.efl_io_positioner_position_set_ptr.Value.Delegate(this.NativeHandle, position);
232       Eina.Error.RaiseIfUnhandledException();
233                   return _ret_var;
234  }
235    /// <summary>Seek in data
236    /// 1.19</summary>
237    /// <param name="offset">Offset in byte relative to whence
238    /// 1.19</param>
239    /// <param name="whence">Whence
240    /// 1.19</param>
241    /// <returns>0 on succeed, a mapping of errno otherwise
242    /// 1.19</returns>
243    public  Eina.Error Seek(  long offset,  Efl.Io.PositionerWhence whence) {
244                                            var _ret_var = Efl.Io.PositionerNativeInherit.efl_io_positioner_seek_ptr.Value.Delegate(this.NativeHandle, offset,  whence);
245       Eina.Error.RaiseIfUnhandledException();
246                               return _ret_var;
247  }
248    /// <summary>Position property
249 /// 1.19</summary>
250 /// <value>Position in file or buffer
251 /// 1.19</value>
252    public  ulong Position {
253       get { return GetPosition(); }
254       set { SetPosition( value); }
255    }
256 }
257 public class PositionerNativeInherit  : Efl.Eo.NativeClass{
258    public  static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
259    public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
260    {
261       var descs = new System.Collections.Generic.List<Efl_Op_Description>();
262       if (efl_io_positioner_position_get_static_delegate == null)
263       efl_io_positioner_position_get_static_delegate = new efl_io_positioner_position_get_delegate(position_get);
264       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_io_positioner_position_get"), func = Marshal.GetFunctionPointerForDelegate(efl_io_positioner_position_get_static_delegate)});
265       if (efl_io_positioner_position_set_static_delegate == null)
266       efl_io_positioner_position_set_static_delegate = new efl_io_positioner_position_set_delegate(position_set);
267       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_io_positioner_position_set"), func = Marshal.GetFunctionPointerForDelegate(efl_io_positioner_position_set_static_delegate)});
268       if (efl_io_positioner_seek_static_delegate == null)
269       efl_io_positioner_seek_static_delegate = new efl_io_positioner_seek_delegate(seek);
270       descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_io_positioner_seek"), func = Marshal.GetFunctionPointerForDelegate(efl_io_positioner_seek_static_delegate)});
271       return descs;
272    }
273    public override IntPtr GetEflClass()
274    {
275       return Efl.Io.PositionerConcrete.efl_io_positioner_mixin_get();
276    }
277    public static  IntPtr GetEflClassStatic()
278    {
279       return Efl.Io.PositionerConcrete.efl_io_positioner_mixin_get();
280    }
281
282
283     private delegate  ulong efl_io_positioner_position_get_delegate(System.IntPtr obj, System.IntPtr pd);
284
285
286     public delegate  ulong efl_io_positioner_position_get_api_delegate(System.IntPtr obj);
287     public static Efl.Eo.FunctionWrapper<efl_io_positioner_position_get_api_delegate> efl_io_positioner_position_get_ptr = new Efl.Eo.FunctionWrapper<efl_io_positioner_position_get_api_delegate>(_Module, "efl_io_positioner_position_get");
288     private static  ulong position_get(System.IntPtr obj, System.IntPtr pd)
289    {
290       Eina.Log.Debug("function efl_io_positioner_position_get was called");
291       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
292       if(wrapper != null) {
293                    ulong _ret_var = default( ulong);
294          try {
295             _ret_var = ((PositionerConcrete)wrapper).GetPosition();
296          } catch (Exception e) {
297             Eina.Log.Warning($"Callback error: {e.ToString()}");
298             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
299          }
300       return _ret_var;
301       } else {
302          return efl_io_positioner_position_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
303       }
304    }
305    private static efl_io_positioner_position_get_delegate efl_io_positioner_position_get_static_delegate;
306
307
308     [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_io_positioner_position_set_delegate(System.IntPtr obj, System.IntPtr pd,    ulong position);
309
310
311     [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_io_positioner_position_set_api_delegate(System.IntPtr obj,    ulong position);
312     public static Efl.Eo.FunctionWrapper<efl_io_positioner_position_set_api_delegate> efl_io_positioner_position_set_ptr = new Efl.Eo.FunctionWrapper<efl_io_positioner_position_set_api_delegate>(_Module, "efl_io_positioner_position_set");
313     private static bool position_set(System.IntPtr obj, System.IntPtr pd,   ulong position)
314    {
315       Eina.Log.Debug("function efl_io_positioner_position_set was called");
316       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
317       if(wrapper != null) {
318                                     bool _ret_var = default(bool);
319          try {
320             _ret_var = ((PositionerConcrete)wrapper).SetPosition( position);
321          } catch (Exception e) {
322             Eina.Log.Warning($"Callback error: {e.ToString()}");
323             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
324          }
325                   return _ret_var;
326       } else {
327          return efl_io_positioner_position_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  position);
328       }
329    }
330    private static efl_io_positioner_position_set_delegate efl_io_positioner_position_set_static_delegate;
331
332
333     private delegate  Eina.Error efl_io_positioner_seek_delegate(System.IntPtr obj, System.IntPtr pd,    long offset,   Efl.Io.PositionerWhence whence);
334
335
336     public delegate  Eina.Error efl_io_positioner_seek_api_delegate(System.IntPtr obj,    long offset,   Efl.Io.PositionerWhence whence);
337     public static Efl.Eo.FunctionWrapper<efl_io_positioner_seek_api_delegate> efl_io_positioner_seek_ptr = new Efl.Eo.FunctionWrapper<efl_io_positioner_seek_api_delegate>(_Module, "efl_io_positioner_seek");
338     private static  Eina.Error seek(System.IntPtr obj, System.IntPtr pd,   long offset,  Efl.Io.PositionerWhence whence)
339    {
340       Eina.Log.Debug("function efl_io_positioner_seek was called");
341       Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
342       if(wrapper != null) {
343                                                        Eina.Error _ret_var = default( Eina.Error);
344          try {
345             _ret_var = ((PositionerConcrete)wrapper).Seek( offset,  whence);
346          } catch (Exception e) {
347             Eina.Log.Warning($"Callback error: {e.ToString()}");
348             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
349          }
350                               return _ret_var;
351       } else {
352          return efl_io_positioner_seek_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)),  offset,  whence);
353       }
354    }
355    private static efl_io_positioner_seek_delegate efl_io_positioner_seek_static_delegate;
356 }
357 } } 
358 namespace Efl { namespace Io { 
359 /// <summary>Seek position modes</summary>
360 public enum PositionerWhence
361 {
362 /// <summary>Seek from start of the stream/file</summary>
363 Start = 0,
364 /// <summary>Seek from current position</summary>
365 Current = 1,
366 /// <summary>Seek from the end of stream/file</summary>
367 End = 2,
368 }
369 } }