aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-04-29 11:20:12 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-07-22 13:49:04 +0200
commitc3c839e82f423fec5598c302fe8fc5465463cc05 (patch)
tree61382cd6a5c1e6cb389d2b3eb3d525eb54aae811 /src
parentdd2c592349c88b0125c3858c542b199524897663 (diff)
Convert the QML Binding wrapper to new data storage
Change-Id: I715184fe339238a7881a4c64af8c976b81362724 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4script.cpp40
-rw-r--r--src/qml/jsruntime/qv4script_p.h18
2 files changed, 36 insertions, 22 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 3ef6cfb34f..60f3df59cf 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -63,9 +63,9 @@ using namespace QV4;
QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml)
: FunctionObject(scope, scope->engine->id_eval, /*createProto = */ false)
- , qml(qml)
- , qmlContext(0)
{
+ d()->qml = qml;
+
Q_ASSERT(scope->inUse());
setVTable(staticVTable());
@@ -79,15 +79,15 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec
defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
- qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
+ d()->qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
scope->engine->popContext();
}
QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml)
: FunctionObject(scope, scope->engine->id_eval, /*createProto = */ false)
- , qml(qml)
- , qmlContext(0)
{
+ d()->qml = qml;
+
Q_ASSERT(scope->inUse());
setVTable(staticVTable());
@@ -98,7 +98,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml)
defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
- qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
+ d()->qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
scope->engine->popContext();
}
@@ -112,7 +112,7 @@ ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *)
if (!This->function())
return QV4::Encode::undefined();
- CallContext *ctx = This->qmlContext;
+ CallContext *ctx = This->d()->qmlContext;
std::fill(ctx->locals, ctx->locals + ctx->function->varCount(), Primitive::undefinedValue());
engine->pushContext(ctx);
ScopedValue result(scope, This->function()->code(ctx, This->function()->codeData));
@@ -124,11 +124,11 @@ ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *)
void QmlBindingWrapper::markObjects(Managed *m, ExecutionEngine *e)
{
QmlBindingWrapper *wrapper = static_cast<QmlBindingWrapper*>(m);
- if (wrapper->qml)
- wrapper->qml->mark(e);
+ if (wrapper->d()->qml)
+ wrapper->d()->qml->mark(e);
FunctionObject::markObjects(m, e);
- if (wrapper->qmlContext)
- wrapper->qmlContext->mark(e);
+ if (wrapper->d()->qmlContext)
+ wrapper->d()->qmlContext->mark(e);
}
static ReturnedValue signalParameterGetter(QV4::CallContext *ctx, uint parameterIndex)
@@ -165,20 +165,27 @@ Returned<FunctionObject> *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo
DEFINE_OBJECT_VTABLE(QmlBindingWrapper);
-struct CompilationUnitHolder : public QV4::Object
+struct CompilationUnitHolder : public Object
{
- V4_OBJECT
+ struct Data : Object::Data {
+ QV4::CompiledData::CompilationUnit *unit;
+ };
+ struct {
+ QV4::CompiledData::CompilationUnit *unit;
+ } __data;
+
+ V4_OBJECT_NEW
CompilationUnitHolder(ExecutionEngine *engine, CompiledData::CompilationUnit *unit)
: Object(engine)
- , unit(unit)
{
- unit->ref();
+ d()->unit = unit;
+ d()->unit->ref();
setVTable(staticVTable());
}
~CompilationUnitHolder()
{
- unit->deref();
+ d()->unit->deref();
}
static void destroy(Managed *that)
@@ -186,7 +193,6 @@ struct CompilationUnitHolder : public QV4::Object
static_cast<CompilationUnitHolder*>(that)->~CompilationUnitHolder();
}
- QV4::CompiledData::CompilationUnit *unit;
};
DEFINE_OBJECT_VTABLE(CompilationUnitHolder);
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index b2c0efc75f..5427ebb704 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -56,7 +56,16 @@ namespace QV4 {
struct ExecutionContext;
struct Q_QML_EXPORT QmlBindingWrapper : FunctionObject {
- V4_OBJECT
+ struct Data : FunctionObject::Data {
+ Object *qml;
+ CallContext *qmlContext;
+ };
+ struct {
+ Object *qml;
+ CallContext *qmlContext;
+ } __data;
+
+ V4_OBJECT_NEW
QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml);
// Constructor for QML functions and signal handlers, resulting binding wrapper is not callable!
@@ -65,13 +74,12 @@ struct Q_QML_EXPORT QmlBindingWrapper : FunctionObject {
static ReturnedValue call(Managed *that, CallData *);
static void markObjects(Managed *m, ExecutionEngine *e);
- CallContext *context() const { return qmlContext; }
+ CallContext *context() const { return d()->qmlContext; }
- static Returned<FunctionObject> *createQmlCallableForFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction, const QList<QByteArray> &signalParameters = QList<QByteArray>(), QString *error = 0);
+ static Returned<FunctionObject> *createQmlCallableForFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction,
+ const QList<QByteArray> &signalParameters = QList<QByteArray>(), QString *error = 0);
private:
- Object *qml;
- CallContext *qmlContext;
};
struct Q_QML_EXPORT Script {