76c5db78f4ad73e01536636316556c1fde9429e3
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / efl / efl_loop_message_future_handler.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 ///<summary>Event argument wrapper for event <see cref="Efl.LoopMessageFutureHandler.MessageFutureEvt"/>.</summary>
11 public class LoopMessageFutureHandlerMessageFutureEvt_Args : EventArgs {
12     ///<summary>Actual event payload.</summary>
13     public Efl.LoopMessageFuture arg { get; set; }
14 }
15 /// <summary>Internal use for future on an efl loop - replacing legacy ecore events</summary>
16 [Efl.LoopMessageFutureHandler.NativeMethods]
17 public class LoopMessageFutureHandler : Efl.LoopMessageHandler, Efl.Eo.IWrapper
18 {
19     ///<summary>Pointer to the native class description.</summary>
20     public override System.IntPtr NativeClass
21     {
22         get
23         {
24             if (((object)this).GetType() == typeof(LoopMessageFutureHandler))
25             {
26                 return GetEflClassStatic();
27             }
28             else
29             {
30                 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
31             }
32         }
33     }
34
35     [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
36         efl_loop_message_future_handler_class_get();
37     /// <summary>Initializes a new instance of the <see cref="LoopMessageFutureHandler"/> class.</summary>
38     /// <param name="parent">Parent instance.</param>
39     public LoopMessageFutureHandler(Efl.Object parent= null
40             ) : base(efl_loop_message_future_handler_class_get(), typeof(LoopMessageFutureHandler), parent)
41     {
42         FinishInstantiation();
43     }
44
45     /// <summary>Initializes a new instance of the <see cref="LoopMessageFutureHandler"/> class.
46     /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
47     /// <param name="raw">The native pointer to be wrapped.</param>
48     protected LoopMessageFutureHandler(System.IntPtr raw) : base(raw)
49     {
50             }
51
52     /// <summary>Initializes a new instance of the <see cref="LoopMessageFutureHandler"/> class.
53     /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
54     /// <param name="baseKlass">The pointer to the base native Eo class.</param>
55     /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
56     /// <param name="parent">The Efl.Object parent of this instance.</param>
57     protected LoopMessageFutureHandler(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)
58     {
59     }
60
61     /// <summary>Verifies if the given object is equal to this one.</summary>
62     /// <param name="instance">The object to compare to.</param>
63     /// <returns>True if both objects point to the same native object.</returns>
64     public override bool Equals(object instance)
65     {
66         var other = instance as Efl.Object;
67         if (other == null)
68         {
69             return false;
70         }
71         return this.NativeHandle == other.NativeHandle;
72     }
73
74     /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
75     /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
76     public override int GetHashCode()
77     {
78         return this.NativeHandle.ToInt32();
79     }
80
81     /// <summary>Turns the native pointer into a string representation.</summary>
82     /// <returns>A string with the type and the native pointer for this object.</returns>
83     public override String ToString()
84     {
85         return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
86     }
87
88     /// <summary>No description supplied.</summary>
89     public event EventHandler<Efl.LoopMessageFutureHandlerMessageFutureEvt_Args> MessageFutureEvt
90     {
91         add
92         {
93             lock (eventLock)
94             {
95                 var wRef = new WeakReference(this);
96                 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
97                 {
98                     var obj = wRef.Target as Efl.Eo.IWrapper;
99                     if (obj != null)
100                     {
101                                                 Efl.LoopMessageFutureHandlerMessageFutureEvt_Args args = new Efl.LoopMessageFutureHandlerMessageFutureEvt_Args();
102                         args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.LoopMessageFuture);
103                         try
104                         {
105                             value?.Invoke(obj, args);
106                         }
107                         catch (Exception e)
108                         {
109                             Eina.Log.Error(e.ToString());
110                             Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
111                         }
112                     }
113                 };
114
115                 string key = "_EFL_LOOP_MESSAGE_FUTURE_HANDLER_EVENT_MESSAGE_FUTURE";
116                 AddNativeEventHandler(efl.Libs.Ecore, key, callerCb, value);
117             }
118         }
119
120         remove
121         {
122             lock (eventLock)
123             {
124                 string key = "_EFL_LOOP_MESSAGE_FUTURE_HANDLER_EVENT_MESSAGE_FUTURE";
125                 RemoveNativeEventHandler(efl.Libs.Ecore, key, value);
126             }
127         }
128     }
129     ///<summary>Method to raise event MessageFutureEvt.</summary>
130     public void OnMessageFutureEvt(Efl.LoopMessageFutureHandlerMessageFutureEvt_Args e)
131     {
132         var key = "_EFL_LOOP_MESSAGE_FUTURE_HANDLER_EVENT_MESSAGE_FUTURE";
133         IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Ecore, key);
134         if (desc == IntPtr.Zero)
135         {
136             Eina.Log.Error($"Failed to get native event {key}");
137             return;
138         }
139
140         IntPtr info = e.arg.NativeHandle;
141         Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
142     }
143     /// <summary>No description supplied.</summary>
144     /// <returns>No description supplied.</returns>
145     virtual public Efl.LoopMessageFuture AddMessageType() {
146          var _ret_var = Efl.LoopMessageFutureHandler.NativeMethods.efl_loop_message_future_handler_message_type_add_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
147         Eina.Error.RaiseIfUnhandledException();
148         return _ret_var;
149  }
150     private static IntPtr GetEflClassStatic()
151     {
152         return Efl.LoopMessageFutureHandler.efl_loop_message_future_handler_class_get();
153     }
154     /// <summary>Wrapper for native methods and virtual method delegates.
155     /// For internal use by generated code only.</summary>
156     public new class NativeMethods : Efl.LoopMessageHandler.NativeMethods
157     {
158         private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule(    efl.Libs.Ecore);
159         /// <summary>Gets the list of Eo operations to override.</summary>
160         /// <returns>The list of Eo operations to be overload.</returns>
161         public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
162         {
163             var descs = new System.Collections.Generic.List<Efl_Op_Description>();
164             var methods = Efl.Eo.Globals.GetUserMethods(type);
165
166             if (efl_loop_message_future_handler_message_type_add_static_delegate == null)
167             {
168                 efl_loop_message_future_handler_message_type_add_static_delegate = new efl_loop_message_future_handler_message_type_add_delegate(message_type_add);
169             }
170
171             if (methods.FirstOrDefault(m => m.Name == "AddMessageType") != null)
172             {
173                 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_loop_message_future_handler_message_type_add"), func = Marshal.GetFunctionPointerForDelegate(efl_loop_message_future_handler_message_type_add_static_delegate) });
174             }
175
176             descs.AddRange(base.GetEoOps(type));
177             return descs;
178         }
179         /// <summary>Returns the Eo class for the native methods of this class.</summary>
180         /// <returns>The native class pointer.</returns>
181         public override IntPtr GetEflClass()
182         {
183             return Efl.LoopMessageFutureHandler.efl_loop_message_future_handler_class_get();
184         }
185
186         #pragma warning disable CA1707, SA1300, SA1600
187
188         [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
189         private delegate Efl.LoopMessageFuture efl_loop_message_future_handler_message_type_add_delegate(System.IntPtr obj, System.IntPtr pd);
190
191         [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))]
192         public delegate Efl.LoopMessageFuture efl_loop_message_future_handler_message_type_add_api_delegate(System.IntPtr obj);
193
194         public static Efl.Eo.FunctionWrapper<efl_loop_message_future_handler_message_type_add_api_delegate> efl_loop_message_future_handler_message_type_add_ptr = new Efl.Eo.FunctionWrapper<efl_loop_message_future_handler_message_type_add_api_delegate>(Module, "efl_loop_message_future_handler_message_type_add");
195
196         private static Efl.LoopMessageFuture message_type_add(System.IntPtr obj, System.IntPtr pd)
197         {
198             Eina.Log.Debug("function efl_loop_message_future_handler_message_type_add was called");
199             Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
200             if (wrapper != null)
201             {
202             Efl.LoopMessageFuture _ret_var = default(Efl.LoopMessageFuture);
203                 try
204                 {
205                     _ret_var = ((LoopMessageFutureHandler)wrapper).AddMessageType();
206                 }
207                 catch (Exception e)
208                 {
209                     Eina.Log.Warning($"Callback error: {e.ToString()}");
210                     Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
211                 }
212
213         return _ret_var;
214
215             }
216             else
217             {
218                 return efl_loop_message_future_handler_message_type_add_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
219             }
220         }
221
222         private static efl_loop_message_future_handler_message_type_add_delegate efl_loop_message_future_handler_message_type_add_static_delegate;
223
224         #pragma warning restore CA1707, SA1300, SA1600
225
226 }
227 }
228 }
229