1 #pragma warning disable 1591
4 using System.Runtime.InteropServices;
8 public struct Error : IComparable<Error>
14 get { return MsgGet(this); }
17 public static Error UNHANDLED_EXCEPTION;
19 public static Error NO_ERROR = new Error(0);
20 public static Error EPERM = new Error(1);
21 public static Error ENOENT = new Error(2);
22 public static Error ECANCELED = new Error(125);
24 public Error(int value) { code = value; }
25 static public implicit operator Error(int val)
27 return new Error(val);
29 static public implicit operator int(Error error)
33 public int CompareTo(Error err)
35 return code.CompareTo(err.code);
37 public override string ToString()
39 return "Eina.Error(" + code + ")";
44 UNHANDLED_EXCEPTION = eina_error_msg_register("Unhandled C# exception occurred.");
47 [DllImport(efl.Libs.Eina)] static extern Error eina_error_msg_register(string msg);
48 [DllImport(efl.Libs.Eina)] static extern Error eina_error_get();
49 [DllImport(efl.Libs.Eina)] static extern void eina_error_set(Error error);
50 [DllImport(efl.Libs.Eina)] static extern IntPtr eina_error_msg_get(Error error);
52 public static void Set(Error error)
54 eina_error_set(error);
57 public static Error Get()
59 return eina_error_get();
62 public static String MsgGet(Error error)
64 IntPtr cstr = eina_error_msg_get(error);
65 return Eina.StringConversion.NativeUtf8ToManagedString(cstr);
68 /// <summary>Raises an exception if an unhandled exception occurred before switching
69 /// back to the native code. For example, in an event handler.</summary>
70 public static void RaiseIfUnhandledException()
73 if (e == UNHANDLED_EXCEPTION)
80 public static void Raise(Error e)
83 throw (new Efl.EflException(MsgGet(e)));
86 public static void Clear()
91 public static Error Register(string msg)
93 return eina_error_msg_register(msg);