1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 /// <summary>A generic configuration interface, that holds key-value pairs.</summary>
10 public interface IConfig :
11 Efl.Eo.IWrapper, IDisposable
13 /// <summary>A generic configuration value, referred to by name.</summary>
14 /// <param name="name">Configuration option name.</param>
15 /// <returns>The value. It will be empty if it doesn't exist. The caller must free it after use (using <c>eina_value_free</c>() in C).</returns>
16 Eina.Value GetConfig( System.String name);
17 /// <summary>A generic configuration value, referred to by name.</summary>
18 /// <param name="name">Configuration option name.</param>
19 /// <param name="value">Configuration option value. May be <c>null</c> if not found.</param>
20 /// <returns><c>false</c> in case of error: value type was invalid, the config can't be changed, config does not exist...</returns>
21 bool SetConfig( System.String name, Eina.Value value);
23 /// <summary>A generic configuration interface, that holds key-value pairs.</summary>
24 sealed public class IConfigConcrete :
29 ///<summary>Pointer to the native class description.</summary>
30 public System.IntPtr NativeClass {
32 if (((object)this).GetType() == typeof (IConfigConcrete))
33 return Efl.IConfigNativeInherit.GetEflClassStatic();
35 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
38 private System.IntPtr handle;
39 ///<summary>Pointer to the native instance.</summary>
40 public System.IntPtr NativeHandle {
41 get { return handle; }
43 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
44 efl_config_interface_get();
45 ///<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>
46 private IConfigConcrete(System.IntPtr raw)
49 RegisterEventProxies();
51 ///<summary>Destructor.</summary>
56 ///<summary>Releases the underlying native instance.</summary>
57 void Dispose(bool disposing)
59 if (handle != System.IntPtr.Zero) {
60 Efl.Eo.Globals.efl_unref(handle);
61 handle = System.IntPtr.Zero;
64 ///<summary>Releases the underlying native instance.</summary>
68 GC.SuppressFinalize(this);
70 ///<summary>Verifies if the given object is equal to this one.</summary>
71 public override bool Equals(object obj)
73 var other = obj as Efl.Object;
76 return this.NativeHandle == other.NativeHandle;
78 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
79 public override int GetHashCode()
81 return this.NativeHandle.ToInt32();
83 ///<summary>Turns the native pointer into a string representation.</summary>
84 public override String ToString()
86 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
88 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
89 void RegisterEventProxies()
92 /// <summary>A generic configuration value, referred to by name.</summary>
93 /// <param name="name">Configuration option name.</param>
94 /// <returns>The value. It will be empty if it doesn't exist. The caller must free it after use (using <c>eina_value_free</c>() in C).</returns>
95 public Eina.Value GetConfig( System.String name) {
96 var _ret_var = Efl.IConfigNativeInherit.efl_config_get_ptr.Value.Delegate(this.NativeHandle, name);
97 Eina.Error.RaiseIfUnhandledException();
100 /// <summary>A generic configuration value, referred to by name.</summary>
101 /// <param name="name">Configuration option name.</param>
102 /// <param name="value">Configuration option value. May be <c>null</c> if not found.</param>
103 /// <returns><c>false</c> in case of error: value type was invalid, the config can't be changed, config does not exist...</returns>
104 public bool SetConfig( System.String name, Eina.Value value) {
105 var _ret_var = Efl.IConfigNativeInherit.efl_config_set_ptr.Value.Delegate(this.NativeHandle, name, value);
106 Eina.Error.RaiseIfUnhandledException();
109 private static IntPtr GetEflClassStatic()
111 return Efl.IConfigConcrete.efl_config_interface_get();
114 public class IConfigNativeInherit : Efl.Eo.NativeClass{
115 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
116 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
118 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
119 var methods = Efl.Eo.Globals.GetUserMethods(type);
120 if (efl_config_get_static_delegate == null)
121 efl_config_get_static_delegate = new efl_config_get_delegate(config_get);
122 if (methods.FirstOrDefault(m => m.Name == "GetConfig") != null)
123 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_config_get"), func = Marshal.GetFunctionPointerForDelegate(efl_config_get_static_delegate)});
124 if (efl_config_set_static_delegate == null)
125 efl_config_set_static_delegate = new efl_config_set_delegate(config_set);
126 if (methods.FirstOrDefault(m => m.Name == "SetConfig") != null)
127 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_config_set"), func = Marshal.GetFunctionPointerForDelegate(efl_config_set_static_delegate)});
130 public override IntPtr GetEflClass()
132 return Efl.IConfigConcrete.efl_config_interface_get();
134 public static IntPtr GetEflClassStatic()
136 return Efl.IConfigConcrete.efl_config_interface_get();
140 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))] private delegate Eina.Value efl_config_get_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name);
143 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshalerOwn))] public delegate Eina.Value efl_config_get_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name);
144 public static Efl.Eo.FunctionWrapper<efl_config_get_api_delegate> efl_config_get_ptr = new Efl.Eo.FunctionWrapper<efl_config_get_api_delegate>(_Module, "efl_config_get");
145 private static Eina.Value config_get(System.IntPtr obj, System.IntPtr pd, System.String name)
147 Eina.Log.Debug("function efl_config_get was called");
148 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
149 if(wrapper != null) {
150 Eina.Value _ret_var = default(Eina.Value);
152 _ret_var = ((IConfig)wrapper).GetConfig( name);
153 } catch (Exception e) {
154 Eina.Log.Warning($"Callback error: {e.ToString()}");
155 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
159 return efl_config_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), name);
162 private static efl_config_get_delegate efl_config_get_static_delegate;
165 [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_config_set_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))] Eina.Value value);
168 [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_config_set_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))] Eina.Value value);
169 public static Efl.Eo.FunctionWrapper<efl_config_set_api_delegate> efl_config_set_ptr = new Efl.Eo.FunctionWrapper<efl_config_set_api_delegate>(_Module, "efl_config_set");
170 private static bool config_set(System.IntPtr obj, System.IntPtr pd, System.String name, Eina.Value value)
172 Eina.Log.Debug("function efl_config_set was called");
173 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
174 if(wrapper != null) {
175 bool _ret_var = default(bool);
177 _ret_var = ((IConfig)wrapper).SetConfig( name, value);
178 } catch (Exception e) {
179 Eina.Log.Warning($"Callback error: {e.ToString()}");
180 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
184 return efl_config_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), name, value);
187 private static efl_config_set_delegate efl_config_set_static_delegate;