diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2014-11-03 20:41:17 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-11-08 19:47:43 +0100 |
commit | 5117c8e79c6d3933a0724b78fde9297a03741239 (patch) | |
tree | f1711d94d4bbaa4782dba2e3b4ca4127a4239491 /src/qml | |
parent | ef8ad8234b481d3985d748f7607ef486e1af086f (diff) |
Move more Data members over to the Heap namespace
Change-Id: I74347da3f0f47220bb1f8cf13b872b547fd18a4d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator_p.h | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectproto_p.h | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 17 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject.cpp | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject_p.h | 62 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script_p.h | 20 |
9 files changed, 110 insertions, 78 deletions
diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index dfd9b0fb34..4398ea9b5a 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -67,17 +67,17 @@ private: ObjectIterator(Value *scratch1, Value *scratch2, uint flags); // Constructor that requires calling init() }; +namespace Heap { +struct ForEachIteratorObject : Object { + ForEachIteratorObject(QV4::ExecutionEngine *engine, QV4::Object *o); + ObjectIterator it; + Value workArea[2]; +}; + +} + struct ForEachIteratorObject: Object { - struct Data : Heap::Object { - Data(ExecutionEngine *engine, QV4::Object *o) - : Heap::Object(engine) - , it(workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { - setVTable(staticVTable()); - } - ObjectIterator it; - Value workArea[2]; - }; - V4_OBJECT(Object) + V4_OBJECT2(ForEachIteratorObject, Object) Q_MANAGED_TYPE(ForeachIteratorObject) ReturnedValue nextPropertyName() { return d()->it.nextPropertyNameAsString(); } @@ -86,6 +86,14 @@ protected: static void markObjects(Heap::Base *that, ExecutionEngine *e); }; +inline +Heap::ForEachIteratorObject::ForEachIteratorObject(QV4::ExecutionEngine *engine, QV4::Object *o) + : Heap::Object(engine) + , it(workArea, workArea + 1, o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) +{ + setVTable(QV4::ForEachIteratorObject::staticVTable()); +} + } diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index f8e6329d85..f3d8affb01 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -49,10 +49,10 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(ObjectCtor); -ObjectCtor::Data::Data(ExecutionContext *scope) +Heap::ObjectCtor::ObjectCtor(QV4::ExecutionContext *scope) : Heap::FunctionObject(scope, QStringLiteral("Object")) { - setVTable(staticVTable()); + setVTable(QV4::ObjectCtor::staticVTable()); } ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData) diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h index f257d376db..ba61d452f5 100644 --- a/src/qml/jsruntime/qv4objectproto_p.h +++ b/src/qml/jsruntime/qv4objectproto_p.h @@ -41,12 +41,17 @@ QT_BEGIN_NAMESPACE namespace QV4 { +namespace Heap { + +struct ObjectCtor : FunctionObject { + ObjectCtor(QV4::ExecutionContext *scope); +}; + +} + struct ObjectCtor: FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope); - }; - V4_OBJECT(FunctionObject) + V4_OBJECT2(ObjectCtor, FunctionObject) static ReturnedValue construct(Managed *that, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index e6f014d05d..59bdf33c55 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -233,11 +233,11 @@ static QV4::ReturnedValue LoadProperty(QV8Engine *engine, QObject *object, } } -QObjectWrapper::Data::Data(ExecutionEngine *engine, QObject *object) +Heap::QObjectWrapper::QObjectWrapper(ExecutionEngine *engine, QObject *object) : Heap::Object(engine) , object(object) { - setVTable(staticVTable()); + setVTable(QV4::QObjectWrapper::staticVTable()); } void QObjectWrapper::initializeBindings(ExecutionEngine *engine) diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 0de3450388..746c158214 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -67,13 +67,18 @@ class QQmlPropertyData; namespace QV4 { struct QObjectSlotDispatcher; -struct Q_QML_EXPORT QObjectWrapper : public QV4::Object +namespace Heap { + +struct QObjectWrapper : Object { + QObjectWrapper(QV4::ExecutionEngine *engine, QObject *object); + QPointer<QObject> object; +}; + +} + +struct Q_QML_EXPORT QObjectWrapper : public Object { - struct Data : QV4::Heap::Object { - Data(ExecutionEngine *engine, QObject *object); - QPointer<QObject> object; - }; - V4_OBJECT(QV4::Object) + V4_OBJECT2(QObjectWrapper, Object) enum RevisionMode { IgnoreRevision, CheckRevision }; diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 5c729656ef..85ab712a09 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -64,37 +64,37 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(RegExpObject); DEFINE_OBJECT_VTABLE(RegExpPrototype); -RegExpObject::Data::Data(InternalClass *ic) +Heap::RegExpObject::RegExpObject(InternalClass *ic) : Heap::Object(ic) { - setVTable(staticVTable()); + setVTable(QV4::RegExpObject::staticVTable()); Scope scope(ic->engine); - Scoped<RegExpObject> o(scope, this); - o->d()->value = RegExp::create(ic->engine, QString(), false, false)->getPointer(); + Scoped<QV4::RegExpObject> o(scope, this); + o->d()->value = QV4::RegExp::create(ic->engine, QString(), false, false)->getPointer(); o->d()->global = false; o->init(ic->engine); } -RegExpObject::Data::Data(ExecutionEngine *engine, RegExp *value, bool global) +Heap::RegExpObject::RegExpObject(QV4::ExecutionEngine *engine, QV4::RegExp *value, bool global) : Heap::Object(engine->regExpClass) , value(value) , global(global) { - setVTable(staticVTable()); + setVTable(QV4::RegExpObject::staticVTable()); Scope scope(engine); - Scoped<RegExpObject> o(scope, this); + Scoped<QV4::RegExpObject> o(scope, this); o->init(engine); } // Converts a QRegExp to a JS RegExp. // The conversion is not 100% exact since ECMA regexp and QRegExp // have different semantics/flags, but we try to do our best. -RegExpObject::Data::Data(ExecutionEngine *engine, const QRegExp &re) +Heap::RegExpObject::RegExpObject(QV4::ExecutionEngine *engine, const QRegExp &re) : Heap::Object(engine->regExpClass) { - setVTable(staticVTable()); + setVTable(QV4::RegExpObject::staticVTable()); value = 0; global = false; @@ -137,9 +137,9 @@ RegExpObject::Data::Data(ExecutionEngine *engine, const QRegExp &re) } Scope scope(engine); - Scoped<RegExpObject> o(scope, this); + Scoped<QV4::RegExpObject> o(scope, this); - o->d()->value = RegExp::create(engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false)->getPointer(); + o->d()->value = QV4::RegExp::create(engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false)->getPointer(); o->init(engine); } @@ -229,14 +229,14 @@ uint RegExpObject::flags() const DEFINE_OBJECT_VTABLE(RegExpCtor); -RegExpCtor::Data::Data(ExecutionContext *scope) +Heap::RegExpCtor::RegExpCtor(QV4::ExecutionContext *scope) : Heap::FunctionObject(scope, QStringLiteral("RegExp")) { - setVTable(staticVTable()); + setVTable(QV4::RegExpCtor::staticVTable()); clearLastMatch(); } -void RegExpCtor::Data::clearLastMatch() +void Heap::RegExpCtor::clearLastMatch() { lastMatch = Primitive::nullValue(); lastInput = internalClass->engine->id_empty; diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 42e6494199..e71e2c21fd 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -55,16 +55,35 @@ QT_BEGIN_NAMESPACE namespace QV4 { -struct RegExpObject: Object { - struct Data : Heap::Object { - Data(ExecutionEngine *engine, RegExp *value, bool global); - Data(ExecutionEngine *engine, const QRegExp &re); - Data(InternalClass *ic); +namespace Heap { - RegExp *value; - bool global; - }; - V4_OBJECT(Object) +struct RegExpObject : Object { + RegExpObject(QV4::ExecutionEngine *engine, QV4::RegExp *value, bool global); + RegExpObject(QV4::ExecutionEngine *engine, const QRegExp &re); + RegExpObject(InternalClass *ic); + + QV4::RegExp *value; + bool global; +}; + +struct RegExpCtor : FunctionObject { + RegExpCtor(QV4::ExecutionContext *scope); + Value lastMatch; + StringValue lastInput; + int lastMatchStart; + int lastMatchEnd; + void clearLastMatch(); +}; + +struct RegExpPrototype : RegExpObject +{ + inline RegExpPrototype(InternalClass *ic); +}; + +} + +struct RegExpObject: Object { + V4_OBJECT2(RegExpObject, Object) Q_MANAGED_TYPE(RegExpObject) // needs to be compatible with the flags in qv4jsir_p.h @@ -96,15 +115,7 @@ protected: struct RegExpCtor: FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope); - Value lastMatch; - StringValue lastInput; - int lastMatchStart; - int lastMatchEnd; - void clearLastMatch(); - }; - V4_OBJECT(FunctionObject) + V4_OBJECT2(RegExpCtor, FunctionObject) Value lastMatch() { return d()->lastMatch; } StringValue lastInput() { return d()->lastInput; } @@ -118,14 +129,7 @@ struct RegExpCtor: FunctionObject struct RegExpPrototype: RegExpObject { - struct Data : RegExpObject::Data - { - Data(InternalClass *ic): RegExpObject::Data(ic) - { - setVTable(staticVTable()); - } - }; - V4_OBJECT(RegExpObject) + V4_OBJECT2(RegExpPrototype, RegExpObject) void init(ExecutionEngine *engine, Object *ctor); @@ -142,6 +146,12 @@ struct RegExpPrototype: RegExpObject static ReturnedValue method_get_rightContext(CallContext *ctx); }; +inline Heap::RegExpPrototype::RegExpPrototype(InternalClass *ic) + : RegExpObject(ic) +{ + setVTable(QV4::RegExpPrototype::staticVTable()); +} + } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 69304e5060..25142d35a6 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -53,20 +53,20 @@ using namespace QV4; -QmlBindingWrapper::Data::Data(ExecutionContext *scope, Function *f, QV4::Object *qml) +Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Function *f, QV4::Object *qml) : Heap::FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false) , qml(qml) { Q_ASSERT(scope->inUse()); - setVTable(staticVTable()); + setVTable(QV4::QmlBindingWrapper::staticVTable()); function = f; if (function) function->compilationUnit->addref(); needsActivation = function ? function->needsActivation() : false; Scope s(scope); - Scoped<QmlBindingWrapper> o(s, this); + Scoped<QV4::QmlBindingWrapper> o(s, this); o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); @@ -74,17 +74,17 @@ QmlBindingWrapper::Data::Data(ExecutionContext *scope, Function *f, QV4::Object s.engine->popContext(); } -QmlBindingWrapper::Data::Data(ExecutionContext *scope, QV4::Object *qml) +Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Object *qml) : Heap::FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false) , qml(qml) { Q_ASSERT(scope->inUse()); - setVTable(staticVTable()); + setVTable(QV4::QmlBindingWrapper::staticVTable()); needsActivation = false; Scope s(scope); - Scoped<QmlBindingWrapper> o(s, this); + Scoped<QV4::QmlBindingWrapper> o(s, this); o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 337354b38b..3379e204e1 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -71,15 +71,19 @@ struct ContextStateSaver { } }; +namespace Heap { +struct QmlBindingWrapper : Heap::FunctionObject { + QmlBindingWrapper(QV4::ExecutionContext *scope, Function *f, QV4::Object *qml); + // Constructor for QML functions and signal handlers, resulting binding wrapper is not callable! + QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Object *qml); + QV4::Object *qml; + QV4::CallContext *qmlContext; +}; + +} + struct Q_QML_EXPORT QmlBindingWrapper : FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope, Function *f, QV4::Object *qml); - // Constructor for QML functions and signal handlers, resulting binding wrapper is not callable! - Data(ExecutionContext *scope, QV4::Object *qml); - QV4::Object *qml; - CallContext *qmlContext; - }; - V4_OBJECT(FunctionObject) + V4_OBJECT2(QmlBindingWrapper, FunctionObject) static ReturnedValue call(Managed *that, CallData *); static void markObjects(Heap::Base *m, ExecutionEngine *e); |