1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
12 /// <summary>Object factory that creates Efl.Canvas.Object objects.
13 /// Translates a given key to an object (item), to be later placed in a text for higher level usages. The translation implementation is left to be decided by the inheriting class, whether it is by treating the <c>key</c> as an image path, or a key associated with a real-path in a hashtable or something else entirely.</summary>
14 [Efl.Canvas.ITextFactoryConcrete.NativeMethods]
15 public interface ITextFactory :
16 Efl.Eo.IWrapper, IDisposable
18 /// <summary>Translates a given <c>key</c> to an item object, and returns the object. The returned object should be owned by the passed <c>object</c>.</summary>
19 /// <param name="kw_object">The parent of the created object</param>
20 /// <param name="key">Key that is associated to an item object</param>
21 Efl.Canvas.Object Create(Efl.Canvas.Object kw_object, System.String key);
23 /// <summary>Object factory that creates Efl.Canvas.Object objects.
24 /// Translates a given key to an object (item), to be later placed in a text for higher level usages. The translation implementation is left to be decided by the inheriting class, whether it is by treating the <c>key</c> as an image path, or a key associated with a real-path in a hashtable or something else entirely.</summary>
25 sealed public class ITextFactoryConcrete :
30 ///<summary>Pointer to the native class description.</summary>
31 public System.IntPtr NativeClass
35 if (((object)this).GetType() == typeof(ITextFactoryConcrete))
37 return GetEflClassStatic();
41 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
46 private System.IntPtr handle;
47 ///<summary>Pointer to the native instance.</summary>
48 public System.IntPtr NativeHandle
50 get { return handle; }
53 [System.Runtime.InteropServices.DllImport(efl.Libs.Evas)] internal static extern System.IntPtr
54 efl_canvas_text_factory_interface_get();
55 /// <summary>Initializes a new instance of the <see cref="ITextFactory"/> class.
56 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
57 private ITextFactoryConcrete(System.IntPtr raw)
61 ///<summary>Destructor.</summary>
62 ~ITextFactoryConcrete()
67 ///<summary>Releases the underlying native instance.</summary>
68 private void Dispose(bool disposing)
70 if (handle != System.IntPtr.Zero)
75 IntPtr gcHandlePtr = IntPtr.Zero;
78 Efl.Eo.Globals.efl_mono_native_dispose(h, gcHandlePtr);
82 Monitor.Enter(Efl.All.InitLock);
83 if (Efl.All.MainLoopInitialized)
85 Efl.Eo.Globals.efl_mono_thread_safe_native_dispose(h, gcHandlePtr);
88 Monitor.Exit(Efl.All.InitLock);
94 ///<summary>Releases the underlying native instance.</summary>
98 GC.SuppressFinalize(this);
101 /// <summary>Verifies if the given object is equal to this one.</summary>
102 /// <param name="instance">The object to compare to.</param>
103 /// <returns>True if both objects point to the same native object.</returns>
104 public override bool Equals(object instance)
106 var other = instance as Efl.Object;
111 return this.NativeHandle == other.NativeHandle;
114 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
115 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
116 public override int GetHashCode()
118 return this.NativeHandle.ToInt32();
121 /// <summary>Turns the native pointer into a string representation.</summary>
122 /// <returns>A string with the type and the native pointer for this object.</returns>
123 public override String ToString()
125 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
128 /// <summary>Translates a given <c>key</c> to an item object, and returns the object. The returned object should be owned by the passed <c>object</c>.</summary>
129 /// <param name="kw_object">The parent of the created object</param>
130 /// <param name="key">Key that is associated to an item object</param>
131 public Efl.Canvas.Object Create(Efl.Canvas.Object kw_object, System.String key) {
132 var _ret_var = Efl.Canvas.ITextFactoryConcrete.NativeMethods.efl_canvas_text_factory_create_ptr.Value.Delegate(this.NativeHandle,kw_object, key);
133 Eina.Error.RaiseIfUnhandledException();
136 private static IntPtr GetEflClassStatic()
138 return Efl.Canvas.ITextFactoryConcrete.efl_canvas_text_factory_interface_get();
140 /// <summary>Wrapper for native methods and virtual method delegates.
141 /// For internal use by generated code only.</summary>
142 public class NativeMethods : Efl.Eo.NativeClass
144 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Evas);
145 /// <summary>Gets the list of Eo operations to override.</summary>
146 /// <returns>The list of Eo operations to be overload.</returns>
147 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
149 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
150 var methods = Efl.Eo.Globals.GetUserMethods(type);
152 if (efl_canvas_text_factory_create_static_delegate == null)
154 efl_canvas_text_factory_create_static_delegate = new efl_canvas_text_factory_create_delegate(create);
157 if (methods.FirstOrDefault(m => m.Name == "Create") != null)
159 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_canvas_text_factory_create"), func = Marshal.GetFunctionPointerForDelegate(efl_canvas_text_factory_create_static_delegate) });
164 /// <summary>Returns the Eo class for the native methods of this class.</summary>
165 /// <returns>The native class pointer.</returns>
166 public override IntPtr GetEflClass()
168 return Efl.Canvas.ITextFactoryConcrete.efl_canvas_text_factory_interface_get();
171 #pragma warning disable CA1707, SA1300, SA1600
173 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.OwnTag>))]
174 private delegate Efl.Canvas.Object efl_canvas_text_factory_create_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.Canvas.Object kw_object, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key);
176 [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.OwnTag>))]
177 public delegate Efl.Canvas.Object efl_canvas_text_factory_create_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.Canvas.Object kw_object, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key);
179 public static Efl.Eo.FunctionWrapper<efl_canvas_text_factory_create_api_delegate> efl_canvas_text_factory_create_ptr = new Efl.Eo.FunctionWrapper<efl_canvas_text_factory_create_api_delegate>(Module, "efl_canvas_text_factory_create");
181 private static Efl.Canvas.Object create(System.IntPtr obj, System.IntPtr pd, Efl.Canvas.Object kw_object, System.String key)
183 Eina.Log.Debug("function efl_canvas_text_factory_create was called");
184 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
187 Efl.Canvas.Object _ret_var = default(Efl.Canvas.Object);
190 _ret_var = ((ITextFactory)wrapper).Create(kw_object, key);
194 Eina.Log.Warning($"Callback error: {e.ToString()}");
195 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
203 return efl_canvas_text_factory_create_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), kw_object, key);
207 private static efl_canvas_text_factory_create_delegate efl_canvas_text_factory_create_static_delegate;
209 #pragma warning restore CA1707, SA1300, SA1600