diff options
Diffstat (limited to 'src/qml/jsruntime/qv4object_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 82f75a49c6..d5195adaf0 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -56,6 +56,7 @@ #include "qv4engine_p.h" #include "qv4scopedvalue_p.h" #include "qv4value_p.h" +#include "qv4internalclass_p.h" #include <QtCore/qtypetraits.h> @@ -67,7 +68,8 @@ namespace QV4 { namespace Heap { struct Object : Base { - inline Object() {} + void init() { Base::init(); } + void destroy() { Base::destroy(); } const Value *propertyData(uint index) const { if (index < inlineMemberSize) return reinterpret_cast<const Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; } Value *propertyData(uint index) { if (index < inlineMemberSize) return reinterpret_cast<Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; } @@ -89,7 +91,13 @@ struct Object : Base { static const QV4::ObjectVTable static_vtbl; \ static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; } \ V4_MANAGED_SIZE_TEST \ - Data *d() const { return static_cast<Data *>(m()); } + Data *d_unchecked() const { return static_cast<Data *>(m()); } \ + Data *d() const { \ + Data *dptr = d_unchecked(); \ + dptr->_checkIsInitialized(); \ + return dptr; \ + } \ + V4_ASSERT_IS_TRIVIAL(Data); #define V4_OBJECT2(DataClass, superClass) \ private: \ @@ -102,7 +110,13 @@ struct Object : Base { static const QV4::ObjectVTable static_vtbl; \ static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; } \ V4_MANAGED_SIZE_TEST \ - QV4::Heap::DataClass *d() const { return static_cast<QV4::Heap::DataClass *>(m()); } + QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \ + QV4::Heap::DataClass *d() const { \ + QV4::Heap::DataClass *dptr = d_unchecked(); \ + dptr->_checkIsInitialized(); \ + return dptr; \ + } \ + V4_ASSERT_IS_TRIVIAL(QV4::Heap::DataClass); #define V4_INTERNALCLASS(c) \ static QV4::InternalClass *defaultInternalClass(QV4::ExecutionEngine *e) \ @@ -114,8 +128,8 @@ struct Object : Base { struct ObjectVTable { VTable vTable; - ReturnedValue (*call)(const Managed *, CallData *data); - ReturnedValue (*construct)(const Managed *, CallData *data); + void (*call)(const Managed *, Scope &scope, CallData *data); + void (*construct)(const Managed *, Scope &scope, CallData *data); ReturnedValue (*get)(const Managed *, String *name, bool *hasProperty); ReturnedValue (*getIndexed)(const Managed *, uint index, bool *hasProperty); void (*put)(Managed *, String *name, const Value &value); @@ -334,14 +348,14 @@ public: { vtable()->advanceIterator(this, it, name, index, p, attributes); } uint getLength() const { return vtable()->getLength(this); } - inline ReturnedValue construct(CallData *d) const - { return vtable()->construct(this, d); } - inline ReturnedValue call(CallData *d) const - { return vtable()->call(this, d); } + inline void construct(Scope &scope, CallData *d) const + { return vtable()->construct(this, scope, d); } + inline void call(Scope &scope, CallData *d) const + { vtable()->call(this, scope, d); } protected: static void markObjects(Heap::Base *that, ExecutionEngine *e); - static ReturnedValue construct(const Managed *m, CallData *); - static ReturnedValue call(const Managed *m, CallData *); + static void construct(const Managed *m, Scope &scope, CallData *); + static void call(const Managed *m, Scope &scope, CallData *); static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty); static void put(Managed *m, String *name, const Value &value); @@ -372,18 +386,22 @@ private: namespace Heap { struct BooleanObject : Object { - BooleanObject() {} - BooleanObject(bool b) - : b(b) - {} + void init() { Object::init(); } + void init(bool b) { + Object::init(); + this->b = b; + } + bool b; }; struct NumberObject : Object { - NumberObject() {} - NumberObject(double val) - : value(val) - {} + void init() { Object::init(); } + void init(double val) { + Object::init(); + value = val; + } + double value; }; @@ -392,10 +410,15 @@ struct ArrayObject : Object { LengthPropertyIndex = 0 }; - ArrayObject() - { init(); } - ArrayObject(const QStringList &list); - void init() + void init() { + Object::init(); + commonInit(); + } + + void init(const QStringList &list); + +private: + void commonInit() { *propertyData(LengthPropertyIndex) = Primitive::fromInt32(0); } }; |