当前位置: 首页>>代码示例>>C++>>正文


C++ ExecState::vm方法代码示例

本文整理汇总了C++中jsc::ExecState::vm方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::vm方法的具体用法?C++ ExecState::vm怎么用?C++ ExecState::vm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsc::ExecState的用法示例。


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

示例1: jsUndefined

static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState& state)
{
    const String& typeArg = state.argument(0).toString(&state)->value(&state);
    bool canBubbleArg = state.argument(1).toBoolean(&state);
    bool cancelableArg = state.argument(2).toBoolean(&state);
    const String originArg = valueToUSVString(&state, state.argument(4));
    const String lastEventIdArg = state.argument(5).toString(&state)->value(&state);
    DOMWindow* sourceArg = JSDOMWindow::toWrapped(state, state.argument(6));
    std::unique_ptr<MessagePortArray> messagePorts;
    std::unique_ptr<ArrayBufferArray> arrayBuffers;
    if (!state.argument(7).isUndefinedOrNull()) {
        messagePorts = std::make_unique<MessagePortArray>();
        arrayBuffers = std::make_unique<ArrayBufferArray>();
        fillMessagePortArray(state, state.argument(7), *messagePorts, *arrayBuffers);
        if (state.hadException())
            return jsUndefined();
    }
    Deprecated::ScriptValue dataArg(state.vm(), state.argument(3));
    if (state.hadException())
        return jsUndefined();

    MessageEvent& event = jsEvent->wrapped();
    event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, WTFMove(messagePorts));
    jsEvent->m_data.set(state.vm(), jsEvent, dataArg.jsValue());
    return jsUndefined();
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:26,代码来源:JSMessageEventCustom.cpp

示例2: payment

JSC::JSValue JSApplePayPaymentAuthorizedEvent::payment(JSC::ExecState& exec) const
{
    if (!m_payment)
        m_payment.set(exec.vm(), this, wrapped().payment().toJS(exec));

    return m_payment.get();
}
开发者ID:eocanha,项目名称:webkit,代码行数:7,代码来源:JSApplePayPaymentAuthorizedEventCustom.cpp

示例3: getCSSCanvasContext

JSValue JSDocument::getCSSCanvasContext(JSC::ExecState& state)
{
    VM& vm = state.vm();
    auto scope = DECLARE_THROW_SCOPE(vm);

    if (UNLIKELY(state.argumentCount() < 4))
        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    auto contextId = state.uncheckedArgument(0).toWTFString(&state);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();
    auto name = state.uncheckedArgument(1).toWTFString(&state);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();
    auto width = convert<int32_t>(state, state.uncheckedArgument(2), NormalConversion);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();
    auto height = convert<int32_t>(state, state.uncheckedArgument(3), NormalConversion);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();

    auto* context = wrapped().getCSSCanvasContext(WTFMove(contextId), WTFMove(name), WTFMove(width), WTFMove(height));
    if (!context)
        return jsNull();

#if ENABLE(WEBGL)
    if (is<WebGLRenderingContextBase>(*context))
        return toJS(&state, globalObject(), downcast<WebGLRenderingContextBase>(*context));
#endif

    return toJS(&state, globalObject(), downcast<CanvasRenderingContext2D>(*context));
}
开发者ID:endlessm,项目名称:WebKit,代码行数:31,代码来源:JSDocumentCustom.cpp

示例4: throwTypeError

static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState& state, WebGLRenderingContextBase& context)
{
    if (state.argumentCount() != 2)
        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
    
    WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
    if (!location && !state.uncheckedArgument(0).isUndefinedOrNull())
        return throwTypeError(&state);
    
    RefPtr<Int32Array> webGLArray = toInt32Array(state.uncheckedArgument(1));
    
    ExceptionCode ec = 0;
    if (webGLArray) {
        switch (f) {
        case f_uniform1v:
            context.uniform1iv(location, *webGLArray, ec);
            break;
        case f_uniform2v:
            context.uniform2iv(location, *webGLArray, ec);
            break;
        case f_uniform3v:
            context.uniform3iv(location, *webGLArray, ec);
            break;
        case f_uniform4v:
            context.uniform4iv(location, *webGLArray, ec);
            break;
        default:
            break;
        }
        
        setDOMException(&state, ec);
        return jsUndefined();
    }
    
    
    Vector<int, 64> array;
    if (!toVector(state, state.uncheckedArgument(1), array))
        return throwTypeError(&state);
    
    switch (f) {
    case f_uniform1v:
        context.uniform1iv(location, array.data(), array.size(), ec);
        break;
    case f_uniform2v:
        context.uniform2iv(location, array.data(), array.size(), ec);
        break;
    case f_uniform3v:
        context.uniform3iv(location, array.data(), array.size(), ec);
        break;
    case f_uniform4v:
        context.uniform4iv(location, array.data(), array.size(), ec);
        break;
    default:
        break;
    }
    
    setDOMException(&state, ec);
    return jsUndefined();
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:59,代码来源:JSWebGLRenderingContextBaseCustom.cpp

示例5: storeError

void ReadableJSStream::storeError(JSC::ExecState& exec, JSValue error)
{
    if (m_error)
        return;
    m_error.set(exec.vm(), error);

    changeStateToErrored();
}
开发者ID:GuoCheng111,项目名称:webkit,代码行数:8,代码来源:ReadableJSStream.cpp

示例6: deserializeIDBValueDataToJSValue

JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
{
    if (!valueData.data())
        return jsUndefined();

    const Vector<uint8_t>& data = *valueData.data();
    JSValue result;
    if (data.size()) {
        RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(data);

        exec.vm().apiLock().lock();
        result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
        exec.vm().apiLock().unlock();
    } else
        result = jsNull();

    return result;
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:18,代码来源:IDBBindingUtilities.cpp

示例7: dispatchDidPause

void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener)
{
    ASSERT(isPaused());
    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
    JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject();
    JSC::ExecState* state = globalObject->globalExec();
    RefPtr<JavaScriptCallFrame> javaScriptCallFrame = JavaScriptCallFrame::create(debuggerCallFrame);
    JSValue jsCallFrame = toJS(state, globalObject, javaScriptCallFrame.get());
    listener->didPause(state, Deprecated::ScriptValue(state->vm(), jsCallFrame), Deprecated::ScriptValue());
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:10,代码来源:ScriptDebugServer.cpp

示例8: initCustomEvent

void CustomEvent::initCustomEvent(JSC::ExecState& state, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue detail)
{
    if (dispatched())
        return;

    initEvent(type, canBubble, cancelable);

    m_detail = { state.vm(), detail };
    m_serializedDetail = nullptr;
    m_triedToSerialize = false;
}
开发者ID:caiolima,项目名称:webkit,代码行数:11,代码来源:CustomEvent.cpp

示例9: callFunction

static inline JSC::JSValue callFunction(JSC::ExecState& state, JSC::JSValue jsFunction, JSC::JSValue thisValue, const JSC::ArgList& arguments)
{
    VM& vm = state.vm();
    auto scope = DECLARE_CATCH_SCOPE(vm);
    JSC::CallData callData;
    auto callType = JSC::getCallData(vm, jsFunction, callData);
    ASSERT(callType != JSC::CallType::None);
    auto result = call(&state, jsFunction, callType, callData, thisValue, arguments);
    scope.assertNoException();
    return result;
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:11,代码来源:ReadableStream.cpp

示例10: dispatchDidPause

void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener)
{
    ASSERT(m_paused);
    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
    JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject();
    JSC::ExecState* state = globalObject->globalExec();
    RefPtr<JavaScriptCallFrame> javaScriptCallFrame = JavaScriptCallFrame::create(debuggerCallFrame);
    JSValue jsCallFrame;
    {
        if (globalObject->inherits(JSDOMGlobalObject::info())) {
            JSDOMGlobalObject* domGlobalObject = jsCast<JSDOMGlobalObject*>(globalObject);
            JSLockHolder lock(state);
            jsCallFrame = toJS(state, domGlobalObject, javaScriptCallFrame.get());
        } else
            jsCallFrame = jsUndefined();
    }
    listener->didPause(state, ScriptValue(state->vm(), jsCallFrame), ScriptValue());
}
开发者ID:jeremysjones,项目名称:webkit,代码行数:18,代码来源:ScriptDebugServer.cpp

示例11: toVector

bool toVector(JSC::ExecState& state, JSC::JSValue value, Vector<T, inlineCapacity>& vector)
{
    if (!value.isObject())
        return false;
    
    JSC::JSObject* object = asObject(value);
    int32_t length = object->get(&state, state.vm().propertyNames->length).toInt32(&state);
    
    if (!vector.tryReserveCapacity(length))
        return false;
    vector.resize(length);
    
    for (int32_t i = 0; i < length; ++i) {
        JSC::JSValue v = object->get(&state, i);
        if (state.hadException())
            return false;
        vector[i] = static_cast<T>(v.toNumber(&state));
    }
    
    return true;
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:21,代码来源:JSWebGLRenderingContextBaseCustom.cpp

示例12: create

Ref<ReadableStream> ReadableStream::create(JSC::ExecState& execState, RefPtr<ReadableStreamSource>&& source)
{
    VM& vm = execState.vm();
    auto scope = DECLARE_CATCH_SCOPE(vm);

    auto& clientData = *static_cast<JSVMClientData*>(vm.clientData);
    auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(execState.lexicalGlobalObject());

    auto* constructor = JSC::asObject(globalObject.get(&execState, clientData.builtinNames().ReadableStreamPrivateName()));

    ConstructData constructData;
    ConstructType constructType = constructor->methodTable(vm)->getConstructData(constructor, constructData);
    ASSERT(constructType != ConstructType::None);

    MarkedArgumentBuffer args;
    args.append(source ? toJSNewlyCreated(&execState, &globalObject, source.releaseNonNull()) : JSC::jsUndefined());
    ASSERT(!args.hasOverflowed());

    auto newReadableStream = jsDynamicCast<JSReadableStream*>(vm, JSC::construct(&execState, constructor, constructType, constructData, args));
    scope.assertNoException();

    return create(globalObject, *newReadableStream);
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:23,代码来源:ReadableStream.cpp

示例13: evaluateBreakpointAction

bool ScriptDebugServer::evaluateBreakpointAction(const ScriptBreakpointAction& breakpointAction)
{
    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();

    switch (breakpointAction.type) {
    case ScriptBreakpointActionTypeLog: {
        dispatchBreakpointActionLog(debuggerCallFrame->exec(), breakpointAction.data);
        break;
    }
    case ScriptBreakpointActionTypeEvaluate: {
        JSValue exception;
        debuggerCallFrame->evaluate(breakpointAction.data, exception);
        if (exception)
            reportException(debuggerCallFrame->exec(), exception);
        break;
    }
    case ScriptBreakpointActionTypeSound:
        dispatchBreakpointActionSound(debuggerCallFrame->exec());
        break;
    case ScriptBreakpointActionTypeProbe: {
        JSValue exception;
        JSValue result = debuggerCallFrame->evaluate(breakpointAction.data, exception);
        if (exception)
            reportException(debuggerCallFrame->exec(), exception);
        
        JSC::ExecState* state = debuggerCallFrame->scope()->globalObject()->globalExec();
        Deprecated::ScriptValue wrappedResult = Deprecated::ScriptValue(state->vm(), exception ? exception : result);
        dispatchDidSampleProbe(state, breakpointAction.identifier, wrappedResult);
        break;
    }
    default:
        ASSERT_NOT_REACHED();
    }

    return true;
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:36,代码来源:ScriptDebugServer.cpp

示例14: idbKeyDataToJSValue

JSValue idbKeyDataToJSValue(JSC::ExecState& exec, const IDBKeyData& keyData)
{
    if (keyData.isNull())
        return jsUndefined();

    Locker<JSLock> locker(exec.vm().apiLock());

    switch (keyData.type()) {
    case KeyType::Array:
        {
            const Vector<IDBKeyData>& inArray = keyData.array();
            size_t size = inArray.size();
            JSArray* outArray = constructEmptyArray(&exec, 0, exec.lexicalGlobalObject(), size);
            for (size_t i = 0; i < size; ++i) {
                auto& arrayKey = inArray.at(i);
                outArray->putDirectIndex(&exec, i, idbKeyDataToJSValue(exec, arrayKey));
            }
            return JSValue(outArray);
        }
    case KeyType::String:
        return jsStringWithCache(&exec, keyData.string());
    case KeyType::Date:
        return jsDateOrNull(&exec, keyData.date());
    case KeyType::Number:
        return jsNumber(keyData.number());
    case KeyType::Min:
    case KeyType::Max:
    case KeyType::Invalid:
        ASSERT_NOT_REACHED();
        return jsUndefined();
    }

    ASSERT_NOT_REACHED();
    return jsUndefined();

}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:36,代码来源:IDBBindingUtilities.cpp

示例15: jsUndefined

static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState& state)
{
    VM& vm = state.vm();
    auto scope = DECLARE_THROW_SCOPE(vm);

    const String& typeArg = state.argument(0).toWTFString(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    bool canBubbleArg = state.argument(1).toBoolean(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    bool cancelableArg = state.argument(2).toBoolean(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    JSValue dataArg = state.argument(3);

    const String originArg = convert<IDLUSVString>(state, state.argument(4));
    RETURN_IF_EXCEPTION(scope, JSValue());

    const String lastEventIdArg = state.argument(5).toWTFString(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    auto sourceArg = convert<IDLNullable<IDLUnion<IDLInterface<DOMWindow>, IDLInterface<MessagePort>>>>(state, state.argument(6));
    RETURN_IF_EXCEPTION(scope, JSValue());
    
    Vector<RefPtr<MessagePort>> messagePorts;
    if (!state.argument(7).isUndefinedOrNull()) {
        messagePorts = convert<IDLSequence<IDLInterface<MessagePort>>>(state, state.argument(7));
        RETURN_IF_EXCEPTION(scope, JSValue());
    }

    MessageEvent& event = jsEvent->wrapped();
    event.initMessageEvent(state, typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts));
    jsEvent->m_data.set(vm, jsEvent, dataArg);
    return jsUndefined();
}
开发者ID:eocanha,项目名称:webkit,代码行数:36,代码来源:JSMessageEventCustom.cpp


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