diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-02 08:01:55 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-05 02:40:47 (GMT) |
commit | a712a6243be29dbfa49c3d1705c8b1babd8c7a1a (patch) | |
tree | b93507563b892be53b7edc2eba1c88ca632a6484 /src | |
parent | 3490b478ed02859f0355438efba900cd853e9c13 (diff) | |
download | Qt-a712a6243be29dbfa49c3d1705c8b1babd8c7a1a.zip Qt-a712a6243be29dbfa49c3d1705c8b1babd8c7a1a.tar.gz Qt-a712a6243be29dbfa49c3d1705c8b1babd8c7a1a.tar.bz2 |
Tweak api to improve ownership issues
Diffstat (limited to 'src')
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass.cpp | 23 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass_p.h | 22 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeobject.cpp | 7 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeobject_p.h | 6 |
4 files changed, 25 insertions, 33 deletions
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 371a3c3..62c1afc 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -94,7 +94,7 @@ QScriptDeclarativeClass::QScriptDeclarativeClass(QScriptEngine *engine) QScriptValue QScriptDeclarativeClass::newObject(QScriptEngine *engine, QScriptDeclarativeClass *scriptClass, - Object object) + Object *object) { Q_ASSERT(engine); Q_ASSERT(scriptClass); @@ -119,7 +119,7 @@ QScriptDeclarativeClass *QScriptDeclarativeClass::scriptClass(const QScriptValue return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass(); } -QScriptDeclarativeClass::Object QScriptDeclarativeClass::object(const QScriptValue &v) +QScriptDeclarativeClass::Object *QScriptDeclarativeClass::object(const QScriptValue &v) { QScriptValuePrivate *d = QScriptValuePrivate::get(v); if (!d || !d->isJSC() || !d->jscValue.isObject(&QScriptObject::info)) @@ -218,7 +218,7 @@ QString QScriptDeclarativeClass::toString(const Identifier &identifier) } QScriptClass::QueryFlags -QScriptDeclarativeClass::queryProperty(const Object &object, const Identifier &name, +QScriptDeclarativeClass::queryProperty(Object *object, const Identifier &name, QScriptClass::QueryFlags flags) { Q_UNUSED(object); @@ -227,14 +227,14 @@ QScriptDeclarativeClass::queryProperty(const Object &object, const Identifier &n return 0; } -QScriptValue QScriptDeclarativeClass::property(const Object &object, const Identifier &name) +QScriptValue QScriptDeclarativeClass::property(Object *object, const Identifier &name) { Q_UNUSED(object); Q_UNUSED(name); return QScriptValue(); } -void QScriptDeclarativeClass::setProperty(const Object &object, const Identifier &name, +void QScriptDeclarativeClass::setProperty(Object *object, const Identifier &name, const QScriptValue &value) { Q_UNUSED(object); @@ -243,31 +243,26 @@ void QScriptDeclarativeClass::setProperty(const Object &object, const Identifier } QScriptValue::PropertyFlags -QScriptDeclarativeClass::propertyFlags(const Object &object, const Identifier &name) +QScriptDeclarativeClass::propertyFlags(Object *object, const Identifier &name) { Q_UNUSED(object); Q_UNUSED(name); return 0; } -QStringList QScriptDeclarativeClass::propertyNames(const Object &object) +QStringList QScriptDeclarativeClass::propertyNames(Object *object) { Q_UNUSED(object); return QStringList(); } -void QScriptDeclarativeClass::destroyed(const Object &object) -{ - Q_UNUSED(object); -} - -QObject *QScriptDeclarativeClass::toQObject(const Object &, bool *ok) +QObject *QScriptDeclarativeClass::toQObject(Object *, bool *ok) { if (ok) *ok = false; return 0; } -QVariant QScriptDeclarativeClass::toVariant(const Object &, bool *ok) +QVariant QScriptDeclarativeClass::toVariant(Object *, bool *ok) { if (ok) *ok = false; return QVariant(); diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index 16f6942..07cfad1 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -65,11 +65,12 @@ class Q_SCRIPT_EXPORT QScriptDeclarativeClass { public: typedef void* Identifier; - typedef void* Object; - static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object); + struct Object { virtual ~Object() {} }; + + static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *); static QScriptDeclarativeClass *scriptClass(const QScriptValue &); - static Object object(const QScriptValue &); + static Object *object(const QScriptValue &); static QScriptValue function(const QScriptValue &, const Identifier &); static QScriptValue property(const QScriptValue &, const Identifier &); @@ -100,18 +101,17 @@ public: QString toString(const Identifier &); - virtual QScriptClass::QueryFlags queryProperty(const Object &, const Identifier &, + virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(const Object &, const Identifier &); - virtual void setProperty(const Object &, const Identifier &name, const QScriptValue &); - virtual QScriptValue::PropertyFlags propertyFlags(const Object &, const Identifier &); + virtual QScriptValue property(Object *, const Identifier &); + virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); + virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &); - virtual QStringList propertyNames(const Object &); + virtual QStringList propertyNames(Object *); - virtual QObject *toQObject(const Object &, bool *ok = 0); - virtual QVariant toVariant(const Object &, bool *ok = 0); - virtual void destroyed(const Object &); + virtual QObject *toQObject(Object *, bool *ok = 0); + virtual QVariant toVariant(Object *, bool *ok = 0); protected: QScopedPointer<QScriptDeclarativeClassPrivate> d_ptr; diff --git a/src/script/bridge/qscriptdeclarativeobject.cpp b/src/script/bridge/qscriptdeclarativeobject.cpp index 62c2686..aa811d1 100644 --- a/src/script/bridge/qscriptdeclarativeobject.cpp +++ b/src/script/bridge/qscriptdeclarativeobject.cpp @@ -64,14 +64,14 @@ namespace QScript { DeclarativeObjectDelegate::DeclarativeObjectDelegate(QScriptDeclarativeClass *c, - QScriptDeclarativeClass::Object &o) + QScriptDeclarativeClass::Object *o) : m_class(c), m_object(o) { } DeclarativeObjectDelegate::~DeclarativeObjectDelegate() { - m_class->destroyed(m_object); + delete m_object; } QScriptObjectDelegate::Type DeclarativeObjectDelegate::type() const @@ -126,7 +126,6 @@ bool DeclarativeObjectDelegate::getPropertyAttributes(const QScriptObject* objec const JSC::Identifier &propertyName, unsigned &attribs) const { - QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep(); QScriptClass::QueryFlags flags = @@ -154,8 +153,6 @@ void DeclarativeObjectDelegate::getPropertyNames(QScriptObject* object, JSC::Exe JSC::PropertyNameArray &propertyNames, unsigned listedAttributes) { - QScriptEnginePrivate *engine = scriptEngineFromExec(exec); - QStringList properties = m_class->propertyNames(m_object); for (int ii = 0; ii < properties.count(); ++ii) { const QString &name = properties.at(ii); diff --git a/src/script/bridge/qscriptdeclarativeobject_p.h b/src/script/bridge/qscriptdeclarativeobject_p.h index 87375d8..ccb07bc 100644 --- a/src/script/bridge/qscriptdeclarativeobject_p.h +++ b/src/script/bridge/qscriptdeclarativeobject_p.h @@ -68,13 +68,13 @@ namespace QScript class DeclarativeObjectDelegate : public QScriptObjectDelegate { public: - DeclarativeObjectDelegate(QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object &o); + DeclarativeObjectDelegate(QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object *o); ~DeclarativeObjectDelegate(); virtual Type type() const; QScriptDeclarativeClass *scriptClass() const { return m_class; } - QScriptDeclarativeClass::Object object() const { return m_object; } + QScriptDeclarativeClass::Object *object() const { return m_object; } virtual bool getOwnPropertySlot(QScriptObject*, JSC::ExecState*, const JSC::Identifier& propertyName, @@ -100,7 +100,7 @@ public: private: QScriptDeclarativeClass *m_class; - QScriptDeclarativeClass::Object m_object; + QScriptDeclarativeClass::Object *m_object; }; } // namespace QScript |