1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 /// <summary>An interface for duplication of objects.
9 /// Objects implementing this interface can be duplicated with <see cref="Efl.IDuplicate.DoDuplicate"/>.</summary>
10 [IDuplicateNativeInherit]
11 public interface IDuplicate :
12 Efl.Eo.IWrapper, IDisposable
14 /// <summary>Creates a carbon copy of this object and returns it.
15 /// The newly created object will have no event handlers or anything of the sort.</summary>
16 /// <returns>Returned carbon copy</returns>
17 Efl.IDuplicate DoDuplicate();
19 /// <summary>An interface for duplication of objects.
20 /// Objects implementing this interface can be duplicated with <see cref="Efl.IDuplicate.DoDuplicate"/>.</summary>
21 sealed public class IDuplicateConcrete :
26 ///<summary>Pointer to the native class description.</summary>
27 public System.IntPtr NativeClass {
29 if (((object)this).GetType() == typeof (IDuplicateConcrete))
30 return Efl.IDuplicateNativeInherit.GetEflClassStatic();
32 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
35 private System.IntPtr handle;
36 ///<summary>Pointer to the native instance.</summary>
37 public System.IntPtr NativeHandle {
38 get { return handle; }
40 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
41 efl_duplicate_interface_get();
42 ///<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>
43 private IDuplicateConcrete(System.IntPtr raw)
46 RegisterEventProxies();
48 ///<summary>Destructor.</summary>
53 ///<summary>Releases the underlying native instance.</summary>
54 void Dispose(bool disposing)
56 if (handle != System.IntPtr.Zero) {
57 Efl.Eo.Globals.efl_unref(handle);
58 handle = System.IntPtr.Zero;
61 ///<summary>Releases the underlying native instance.</summary>
65 GC.SuppressFinalize(this);
67 ///<summary>Verifies if the given object is equal to this one.</summary>
68 public override bool Equals(object obj)
70 var other = obj as Efl.Object;
73 return this.NativeHandle == other.NativeHandle;
75 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
76 public override int GetHashCode()
78 return this.NativeHandle.ToInt32();
80 ///<summary>Turns the native pointer into a string representation.</summary>
81 public override String ToString()
83 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
85 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
86 void RegisterEventProxies()
89 /// <summary>Creates a carbon copy of this object and returns it.
90 /// The newly created object will have no event handlers or anything of the sort.</summary>
91 /// <returns>Returned carbon copy</returns>
92 public Efl.IDuplicate DoDuplicate() {
93 var _ret_var = Efl.IDuplicateNativeInherit.efl_duplicate_ptr.Value.Delegate(this.NativeHandle);
94 Eina.Error.RaiseIfUnhandledException();
97 private static IntPtr GetEflClassStatic()
99 return Efl.IDuplicateConcrete.efl_duplicate_interface_get();
102 public class IDuplicateNativeInherit : Efl.Eo.NativeClass{
103 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
104 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
106 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
107 var methods = Efl.Eo.Globals.GetUserMethods(type);
108 if (efl_duplicate_static_delegate == null)
109 efl_duplicate_static_delegate = new efl_duplicate_delegate(duplicate);
110 if (methods.FirstOrDefault(m => m.Name == "DoDuplicate") != null)
111 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_duplicate"), func = Marshal.GetFunctionPointerForDelegate(efl_duplicate_static_delegate)});
114 public override IntPtr GetEflClass()
116 return Efl.IDuplicateConcrete.efl_duplicate_interface_get();
118 public static IntPtr GetEflClassStatic()
120 return Efl.IDuplicateConcrete.efl_duplicate_interface_get();
124 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.IDuplicateConcrete, Efl.Eo.OwnTag>))] private delegate Efl.IDuplicate efl_duplicate_delegate(System.IntPtr obj, System.IntPtr pd);
127 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalTest<Efl.IDuplicateConcrete, Efl.Eo.OwnTag>))] public delegate Efl.IDuplicate efl_duplicate_api_delegate(System.IntPtr obj);
128 public static Efl.Eo.FunctionWrapper<efl_duplicate_api_delegate> efl_duplicate_ptr = new Efl.Eo.FunctionWrapper<efl_duplicate_api_delegate>(_Module, "efl_duplicate");
129 private static Efl.IDuplicate duplicate(System.IntPtr obj, System.IntPtr pd)
131 Eina.Log.Debug("function efl_duplicate was called");
132 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
133 if(wrapper != null) {
134 Efl.IDuplicate _ret_var = default(Efl.IDuplicate);
136 _ret_var = ((IDuplicate)wrapper).DoDuplicate();
137 } catch (Exception e) {
138 Eina.Log.Warning($"Callback error: {e.ToString()}");
139 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
143 return efl_duplicate_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
146 private static efl_duplicate_delegate efl_duplicate_static_delegate;