Remove qv8engine usage in the contextwrapper

Change-Id: Iaf807add5d971e96cac57e38e13385e901f9c930
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
Lars Knoll 2014-12-30 21:36:00 +01:00 committed by Lars Knoll
parent 3e054a80dd
commit bede2a3ac7
10 changed files with 26 additions and 29 deletions

View File

@ -1417,7 +1417,7 @@ QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowEngine *engine, int name
Scope scope(engine);
ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
Scoped<QmlContextWrapper> wrapper(scope, engine->qmlContextObject());
return wrapper->qmlSingletonWrapper(engine->v8Engine, name);
return wrapper->qmlSingletonWrapper(engine, name);
}
void Runtime::convertThisToObject(ExecutionEngine *engine)

View File

@ -169,7 +169,7 @@ Heap::FunctionObject *QmlBindingWrapper::createQmlCallableForFunction(QQmlContex
{
ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->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());
QV4::Scoped<QV4::QmlBindingWrapper> wrapper(valueScope, engine->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScopeObject));
QV4::Scoped<CallContext> wrapperContext(valueScope, wrapper->context());

View File

@ -53,8 +53,8 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlContextWrapper);
Heap::QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
: Heap::Object(QV8Engine::getV4(engine))
Heap::QmlContextWrapper::QmlContextWrapper(QV4::ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
: Heap::Object(engine)
, readOnly(true)
, ownsContext(ownsContext)
, isNullWrapper(false)
@ -70,18 +70,16 @@ Heap::QmlContextWrapper::~QmlContextWrapper()
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);
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();
}
ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url)
ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url)
{
ExecutionEngine *v4 = QV8Engine::getV4(v8);
Scope scope(v4);
QQmlContextData *context = new QQmlContextData;
@ -89,7 +87,7 @@ ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url)
context->isInternal = 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;
return w.asReturnedValue();
}
@ -198,7 +196,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
// Fall through
}
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->v8Engine->engine());
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->qmlEngine());
while (context) {
// Search context properties
@ -353,7 +351,7 @@ void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const C
// Let the caller check and avoid the function call :)
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)
return;
QQmlEnginePrivate::PropertyCapture *capture = ep->propertyCapture;
@ -400,7 +398,7 @@ ReturnedValue QmlContextWrapper::idObjectsArray()
return d()->idObjectsWrapper->asReturnedValue();
}
ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name)
ReturnedValue QmlContextWrapper::qmlSingletonWrapper(ExecutionEngine *v4, String *name)
{
if (!d()->context->imports)
return Encode::undefined();
@ -410,9 +408,9 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name
Q_ASSERT(r.isValid());
Q_ASSERT(r.type);
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();
siinfo->init(e);
@ -451,7 +449,7 @@ ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasPr
*hasProperty = true;
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)
ep->captureProperty(&context->idValues[index].bindings);

View File

@ -68,7 +68,7 @@ namespace Heap {
struct QQmlIdObjectsArray;
struct QmlContextWrapper : Object {
QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
QmlContextWrapper(ExecutionEngine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
~QmlContextWrapper();
bool readOnly;
bool ownsContext;
@ -91,8 +91,8 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
V4_OBJECT2(QmlContextWrapper, Object)
V4_NEEDS_DESTROY
static ReturnedValue qmlScope(QV8Engine *e, QQmlContextData *ctxt, QObject *scope);
static ReturnedValue urlScope(QV8Engine *e, const QUrl &);
static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope);
static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &);
static QQmlContextData *callingContext(ExecutionEngine *v4);
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);
ReturnedValue idObjectsArray();
ReturnedValue qmlSingletonWrapper(QV8Engine *e, String *name);
ReturnedValue qmlSingletonWrapper(ExecutionEngine *e, String *name);
};

View File

@ -289,7 +289,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
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::ScopedValue result(scope);
script.parse();
@ -322,7 +322,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, Q
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
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::ScopedValue result(scope);
script.parse();

View File

@ -264,7 +264,7 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance)
Q_ASSERT(!sharedState->allJavaScriptObjects);
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::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope));
// ### GC
@ -1176,7 +1176,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
ref = QV4::QObjectWrapper::wrap(v4, instance);
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::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope));
// ### GC

View File

@ -2462,7 +2462,6 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
Q_ASSERT(parentCtxt && parentCtxt->engine);
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
QV8Engine *v8engine = ep->v8engine();
QV4::ExecutionEngine *v4 = QV8Engine::getV4(parentCtxt->engine);
QV4::Scope scope(v4);
@ -2521,7 +2520,7 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
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);
m_program->qml = qmlglobal;

View File

@ -99,7 +99,7 @@ static ReturnedValue constructMeObject(const ValueRef thisObj, QV8Engine *e)
Scope scope(v4);
ScopedObject meObj(scope, v4->newObject());
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);
return meObj.asReturnedValue();
}

View File

@ -300,7 +300,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *scri
QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
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());
Q_ASSERT(!!w);

View File

@ -3950,7 +3950,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
{
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)
}