summaryrefslogtreecommitdiffstats
path: root/src/script/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/qscriptcontext.cpp14
-rw-r--r--src/script/api/qscriptengine.cpp26
-rw-r--r--src/script/api/qscriptengine_p.h1
-rw-r--r--src/script/api/qscriptstring.cpp6
-rw-r--r--src/script/api/qscriptvalueiterator.cpp6
5 files changed, 51 insertions, 2 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index b1732ee..639af80 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -161,6 +161,7 @@ QScriptContext::QScriptContext()
QScriptValue QScriptContext::throwValue(const QScriptValue &value)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::JSValue jscValue = QScript::scriptEngineFromExec(frame)->scriptValueToJSCValue(value);
frame->setException(jscValue);
return value;
@@ -183,6 +184,7 @@ QScriptValue QScriptContext::throwValue(const QScriptValue &value)
QScriptValue QScriptContext::throwError(Error error, const QString &text)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::ErrorType jscError = JSC::GeneralError;
switch (error) {
case UnknownError:
@@ -218,6 +220,7 @@ QScriptValue QScriptContext::throwError(Error error, const QString &text)
QScriptValue QScriptContext::throwError(const QString &text)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::JSObject *result = JSC::throwError(frame, JSC::GeneralError, text);
return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(result);
}
@@ -265,6 +268,7 @@ QScriptValue QScriptContext::argument(int index) const
QScriptValue QScriptContext::callee() const
{
const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(frame->callee());
}
@@ -286,6 +290,7 @@ QScriptValue QScriptContext::callee() const
QScriptValue QScriptContext::argumentsObject() const
{
JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
if (frame == frame->lexicalGlobalObject()->globalExec()) {
// <global> context doesn't have arguments. return an empty object
@@ -322,6 +327,7 @@ QScriptValue QScriptContext::argumentsObject() const
bool QScriptContext::isCalledAsConstructor() const
{
JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
//For native functions, look up flags.
uint flags = QScriptEnginePrivate::contextFlags(frame);
@@ -355,6 +361,7 @@ bool QScriptContext::isCalledAsConstructor() const
QScriptContext *QScriptContext::parentContext() const
{
const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::CallFrame *callerFrame = frame->callerFrame()->removeHostCallFrameFlag();
return QScriptEnginePrivate::contextForFrame(callerFrame);
}
@@ -412,6 +419,7 @@ void QScriptContext::setReturnValue(const QScriptValue &result)
QScriptValue QScriptContext::activationObject() const
{
JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
JSC::JSObject *result = 0;
uint flags = QScriptEnginePrivate::contextFlags(frame);
@@ -477,6 +485,7 @@ void QScriptContext::setActivationObject(const QScriptValue &activation)
}
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
+ QScript::APIShim shim(engine);
JSC::JSObject *object = JSC::asObject(engine->scriptValueToJSCValue(activation));
if (object == engine->originalGlobalObjectProxy)
object = engine->originalGlobalObject();
@@ -521,6 +530,7 @@ 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();
@@ -536,6 +546,7 @@ QScriptValue QScriptContext::thisObject() const
void QScriptContext::setThisObject(const QScriptValue &thisObject)
{
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
+ QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
if (!thisObject.isObject())
return;
if (thisObject.engine() != engine()) {
@@ -662,6 +673,7 @@ QScriptValueList QScriptContext::scopeChain() const
activationObject(); //ensure the creation of the normal scope for native context
const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
+ QScript::APIShim shim(engine);
QScriptValueList result;
JSC::ScopeChainNode *node = frame->scopeChain();
JSC::ScopeChainIterator it(node);
@@ -700,6 +712,7 @@ void QScriptContext::pushScope(const QScriptValue &object)
}
JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
+ QScript::APIShim shim(engine);
JSC::JSObject *jscObject = JSC::asObject(engine->scriptValueToJSCValue(object));
if (jscObject == engine->originalGlobalObjectProxy)
jscObject = engine->originalGlobalObject();
@@ -733,6 +746,7 @@ QScriptValue QScriptContext::popScope()
JSC::ScopeChainNode *scope = frame->scopeChain();
Q_ASSERT(scope != 0);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
+ QScript::APIShim shim(engine);
QScriptValue result = engine->scriptValueFromJSCValue(scope->object);
if (!scope->next) {
// We cannot have a null scope chain, so just zap the object pointer.
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 70f798e..13b8e7c 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1900,6 +1900,7 @@ QScriptEngine::~QScriptEngine()
QScriptValue QScriptEngine::globalObject() const
{
Q_D(const QScriptEngine);
+ QScript::APIShim shim(const_cast<QScriptEnginePrivate*>(d));
JSC::JSObject *result = d->globalObject();
return const_cast<QScriptEnginePrivate*>(d)->scriptValueFromJSCValue(result);
}
@@ -1921,6 +1922,7 @@ void QScriptEngine::setGlobalObject(const QScriptValue &object)
Q_D(QScriptEngine);
if (!object.isObject())
return;
+ QScript::APIShim shim(d);
JSC::JSObject *jscObject = JSC::asObject(d->scriptValueToJSCValue(object));
d->setGlobalObject(jscObject);
}
@@ -1977,6 +1979,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun,
int length)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::ExecState* exec = d->currentFrame;
JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun);
QScriptValue result = d->scriptValueFromJSCValue(function);
@@ -2000,6 +2003,7 @@ extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
QScriptValue QScriptEngine::newRegExp(const QRegExp &regexp)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newRegExp(d->currentFrame, regexp));
}
@@ -2018,6 +2022,7 @@ QScriptValue QScriptEngine::newRegExp(const QRegExp &regexp)
QScriptValue QScriptEngine::newVariant(const QVariant &value)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newVariant(value));
}
@@ -2051,6 +2056,7 @@ QScriptValue QScriptEngine::newVariant(const QScriptValue &object,
const QVariant &value)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::JSValue jsObject = d->scriptValueToJSCValue(object);
return d->scriptValueFromJSCValue(d->newVariant(jsObject, value));
}
@@ -2082,6 +2088,7 @@ QScriptValue QScriptEngine::newQObject(QObject *object, ValueOwnership ownership
const QObjectWrapOptions &options)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::JSValue jscQObject = d->newQObject(object, ownership, options);
return d->scriptValueFromJSCValue(jscQObject);
}
@@ -2118,8 +2125,10 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject,
ValueOwnership ownership,
const QObjectWrapOptions &options)
{
+ Q_D(QScriptEngine);
if (!scriptObject.isObject())
return newQObject(qtObject, ownership, options);
+ QScript::APIShim shim(d);
JSC::JSObject *jscObject = JSC::asObject(QScriptValuePrivate::get(scriptObject)->jscValue);
if (!jscObject->inherits(&QScriptObject::info)) {
qWarning("QScriptEngine::newQObject(): changing class of non-QScriptObject not supported");
@@ -2150,6 +2159,7 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject,
QScriptValue QScriptEngine::newObject()
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newObject());
}
@@ -2171,6 +2181,7 @@ QScriptValue QScriptEngine::newObject(QScriptClass *scriptClass,
const QScriptValue &data)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::ExecState* exec = d->currentFrame;
QScriptObject *result = new (exec) QScriptObject(d->scriptObjectStructure);
result->setDelegate(new QScript::ClassObjectDelegate(scriptClass));
@@ -2238,6 +2249,7 @@ QScriptValue QScriptEngine::newActivationObject()
QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, int length)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::ExecState* exec = d->currentFrame;
JSC::JSValue function = new (exec)QScript::FunctionWrapper(exec, length, JSC::Identifier(exec, ""), fun);
QScriptValue result = d->scriptValueFromJSCValue(function);
@@ -2255,6 +2267,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun, in
QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature fun, void *arg)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::ExecState* exec = d->currentFrame;
JSC::JSValue function = new (exec)QScript::FunctionWithArgWrapper(exec, /*length=*/0, JSC::Identifier(exec, ""), fun, arg);
QScriptValue result = d->scriptValueFromJSCValue(function);
@@ -2273,6 +2286,7 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionWithArgSignature
QScriptValue QScriptEngine::newArray(uint length)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newArray(d->currentFrame, length));
}
@@ -2286,6 +2300,7 @@ QScriptValue QScriptEngine::newArray(uint length)
QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &flags)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newRegExp(d->currentFrame, pattern, flags));
}
@@ -2297,6 +2312,7 @@ QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &fla
QScriptValue QScriptEngine::newDate(qsreal value)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newDate(d->currentFrame, value));
}
@@ -2308,6 +2324,7 @@ QScriptValue QScriptEngine::newDate(qsreal value)
QScriptValue QScriptEngine::newDate(const QDateTime &value)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->newDate(d->currentFrame, value));
}
@@ -2331,6 +2348,7 @@ QScriptValue QScriptEngine::newQMetaObject(
const QMetaObject *metaObject, const QScriptValue &ctor)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::JSValue jscCtor = d->scriptValueToJSCValue(ctor);
JSC::JSValue jscQMetaObject = d->newQMetaObject(metaObject, jscCtor);
return d->scriptValueFromJSCValue(jscQMetaObject);
@@ -2583,6 +2601,7 @@ QScriptContext *QScriptEngine::currentContext() const
QScriptContext *QScriptEngine::pushContext()
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::CallFrame* newFrame = d->pushContext(d->currentFrame, d->currentFrame->globalData().dynamicGlobalObject,
JSC::ArgList(), /*callee = */0);
@@ -2674,6 +2693,7 @@ void QScriptEngine::popContext()
if (agent())
agent()->contextPop();
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
if (d->currentFrame->returnPC() != 0 || d->currentFrame->codeBlock() != 0
|| !currentContext()->parentContext()) {
qWarning("QScriptEngine::popContext() doesn't match with pushContext()");
@@ -2869,6 +2889,7 @@ void QScriptEngine::setDefaultPrototype(int metaTypeId, const QScriptValue &prot
QScriptValue QScriptEngine::create(int type, const void *ptr)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
return d->scriptValueFromJSCValue(d->create(d->currentFrame, type, ptr));
}
@@ -3315,6 +3336,7 @@ void QScriptEngine::registerCustomType(int type, MarshalFunction mf,
const QScriptValue &prototype)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
QScriptTypeInfo *info = d->m_typeInfos.value(type);
if (!info) {
info = new QScriptTypeInfo();
@@ -3381,6 +3403,7 @@ QScriptValue QScriptEngine::importExtension(const QString &extension)
Q_UNUSED(extension);
#else
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
if (d->importedExtensions.contains(extension))
return undefinedValue(); // already imported
@@ -4021,6 +4044,7 @@ bool qScriptConnect(QObject *sender, const char *signal,
if (receiver.isObject() && (receiver.engine() != function.engine()))
return false;
QScriptEnginePrivate *engine = QScriptEnginePrivate::get(function.engine());
+ QScript::APIShim shim(engine);
JSC::JSValue jscReceiver = engine->scriptValueToJSCValue(receiver);
JSC::JSValue jscFunction = engine->scriptValueToJSCValue(function);
return engine->scriptConnect(sender, signal, jscReceiver, jscFunction,
@@ -4047,6 +4071,7 @@ bool qScriptDisconnect(QObject *sender, const char *signal,
if (receiver.isObject() && (receiver.engine() != function.engine()))
return false;
QScriptEnginePrivate *engine = QScriptEnginePrivate::get(function.engine());
+ QScript::APIShim shim(engine);
JSC::JSValue jscReceiver = engine->scriptValueToJSCValue(receiver);
JSC::JSValue jscFunction = engine->scriptValueToJSCValue(function);
return engine->scriptDisconnect(sender, signal, jscReceiver, jscFunction);
@@ -4152,6 +4177,7 @@ QScriptString QScriptEngine::toStringHandle(const QString &str)
QScriptValue QScriptEngine::toObject(const QScriptValue &value)
{
Q_D(QScriptEngine);
+ QScript::APIShim shim(d);
JSC::JSValue jscValue = d->scriptValueToJSCValue(value);
if (!jscValue || jscValue.isUndefined() || jscValue.isNull())
return QScriptValue();
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 70ab7c9..5c2007f 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -798,7 +798,6 @@ inline void QScriptEnginePrivate::unregisterScriptString(QScriptStringPrivate *v
registeredScriptStrings = value->next;
value->prev = 0;
value->next = 0;
- JSC::setCurrentIdentifierTable(globalData->identifierTable);
}
inline QScriptContext *QScriptEnginePrivate::contextForFrame(JSC::ExecState *frame)
diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp
index 7978b61..d0b0ffd 100644
--- a/src/script/api/qscriptstring.cpp
+++ b/src/script/api/qscriptstring.cpp
@@ -92,8 +92,12 @@ QScriptString::~QScriptString()
d->ref.ref(); // avoid deletion
break;
case QScriptStringPrivate::HeapAllocated:
- if (d->engine && (d->ref == 1))
+ if (d->engine && (d->ref == 1)) {
+ // Make sure the identifier is removed from the correct engine.
+ QScript::APIShim(d->engine);
+ d->identifier = JSC::Identifier();
d->engine->unregisterScriptString(d);
+ }
break;
}
}
diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp
index ecda5fc..77d43b3 100644
--- a/src/script/api/qscriptvalueiterator.cpp
+++ b/src/script/api/qscriptvalueiterator.cpp
@@ -150,6 +150,12 @@ QScriptValueIterator::QScriptValueIterator(const QScriptValue &object)
*/
QScriptValueIterator::~QScriptValueIterator()
{
+ Q_D(QScriptValueIterator);
+ if (d && d->engine()) {
+ // Make sure identifiers are removed from the correct engine.
+ QScript::APIShim shim(d->engine());
+ d->propertyNames.clear();
+ }
}
/*!