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
10 [TextMarkupUtilNativeInherit]
11 public class TextMarkupUtil : Efl.Eo.IWrapper, IDisposable
13 public static System.IntPtr klass = System.IntPtr.Zero;
14 public static Efl.TextMarkupUtilNativeInherit nativeInherit = new Efl.TextMarkupUtilNativeInherit();
15 ///<summary>Pointer to the native class description.</summary>
16 public virtual System.IntPtr NativeClass {
18 if (((object)this).GetType() == typeof (TextMarkupUtil))
19 return Efl.TextMarkupUtilNativeInherit.GetEflClassStatic();
21 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
24 private static readonly object klassAllocLock = new object();
25 protected bool inherited;
26 protected System.IntPtr handle;
27 ///<summary>Pointer to the native instance.</summary>
28 public System.IntPtr NativeHandle {
29 get { return handle; }
31 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
32 efl_text_markup_util_class_get();
33 ///<summary>Creates a new instance.</summary>
34 ///<param name="parent">Parent instance.</param>
35 public TextMarkupUtil(Efl.Object parent= null
37 this(efl_text_markup_util_class_get(), typeof(TextMarkupUtil), parent)
39 FinishInstantiation();
41 ///<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>
42 public TextMarkupUtil(System.IntPtr raw)
45 register_event_proxies();
47 protected TextMarkupUtil(IntPtr base_klass, System.Type managed_type, Efl.Object parent)
49 inherited = ((object)this).GetType() != managed_type;
50 IntPtr actual_klass = base_klass;
52 actual_klass = Efl.Eo.ClassRegister.GetInheritKlassOrRegister(base_klass, ((object)this).GetType());
54 handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);
55 register_event_proxies();
57 protected void FinishInstantiation()
60 Efl.Eo.Globals.data_set(this);
62 handle = Efl.Eo.Globals.instantiate_end(handle);
63 Eina.Error.RaiseIfUnhandledException();
65 ///<summary>Destructor.</summary>
70 ///<summary>Releases the underlying native instance.</summary>
71 protected virtual void Dispose(bool disposing)
73 if (handle != System.IntPtr.Zero) {
74 Efl.Eo.Globals.efl_unref(handle);
75 handle = System.IntPtr.Zero;
78 ///<summary>Releases the underlying native instance.</summary>
82 GC.SuppressFinalize(this);
84 ///<summary>Casts obj into an instance of this type.</summary>
85 public static TextMarkupUtil static_cast(Efl.Object obj)
88 throw new System.ArgumentNullException("obj");
89 return new TextMarkupUtil(obj.NativeHandle);
91 ///<summary>Verifies if the given object is equal to this one.</summary>
92 public override bool Equals(object obj)
94 var other = obj as Efl.Object;
97 return this.NativeHandle == other.NativeHandle;
99 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
100 public override int GetHashCode()
102 return this.NativeHandle.ToInt32();
104 ///<summary>Turns the native pointer into a string representation.</summary>
105 public override String ToString()
107 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
109 protected virtual void register_event_proxies()
112 /// <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.
114 /// <param name="text">The text (UTF-8) to convert to markup
116 /// <returns>The markup representation of given text
118 public static System.String TextToMarkup( System.String text) {
119 var _ret_var = Efl.TextMarkupUtilNativeInherit.efl_text_markup_util_text_to_markup_ptr.Value.Delegate( text);
120 Eina.Error.RaiseIfUnhandledException();
123 /// <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.
125 /// <param name="text">The markup-text to convert to text (UTF-8)
127 /// <returns>The text representation of given format
129 public static System.String MarkupToText( System.String text) {
130 var _ret_var = Efl.TextMarkupUtilNativeInherit.efl_text_markup_util_markup_to_text_ptr.Value.Delegate( text);
131 Eina.Error.RaiseIfUnhandledException();
134 private static IntPtr GetEflClassStatic()
136 return Efl.TextMarkupUtil.efl_text_markup_util_class_get();
139 public class TextMarkupUtilNativeInherit : Efl.Eo.NativeClass{
140 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
141 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
143 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
146 public override IntPtr GetEflClass()
148 return Efl.TextMarkupUtil.efl_text_markup_util_class_get();
150 public static IntPtr GetEflClassStatic()
152 return Efl.TextMarkupUtil.efl_text_markup_util_class_get();
156 [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);
159 [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);
160 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");
161 private static System.String text_to_markup(System.IntPtr obj, System.IntPtr pd, System.String text)
163 Eina.Log.Debug("function efl_text_markup_util_text_to_markup was called");
164 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
165 if(wrapper != null) {
166 System.String _ret_var = default( System.String);
168 _ret_var = TextMarkupUtil.TextToMarkup( text);
169 } catch (Exception e) {
170 Eina.Log.Warning($"Callback error: {e.ToString()}");
171 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
175 return efl_text_markup_util_text_to_markup_ptr.Value.Delegate( text);
180 [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);
183 [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);
184 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");
185 private static System.String markup_to_text(System.IntPtr obj, System.IntPtr pd, System.String text)
187 Eina.Log.Debug("function efl_text_markup_util_markup_to_text was called");
188 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
189 if(wrapper != null) {
190 System.String _ret_var = default( System.String);
192 _ret_var = TextMarkupUtil.MarkupToText( text);
193 } catch (Exception e) {
194 Eina.Log.Warning($"Callback error: {e.ToString()}");
195 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
199 return efl_text_markup_util_markup_to_text_ptr.Value.Delegate( text);