/*!
  Returns the `this' object associated with this QScriptContext.
*/
QScriptValue QScriptContext::thisObject() const
{
    JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
    QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
    QScript::APIShim shim(engine);
    JSC::JSValue result = engine->thisForContext(frame);
    if (!result || result.isNull())
        result = frame->globalThisValue();
    return engine->scriptValueFromJSCValue(result);
}
Beispiel #2
0
PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue value)
{
    if (value.isNull())
        return IDBKey::create();
    if (value.isInt32())
        return IDBKey::create(value.toInt32(exec));
    if (value.isString())
        return IDBKey::create(ustringToString(value.toString(exec)));
    // FIXME: Implement dates.
    return 0;
}
Beispiel #3
0
JSType JSValueGetType(JSContextRef, JSValueRef value)
{
    JSC::JSValue* jsValue = toJS(value);
    if (jsValue->isUndefined())
        return kJSTypeUndefined;
    if (jsValue->isNull())
        return kJSTypeNull;
    if (jsValue->isBoolean())
        return kJSTypeBoolean;
    if (jsValue->isNumber())
        return kJSTypeNumber;
    if (jsValue->isString())
        return kJSTypeString;
    ASSERT(jsValue->isObject());
    return kJSTypeObject;
}
JSType JSValueGetType(JSContextRef ctx, JSValueRef value)
{
    JSC::ExecState* exec = toJS(ctx);
    exec->globalData().heap.registerThread();
    JSC::JSLock lock(exec);

    JSC::JSValue jsValue = toJS(exec, value);

    if (jsValue.isUndefined())
        return kJSTypeUndefined;
    if (jsValue.isNull())
        return kJSTypeNull;
    if (jsValue.isBoolean())
        return kJSTypeBoolean;
    if (jsValue.isNumber())
        return kJSTypeNumber;
    if (jsValue.isString())
        return kJSTypeString;
    ASSERT(jsValue.isObject());
    return kJSTypeObject;
}
Beispiel #5
0
static bool buildOptions(FetchRequest::InternalRequest& request, ScriptExecutionContext& context, const Dictionary& init)
{
    JSC::JSValue window;
    if (init.get("window", window)) {
        if (!window.isNull())
            return false;
    }

    if (!setReferrer(request, context, init))
        return false;

    String value;
    if (init.get("referrerPolicy", value) && !setReferrerPolicy(request.options, value))
        return false;

    if (init.get("mode", value) && !setMode(request.options, value))
        return false;
    if (request.options.mode() == FetchOptions::Mode::Navigate)
        return false;

    if (init.get("credentials", value) && !setCredentials(request.options, value))
        return false;

    if (init.get("cache", value) && !setCache(request.options, value))
        return false;

    if (init.get("redirect", value) && !setRedirect(request.options, value))
        return false;

    init.get("integrity", request.integrity);

    if (init.get("method", value) && !setMethod(request.request, value))
        return false;

    return true;
}