Remove qv8engine usage in the contextwrapper
Change-Id: Iaf807add5d971e96cac57e38e13385e901f9c930 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
3e054a80dd
commit
bede2a3ac7
|
@ -1417,7 +1417,7 @@ QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowEngine *engine, int name
|
||||||
Scope scope(engine);
|
Scope scope(engine);
|
||||||
ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
|
ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
|
||||||
Scoped<QmlContextWrapper> wrapper(scope, engine->qmlContextObject());
|
Scoped<QmlContextWrapper> wrapper(scope, engine->qmlContextObject());
|
||||||
return wrapper->qmlSingletonWrapper(engine->v8Engine, name);
|
return wrapper->qmlSingletonWrapper(engine, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runtime::convertThisToObject(ExecutionEngine *engine)
|
void Runtime::convertThisToObject(ExecutionEngine *engine)
|
||||||
|
|
|
@ -169,7 +169,7 @@ Heap::FunctionObject *QmlBindingWrapper::createQmlCallableForFunction(QQmlContex
|
||||||
{
|
{
|
||||||
ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->engine);
|
ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->engine);
|
||||||
QV4::Scope valueScope(engine);
|
QV4::Scope valueScope(engine);
|
||||||
QV4::ScopedObject qmlScopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(engine->v8Engine, qmlContext, scopeObject));
|
QV4::ScopedObject qmlScopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(engine, qmlContext, scopeObject));
|
||||||
ScopedContext global(valueScope, valueScope.engine->rootContext());
|
ScopedContext global(valueScope, valueScope.engine->rootContext());
|
||||||
QV4::Scoped<QV4::QmlBindingWrapper> wrapper(valueScope, engine->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScopeObject));
|
QV4::Scoped<QV4::QmlBindingWrapper> wrapper(valueScope, engine->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScopeObject));
|
||||||
QV4::Scoped<CallContext> wrapperContext(valueScope, wrapper->context());
|
QV4::Scoped<CallContext> wrapperContext(valueScope, wrapper->context());
|
||||||
|
|
|
@ -53,8 +53,8 @@ using namespace QV4;
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(QmlContextWrapper);
|
DEFINE_OBJECT_VTABLE(QmlContextWrapper);
|
||||||
|
|
||||||
Heap::QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
|
Heap::QmlContextWrapper::QmlContextWrapper(QV4::ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
|
||||||
: Heap::Object(QV8Engine::getV4(engine))
|
: Heap::Object(engine)
|
||||||
, readOnly(true)
|
, readOnly(true)
|
||||||
, ownsContext(ownsContext)
|
, ownsContext(ownsContext)
|
||||||
, isNullWrapper(false)
|
, isNullWrapper(false)
|
||||||
|
@ -70,18 +70,16 @@ Heap::QmlContextWrapper::~QmlContextWrapper()
|
||||||
context->destroy();
|
context->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnedValue QmlContextWrapper::qmlScope(QV8Engine *v8, QQmlContextData *ctxt, QObject *scope)
|
ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope)
|
||||||
{
|
{
|
||||||
ExecutionEngine *v4 = QV8Engine::getV4(v8);
|
|
||||||
Scope valueScope(v4);
|
Scope valueScope(v4);
|
||||||
|
|
||||||
Scoped<QmlContextWrapper> w(valueScope, v4->memoryManager->alloc<QmlContextWrapper>(v8, ctxt, scope));
|
Scoped<QmlContextWrapper> w(valueScope, v4->memoryManager->alloc<QmlContextWrapper>(v4, ctxt, scope));
|
||||||
return w.asReturnedValue();
|
return w.asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url)
|
ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url)
|
||||||
{
|
{
|
||||||
ExecutionEngine *v4 = QV8Engine::getV4(v8);
|
|
||||||
Scope scope(v4);
|
Scope scope(v4);
|
||||||
|
|
||||||
QQmlContextData *context = new QQmlContextData;
|
QQmlContextData *context = new QQmlContextData;
|
||||||
|
@ -89,7 +87,7 @@ ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url)
|
||||||
context->isInternal = true;
|
context->isInternal = true;
|
||||||
context->isJSContext = true;
|
context->isJSContext = true;
|
||||||
|
|
||||||
Scoped<QmlContextWrapper> w(scope, v4->memoryManager->alloc<QmlContextWrapper>(v8, context, (QObject*)0, true));
|
Scoped<QmlContextWrapper> w(scope, v4->memoryManager->alloc<QmlContextWrapper>(v4, context, (QObject*)0, true));
|
||||||
w->d()->isNullWrapper = true;
|
w->d()->isNullWrapper = true;
|
||||||
return w.asReturnedValue();
|
return w.asReturnedValue();
|
||||||
}
|
}
|
||||||
|
@ -198,7 +196,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
|
||||||
// Fall through
|
// Fall through
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->v8Engine->engine());
|
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->qmlEngine());
|
||||||
|
|
||||||
while (context) {
|
while (context) {
|
||||||
// Search context properties
|
// Search context properties
|
||||||
|
@ -353,7 +351,7 @@ void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const C
|
||||||
// Let the caller check and avoid the function call :)
|
// Let the caller check and avoid the function call :)
|
||||||
Q_ASSERT(compiledFunction->hasQmlDependencies());
|
Q_ASSERT(compiledFunction->hasQmlDependencies());
|
||||||
|
|
||||||
QQmlEnginePrivate *ep = engine->v8Engine->engine() ? QQmlEnginePrivate::get(engine->v8Engine->engine()) : 0;
|
QQmlEnginePrivate *ep = engine->qmlEngine() ? QQmlEnginePrivate::get(engine->qmlEngine()) : 0;
|
||||||
if (!ep)
|
if (!ep)
|
||||||
return;
|
return;
|
||||||
QQmlEnginePrivate::PropertyCapture *capture = ep->propertyCapture;
|
QQmlEnginePrivate::PropertyCapture *capture = ep->propertyCapture;
|
||||||
|
@ -400,7 +398,7 @@ ReturnedValue QmlContextWrapper::idObjectsArray()
|
||||||
return d()->idObjectsWrapper->asReturnedValue();
|
return d()->idObjectsWrapper->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name)
|
ReturnedValue QmlContextWrapper::qmlSingletonWrapper(ExecutionEngine *v4, String *name)
|
||||||
{
|
{
|
||||||
if (!d()->context->imports)
|
if (!d()->context->imports)
|
||||||
return Encode::undefined();
|
return Encode::undefined();
|
||||||
|
@ -410,9 +408,9 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name
|
||||||
Q_ASSERT(r.isValid());
|
Q_ASSERT(r.isValid());
|
||||||
Q_ASSERT(r.type);
|
Q_ASSERT(r.type);
|
||||||
Q_ASSERT(r.type->isSingleton());
|
Q_ASSERT(r.type->isSingleton());
|
||||||
Q_ASSERT(v8);
|
Q_ASSERT(v4);
|
||||||
|
|
||||||
QQmlEngine *e = v8->engine();
|
QQmlEngine *e = v4->qmlEngine();
|
||||||
QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo();
|
QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo();
|
||||||
siinfo->init(e);
|
siinfo->init(e);
|
||||||
|
|
||||||
|
@ -451,7 +449,7 @@ ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasPr
|
||||||
*hasProperty = true;
|
*hasProperty = true;
|
||||||
|
|
||||||
ExecutionEngine *v4 = m->engine();
|
ExecutionEngine *v4 = m->engine();
|
||||||
QQmlEnginePrivate *ep = v4->v8Engine->engine() ? QQmlEnginePrivate::get(v4->v8Engine->engine()) : 0;
|
QQmlEnginePrivate *ep = v4->qmlEngine() ? QQmlEnginePrivate::get(v4->qmlEngine()) : 0;
|
||||||
if (ep)
|
if (ep)
|
||||||
ep->captureProperty(&context->idValues[index].bindings);
|
ep->captureProperty(&context->idValues[index].bindings);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Heap {
|
||||||
struct QQmlIdObjectsArray;
|
struct QQmlIdObjectsArray;
|
||||||
|
|
||||||
struct QmlContextWrapper : Object {
|
struct QmlContextWrapper : Object {
|
||||||
QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
|
QmlContextWrapper(ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
|
||||||
~QmlContextWrapper();
|
~QmlContextWrapper();
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
bool ownsContext;
|
bool ownsContext;
|
||||||
|
@ -91,8 +91,8 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
|
||||||
V4_OBJECT2(QmlContextWrapper, Object)
|
V4_OBJECT2(QmlContextWrapper, Object)
|
||||||
V4_NEEDS_DESTROY
|
V4_NEEDS_DESTROY
|
||||||
|
|
||||||
static ReturnedValue qmlScope(QV8Engine *e, QQmlContextData *ctxt, QObject *scope);
|
static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope);
|
||||||
static ReturnedValue urlScope(QV8Engine *e, const QUrl &);
|
static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &);
|
||||||
|
|
||||||
static QQmlContextData *callingContext(ExecutionEngine *v4);
|
static QQmlContextData *callingContext(ExecutionEngine *v4);
|
||||||
static void takeContextOwnership(const ValueRef qmlglobal);
|
static void takeContextOwnership(const ValueRef qmlglobal);
|
||||||
|
@ -110,7 +110,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
|
||||||
static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
|
static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
|
||||||
|
|
||||||
ReturnedValue idObjectsArray();
|
ReturnedValue idObjectsArray();
|
||||||
ReturnedValue qmlSingletonWrapper(QV8Engine *e, String *name);
|
ReturnedValue qmlSingletonWrapper(ExecutionEngine *e, String *name);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
|
||||||
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
|
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
|
||||||
QV4::Scope scope(v4);
|
QV4::Scope scope(v4);
|
||||||
|
|
||||||
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, scopeObject));
|
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(v4, ctxt, scopeObject));
|
||||||
QV4::Script script(v4, qmlScopeObject, code, filename, line);
|
QV4::Script script(v4, qmlScopeObject, code, filename, line);
|
||||||
QV4::ScopedValue result(scope);
|
QV4::ScopedValue result(scope);
|
||||||
script.parse();
|
script.parse();
|
||||||
|
@ -322,7 +322,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, Q
|
||||||
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
|
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
|
||||||
QV4::Scope scope(v4);
|
QV4::Scope scope(v4);
|
||||||
|
|
||||||
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, qmlScope));
|
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(v4, ctxt, qmlScope));
|
||||||
QV4::Script script(v4, qmlScopeObject, code, filename, line);
|
QV4::Script script(v4, qmlScopeObject, code, filename, line);
|
||||||
QV4::ScopedValue result(scope);
|
QV4::ScopedValue result(scope);
|
||||||
script.parse();
|
script.parse();
|
||||||
|
|
|
@ -264,7 +264,7 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance)
|
||||||
Q_ASSERT(!sharedState->allJavaScriptObjects);
|
Q_ASSERT(!sharedState->allJavaScriptObjects);
|
||||||
sharedState->allJavaScriptObjects = valueScope.alloc(compiledData->totalObjectCount);
|
sharedState->allJavaScriptObjects = valueScope.alloc(compiledData->totalObjectCount);
|
||||||
|
|
||||||
QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject));
|
QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(v4, context, _scopeObject));
|
||||||
QV4::ScopedContext global(valueScope, valueScope.engine->rootContext());
|
QV4::ScopedContext global(valueScope, valueScope.engine->rootContext());
|
||||||
QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope));
|
QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope));
|
||||||
// ### GC
|
// ### GC
|
||||||
|
@ -1176,7 +1176,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
|
||||||
ref = QV4::QObjectWrapper::wrap(v4, instance);
|
ref = QV4::QObjectWrapper::wrap(v4, instance);
|
||||||
|
|
||||||
QV4::Scope valueScope(v4);
|
QV4::Scope valueScope(v4);
|
||||||
QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject));
|
QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(v4, context, _scopeObject));
|
||||||
QV4::ScopedContext global(valueScope, valueScope.engine->rootContext());
|
QV4::ScopedContext global(valueScope, valueScope.engine->rootContext());
|
||||||
QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope));
|
QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope));
|
||||||
// ### GC
|
// ### GC
|
||||||
|
|
|
@ -2462,7 +2462,6 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
|
||||||
|
|
||||||
Q_ASSERT(parentCtxt && parentCtxt->engine);
|
Q_ASSERT(parentCtxt && parentCtxt->engine);
|
||||||
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
|
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
|
||||||
QV8Engine *v8engine = ep->v8engine();
|
|
||||||
QV4::ExecutionEngine *v4 = QV8Engine::getV4(parentCtxt->engine);
|
QV4::ExecutionEngine *v4 = QV8Engine::getV4(parentCtxt->engine);
|
||||||
QV4::Scope scope(v4);
|
QV4::Scope scope(v4);
|
||||||
|
|
||||||
|
@ -2521,7 +2520,7 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
|
||||||
return QV4::PersistentValue();
|
return QV4::PersistentValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
QV4::ScopedValue qmlglobal(scope, QV4::QmlContextWrapper::qmlScope(v8engine, ctxt, 0));
|
QV4::ScopedValue qmlglobal(scope, QV4::QmlContextWrapper::qmlScope(v4, ctxt, 0));
|
||||||
QV4::QmlContextWrapper::takeContextOwnership(qmlglobal);
|
QV4::QmlContextWrapper::takeContextOwnership(qmlglobal);
|
||||||
|
|
||||||
m_program->qml = qmlglobal;
|
m_program->qml = qmlglobal;
|
||||||
|
|
|
@ -99,7 +99,7 @@ static ReturnedValue constructMeObject(const ValueRef thisObj, QV8Engine *e)
|
||||||
Scope scope(v4);
|
Scope scope(v4);
|
||||||
ScopedObject meObj(scope, v4->newObject());
|
ScopedObject meObj(scope, v4->newObject());
|
||||||
meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ThisObject"))), thisObj);
|
meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ThisObject"))), thisObj);
|
||||||
ScopedValue v(scope, QmlContextWrapper::qmlScope(e, e->callingContext(), 0));
|
ScopedValue v(scope, QmlContextWrapper::qmlScope(v4, e->callingContext(), 0));
|
||||||
meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ActivationObject"))), v);
|
meObj->put(ScopedString(scope, v4->newString(QStringLiteral("ActivationObject"))), v);
|
||||||
return meObj.asReturnedValue();
|
return meObj.asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,7 +300,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *scri
|
||||||
QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
|
QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
|
||||||
QV4::Scope scope(v4);
|
QV4::Scope scope(v4);
|
||||||
|
|
||||||
script->object = QV4::QmlContextWrapper::urlScope(workerEngine, script->source);
|
script->object = QV4::QmlContextWrapper::urlScope(v4, script->source);
|
||||||
|
|
||||||
QV4::Scoped<QV4::QmlContextWrapper> w(scope, script->object.value());
|
QV4::Scoped<QV4::QmlContextWrapper> w(scope, script->object.value());
|
||||||
Q_ASSERT(!!w);
|
Q_ASSERT(!!w);
|
||||||
|
|
|
@ -3950,7 +3950,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
|
||||||
|
|
||||||
{
|
{
|
||||||
QV4::Scope scope(QV8Engine::getV4((engine)));
|
QV4::Scope scope(QV8Engine::getV4((engine)));
|
||||||
QV4::ScopedValue temporaryScope(scope, QV4::QmlContextWrapper::qmlScope(engine, scriptContext, 0));
|
QV4::ScopedValue temporaryScope(scope, QV4::QmlContextWrapper::qmlScope(scope.engine, scriptContext, 0));
|
||||||
Q_UNUSED(temporaryScope)
|
Q_UNUSED(temporaryScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue