Exemple #1
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 #2
0
 public static IntPtr BoxLispObject(IntPtr handle)
 {
     return BoxObject(LispObject.Create(handle));
 }