1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 /// <summary>Abstract Efl class
9 /// (Since EFL 1.22)</summary>
11 public abstract class Class : Efl.Eo.IWrapper, IDisposable
13 ///<summary>Pointer to the native class description.</summary>
14 public virtual System.IntPtr NativeClass {
16 if (((object)this).GetType() == typeof (Class))
17 return Efl.ClassNativeInherit.GetEflClassStatic();
19 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
22 protected bool inherited;
23 protected System.IntPtr handle;
24 ///<summary>Pointer to the native instance.</summary>
25 public System.IntPtr NativeHandle {
26 get { return handle; }
28 [System.Runtime.InteropServices.DllImport(efl.Libs.Eo)] internal static extern System.IntPtr
29 efl_class_class_get();
30 ///<summary>Creates a new instance.</summary>
31 ///<param name="parent">Parent instance.</param>
32 public Class(Efl.Object parent= null
34 this(efl_class_class_get(), typeof(Class), parent)
36 FinishInstantiation();
38 ///<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>
39 protected Class(System.IntPtr raw)
42 RegisterEventProxies();
44 [Efl.Eo.PrivateNativeClass]
45 private class ClassRealized : Class
47 private ClassRealized(IntPtr ptr) : base(ptr)
51 protected Class(IntPtr base_klass, System.Type managed_type, Efl.Object parent)
53 inherited = ((object)this).GetType() != managed_type;
54 IntPtr actual_klass = base_klass;
56 actual_klass = Efl.Eo.ClassRegister.GetInheritKlassOrRegister(base_klass, ((object)this).GetType());
58 handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);
59 RegisterEventProxies();
62 Efl.Eo.Globals.PrivateDataSet(this);
65 protected void FinishInstantiation()
67 handle = Efl.Eo.Globals.instantiate_end(handle);
68 Eina.Error.RaiseIfUnhandledException();
70 ///<summary>Destructor.</summary>
75 ///<summary>Releases the underlying native instance.</summary>
76 protected virtual void Dispose(bool disposing)
78 if (handle != System.IntPtr.Zero) {
79 Efl.Eo.Globals.efl_unref(handle);
80 handle = System.IntPtr.Zero;
83 ///<summary>Releases the underlying native instance.</summary>
87 GC.SuppressFinalize(this);
89 ///<summary>Verifies if the given object is equal to this one.</summary>
90 public override bool Equals(object obj)
92 var other = obj as Efl.Object;
95 return this.NativeHandle == other.NativeHandle;
97 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
98 public override int GetHashCode()
100 return this.NativeHandle.ToInt32();
102 ///<summary>Turns the native pointer into a string representation.</summary>
103 public override String ToString()
105 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
107 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
108 protected virtual void RegisterEventProxies()
111 private static IntPtr GetEflClassStatic()
113 return Efl.Class.efl_class_class_get();
116 public class ClassNativeInherit : Efl.Eo.NativeClass{
117 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Eo);
118 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
120 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
121 var methods = Efl.Eo.Globals.GetUserMethods(type);
124 public override IntPtr GetEflClass()
126 return Efl.Class.efl_class_class_get();
128 public static IntPtr GetEflClassStatic()
130 return Efl.Class.efl_class_class_get();