aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-13 14:11:55 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-18 13:14:03 +0200
commit49aead7f236f8b8a6ab85adc4b5eace1c1e4dde6 (patch)
tree21b01c30b568bd79176a5dfe4ec2437e2545660e /src/qml/jsruntime/qv4object_p.h
parent2a43ec129a544d80c9cc3266b5eccce0f6ba66ef (diff)
Extend the ReturnedValue mechanism to pointers to Managed objects
Add a Returned<T> that we can return instead of raw pointers to Managed objects. Start using the Returned<T> for a few methods. Also clean up all our classes to use the Q_MANAGED macro instead of manually defining their vtable. Change-Id: I0a2962e47f3de955cd2cd8474f8f3fcc9e36d084 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4object_p.h')
-rw-r--r--src/qml/jsruntime/qv4object_p.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 5ae167d782..b7b08c2b34 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -105,6 +105,7 @@ typedef Value (*PropertyEnumeratorFunction)(Object *object);
typedef PropertyAttributes (*PropertyQueryFunction)(const Object *object, String *name);
struct Q_QML_EXPORT Object: Managed {
+ Q_MANAGED
uint memberDataAlloc;
Property *memberData;
@@ -182,6 +183,9 @@ struct Q_QML_EXPORT Object: Managed {
static Object *cast(const Value &v) {
return v.asObject();
}
+ static Value toValue(Object *o) {
+ return Value::fromObject(o);
+ }
// Array handling
@@ -283,7 +287,8 @@ public:
void ensureArrayAttributes();
inline bool protoHasArray() {
- Object *p = this;
+ Scope scope(engine());
+ Scoped<Object> p(scope, this);
while ((p = p->prototype()))
if (p->arrayDataLen)
@@ -313,7 +318,6 @@ public:
using Managed::setLookup;
using Managed::advanceIterator;
protected:
- static const ManagedVTable static_vtbl;
static void destroy(Managed *that);
static void markObjects(Managed *that);
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);