#pragma warning disable CS1591
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
namespace Efl {
/// 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.
/// The object will trigger relevant events depending on what's happening.
[LoopFdNativeInherit]
public class LoopFd : Efl.LoopConsumer, Efl.Eo.IWrapper
{
///Pointer to the native class description.
public override System.IntPtr NativeClass {
get {
if (((object)this).GetType() == typeof (LoopFd))
return Efl.LoopFdNativeInherit.GetEflClassStatic();
else
return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
}
}
[System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
efl_loop_fd_class_get();
///Creates a new instance.
///Parent instance.
public LoopFd(Efl.Object parent= null
) :
base(efl_loop_fd_class_get(), typeof(LoopFd), parent)
{
FinishInstantiation();
}
///Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.
protected LoopFd(System.IntPtr raw) : base(raw)
{
RegisterEventProxies();
}
///Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.
protected LoopFd(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}
///Verifies if the given object is equal to this one.
public override bool Equals(object obj)
{
var other = obj as Efl.Object;
if (other == null)
return false;
return this.NativeHandle == other.NativeHandle;
}
///Gets the hash code for this object based on the native pointer it points to.
public override int GetHashCode()
{
return this.NativeHandle.ToInt32();
}
///Turns the native pointer into a string representation.
public override String ToString()
{
return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
}
private static object ReadEvtKey = new object();
/// Called when a read happened on the file descriptor
public event EventHandler ReadEvt
{
add {
lock (eventLock) {
string key = "_EFL_LOOP_FD_EVENT_READ";
if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_ReadEvt_delegate)) {
eventHandlers.AddHandler(ReadEvtKey , value);
} else
Eina.Log.Error($"Error adding proxy for event {key}");
}
}
remove {
lock (eventLock) {
string key = "_EFL_LOOP_FD_EVENT_READ";
if (RemoveNativeEventHandler(key, this.evt_ReadEvt_delegate)) {
eventHandlers.RemoveHandler(ReadEvtKey , value);
} else
Eina.Log.Error($"Error removing proxy for event {key}");
}
}
}
///Method to raise event ReadEvt.
public void On_ReadEvt(EventArgs e)
{
EventHandler evt;
lock (eventLock) {
evt = (EventHandler)eventHandlers[ReadEvtKey];
}
evt?.Invoke(this, e);
}
Efl.EventCb evt_ReadEvt_delegate;
private void on_ReadEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
{
EventArgs args = EventArgs.Empty;
try {
On_ReadEvt(args);
} catch (Exception e) {
Eina.Log.Error(e.ToString());
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
}
private static object WriteEvtKey = new object();
/// Called when a write happened on the file descriptor
public event EventHandler WriteEvt
{
add {
lock (eventLock) {
string key = "_EFL_LOOP_FD_EVENT_WRITE";
if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_WriteEvt_delegate)) {
eventHandlers.AddHandler(WriteEvtKey , value);
} else
Eina.Log.Error($"Error adding proxy for event {key}");
}
}
remove {
lock (eventLock) {
string key = "_EFL_LOOP_FD_EVENT_WRITE";
if (RemoveNativeEventHandler(key, this.evt_WriteEvt_delegate)) {
eventHandlers.RemoveHandler(WriteEvtKey , value);
} else
Eina.Log.Error($"Error removing proxy for event {key}");
}
}
}
///Method to raise event WriteEvt.
public void On_WriteEvt(EventArgs e)
{
EventHandler evt;
lock (eventLock) {
evt = (EventHandler)eventHandlers[WriteEvtKey];
}
evt?.Invoke(this, e);
}
Efl.EventCb evt_WriteEvt_delegate;
private void on_WriteEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
{
EventArgs args = EventArgs.Empty;
try {
On_WriteEvt(args);
} catch (Exception e) {
Eina.Log.Error(e.ToString());
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
}
private static object ErrorEvtKey = new object();
/// Called when a error occurred on the file descriptor
public event EventHandler ErrorEvt
{
add {
lock (eventLock) {
string key = "_EFL_LOOP_FD_EVENT_ERROR";
if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_ErrorEvt_delegate)) {
eventHandlers.AddHandler(ErrorEvtKey , value);
} else
Eina.Log.Error($"Error adding proxy for event {key}");
}
}
remove {
lock (eventLock) {
string key = "_EFL_LOOP_FD_EVENT_ERROR";
if (RemoveNativeEventHandler(key, this.evt_ErrorEvt_delegate)) {
eventHandlers.RemoveHandler(ErrorEvtKey , value);
} else
Eina.Log.Error($"Error removing proxy for event {key}");
}
}
}
///Method to raise event ErrorEvt.
public void On_ErrorEvt(EventArgs e)
{
EventHandler evt;
lock (eventLock) {
evt = (EventHandler)eventHandlers[ErrorEvtKey];
}
evt?.Invoke(this, e);
}
Efl.EventCb evt_ErrorEvt_delegate;
private void on_ErrorEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
{
EventArgs args = EventArgs.Empty;
try {
On_ErrorEvt(args);
} catch (Exception e) {
Eina.Log.Error(e.ToString());
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
}
///Register the Eo event wrappers making the bridge to C# events. Internal usage only.
protected override void RegisterEventProxies()
{
base.RegisterEventProxies();
evt_ReadEvt_delegate = new Efl.EventCb(on_ReadEvt_NativeCallback);
evt_WriteEvt_delegate = new Efl.EventCb(on_WriteEvt_NativeCallback);
evt_ErrorEvt_delegate = new Efl.EventCb(on_ErrorEvt_NativeCallback);
}
/// Defines which file descriptor to watch. If it is a file, use file_fd variant.
/// The file descriptor.
virtual public int GetFd() {
var _ret_var = Efl.LoopFdNativeInherit.efl_loop_fd_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
Eina.Error.RaiseIfUnhandledException();
return _ret_var;
}
/// Defines the fd to watch.
/// The file descriptor.
///
virtual public void SetFd( int fd) {
Efl.LoopFdNativeInherit.efl_loop_fd_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), fd);
Eina.Error.RaiseIfUnhandledException();
}
/// Defines which file descriptor to watch when watching a file.
/// The file descriptor.
virtual public int GetFdFile() {
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));
Eina.Error.RaiseIfUnhandledException();
return _ret_var;
}
/// Defines the fd to watch on.
/// The file descriptor.
///
virtual public void SetFdFile( int fd) {
Efl.LoopFdNativeInherit.efl_loop_fd_file_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), fd);
Eina.Error.RaiseIfUnhandledException();
}
/// Defines which file descriptor to watch. If it is a file, use file_fd variant.
/// The file descriptor.
public int Fd {
get { return GetFd(); }
set { SetFd( value); }
}
/// Defines which file descriptor to watch when watching a file.
/// The file descriptor.
public int FdFile {
get { return GetFdFile(); }
set { SetFdFile( value); }
}
private static IntPtr GetEflClassStatic()
{
return Efl.LoopFd.efl_loop_fd_class_get();
}
}
public class LoopFdNativeInherit : Efl.LoopConsumerNativeInherit{
public new static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Ecore);
public override System.Collections.Generic.List GetEoOps(System.Type type)
{
var descs = new System.Collections.Generic.List();
var methods = Efl.Eo.Globals.GetUserMethods(type);
if (efl_loop_fd_get_static_delegate == null)
efl_loop_fd_get_static_delegate = new efl_loop_fd_get_delegate(fd_get);
if (methods.FirstOrDefault(m => m.Name == "GetFd") != null)
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)});
if (efl_loop_fd_set_static_delegate == null)
efl_loop_fd_set_static_delegate = new efl_loop_fd_set_delegate(fd_set);
if (methods.FirstOrDefault(m => m.Name == "SetFd") != null)
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)});
if (efl_loop_fd_file_get_static_delegate == null)
efl_loop_fd_file_get_static_delegate = new efl_loop_fd_file_get_delegate(fd_file_get);
if (methods.FirstOrDefault(m => m.Name == "GetFdFile") != null)
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)});
if (efl_loop_fd_file_set_static_delegate == null)
efl_loop_fd_file_set_static_delegate = new efl_loop_fd_file_set_delegate(fd_file_set);
if (methods.FirstOrDefault(m => m.Name == "SetFdFile") != null)
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)});
descs.AddRange(base.GetEoOps(type));
return descs;
}
public override IntPtr GetEflClass()
{
return Efl.LoopFd.efl_loop_fd_class_get();
}
public static new IntPtr GetEflClassStatic()
{
return Efl.LoopFd.efl_loop_fd_class_get();
}
private delegate int efl_loop_fd_get_delegate(System.IntPtr obj, System.IntPtr pd);
public delegate int efl_loop_fd_get_api_delegate(System.IntPtr obj);
public static Efl.Eo.FunctionWrapper efl_loop_fd_get_ptr = new Efl.Eo.FunctionWrapper(_Module, "efl_loop_fd_get");
private static int fd_get(System.IntPtr obj, System.IntPtr pd)
{
Eina.Log.Debug("function efl_loop_fd_get was called");
Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
if(wrapper != null) {
int _ret_var = default(int);
try {
_ret_var = ((LoopFd)wrapper).GetFd();
} catch (Exception e) {
Eina.Log.Warning($"Callback error: {e.ToString()}");
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
return _ret_var;
} else {
return efl_loop_fd_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
}
}
private static efl_loop_fd_get_delegate efl_loop_fd_get_static_delegate;
private delegate void efl_loop_fd_set_delegate(System.IntPtr obj, System.IntPtr pd, int fd);
public delegate void efl_loop_fd_set_api_delegate(System.IntPtr obj, int fd);
public static Efl.Eo.FunctionWrapper efl_loop_fd_set_ptr = new Efl.Eo.FunctionWrapper(_Module, "efl_loop_fd_set");
private static void fd_set(System.IntPtr obj, System.IntPtr pd, int fd)
{
Eina.Log.Debug("function efl_loop_fd_set was called");
Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
if(wrapper != null) {
try {
((LoopFd)wrapper).SetFd( fd);
} catch (Exception e) {
Eina.Log.Warning($"Callback error: {e.ToString()}");
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
} else {
efl_loop_fd_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), fd);
}
}
private static efl_loop_fd_set_delegate efl_loop_fd_set_static_delegate;
private delegate int efl_loop_fd_file_get_delegate(System.IntPtr obj, System.IntPtr pd);
public delegate int efl_loop_fd_file_get_api_delegate(System.IntPtr obj);
public static Efl.Eo.FunctionWrapper efl_loop_fd_file_get_ptr = new Efl.Eo.FunctionWrapper(_Module, "efl_loop_fd_file_get");
private static int fd_file_get(System.IntPtr obj, System.IntPtr pd)
{
Eina.Log.Debug("function efl_loop_fd_file_get was called");
Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
if(wrapper != null) {
int _ret_var = default(int);
try {
_ret_var = ((LoopFd)wrapper).GetFdFile();
} catch (Exception e) {
Eina.Log.Warning($"Callback error: {e.ToString()}");
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
return _ret_var;
} else {
return efl_loop_fd_file_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
}
}
private static efl_loop_fd_file_get_delegate efl_loop_fd_file_get_static_delegate;
private delegate void efl_loop_fd_file_set_delegate(System.IntPtr obj, System.IntPtr pd, int fd);
public delegate void efl_loop_fd_file_set_api_delegate(System.IntPtr obj, int fd);
public static Efl.Eo.FunctionWrapper efl_loop_fd_file_set_ptr = new Efl.Eo.FunctionWrapper(_Module, "efl_loop_fd_file_set");
private static void fd_file_set(System.IntPtr obj, System.IntPtr pd, int fd)
{
Eina.Log.Debug("function efl_loop_fd_file_set was called");
Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
if(wrapper != null) {
try {
((LoopFd)wrapper).SetFdFile( fd);
} catch (Exception e) {
Eina.Log.Warning($"Callback error: {e.ToString()}");
Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
}
} else {
efl_loop_fd_file_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), fd);
}
}
private static efl_loop_fd_file_set_delegate efl_loop_fd_file_set_static_delegate;
}
}