internalClass->engine->popContext();
}
-Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::QmlContextWrapper *qml)
- : Heap::FunctionObject(scope, scope->d()->engine->id_eval(), /*createProto = */ false)
-{
- Q_ASSERT(scope->inUse());
-
- Scope s(scope);
- Scoped<QV4::QmlBindingWrapper> protectThis(s, this);
-
- this->scope = scope->newQmlContext(qml);
- internalClass->engine->popContext();
-}
-
ReturnedValue QmlBindingWrapper::call(const Managed *that, CallData *callData)
{
const QmlBindingWrapper *This = static_cast<const QmlBindingWrapper *>(that);
QV4::Scope valueScope(engine);
QV4::Scoped<QmlContextWrapper> 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<QmlContext> wrapperContext(valueScope, wrapper->context());
+ QV4::Scoped<QmlContext> wrapperContext(valueScope, global->newQmlContext(qmlScopeObject));
+ engine->popContext();
if (!signalParameters.isEmpty()) {
if (error)
namespace Heap {
struct QmlBindingWrapper : Heap::FunctionObject {
QmlBindingWrapper(QV4::ExecutionContext *scope, Function *f, QV4::QmlContextWrapper *qml);
- // Constructor for QML functions and signal handlers, resulting binding wrapper is not callable!
- QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::QmlContextWrapper *qml);
};
}
static ReturnedValue call(const Managed *that, CallData *callData);
- Heap::QmlContext *context() const { return static_cast<Heap::QmlContext *>(d()->scope.ptr); }
-
static Heap::FunctionObject *createQmlCallableForFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction,
const QList<QByteArray> &signalParameters = QList<QByteArray>(), QString *error = 0);
};
_ddata = 0;
_propertyCache = 0;
_vmeMetaObject = 0;
- _qmlBindingWrapper = 0;
+ _qmlContext = 0;
}
QQmlObjectCreator::~QQmlObjectCreator()
Q_ASSERT(!sharedState->allJavaScriptObjects);
sharedState->allJavaScriptObjects = valueScope.alloc(compiledData->totalObjectCount);
- QV4::Value *qmlBindingWrapper = valueScope.alloc(1);
+ QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc(1));
- qSwap(_qmlBindingWrapper, qmlBindingWrapper);
+ qSwap(_qmlContext, qmlContext);
qSwap(_propertyCache, cache);
qSwap(_qobject, instance);
qSwap(_qobject, instance);
qSwap(_propertyCache, cache);
- qSwap(_qmlBindingWrapper, qmlBindingWrapper);
+ qSwap(_qmlContext, qmlContext);
qSwap(_scopeObject, scopeObject);
phase = ObjectsCreated;
context->setIdProperty(idEntry.value(), instance);
}
-QV4::Heap::ExecutionContext *QQmlObjectCreator::currentQmlContext()
+QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext()
{
- if (!_qmlBindingWrapper->objectValue()) {
+ if (!_qmlContext->objectValue()) {
QV4::Scope valueScope(v4);
QV4::Scoped<QV4::QmlContextWrapper> qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(v4, context, _scopeObject));
QV4::ScopedContext global(valueScope, v4->rootContext());
- *_qmlBindingWrapper = v4->memoryManager->alloc<QV4::QmlBindingWrapper>(global, qmlScope);
+ _qmlContext->setM(global->newQmlContext(qmlScope));
+ v4->popContext();
}
- return static_cast<QV4::QmlBindingWrapper*>(_qmlBindingWrapper->objectValue())->context();
+ return _qmlContext->d();
}
QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isContextObject)
++sharedState->allJavaScriptObjects;
QV4::Scope valueScope(v4);
- QV4::Value *qmlBindingWrapper = valueScope.alloc(1);
+ QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc(1));
- qSwap(_qmlBindingWrapper, qmlBindingWrapper);
+ qSwap(_qmlContext, qmlContext);
bool result = populateInstance(index, instance, /*binding target*/instance, /*value type property*/0, bindingsToSkip);
- qSwap(_qmlBindingWrapper, qmlBindingWrapper);
+ qSwap(_qmlContext, qmlContext);
qSwap(_scopeObject, scopeObject);
return result ? instance : 0;