您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ toV8Context函数代码示例

51自学网 2021-06-03 08:53:43
  C++
这篇教程C++ toV8Context函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中toV8Context函数的典型用法代码示例。如果您正苦于以下问题:C++ toV8Context函数的具体用法?C++ toV8Context怎么用?C++ toV8Context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了toV8Context函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: handleScope

void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg){    if (!canInvokeCallback())        return;    v8::HandleScope handleScope(m_isolate);    v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());    if (v8Context.IsEmpty())        return;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> thisHandle = thisValue.v8Value();    if (thisHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return;    }    ASSERT(thisHandle->IsObject());    v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg);    if (stringArgHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return;    }    v8::Handle<v8::Value> argv[] = { stringArgHandle };    invokeCallback(m_callback.newLocal(m_isolate), v8::Handle<v8::Object>::Cast(thisHandle), 1, argv, executionContext(), m_isolate);}
开发者ID:junmin-zhu,项目名称:blink,代码行数:29,


示例2: m_isolate

ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourceCode, Frame* frame)    : m_isolate(V8PerIsolateData::mainThreadIsolate())    , m_isPreprocessing(false){    ASSERT(frame);    v8::TryCatch tryCatch;    tryCatch.SetVerbose(true);    Vector<ScriptSourceCode> sources;    sources.append(preprocessorSourceCode);    Vector<ScriptValue> scriptResults;    frame->script().executeScriptInIsolatedWorld(ScriptPreprocessorIsolatedWorldId, sources, DOMWrapperWorld::mainWorldExtensionGroup, &scriptResults);    if (scriptResults.size() != 1) {        frame->host()->console().addMessage(JSMessageSource, ErrorMessageLevel, "ScriptPreprocessor internal error, one ScriptSourceCode must give exactly one result.");        return;    }    ScriptValue preprocessorFunction = scriptResults[0];    if (!preprocessorFunction.isFunction()) {        frame->host()->console().addMessage(JSMessageSource, ErrorMessageLevel, "The preprocessor must compile to a function.");        return;    }    m_world = DOMWrapperWorld::ensureIsolatedWorld(ScriptPreprocessorIsolatedWorldId, DOMWrapperWorld::mainWorldExtensionGroup);    v8::Local<v8::Context> context = toV8Context(m_isolate, frame, m_world.get());    m_context.set(m_isolate, context);    m_preprocessorFunction.set(m_isolate, v8::Handle<v8::Function>::Cast(preprocessorFunction.v8Value()));}
开发者ID:glenkim-dev,项目名称:blink-crosswalk,代码行数:29,


示例3: toV8Context

bool V8MetadataCallback::handleEvent(Metadata* metadata){    if (!canInvokeCallback())        return true;    v8::HandleScope handleScope;    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> metadataHandle = toV8(metadata);    if (metadataHandle.IsEmpty()) {        CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        metadataHandle    };    bool callbackReturnValue = false;    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:26,


示例4: toV8Context

bool V8RTCErrorCallback::handleEvent(const String& errorInformation){    if (!canInvokeCallback())        return true;    v8::HandleScope handleScope;    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> errorInformationHandle = deprecatedV8String(errorInformation);    if (errorInformationHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        errorInformationHandle    };    bool callbackReturnValue = false;    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());}
开发者ID:sanyaade-embedded-systems,项目名称:armhf-node-webkit,代码行数:27,


示例5: handleScope

void V8MutationCallback::call(const Vector<RefPtr<MutationRecord> >& mutations, MutationObserver* observer){    if (!canInvokeCallback())        return;    v8::HandleScope handleScope(m_isolate);    v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());    if (v8Context.IsEmpty())        return;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Function> callback = m_callback.newLocal(m_isolate);    if (callback.IsEmpty())        return;    v8::Handle<v8::Value> observerHandle = toV8(observer, v8::Handle<v8::Object>(), m_isolate);    if (observerHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return;    }    if (!observerHandle->IsObject())        return;    v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(observerHandle);    v8::Handle<v8::Value> argv[] = { v8Array(mutations, m_isolate), observerHandle };    v8::TryCatch exceptionCatcher;    exceptionCatcher.SetVerbose(true);    ScriptController::callFunction(executionContext(), callback, thisObject, 2, argv, m_isolate);}
开发者ID:Mihiri,项目名称:blink,代码行数:34,


示例6: m_isPreprocessing

ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourceCode, LocalFrame* frame)    : m_isPreprocessing(false){    RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(ScriptPreprocessorIsolatedWorldId, DOMWrapperWorld::mainWorldExtensionGroup);    m_scriptState = ScriptState::from(toV8Context(frame, *world));    v8::HandleScope handleScope(m_scriptState->isolate());    ASSERT(frame);    v8::TryCatch tryCatch;    tryCatch.SetVerbose(true);    Vector<ScriptSourceCode> sources;    sources.append(preprocessorSourceCode);    Vector<v8::Local<v8::Value> > scriptResults;    frame->script().executeScriptInIsolatedWorld(ScriptPreprocessorIsolatedWorldId, sources, DOMWrapperWorld::mainWorldExtensionGroup, &scriptResults);    if (scriptResults.size() != 1) {        frame->console().addMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, "ScriptPreprocessor internal error, one ScriptSourceCode must give exactly one result."));        return;    }    v8::Local<v8::Value> preprocessorFunction = scriptResults[0];    if (preprocessorFunction.IsEmpty() || !preprocessorFunction->IsFunction()) {        frame->console().addMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, "The preprocessor must compile to a function."));        return;    }    m_preprocessorFunction.set(m_scriptState->isolate(), v8::Handle<v8::Function>::Cast(preprocessorFunction));}
开发者ID:335969568,项目名称:Blink-1,代码行数:27,


示例7: eventListenerHandlerLocation

bool eventListenerHandlerLocation(Document* document, EventListener* listener, String& sourceName, String& scriptId, int& lineNumber){    if (listener->type() != EventListener::JSEventListenerType)        return false;    v8::HandleScope scope(toIsolate(document));    V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener);    v8::Handle<v8::Context> context = toV8Context(document, v8Listener->world());    v8::Context::Scope contextScope(context);    v8::Local<v8::Object> object = v8Listener->getListenerObject(document);    if (object.IsEmpty())        return false;    v8::Handle<v8::Function> function = eventListenerEffectiveFunction(scope.GetIsolate(), object);    if (function.IsEmpty())        return false;    v8::Handle<v8::Function> originalFunction = getBoundFunction(function);    int scriptIdValue = originalFunction->ScriptId();    scriptId = String::number(scriptIdValue);    v8::ScriptOrigin origin = originalFunction->GetScriptOrigin();    if (!origin.ResourceName().IsEmpty() && origin.ResourceName()->IsString())        sourceName = toCoreString(origin.ResourceName().As<v8::String>());    else        sourceName = "";    lineNumber = originalFunction->GetScriptLineNumber();    return true;}
开发者ID:kublaj,项目名称:blink,代码行数:26,


示例8: toIsolate

void V8CustomElementLifecycleCallbacks::attributeChanged(Element* element, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue){    if (!canInvokeCallback())        return;    v8::Isolate* isolate = toIsolate(scriptExecutionContext());    v8::HandleScope handleScope(isolate);    v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_world.get());    if (context.IsEmpty())        return;    v8::Context::Scope scope(context);    v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).As<v8::Object>();    ASSERT(!receiver.IsEmpty());    v8::Handle<v8::Function> callback = m_attributeChanged.newLocal(isolate);    if (callback.IsEmpty())        return;    v8::Handle<v8::Value> argv[] = {        v8String(name, isolate),        oldValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handle<v8::Value>(v8String(oldValue, isolate)),        newValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handle<v8::Value>(v8String(newValue, isolate))    };    v8::TryCatch exceptionCatcher;    exceptionCatcher.SetVerbose(true);    ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv, isolate);}
开发者ID:halton,项目名称:blink-crosswalk,代码行数:30,


示例9: toLocalDOMWindow

void V8Window::eventAttributeGetterCustom(    const v8::PropertyCallbackInfo<v8::Value>& info) {  LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder()));  ExceptionState exceptionState(ExceptionState::GetterContext, "event",                                "Window", info.Holder(), info.GetIsolate());  if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),                                            impl, exceptionState)) {    return;  }  LocalFrame* frame = impl->frame();  ASSERT(frame);  // This is a fast path to retrieve info.Holder()->CreationContext().  v8::Local<v8::Context> context =      toV8Context(frame, DOMWrapperWorld::current(info.GetIsolate()));  if (context.IsEmpty())    return;  v8::Local<v8::Value> jsEvent = V8HiddenValue::getHiddenValue(      ScriptState::current(info.GetIsolate()), context->Global(),      V8HiddenValue::event(info.GetIsolate()));  if (jsEvent.IsEmpty())    return;  v8SetReturnValue(info, jsEvent);}
开发者ID:mirror,项目名称:chromium,代码行数:25,


示例10: toV8Context

bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error){    if (!canInvokeCallback())        return true;    v8::HandleScope handleScope;    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> transactionHandle = toV8(transaction);    v8::Handle<v8::Value> errorHandle = toV8(error);    if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) {        CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        transactionHandle,        errorHandle    };    bool callbackReturnValue = false;    // Step 6: If the error callback returns false, then move on to the next    // statement, if any, or onto the next overall step otherwise. Otherwise,    // the error callback did not return false, or there was no error callback.    // Jump to the last step in the overall steps.    return invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;}
开发者ID:1833183060,项目名称:wke,代码行数:32,


示例11: handleScope

bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error){    if (!canInvokeCallback())        return true;    v8::Isolate* isolate = v8::Isolate::GetCurrent();    v8::HandleScope handleScope(isolate);    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> transactionHandle = toV8(transaction, v8::Handle<v8::Object>(), v8Context->GetIsolate());    v8::Handle<v8::Value> errorHandle = toV8(error, v8::Handle<v8::Object>(), isolate);    if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        transactionHandle,        errorHandle    };    bool callbackReturnValue = false;    // Step 6: If the error callback returns false, then move on to the next    // statement, if any, or onto the next overall step otherwise. Otherwise,    // the error callback did not return false, or there was no error callback.    // Jump to the last step in the overall steps.    return invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext(), isolate) || callbackReturnValue;}
开发者ID:halton,项目名称:blink-crosswalk,代码行数:34,


示例12: ASSERT

PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ScriptExecutionContext* context){    ASSERT(v8::Context::InContext());    ASSERT(context);    v8::Isolate* isolate = v8::Isolate::GetCurrent();    return adoptRef(new ScriptPromiseResolver(toV8Context(context, DOMWrapperWorld::current())->Global(), isolate));}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:7,


示例13: toV8Context

bool V8SQLTransactionSyncCallback::handleEvent(SQLTransactionSync* transaction){    if (!canInvokeCallback())        return true;    v8::HandleScope handleScope;    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> transactionHandle = toV8(transaction);    if (transactionHandle.IsEmpty()) {        CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        transactionHandle    };    bool callbackReturnValue = false;    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:26,


示例14: ASSERT

void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event* event){    // Don't reenter V8 if execution was terminated in this instance of V8.    if (context->isJSExecutionForbidden())        return;    ASSERT(event);    // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it.    // See issue 889829.    RefPtr<V8AbstractEventListener> protect(this);    v8::HandleScope handleScope;    v8::Local<v8::Context> v8Context = toV8Context(context, worldContext());    if (v8Context.IsEmpty())        return;    // Enter the V8 context in which to perform the event handling.    v8::Context::Scope scope(v8Context);    // Get the V8 wrapper for the event object.    v8::Handle<v8::Value> jsEvent = toV8(event);    ASSERT(!jsEvent.IsEmpty());    invokeEventHandler(context, event, jsEvent);}
开发者ID:jiezh,项目名称:h5vcc,代码行数:27,


示例15: toV8Context

bool V8SQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet){    if (!canInvokeCallback())        return true;    v8::HandleScope handleScope;    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> transactionHandle = toV8(transaction);    if (transactionHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> resultSetHandle = toV8(resultSet);    if (resultSetHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        transactionHandle,        resultSetHandle    };    bool callbackReturnValue = false;    return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext());}
开发者ID:sanyaade-embedded-systems,项目名称:armhf-node-webkit,代码行数:34,


示例16: toV8Context

bool V8PositionErrorCallback::handleEvent(PositionError* error){    if (!canInvokeCallback())        return true;    v8::HandleScope handleScope;    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> errorHandle = toV8(error);    if (errorHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = {        errorHandle    };    bool callbackReturnValue = false;    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());}
开发者ID:sanyaade-embedded-systems,项目名称:armhf-node-webkit,代码行数:27,


示例17: handleScope

bool V8TestCallback::callbackWithTestInterfaceEmptyArg(TestInterfaceEmpty* class2Arg, const String& strArg){    if (!canInvokeCallback())        return true;    v8::Isolate* isolate = v8::Isolate::GetCurrent();    v8::HandleScope handleScope(isolate);    v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get());    if (v8Context.IsEmpty())        return true;    v8::Context::Scope scope(v8Context);    v8::Handle<v8::Value> class2ArgHandle = toV8(class2Arg, v8::Handle<v8::Object>(), isolate);    if (class2ArgHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> strArgHandle = v8String(strArg, isolate);    if (strArgHandle.IsEmpty()) {        if (!isScriptControllerTerminating())            CRASH();        return true;    }    v8::Handle<v8::Value> argv[] = { class2ArgHandle, strArgHandle };    bool callbackReturnValue = false;    return !invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, executionContext(), isolate);}
开发者ID:cvsuser-chromium,项目名称:third_party_WebKit,代码行数:30,


示例18: getJSListenerFunctions

static v8::Handle<v8::Array> getJSListenerFunctions(Document* document, const EventListenerInfo& listenerInfo){    v8::Local<v8::Array> result = v8::Array::New();    size_t handlersCount = listenerInfo.eventListenerVector.size();    for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {        RefPtr<EventListener> listener = listenerInfo.eventListenerVector[i].listener;        if (listener->type() != EventListener::JSEventListenerType) {            ASSERT_NOT_REACHED();            continue;        }        V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener.get());        v8::Local<v8::Context> context = toV8Context(document, v8Listener->world());        // Hide listeners from other contexts.        if (context != v8::Context::GetCurrent())            continue;        v8::Local<v8::Object> function;        {            // getListenerObject() may cause JS in the event attribute to get compiled, potentially unsuccessfully.            v8::TryCatch block;            function = v8Listener->getListenerObject(document);            if (block.HasCaught())                continue;        }        ASSERT(!function.IsEmpty());        v8::Local<v8::Object> listenerEntry = v8::Object::New();        listenerEntry->Set(v8::String::NewSymbol("listener"), function);        listenerEntry->Set(v8::String::NewSymbol("useCapture"), v8::Boolean::New(listenerInfo.eventListenerVector[i].useCapture));        result->Set(v8::Number::New(outputIndex++), listenerEntry);    }    return result;}
开发者ID:Channely,项目名称:know-your-chrome,代码行数:31,


示例19: mainWorldContext

static v8::Local<v8::Context> mainWorldContext(v8::Isolate* isolate, NPP npp, NPObject* npObject){    ASSERT(npObject->_class == &V8NPObjectClass);    V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject);    DOMWindow* window = object->rootObject;    if (!window || !window->isCurrentlyDisplayedInFrame())        return v8::Local<v8::Context>();    return toV8Context(isolate, object->rootObject->frame(), DOMWrapperWorld::mainWorld());}
开发者ID:glenkim-dev,项目名称:blink-crosswalk,代码行数:9,



注:本文中的toV8Context函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ toV8Fast函数代码示例
C++ toV8函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。