using System; using System.Runtime.InteropServices; using PorygonSharp.EvalValues; namespace PorygonSharp.UserData { internal class UserDataReturnValue { private readonly IntPtr _ptr; public UserDataReturnValue(EvalValue value) { _ptr = ReturnValue(value.GetPointer()); } public UserDataReturnValue(string message) { _ptr = ErrorValue(message); } public static implicit operator UserDataReturnValue(EvalValue val) { return new UserDataReturnValue(val); } internal IntPtr GetPointer() { return _ptr; } [DllImport("PorygonLang", EntryPoint = "ReturnValue", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr ReturnValue(IntPtr value); [DllImport("PorygonLang", EntryPoint = "ErrorValue", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr ErrorValue(string message); } }