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); }
public void InvokeWithArrayBufferOrViewData(Action <IntPtr> action) { using (var actionScope = V8ProxyHelpers.CreateAddRefHostObjectScope(action)) { var pAction = actionScope.Value; V8SplitProxyNative.Invoke(instance => instance.V8Object_InvokeWithArrayBufferOrViewData(Handle, pAction)); } }
private static Invocability GetHostObjectInvocability(IntPtr pObject) { try { return(V8ProxyHelpers.GetHostObjectInvocability(pObject)); } catch (Exception exception) { ScheduleHostException(pObject, exception); return(default);
private static void ProcessCpuProfile(V8CpuProfile.Ptr pProfile, IntPtr pAction) { try { V8ProxyHelpers.GetHostObject <Action <V8CpuProfile.Ptr> >(pAction)(pProfile); } catch (Exception exception) { ScheduleHostException(exception); } }
private static void ProcessArrayBufferOrViewData(IntPtr pData, IntPtr pAction) { try { V8ProxyHelpers.GetHostObject <Action <IntPtr> >(pAction)(pData); } catch (Exception exception) { ScheduleHostException(exception); } }
private static void InvokeHostAction(IntPtr pAction) { try { V8ProxyHelpers.GetHostObject <Action>(pAction)(); } catch (Exception exception) { ScheduleHostException(exception); } }
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; } }
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); }
private static void ReleaseHostObject(IntPtr pObject) { V8ProxyHelpers.ReleaseHostObject(pObject); }
private static IntPtr AddRefHostObject(IntPtr pObject) { return(V8ProxyHelpers.AddRefHostObject(pObject)); }
private static void DestroyDebugAgent(IntPtr pAgent) { V8ProxyHelpers.GetHostObject <V8DebugAgent>(pAgent).Dispose(); V8ProxyHelpers.ReleaseHostObject(pAgent); }
private static void SendDebugMessage(IntPtr pAgent, StdString.Ptr pContent) { V8ProxyHelpers.GetHostObject <V8DebugAgent>(pAgent).SendMessage(StdString.GetValue(pContent)); }
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)))); }
private static bool RemoveV8ObjectCacheEntry(IntPtr pCache, IntPtr pObject) { return(V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache).Remove(V8ProxyHelpers.GetHostObject(pObject))); }
private static void GetAllCachedV8Objects(IntPtr pCache, StdPtrArray.Ptr pV8ObjectPtrs) { var cache = V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache); StdPtrArray.CopyFromArray(pV8ObjectPtrs, cache.Values.ToArray()); }
private static void ScheduleHostException(IntPtr pObject, Exception exception) { V8SplitProxyNative.InvokeNoThrow(instance => instance.HostException_Schedule(exception.GetBaseException().Message, V8ProxyHelpers.MarshalExceptionToScript(pObject, exception))); }
private static void CacheV8Object(IntPtr pCache, IntPtr pObject, IntPtr pV8Object) { V8ProxyHelpers.GetHostObject <Dictionary <object, IntPtr> >(pCache).Add(V8ProxyHelpers.GetHostObject(pObject), pV8Object); }
private static IntPtr CreateV8ObjectCache() { return(V8ProxyHelpers.AddRefHostObject(new Dictionary <object, IntPtr>())); }