aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-03-15 12:10:01 +1000
committerCharles Yin <charles.yin@nokia.com>2011-05-13 13:53:37 +1000
commit30327650798ba63281c7b9344c9d824d00dce82a (patch)
tree66f77f34ae7a8c3f9e8aac9881645d408463e52f
parent4890cbe42867d5ca22c57b2e4ab201cdd37435f8 (diff)
cache the arguments in property cache data
Change-Id: Ie02b94c2ddb1d5d7b7bb6556a01a5ae86a438c57 (cherry picked from commit 39fed3e2601935c1d6834bb5e75266e5b280e5cd)
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp31
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h5
2 files changed, 33 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index 9cbb4fa8cc..f39cdd9e6c 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -93,6 +93,26 @@ void QDeclarativePropertyCache::Data::load(const QMetaProperty &p, QDeclarativeE
revision = p.revision();
}
+int QDeclarativePropertyCache::Data::enumType(const QMetaObject *meta, const QString &strname)
+{
+ QByteArray str = strname.toUtf8();
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = str.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = str.left(scopeIdx);
+ name = str.mid(scopeIdx + 2);
+ } else {
+ name = str;
+ }
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
+ return QVariant::Int;
+ }
+ return QVariant::Invalid;
+}
+
void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
{
coreIndex = m.methodIndex();
@@ -107,8 +127,17 @@ void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
propType = QMetaType::type(returnType);
QList<QByteArray> params = m.parameterTypes();
- if (!params.isEmpty())
+ if (!params.isEmpty()) {
flags |= Data::HasArguments;
+ paramTypes.resize(params.size());
+ for (int i = 0; i < params.size(); ++i) {
+ paramTypes[i] = QMetaType::type(params.at(i));
+ if (paramTypes[i] == QVariant::Invalid)
+ paramTypes[i] = enumType(m.enclosingMetaObject(), QString::fromLatin1(params.at(i)));
+ if (paramTypes[i] == QVariant::Invalid)
+ paramTypes[i] = -1; //Unknown method parameter type
+ }
+ }
revision = m.revision();
}
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index 65a8725b8f..86ccfe0187 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE
class QDeclarativeEngine;
class QMetaProperty;
-
class Q_AUTOTEST_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup
{
public:
@@ -74,6 +73,7 @@ public:
struct Data {
inline Data();
+
inline bool operator==(const Data &);
enum Flag {
@@ -115,8 +115,9 @@ public:
int overrideIndex : 31;
int revision;
int metaObjectOffset;
-
+ QVector<int> paramTypes;
static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine = 0);
+ int enumType(const QMetaObject *meta, const QString &strname);
void load(const QMetaProperty &, QDeclarativeEngine *engine = 0);
void load(const QMetaMethod &);
QString name(QObject *);