コード例 #1
0
ファイル: JSTestInterface.cpp プロジェクト: edcwconan/webkit
EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2(ExecState* state)
{
    JSValue thisValue = state->thisValue();
    auto castedThis = jsDynamicCast<JSTestInterface*>(thisValue);
    if (UNLIKELY(!castedThis))
        return throwThisTypeError(*state, "TestInterface", "supplementalMethod2");
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestInterface::info());
    auto& impl = castedThis->wrapped();
    if (UNLIKELY(state->argumentCount() < 2))
        return throwVMError(state, createNotEnoughArgumentsError(state));
    ExceptionCode ec = 0;
    auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
    if (!context)
        return JSValue::encode(jsUndefined());
    auto strArg = state->argument(0).toWTFString(state);
    if (UNLIKELY(state->hadException()))
        return JSValue::encode(jsUndefined());
    auto objArg = JSTestObj::toWrapped(state->argument(1));
    if (UNLIKELY(!objArg))
        return throwArgumentTypeError(*state, 1, "objArg", "TestInterface", "supplementalMethod2", "TestObj");
    JSValue result = toJS(state, castedThis->globalObject(), WebCore::TestSupplemental::supplementalMethod2(impl, *context, WTFMove(strArg), *objArg, ec));

    setDOMException(state, ec);
    return JSValue::encode(result);
}
コード例 #2
0
ファイル: JSTestInterface.cpp プロジェクト: edcwconan/webkit
EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod3(ExecState* state)
{
    JSValue thisValue = state->thisValue();
    auto castedThis = jsDynamicCast<JSTestInterface*>(thisValue);
    if (UNLIKELY(!castedThis))
        return throwThisTypeError(*state, "TestInterface", "supplementalMethod3");
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestInterface::info());
    return JSValue::encode(castedThis->supplementalMethod3(*state));
}
コード例 #3
0
EncodedJSValue JSC_HOST_CALL jsTestJSBuiltinConstructorPrototypeFunctionTestCustomFunction(ExecState* state)
{
    JSValue thisValue = state->thisValue();
    JSTestJSBuiltinConstructor* castedThis = jsDynamicCast<JSTestJSBuiltinConstructor*>(thisValue);
    if (UNLIKELY(!castedThis))
        return throwThisTypeError(*state, "TestJSBuiltinConstructor", "testCustomFunction");
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestJSBuiltinConstructor::info());
    return JSValue::encode(castedThis->testCustomFunction(*state));
}
コード例 #4
0
JSC::JSValue JSMediaStreamTrack::getCapabilities(ExecState& state)
{
    JSValue thisValue = state.thisValue();
    JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
    if (UNLIKELY(!castedThis))
        return JSValue::decode(throwThisTypeError(state, "MediaStreamTrack", "getSettings"));

    JSObject* object = constructEmptyObject(&state);
    auto& impl = castedThis->wrapped();
    RefPtr<RealtimeMediaSourceCapabilities> capabilities = WTF::getPtr(impl.getCapabilities());

    if (capabilities->supportsWidth())
        object->putDirect(state.vm(), Identifier::fromString(&state, "width"), capabilityValue(capabilities->width(), state), DontDelete | ReadOnly);
    if (capabilities->supportsHeight())
        object->putDirect(state.vm(), Identifier::fromString(&state, "height"), capabilityValue(capabilities->height(), state), DontDelete | ReadOnly);
    if (capabilities->supportsAspectRatio())
        object->putDirect(state.vm(), Identifier::fromString(&state, "aspectRatio"), capabilityValue(capabilities->aspectRatio(), state), DontDelete | ReadOnly);
    if (capabilities->supportsFrameRate())
        object->putDirect(state.vm(), Identifier::fromString(&state, "frameRate"), capabilityValue(capabilities->frameRate(), state), DontDelete | ReadOnly);
    if (capabilities->supportsFacingMode()) {
        const Vector<RealtimeMediaSourceSettings::VideoFacingMode>& modes = capabilities->facingMode();
        Vector<String> facingModes;
        if (modes.size()) {

            facingModes.reserveCapacity(modes.size());

            for (auto& mode : modes)
                facingModes.append(RealtimeMediaSourceSettings::facingMode(mode));
        }

        object->putDirect(state.vm(), Identifier::fromString(&state, "facingMode"), jsArray(&state, castedThis->globalObject(), facingModes), DontDelete | ReadOnly);
    }
    if (capabilities->supportsVolume())
        object->putDirect(state.vm(), Identifier::fromString(&state, "volume"), capabilityValue(capabilities->volume(), state), DontDelete | ReadOnly);
    if (capabilities->supportsSampleRate())
        object->putDirect(state.vm(), Identifier::fromString(&state, "sampleRate"), capabilityValue(capabilities->sampleRate(), state), DontDelete | ReadOnly);
    if (capabilities->supportsSampleSize())
        object->putDirect(state.vm(), Identifier::fromString(&state, "sampleSize"), capabilityValue(capabilities->sampleSize(), state), DontDelete | ReadOnly);
    if (capabilities->supportsEchoCancellation()) {
        Vector<String> cancellation;
        cancellation.reserveCapacity(2);

        cancellation.append("true");
        cancellation.append(capabilities->echoCancellation() == RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite ? "true" : "false");

        object->putDirect(state.vm(), Identifier::fromString(&state, "echoCancellation"), jsArray(&state, castedThis->globalObject(), cancellation), DontDelete | ReadOnly);
    }
    if (capabilities->supportsDeviceId())
        object->putDirect(state.vm(), Identifier::fromString(&state, "deviceId"), jsStringWithCache(&state, capabilities->deviceId()), DontDelete | ReadOnly);
    if (capabilities->supportsGroupId())
        object->putDirect(state.vm(), Identifier::fromString(&state, "groupId"), jsStringWithCache(&state, capabilities->groupId()), DontDelete | ReadOnly);
    

    return object;
}
コード例 #5
0
ファイル: JSTestInterface.cpp プロジェクト: edcwconan/webkit
EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod1(ExecState* state)
{
    JSValue thisValue = state->thisValue();
    auto castedThis = jsDynamicCast<JSTestInterface*>(thisValue);
    if (UNLIKELY(!castedThis))
        return throwThisTypeError(*state, "TestInterface", "supplementalMethod1");
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestInterface::info());
    auto& impl = castedThis->wrapped();
    WebCore::TestSupplemental::supplementalMethod1(impl);
    return JSValue::encode(jsUndefined());
}
コード例 #6
0
JSC::JSValue JSMediaStreamTrack::getSettings(ExecState& state)
{
    JSValue thisValue = state.thisValue();
    JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
    if (UNLIKELY(!castedThis))
        return JSValue::decode(throwThisTypeError(state, "MediaStreamTrack", "getSettings"));

    JSObject* object = constructEmptyObject(&state);
    auto& impl = castedThis->wrapped();
    RefPtr<MediaSourceSettings> settings = WTF::getPtr(impl.getSettings());

    if (settings->supportsWidth())
        object->putDirect(state.vm(), Identifier::fromString(&state, "width"), jsNumber(settings->width()), DontDelete | ReadOnly);
    if (settings->supportsHeight())
        object->putDirect(state.vm(), Identifier::fromString(&state, "height"), jsNumber(settings->height()), DontDelete | ReadOnly);
    if (settings->supportsAspectRatio())
        object->putDirect(state.vm(), Identifier::fromString(&state, "aspectRatio"), jsDoubleNumber(settings->aspectRatio()), DontDelete | ReadOnly);
    if (settings->supportsFrameRate())
        object->putDirect(state.vm(), Identifier::fromString(&state, "frameRate"), jsDoubleNumber(settings->frameRate()), DontDelete | ReadOnly);
    if (settings->supportsFacingMode())
        object->putDirect(state.vm(), Identifier::fromString(&state, "facingMode"), jsStringWithCache(&state, settings->facingMode()), DontDelete | ReadOnly);
    if (settings->supportsVolume())
        object->putDirect(state.vm(), Identifier::fromString(&state, "volume"), jsDoubleNumber(settings->volume()), DontDelete | ReadOnly);
    if (settings->supportsSampleRate())
        object->putDirect(state.vm(), Identifier::fromString(&state, "sampleRate"), jsNumber(settings->sampleRate()), DontDelete | ReadOnly);
    if (settings->supportsSampleSize())
        object->putDirect(state.vm(), Identifier::fromString(&state, "sampleSize"), jsNumber(settings->sampleSize()), DontDelete | ReadOnly);
    if (settings->supportsEchoCancellation())
        object->putDirect(state.vm(), Identifier::fromString(&state, "echoCancellation"), jsBoolean(settings->echoCancellation()), DontDelete | ReadOnly);
    if (settings->supportsDeviceId())
        object->putDirect(state.vm(), Identifier::fromString(&state, "deviceId"), jsStringWithCache(&state, settings->deviceId()), DontDelete | ReadOnly);
    if (settings->supportsGroupId())
        object->putDirect(state.vm(), Identifier::fromString(&state, "groupId"), jsStringWithCache(&state, settings->groupId()), DontDelete | ReadOnly);
    
    return object;
}