diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-01-11 05:05:10 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-01-11 05:05:10 (GMT) |
commit | 7287f1f01e7000a21f52f463a459fa0285db4cca (patch) | |
tree | 8db949be2f3470d7c06196ba9a8735a051b8abd3 | |
parent | 8c7dfd168d9eb42a75b79d8b448902b0df490419 (diff) | |
parent | 5f890ee9201b7ff05bc0da06265f6ad4212da9c6 (diff) | |
download | Qt-7287f1f01e7000a21f52f463a459fa0285db4cca.zip Qt-7287f1f01e7000a21f52f463a459fa0285db4cca.tar.gz Qt-7287f1f01e7000a21f52f463a459fa0285db4cca.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | src/declarative/qml/qmlcontextscriptclass.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontextscriptclass_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmllistscriptclass.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmllistscriptclass_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 20 | ||||
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmltypenamescriptclass.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmltypenamescriptclass_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlvaluetypescriptclass.cpp | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlvaluetypescriptclass_p.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qmlstate_p.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qmltransition_p.h | 2 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass.cpp | 169 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass_p.h | 31 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeobject.cpp | 4 | ||||
-rw-r--r-- | tests/benchmarks/declarative/text/tst_text.cpp | 75 |
17 files changed, 304 insertions, 31 deletions
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 588a397..8ab3f8d 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -196,7 +196,8 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje return 0; } -QScriptValue QmlContextScriptClass::property(Object *object, const Identifier &name) +QmlContextScriptClass::Value +QmlContextScriptClass::property(Object *object, const Identifier &name) { Q_UNUSED(object); diff --git a/src/declarative/qml/qmlcontextscriptclass_p.h b/src/declarative/qml/qmlcontextscriptclass_p.h index a577d52..f652371 100644 --- a/src/declarative/qml/qmlcontextscriptclass_p.h +++ b/src/declarative/qml/qmlcontextscriptclass_p.h @@ -77,7 +77,7 @@ public: protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(Object *, const Identifier &); + virtual Value property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); private: diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index f5ff2c0..b275625 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -100,7 +100,7 @@ QmlListScriptClass::queryProperty(Object *object, const Identifier &name, } } -QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) +QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identifier &name) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); @@ -123,7 +123,7 @@ QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) quint32 count = qlist.count(); if (name == m_lengthId.identifier) - return count; + return Value(scriptEngine, count); else if (lastIndex < count) return enginePriv->objectClass->newQObject(qlist.at(lastIndex)); else @@ -136,7 +136,7 @@ QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) quint32 count = qmllist.count(); if (name == m_lengthId.identifier) - return count; + return Value(scriptEngine, count); else if (lastIndex < count) return enginePriv->objectClass->newQObject(qmllist.at(lastIndex)); else diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h index 0c10472..43ca929 100644 --- a/src/declarative/qml/qmllistscriptclass_p.h +++ b/src/declarative/qml/qmllistscriptclass_p.h @@ -70,7 +70,7 @@ public: protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(Object *, const Identifier &); + virtual Value property(Object *, const Identifier &); private: PersistentIdentifier m_lengthId; diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 0b79a21..d9c007d 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -1102,9 +1102,11 @@ bool QmlMetaType::copy(int type, void *data, const void *copy) case QMetaType::QBitmap: *static_cast<NS(QBitmap) *>(data) = *static_cast<const NS(QBitmap)*>(copy); return true; +#ifndef QT_NO_CURSOR case QMetaType::QCursor: *static_cast<NS(QCursor) *>(data) = *static_cast<const NS(QCursor)*>(copy); return true; +#endif case QMetaType::QSizePolicy: *static_cast<NS(QSizePolicy) *>(data) = *static_cast<const NS(QSizePolicy)*>(copy); return true; @@ -1308,9 +1310,11 @@ bool QmlMetaType::copy(int type, void *data, const void *copy) case QMetaType::QBitmap: *static_cast<NS(QBitmap) *>(data) = NS(QBitmap)(); return true; +#ifndef QT_NO_CURSOR case QMetaType::QCursor: *static_cast<NS(QCursor) *>(data) = NS(QCursor)(); return true; +#endif case QMetaType::QSizePolicy: *static_cast<NS(QSizePolicy) *>(data) = NS(QSizePolicy)(); return true; diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index cb665d1..1023579 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -189,12 +189,14 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name, return 0; } -QScriptValue QmlObjectScriptClass::property(Object *object, const Identifier &name) +QmlObjectScriptClass::Value +QmlObjectScriptClass::property(Object *object, const Identifier &name) { return property(toQObject(object), name); } -QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name) +QmlObjectScriptClass::Value +QmlObjectScriptClass::property(QObject *obj, const Identifier &name) { if (name == m_destroyId.identifier) return m_destroy; @@ -256,37 +258,37 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name qreal rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::Int) { int rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::Bool) { bool rv = false; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::QString) { QString rv; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::UInt) { uint rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::Float) { float rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::Double) { double rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return QScriptValue(scriptEngine, rv); + return Value(scriptEngine, rv); } else { QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj); return enginePriv->scriptValueFromVariant(var); diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h index ca50688..5c488db 100644 --- a/src/declarative/qml/qmlobjectscriptclass_p.h +++ b/src/declarative/qml/qmlobjectscriptclass_p.h @@ -86,7 +86,7 @@ public: QScriptClass::QueryFlags flags, QmlContext *evalContext, QueryHints hints = 0); - QScriptValue property(QObject *, const Identifier &); + Value property(QObject *, const Identifier &); void setProperty(QObject *, const Identifier &name, const QScriptValue &, QmlContext *evalContext = 0); @@ -94,7 +94,7 @@ protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(Object *, const Identifier &); + virtual Value property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual bool isQObject() const; virtual QObject *toQObject(Object *, bool *ok = 0); diff --git a/src/declarative/qml/qmltypenamescriptclass.cpp b/src/declarative/qml/qmltypenamescriptclass.cpp index 72106ae..c4c5f53 100644 --- a/src/declarative/qml/qmltypenamescriptclass.cpp +++ b/src/declarative/qml/qmltypenamescriptclass.cpp @@ -139,7 +139,7 @@ QmlTypeNameScriptClass::queryProperty(Object *obj, const Identifier &name, return 0; } -QScriptValue QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) +QmlTypeNameScriptClass::Value QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) { QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); if (type) { diff --git a/src/declarative/qml/qmltypenamescriptclass_p.h b/src/declarative/qml/qmltypenamescriptclass_p.h index e72c05c..702930f 100644 --- a/src/declarative/qml/qmltypenamescriptclass_p.h +++ b/src/declarative/qml/qmltypenamescriptclass_p.h @@ -77,7 +77,7 @@ protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(Object *, const Identifier &); + virtual Value property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); private: diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp index 78580e3..65a63f4 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass.cpp +++ b/src/declarative/qml/qmlvaluetypescriptclass.cpp @@ -67,7 +67,8 @@ QScriptValue QmlValueTypeScriptClass::newObject(QObject *object, int coreIndex, ref->type = type; ref->object = object; ref->property = coreIndex; - return QScriptDeclarativeClass::newObject(QmlEnginePrivate::getScriptEngine(engine), this, ref); + QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + return QScriptDeclarativeClass::newObject(scriptEngine, this, ref); } QScriptClass::QueryFlags @@ -97,7 +98,7 @@ QmlValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name, return rv; } -QScriptValue QmlValueTypeScriptClass::property(Object *obj, const Identifier &) +QmlValueTypeScriptClass::Value QmlValueTypeScriptClass::property(Object *obj, const Identifier &) { QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj); diff --git a/src/declarative/qml/qmlvaluetypescriptclass_p.h b/src/declarative/qml/qmlvaluetypescriptclass_p.h index 98d0251..9214987 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass_p.h +++ b/src/declarative/qml/qmlvaluetypescriptclass_p.h @@ -70,7 +70,7 @@ public: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(Object *, const Identifier &); + virtual Value property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual QVariant toVariant(Object *, bool *ok = 0); diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 95a6fc5..fdac847 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -133,7 +133,7 @@ class Q_DECLARATIVE_EXPORT QmlState : public QObject Q_PROPERTY(QString extend READ extends WRITE setExtends) Q_PROPERTY(QmlList<QmlStateOperation *>* changes READ changes) Q_CLASSINFO("DefaultProperty", "changes") - Q_CLASSINFO("DeferredPropertyNames", "changes"); + Q_CLASSINFO("DeferredPropertyNames", "changes") public: QmlState(QObject *parent=0); diff --git a/src/declarative/util/qmltransition_p.h b/src/declarative/util/qmltransition_p.h index 0a9b036..c1a6f66 100644 --- a/src/declarative/util/qmltransition_p.h +++ b/src/declarative/util/qmltransition_p.h @@ -67,7 +67,7 @@ class Q_DECLARATIVE_EXPORT QmlTransition : public QObject Q_PROPERTY(bool reversible READ reversible WRITE setReversible) Q_PROPERTY(QmlList<QmlAbstractAnimation *>* animations READ animations) Q_CLASSINFO("DefaultProperty", "animations") - Q_CLASSINFO("DeferredPropertyNames", "animations"); + Q_CLASSINFO("DeferredPropertyNames", "animations") public: QmlTransition(QObject *parent=0); diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 2c13066..d67804a 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -35,6 +35,107 @@ QT_BEGIN_NAMESPACE +/*! +\class QScriptDeclarativeClass::Value +\internal +\brief The QScriptDeclarativeClass::Value class acts as a container for JavaScript data types. + +QScriptDeclarativeClass::Value class is similar to QScriptValue, but it is slightly faster. +Unlike QScriptValue, however, Value instances cannot be stored as they may not survive garbage +collection. If you need to store a Value, convert it to a QScriptValue and store that. +*/ + +QScriptDeclarativeClass::Value::Value() +{ + new (this) JSC::JSValue(); +} + +QScriptDeclarativeClass::Value::Value(const Value &other) +{ + new (this) JSC::JSValue((JSC::JSValue &)other); +} + +static QScriptDeclarativeClass::Value jscToValue(const JSC::JSValue &val) +{ + return QScriptDeclarativeClass::Value((QScriptDeclarativeClass::Value &)val); +} + +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, int value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::frameForContext(ctxt), value); +} + +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, uint value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::frameForContext(ctxt), value); +} + +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, bool value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::frameForContext(ctxt), value); +} + +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, double value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::frameForContext(ctxt), value); +} + +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, float value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::frameForContext(ctxt), value); +} + +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, const QString &value) +{ + new (this) JSC::JSValue(JSC::jsString(QScriptEnginePrivate::frameForContext(ctxt), value)); +} + +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, int value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->currentFrame, value); +} + +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, uint value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->currentFrame, value); +} + +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, bool value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->currentFrame, value); +} + +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, double value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->currentFrame, value); +} + +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, float value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->currentFrame, value); +} + +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, const QString &value) +{ + new (this) JSC::JSValue(JSC::jsString(QScriptEnginePrivate::get(eng)->currentFrame, value)); +} + +QScriptDeclarativeClass::Value::Value(const QScriptValue &value) +{ + new (this) JSC::JSValue(QScriptValuePrivate::get(&value)->engine->scriptValueToJSCValue(value)); +} + + +QScriptDeclarativeClass::Value::~Value() +{ + ((JSC::JSValue *)(this))->~JSValue(); +} + +QScriptValue QScriptDeclarativeClass::Value::toScriptValue(QScriptEngine *engine) const +{ + return QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue((JSC::JSValue &)*this); +} + QScriptDeclarativeClass::PersistentIdentifier::PersistentIdentifier() : identifier(0) { @@ -83,6 +184,22 @@ QScriptValue QScriptDeclarativeClass::newObject(QScriptEngine *engine, return p->scriptValueFromJSCValue(result); } +QScriptDeclarativeClass::Value +QScriptDeclarativeClass::newObjectValue(QScriptEngine *engine, + QScriptDeclarativeClass *scriptClass, + Object *object) +{ + Q_ASSERT(engine); + Q_ASSERT(scriptClass); + + QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine)); + + JSC::ExecState* exec = p->currentFrame; + QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure); + result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object)); + return jscToValue(JSC::JSValue(result)); +} + QScriptDeclarativeClass *QScriptDeclarativeClass::scriptClass(const QScriptValue &v) { QScriptValuePrivate *d = QScriptValuePrivate::get(v); @@ -152,6 +269,53 @@ QScriptValue QScriptDeclarativeClass::property(const QScriptValue &v, const Iden return QScriptValue(); } +QScriptDeclarativeClass::Value +QScriptDeclarativeClass::functionValue(const QScriptValue &v, const Identifier &name) +{ + QScriptValuePrivate *d = QScriptValuePrivate::get(v); + + if (!d->isObject()) + return Value(); + + JSC::ExecState *exec = d->engine->currentFrame; + JSC::JSObject *object = d->jscValue.getObject(); + JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object)); + JSC::JSValue result; + + JSC::Identifier id(exec, (JSC::UString::Rep *)name); + + if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) { + result = slot.getValue(exec, id); + if (QScript::isFunction(result)) + return jscToValue(result); + } + + return Value(); +} + +QScriptDeclarativeClass::Value +QScriptDeclarativeClass::propertyValue(const QScriptValue &v, const Identifier &name) +{ + QScriptValuePrivate *d = QScriptValuePrivate::get(v); + + if (!d->isObject()) + return Value(); + + JSC::ExecState *exec = d->engine->currentFrame; + JSC::JSObject *object = d->jscValue.getObject(); + JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object)); + JSC::JSValue result; + + JSC::Identifier id(exec, (JSC::UString::Rep *)name); + + if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) { + result = slot.getValue(exec, id); + return jscToValue(result); + } + + return Value(); +} + /* Returns the scope chain entry at \a index. If index is less than 0, returns entries starting at the end. For example, scopeChainValue(context, -1) will return @@ -291,11 +455,12 @@ QScriptDeclarativeClass::queryProperty(Object *object, const Identifier &name, return 0; } -QScriptValue QScriptDeclarativeClass::property(Object *object, const Identifier &name) +QScriptDeclarativeClass::Value +QScriptDeclarativeClass::property(Object *object, const Identifier &name) { Q_UNUSED(object); Q_UNUSED(name); - return QScriptValue(); + return Value(); } void QScriptDeclarativeClass::setProperty(Object *object, const Identifier &name, diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index f2557bd..87ab964 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -47,16 +47,45 @@ class QScriptContext; class Q_SCRIPT_EXPORT QScriptDeclarativeClass { public: + class Value + { + public: + Value(); + Value(const Value &); + Value(const QScriptValue &); + + Value(QScriptContext *, int); + Value(QScriptContext *, uint); + Value(QScriptContext *, bool); + Value(QScriptContext *, double); + Value(QScriptContext *, float); + Value(QScriptContext *, const QString &); + Value(QScriptEngine *, int); + Value(QScriptEngine *, uint); + Value(QScriptEngine *, bool); + Value(QScriptEngine *, double); + Value(QScriptEngine *, float); + Value(QScriptEngine *, const QString &); + ~Value(); + + QScriptValue toScriptValue(QScriptEngine *) const; + private: + char dummy[8]; + }; + typedef void* Identifier; struct Object { virtual ~Object() {} }; static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *); + static Value newObjectValue(QScriptEngine *, QScriptDeclarativeClass *, Object *); static QScriptDeclarativeClass *scriptClass(const QScriptValue &); static Object *object(const QScriptValue &); static QScriptValue function(const QScriptValue &, const Identifier &); static QScriptValue property(const QScriptValue &, const Identifier &); + static Value functionValue(const QScriptValue &, const Identifier &); + static Value propertyValue(const QScriptValue &, const Identifier &); static QScriptValue scopeChainValue(QScriptContext *, int index); static QScriptContext *pushCleanContext(QScriptEngine *); @@ -91,7 +120,7 @@ public: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual QScriptValue property(Object *, const Identifier &); + virtual Value property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &); diff --git a/src/script/bridge/qscriptdeclarativeobject.cpp b/src/script/bridge/qscriptdeclarativeobject.cpp index 6b4f5cb..72e31a9 100644 --- a/src/script/bridge/qscriptdeclarativeobject.cpp +++ b/src/script/bridge/qscriptdeclarativeobject.cpp @@ -74,9 +74,9 @@ bool DeclarativeObjectDelegate::getOwnPropertySlot(QScriptObject* object, QScriptClass::QueryFlags flags = m_class->queryProperty(m_object, identifier, QScriptClass::HandlesReadAccess); if (flags & QScriptClass::HandlesReadAccess) { - QScriptValue value = m_class->property(m_object, identifier); + QScriptDeclarativeClass::Value val = m_class->property(m_object, identifier); p->context = 0; - slot.setValue(engine->scriptValueToJSCValue(value)); + slot.setValue((const JSC::JSValue &)val); return true; } p->context = 0; diff --git a/tests/benchmarks/declarative/text/tst_text.cpp b/tests/benchmarks/declarative/text/tst_text.cpp index e69ecd8..c7ea884 100644 --- a/tests/benchmarks/declarative/text/tst_text.cpp +++ b/tests/benchmarks/declarative/text/tst_text.cpp @@ -62,6 +62,11 @@ private slots: void document(); void paintDocToPixmap(); void paintDocToPixmap_painterFill(); + void control(); + void paintControlToPixmap(); + void paintControlToPixmap_painterFill(); + void constructControl(); + void constructDocument(); private: QString m_text; @@ -144,6 +149,48 @@ void tst_text::paintLayoutToPixmap_painterFill() void tst_text::document() { + QTextDocument *doc = new QTextDocument; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_text); + } +} + +void tst_text::paintDocToPixmap() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_text); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + doc->drawContents(&p/*, QRectF(QPointF(0, 0), QSizeF(size))*/); + } +} + +void tst_text::paintDocToPixmap_painterFill() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_text); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + doc->drawContents(&p/*, QRectF(QPointF(0, 0), QSizeF(size))*/); + } +} + +void tst_text::control() +{ QTextControl *control = new QTextControl(m_text); QBENCHMARK { @@ -153,11 +200,12 @@ void tst_text::document() } } -void tst_text::paintDocToPixmap() +void tst_text::paintControlToPixmap() { QTextControl *control = new QTextControl; QTextDocument *doc = control->document(); doc->setHtml(m_text); + doc->setTextWidth(300); QSize size = doc->size().toSize(); QBENCHMARK { @@ -168,11 +216,12 @@ void tst_text::paintDocToPixmap() } } -void tst_text::paintDocToPixmap_painterFill() +void tst_text::paintControlToPixmap_painterFill() { QTextControl *control = new QTextControl; QTextDocument *doc = control->document(); doc->setHtml(m_text); + doc->setTextWidth(300); QSize size = doc->size().toSize(); QBENCHMARK { @@ -185,5 +234,27 @@ void tst_text::paintDocToPixmap_painterFill() } } +void tst_text::constructControl() +{ + QTextControl *control = new QTextControl; + delete control; + + QBENCHMARK { + QTextControl *control = new QTextControl; + delete control; + } +} + +void tst_text::constructDocument() +{ + QTextDocument *doc = new QTextDocument; + delete doc; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + delete doc; + } +} + QTEST_MAIN(tst_text) #include "tst_text.moc" |