예제 #1
0
        private static void ScheduleScriptInterruptedException(StdString.Ptr pEngineName, StdString.Ptr pMessage, StdString.Ptr pStackTrace, bool isFatal, bool executionStarted, V8Value.Ptr pScriptException, V8Value.Ptr pInnerException)
        {
            Debug.Assert(ScheduledException == null);
            var scriptException = ScriptEngine.Current?.MarshalToHost(V8Value.Get(pScriptException), false);
            var innerException  = V8ProxyHelpers.MarshalExceptionToHost(V8Value.Get(pInnerException));

            ScheduledException = new ScriptInterruptedException(StdString.GetValue(pEngineName), StdString.GetValue(pMessage), StdString.GetValue(pStackTrace), 0, isFatal, executionStarted, scriptException, innerException);
        }
예제 #2
0
 public void InvokeWithArrayBufferOrViewData(Action <IntPtr> action)
 {
     using (var actionScope = V8ProxyHelpers.CreateAddRefHostObjectScope(action))
     {
         var pAction = actionScope.Value;
         V8SplitProxyNative.Invoke(instance => instance.V8Object_InvokeWithArrayBufferOrViewData(Handle, pAction));
     }
 }
예제 #3
0
 private static Invocability GetHostObjectInvocability(IntPtr pObject)
 {
     try
     {
         return(V8ProxyHelpers.GetHostObjectInvocability(pObject));
     }
     catch (Exception exception)
     {
         ScheduleHostException(pObject, exception);
         return(default);
예제 #4
0
 private static void ProcessCpuProfile(V8CpuProfile.Ptr pProfile, IntPtr pAction)
 {
     try
     {
         V8ProxyHelpers.GetHostObject <Action <V8CpuProfile.Ptr> >(pAction)(pProfile);
     }
     catch (Exception exception)
     {
         ScheduleHostException(exception);
     }
 }
예제 #5
0
 private static void ProcessArrayBufferOrViewData(IntPtr pData, IntPtr pAction)
 {
     try
     {
         V8ProxyHelpers.GetHostObject <Action <IntPtr> >(pAction)(pData);
     }
     catch (Exception exception)
     {
         ScheduleHostException(exception);
     }
 }
예제 #6
0
 private static void InvokeHostAction(IntPtr pAction)
 {
     try
     {
         V8ProxyHelpers.GetHostObject <Action>(pAction)();
     }
     catch (Exception exception)
     {
         ScheduleHostException(exception);
     }
 }
예제 #7
0
        private static void ScheduleForwardingException(V8Value.Ptr pException)
        {
            Debug.Assert(ScheduledException == null);

            var exception = V8ProxyHelpers.MarshalExceptionToHost(V8Value.Get(pException));

            if (exception is ScriptEngineException scriptEngineException)
            {
                ScheduledException = new ScriptEngineException(scriptEngineException.EngineName, scriptEngineException.Message, scriptEngineException.ErrorDetails, scriptEngineException.HResult, scriptEngineException.IsFatal, scriptEngineException.ExecutionStarted, scriptEngineException.ScriptException, scriptEngineException);
            }
            else if (exception is ScriptInterruptedException scriptInterruptedException)
            {
                ScheduledException = new ScriptInterruptedException(scriptInterruptedException.EngineName, scriptInterruptedException.Message, scriptInterruptedException.ErrorDetails, scriptInterruptedException.HResult, scriptInterruptedException.IsFatal, scriptInterruptedException.ExecutionStarted, scriptInterruptedException.ScriptException, scriptInterruptedException);
            }
            else
            {
                ScheduledException = exception;
            }
        }
예제 #8
0
 private static IntPtr GetCachedV8Object(IntPtr pCache, IntPtr pObject)
 {
     return(V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache).TryGetValue(V8ProxyHelpers.GetHostObject(pObject), out IntPtr pV8Object) ? pV8Object : IntPtr.Zero);
 }
예제 #9
0
 private static void ReleaseHostObject(IntPtr pObject)
 {
     V8ProxyHelpers.ReleaseHostObject(pObject);
 }
예제 #10
0
 private static IntPtr AddRefHostObject(IntPtr pObject)
 {
     return(V8ProxyHelpers.AddRefHostObject(pObject));
 }
예제 #11
0
 private static void DestroyDebugAgent(IntPtr pAgent)
 {
     V8ProxyHelpers.GetHostObject <V8DebugAgent>(pAgent).Dispose();
     V8ProxyHelpers.ReleaseHostObject(pAgent);
 }
예제 #12
0
 private static void SendDebugMessage(IntPtr pAgent, StdString.Ptr pContent)
 {
     V8ProxyHelpers.GetHostObject <V8DebugAgent>(pAgent).SendMessage(StdString.GetValue(pContent));
 }
예제 #13
0
 private static IntPtr CreateDebugAgent(StdString.Ptr pName, StdString.Ptr pVersion, int port, bool remote, V8DebugCallback.Handle hCallback)
 {
     return(V8ProxyHelpers.AddRefHostObject(new V8DebugAgent(StdString.GetValue(pName), StdString.GetValue(pVersion), port, remote, new V8DebugListenerImpl(hCallback))));
 }
예제 #14
0
 private static bool RemoveV8ObjectCacheEntry(IntPtr pCache, IntPtr pObject)
 {
     return(V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache).Remove(V8ProxyHelpers.GetHostObject(pObject)));
 }
예제 #15
0
        private static void GetAllCachedV8Objects(IntPtr pCache, StdPtrArray.Ptr pV8ObjectPtrs)
        {
            var cache = V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache);

            StdPtrArray.CopyFromArray(pV8ObjectPtrs, cache.Values.ToArray());
        }
예제 #16
0
 private static void ScheduleHostException(IntPtr pObject, Exception exception)
 {
     V8SplitProxyNative.InvokeNoThrow(instance => instance.HostException_Schedule(exception.GetBaseException().Message, V8ProxyHelpers.MarshalExceptionToScript(pObject, exception)));
 }
예제 #17
0
 private static void CacheV8Object(IntPtr pCache, IntPtr pObject, IntPtr pV8Object)
 {
     V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache).Add(V8ProxyHelpers.GetHostObject(pObject), pV8Object);
 }
예제 #18
0
 private static IntPtr CreateV8ObjectCache()
 {
     return(V8ProxyHelpers.AddRefHostObject(new Dictionary <object, IntPtr>()));
 }