1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>An interface for duplication of objects.
11 /// Objects implementing this interface can be duplicated with <see cref="Efl.IDuplicate.Duplicate"/>.</summary>
12 [Efl.IDuplicateConcrete.NativeMethods]
13 public interface IDuplicate :
14 Efl.Eo.IWrapper, IDisposable
16 /// <summary>Creates a carbon copy of this object and returns it.
17 /// The newly created object will have no event handlers or anything of the sort.</summary>
18 /// <returns>Returned carbon copy</returns>
19 Efl.IDuplicate Duplicate();
21 /// <summary>An interface for duplication of objects.
22 /// Objects implementing this interface can be duplicated with <see cref="Efl.IDuplicate.Duplicate"/>.</summary>
23 sealed public class IDuplicateConcrete :
28 ///<summary>Pointer to the native class description.</summary>
29 public System.IntPtr NativeClass
33 if (((object)this).GetType() == typeof(IDuplicateConcrete))
35 return GetEflClassStatic();
39 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
44 private System.IntPtr handle;
45 ///<summary>Pointer to the native instance.</summary>
46 public System.IntPtr NativeHandle
48 get { return handle; }
51 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
52 efl_duplicate_interface_get();
53 /// <summary>Initializes a new instance of the <see cref="IDuplicate"/> class.
54 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
55 private IDuplicateConcrete(System.IntPtr raw)
59 ///<summary>Destructor.</summary>
65 ///<summary>Releases the underlying native instance.</summary>
66 private void Dispose(bool disposing)
68 if (handle != System.IntPtr.Zero)
73 IntPtr gcHandlePtr = IntPtr.Zero;
76 Efl.Eo.Globals.efl_mono_native_dispose(h, gcHandlePtr);
80 Monitor.Enter(Efl.All.InitLock);
81 if (Efl.All.MainLoopInitialized)
83 Efl.Eo.Globals.efl_mono_thread_safe_native_dispose(h, gcHandlePtr);
86 Monitor.Exit(Efl.All.InitLock);
92 ///<summary>Releases the underlying native instance.</summary>
96 GC.SuppressFinalize(this);
99 /// <summary>Verifies if the given object is equal to this one.</summary>
100 /// <param name="instance">The object to compare to.</param>
101 /// <returns>True if both objects point to the same native object.</returns>
102 public override bool Equals(object instance)
104 var other = instance as Efl.Object;
109 return this.NativeHandle == other.NativeHandle;
112 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
113 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
114 public override int GetHashCode()
116 return this.NativeHandle.ToInt32();
119 /// <summary>Turns the native pointer into a string representation.</summary>
120 /// <returns>A string with the type and the native pointer for this object.</returns>
121 public override String ToString()
123 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
126 /// <summary>Creates a carbon copy of this object and returns it.
127 /// The newly created object will have no event handlers or anything of the sort.</summary>
128 /// <returns>Returned carbon copy</returns>
129 public Efl.IDuplicate Duplicate() {
130 var _ret_var = Efl.IDuplicateConcrete.NativeMethods.efl_duplicate_ptr.Value.Delegate(this.NativeHandle);
131 Eina.Error.RaiseIfUnhandledException();
134 private static IntPtr GetEflClassStatic()
136 return Efl.IDuplicateConcrete.efl_duplicate_interface_get();
138 /// <summary>Wrapper for native methods and virtual method delegates.
139 /// For internal use by generated code only.</summary>
140 public class NativeMethods : Efl.Eo.NativeClass
142 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
143 /// <summary>Gets the list of Eo operations to override.</summary>
144 /// <returns>The list of Eo operations to be overload.</returns>
145 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
147 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
148 var methods = Efl.Eo.Globals.GetUserMethods(type);
150 if (efl_duplicate_static_delegate == null)
152 efl_duplicate_static_delegate = new efl_duplicate_delegate(duplicate);
155 if (methods.FirstOrDefault(m => m.Name == "Duplicate") != null)
157 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_duplicate"), func = Marshal.GetFunctionPointerForDelegate(efl_duplicate_static_delegate) });
162 /// <summary>Returns the Eo class for the native methods of this class.</summary>
163 /// <returns>The native class pointer.</returns>
164 public override IntPtr GetEflClass()
166 return Efl.IDuplicateConcrete.efl_duplicate_interface_get();
169 #pragma warning disable CA1707, SA1300, SA1600
171 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.OwnTag>))]
172 private delegate Efl.IDuplicate efl_duplicate_delegate(System.IntPtr obj, System.IntPtr pd);
174 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.OwnTag>))]
175 public delegate Efl.IDuplicate efl_duplicate_api_delegate(System.IntPtr obj);
177 public static Efl.Eo.FunctionWrapper<efl_duplicate_api_delegate> efl_duplicate_ptr = new Efl.Eo.FunctionWrapper<efl_duplicate_api_delegate>(Module, "efl_duplicate");
179 private static Efl.IDuplicate duplicate(System.IntPtr obj, System.IntPtr pd)
181 Eina.Log.Debug("function efl_duplicate was called");
182 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
185 Efl.IDuplicate _ret_var = default(Efl.IDuplicate);
188 _ret_var = ((IDuplicate)wrapper).Duplicate();
192 Eina.Log.Warning($"Callback error: {e.ToString()}");
193 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
201 return efl_duplicate_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
205 private static efl_duplicate_delegate efl_duplicate_static_delegate;
207 #pragma warning restore CA1707, SA1300, SA1600