1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 /// <summary>Utility class for markup, such as conversions</summary>
9 [TextMarkupUtilNativeInherit]
10 public class TextMarkupUtil : Efl.Eo.IWrapper, IDisposable
12 ///<summary>Pointer to the native class description.</summary>
13 public virtual System.IntPtr NativeClass {
15 if (((object)this).GetType() == typeof (TextMarkupUtil))
16 return Efl.TextMarkupUtilNativeInherit.GetEflClassStatic();
18 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
21 protected bool inherited;
22 protected System.IntPtr handle;
23 ///<summary>Pointer to the native instance.</summary>
24 public System.IntPtr NativeHandle {
25 get { return handle; }
27 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
28 efl_text_markup_util_class_get();
29 ///<summary>Creates a new instance.</summary>
30 ///<param name="parent">Parent instance.</param>
31 public TextMarkupUtil(Efl.Object parent= null
33 this(efl_text_markup_util_class_get(), typeof(TextMarkupUtil), parent)
35 FinishInstantiation();
37 ///<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>
38 protected TextMarkupUtil(System.IntPtr raw)
41 RegisterEventProxies();
43 protected TextMarkupUtil(IntPtr base_klass, System.Type managed_type, Efl.Object parent)
45 inherited = ((object)this).GetType() != managed_type;
46 IntPtr actual_klass = base_klass;
48 actual_klass = Efl.Eo.ClassRegister.GetInheritKlassOrRegister(base_klass, ((object)this).GetType());
50 handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);
51 RegisterEventProxies();
54 Efl.Eo.Globals.PrivateDataSet(this);
57 protected void FinishInstantiation()
59 handle = Efl.Eo.Globals.instantiate_end(handle);
60 Eina.Error.RaiseIfUnhandledException();
62 ///<summary>Destructor.</summary>
67 ///<summary>Releases the underlying native instance.</summary>
68 protected virtual void Dispose(bool disposing)
70 if (handle != System.IntPtr.Zero) {
71 Efl.Eo.Globals.efl_unref(handle);
72 handle = System.IntPtr.Zero;
75 ///<summary>Releases the underlying native instance.</summary>
79 GC.SuppressFinalize(this);
81 ///<summary>Verifies if the given object is equal to this one.</summary>
82 public override bool Equals(object obj)
84 var other = obj as Efl.Object;
87 return this.NativeHandle == other.NativeHandle;
89 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
90 public override int GetHashCode()
92 return this.NativeHandle.ToInt32();
94 ///<summary>Turns the native pointer into a string representation.</summary>
95 public override String ToString()
97 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
99 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
100 protected virtual void RegisterEventProxies()
103 /// <summary>Converts a given (UTF-8) text to a markup-compatible string. This is used mainly to set a plain text with the $.markup_set property.</summary>
104 /// <param name="text">The text (UTF-8) to convert to markup</param>
105 /// <returns>The markup representation of given text</returns>
106 public static System.String TextToMarkup( System.String text) {
107 var _ret_var = Efl.TextMarkupUtilNativeInherit.efl_text_markup_util_text_to_markup_ptr.Value.Delegate( text);
108 Eina.Error.RaiseIfUnhandledException();
111 /// <summary>Converts a given (UTF-8) text to a markup-compatible string. This is used mainly to set a plain text with the $.markup_set property.</summary>
112 /// <param name="text">The markup-text to convert to text (UTF-8)</param>
113 /// <returns>The text representation of given format</returns>
114 public static System.String MarkupToText( System.String text) {
115 var _ret_var = Efl.TextMarkupUtilNativeInherit.efl_text_markup_util_markup_to_text_ptr.Value.Delegate( text);
116 Eina.Error.RaiseIfUnhandledException();
119 private static IntPtr GetEflClassStatic()
121 return Efl.TextMarkupUtil.efl_text_markup_util_class_get();
124 public class TextMarkupUtilNativeInherit : Efl.Eo.NativeClass{
125 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
126 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
128 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
129 var methods = Efl.Eo.Globals.GetUserMethods(type);
132 public override IntPtr GetEflClass()
134 return Efl.TextMarkupUtil.efl_text_markup_util_class_get();
136 public static IntPtr GetEflClassStatic()
138 return Efl.TextMarkupUtil.efl_text_markup_util_class_get();
142 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))] private delegate System.String efl_text_markup_util_text_to_markup_delegate( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String text);
145 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))] public delegate System.String efl_text_markup_util_text_to_markup_api_delegate( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String text);
146 public static Efl.Eo.FunctionWrapper<efl_text_markup_util_text_to_markup_api_delegate> efl_text_markup_util_text_to_markup_ptr = new Efl.Eo.FunctionWrapper<efl_text_markup_util_text_to_markup_api_delegate>(_Module, "efl_text_markup_util_text_to_markup");
147 private static System.String text_to_markup(System.IntPtr obj, System.IntPtr pd, System.String text)
149 Eina.Log.Debug("function efl_text_markup_util_text_to_markup was called");
150 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
151 if(wrapper != null) {
152 System.String _ret_var = default(System.String);
154 _ret_var = TextMarkupUtil.TextToMarkup( text);
155 } catch (Exception e) {
156 Eina.Log.Warning($"Callback error: {e.ToString()}");
157 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
161 return efl_text_markup_util_text_to_markup_ptr.Value.Delegate( text);
166 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))] private delegate System.String efl_text_markup_util_markup_to_text_delegate( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String text);
169 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))] public delegate System.String efl_text_markup_util_markup_to_text_api_delegate( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String text);
170 public static Efl.Eo.FunctionWrapper<efl_text_markup_util_markup_to_text_api_delegate> efl_text_markup_util_markup_to_text_ptr = new Efl.Eo.FunctionWrapper<efl_text_markup_util_markup_to_text_api_delegate>(_Module, "efl_text_markup_util_markup_to_text");
171 private static System.String markup_to_text(System.IntPtr obj, System.IntPtr pd, System.String text)
173 Eina.Log.Debug("function efl_text_markup_util_markup_to_text was called");
174 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
175 if(wrapper != null) {
176 System.String _ret_var = default(System.String);
178 _ret_var = TextMarkupUtil.MarkupToText( text);
179 } catch (Exception e) {
180 Eina.Log.Warning($"Callback error: {e.ToString()}");
181 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
185 return efl_text_markup_util_markup_to_text_ptr.Value.Delegate( text);