Exemple #1
0
        public static void InstallCallbacks(
            IntPtr freeLispHandleCallback,
            IntPtr applyCallback,
            out IntPtr exception)
        {
            exception = IntPtr.Zero;
            Exception e = null;
#if ENABLE_TASK_HACK
            var task = Task.Factory.StartNew(() =>
            {
#endif
            try
            {
                LispObject.InstallCallbacks(
                    freeLispHandleCallback,
                    applyCallback);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                e = ex;
            }
#if ENABLE_TASK_HACK
            });
            Task.WaitAny(task);
#endif

            if (e != null)
                exception = BoxObject(e);
        }
Exemple #2
0
        public static void GetDelegateForLispFunction(
            IntPtr function,
            IntPtr delegateType,
            out IntPtr result,
            out int typeCode,
            out IntPtr exception)
        {
            result = IntPtr.Zero;
            typeCode = (int) TypeCode.Empty;
            exception = IntPtr.Zero;
            Exception e = null;
            object invocationResult = null;

#if ENABLE_TASK_HACK
            var task = Task.Factory.StartNew(() =>
            {
#endif
            try
            {
                var type = (Type)UnboxObject(delegateType);
                invocationResult = LispObject.Create(function).AsDelegate(type);
            }
            catch (TargetInvocationException ex)
            {
#if DEBUG
                Log.Exception(ex);
#endif
                e = ex.InnerException;
            }
            catch (Exception ex)
            {
#if DEBUG
                Log.Exception(ex);
#endif
                e = ex;
            }
#if ENABLE_TASK_HACK
            });
            Task.WaitAny(task);
#endif

            result = BoxObject(invocationResult);
            typeCode = invocationResult.GetFullTypeCode();
            exception = BoxObject(e);
        }
Exemple #3
0
 public LispException(LispObject value)
 {
     Value = value;
 }
Exemple #4
0
 public static IntPtr BoxLispObject(IntPtr handle)
 {
     return BoxObject(LispObject.Create(handle));
 }