aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-06-26 09:43:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-28 14:56:04 +0200
commitf7d727f62c1f1bc0ab756a62ce51b042abf76eb5 (patch)
tree9dd5dc892fb155827e9a4aee5007884ee29e490c /src/qml/qml
parent553b41c407985e5b18f089679c014d884624afbd (diff)
Get rid of QHashedV4String
This was required while we were using V8, but now we can simply pass QV4::String pointers. Change-Id: If6338e4a455d6132fe14e5e603e4fe9e477d1ffb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h96
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp10
-rw-r--r--src/qml/qml/qqmlintegercache_p.h4
-rw-r--r--src/qml/qml/qqmlmetatype.cpp6
-rw-r--r--src/qml/qml/qqmlmetatype_p.h9
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp12
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h2
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp4
-rw-r--r--src/qml/qml/qqmltypenamecache_p.h4
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp8
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp6
-rw-r--r--src/qml/qml/v4/qv4qobjectwrapper.cpp12
-rw-r--r--src/qml/qml/v4/qv4string_p.h3
13 files changed, 55 insertions, 121 deletions
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index efcee0fb51..4815f787b6 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -98,27 +98,6 @@ private:
mutable quint32 m_hash;
};
-class Q_AUTOTEST_EXPORT QHashedV4String
-{
-public:
- inline QHashedV4String();
- explicit inline QHashedV4String(const QV4::Value &s);
- inline QHashedV4String(const QHashedV4String &string);
- inline QHashedV4String &operator=(const QHashedV4String &other);
-
- inline bool operator==(const QHashedV4String &string);
-
- inline quint32 hash() const;
- inline int length() const;
-
- inline QV4::Value string() const;
-
- inline QString toString() const;
-
-private:
- QV4::Value m_string;
-};
-
class QHashedCStringRef;
class Q_AUTOTEST_EXPORT QHashedStringRef
{
@@ -267,9 +246,17 @@ public:
}
}
- inline bool equals(const QHashedV4String &string) const {
- return length == string.length() && hash == string.hash() &&
- equals(string.string());
+ inline bool equals(const QV4::String *string) const {
+ if (length != string->length() || hash != string->hashValue())
+ return false;
+ if (isQString()) {
+ QStringDataPtr dd;
+ dd.ptr = strData;
+ strData->ref.ref();
+ return QString(dd) == string->toQString();
+ } else {
+ return QLatin1String(cStrData(), length) == string->toQString();
+ }
}
inline bool equals(const QHashedStringRef &string) const {
@@ -326,7 +313,8 @@ struct HashedForm {};
template<> struct HashedForm<QString> { typedef QHashedString Type; };
template<> struct HashedForm<QStringRef> { typedef QHashedStringRef Type; };
template<> struct HashedForm<QHashedString> { typedef const QHashedString &Type; };
-template<> struct HashedForm<QHashedV4String> { typedef const QHashedV4String &Type; };
+template<> struct HashedForm<QV4::String *> { typedef const QV4::String *Type; };
+template<> struct HashedForm<const QV4::String *> { typedef const QV4::String *Type; };
template<> struct HashedForm<QHashedStringRef> { typedef const QHashedStringRef &Type; };
template<> struct HashedForm<QLatin1String> { typedef QHashedCStringRef Type; };
template<> struct HashedForm<QHashedCStringRef> { typedef const QHashedCStringRef &Type; };
@@ -337,7 +325,8 @@ public:
static HashedForm<QString>::Type hashedString(const QString &s) { return QHashedString(s);}
static HashedForm<QStringRef>::Type hashedString(const QStringRef &s) { return QHashedStringRef(s.constData(), s.size());}
static HashedForm<QHashedString>::Type hashedString(const QHashedString &s) { return s; }
- static HashedForm<QHashedV4String>::Type hashedString(const QHashedV4String &s) { return s; }
+ static HashedForm<QV4::String *>::Type hashedString(QV4::String *s) { return s; }
+ static HashedForm<const QV4::String *>::Type hashedString(const QV4::String *s) { return s; }
static HashedForm<QHashedStringRef>::Type hashedString(const QHashedStringRef &s) { return s; }
static HashedForm<QLatin1String>::Type hashedString(const QLatin1String &s) { return QHashedCStringRef(s.data(), s.size()); }
@@ -345,14 +334,15 @@ public:
static const QString &toQString(const QString &s) { return s; }
static const QString &toQString(const QHashedString &s) { return s; }
- static QString toQString(const QHashedV4String &s) { return s.toString(); }
+ static QString toQString(const QV4::String *s) { return s->toQString(); }
static QString toQString(const QHashedStringRef &s) { return s.toString(); }
static QString toQString(const QLatin1String &s) { return QString(s); }
static QString toQString(const QHashedCStringRef &s) { return s.toUtf16(); }
static inline quint32 hashOf(const QHashedStringRef &s) { return s.hash(); }
- static inline quint32 hashOf(const QHashedV4String &s) { return s.hash(); }
+ static inline quint32 hashOf(QV4::String *s) { return s->hashValue(); }
+ static inline quint32 hashOf(const QV4::String *s) { return s->hashValue(); }
template<typename K>
static inline quint32 hashOf(const K &key) { return hashedString(key).hash(); }
@@ -464,7 +454,7 @@ public:
template<typename K>
inline T *value(const K &) const;
- inline T *value(const QHashedV4String &string) const;
+ inline T *value(const QV4::String *string) const;
inline T *value(const ConstIterator &) const;
template<typename K>
@@ -873,7 +863,7 @@ T *QStringHash<T>::value(const ConstIterator &iter) const
}
template<class T>
-T *QStringHash<T>::value(const QHashedV4String &string) const
+T *QStringHash<T>::value(const QV4::String *string) const
{
Node *n = findNode(string);
return n?&n->value:0;
@@ -1099,52 +1089,6 @@ quint32 QHashedString::existingHash() const
return m_hash;
}
-QHashedV4String::QHashedV4String()
-{
-}
-
-QHashedV4String::QHashedV4String(const QV4::Value &s)
- : m_string(s)
-{
- Q_ASSERT(s.isString());
-}
-
-QHashedV4String::QHashedV4String(const QHashedV4String &string)
- : m_string(string.m_string)
-{
-}
-
-QHashedV4String &QHashedV4String::operator=(const QHashedV4String &other)
-{
- m_string = other.m_string;
- return *this;
-}
-
-bool QHashedV4String::operator==(const QHashedV4String &string)
-{
- return m_string.asString()->isEqualTo(string.m_string.asString());
-}
-
-quint32 QHashedV4String::hash() const
-{
- return m_string.asString()->hashValue();
-}
-
-int QHashedV4String::length() const
-{
- return m_string.asString()->toQString().length();
-}
-
-QV4::Value QHashedV4String::string() const
-{
- return m_string;
-}
-
-QString QHashedV4String::toString() const
-{
- return m_string.toQString();
-}
-
QHashedStringRef::QHashedStringRef()
: m_data(0), m_length(0), m_hash(0)
{
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 6a3fd154d3..60345f6626 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -170,11 +170,9 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
QObject *scopeObject = resource->getScopeObject();
- QHashedV4String propertystring(Value::fromString(name));
-
if (context->imports && name->startsWithUpper()) {
// Search for attached properties, enums and imported scripts
- QQmlTypeNameCache::Result r = context->imports->query(propertystring);
+ QQmlTypeNameCache::Result r = context->imports->query(name);
if (r.isValid()) {
if (hasProperty)
@@ -201,7 +199,7 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
while (context) {
// Search context properties
if (context->propertyNames) {
- int propertyIdx = context->propertyNames->value(propertystring);
+ int propertyIdx = context->propertyNames->value(name);
if (propertyIdx != -1) {
@@ -302,11 +300,9 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value)
QObject *scopeObject = wrapper->getScopeObject();
- QHashedV4String propertystring(Value::fromString(name));
-
while (context) {
// Search context properties
- if (context->propertyNames && -1 != context->propertyNames->value(propertystring))
+ if (context->propertyNames && -1 != context->propertyNames->value(name))
return;
// Search scope object
diff --git a/src/qml/qml/qqmlintegercache_p.h b/src/qml/qml/qqmlintegercache_p.h
index 5fe4039f3c..98b57af279 100644
--- a/src/qml/qml/qqmlintegercache_p.h
+++ b/src/qml/qml/qqmlintegercache_p.h
@@ -71,7 +71,7 @@ public:
void reserve(int);
int value(const QString &);
- inline int value(const QHashedV4String &);
+ inline int value(const QV4::String *);
QString findId(int value) const;
@@ -80,7 +80,7 @@ private:
StringCache stringCache;
};
-int QQmlIntegerCache::value(const QHashedV4String &name)
+int QQmlIntegerCache::value(const QV4::String *name)
{
int *result = stringCache.value(name);
return result?*result:-1;
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 9a9e6df366..188fa7db0d 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -902,7 +902,7 @@ int QQmlType::enumValue(const QHashedCStringRef &name, bool *ok) const
return -1;
}
-int QQmlType::enumValue(const QHashedV4String &name, bool *ok) const
+int QQmlType::enumValue(const QV4::String *name, bool *ok) const
{
Q_ASSERT(ok);
*ok = true;
@@ -976,7 +976,7 @@ QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor)
return 0;
}
-QQmlType *QQmlTypeModule::type(const QHashedV4String &name, int minor)
+QQmlType *QQmlTypeModule::type(const QV4::String *name, int minor)
{
QReadLocker lock(metaTypeDataLock());
@@ -1045,7 +1045,7 @@ QQmlType *QQmlTypeModuleVersion::type(const QHashedStringRef &name) const
else return 0;
}
-QQmlType *QQmlTypeModuleVersion::type(const QHashedV4String &name) const
+QQmlType *QQmlTypeModuleVersion::type(const QV4::String *name) const
{
if (m_module) return m_module->type(name, m_minor);
else return 0;
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 26fba2b2fc..e44eade902 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -61,6 +61,8 @@
#include <QtCore/qbitarray.h>
#include <QtQml/qjsvalue.h>
+#include <private/qv4string_p.h>
+
QT_BEGIN_NAMESPACE
class QQmlType;
@@ -136,7 +138,6 @@ private:
struct QQmlMetaTypeData;
class QHashedCStringRef;
-class QHashedV4String;
class Q_QML_PRIVATE_EXPORT QQmlType
{
public:
@@ -213,7 +214,7 @@ public:
int enumValue(const QHashedStringRef &, bool *ok) const;
int enumValue(const QHashedCStringRef &, bool *ok) const;
- int enumValue(const QHashedV4String &, bool *ok) const;
+ int enumValue(const QV4::String *, bool *ok) const;
private:
QQmlType *superType() const;
friend class QQmlTypePrivate;
@@ -252,7 +253,7 @@ public:
int maximumMinorVersion() const;
QQmlType *type(const QHashedStringRef &, int);
- QQmlType *type(const QHashedV4String &, int);
+ QQmlType *type(const QV4::String *, int);
QList<QQmlType*> singletonTypes(int) const;
@@ -279,7 +280,7 @@ public:
int minorVersion() const;
QQmlType *type(const QHashedStringRef &) const;
- QQmlType *type(const QHashedV4String &) const;
+ QQmlType *type(const QV4::String *) const;
private:
QQmlTypeModule *m_module;
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 08005f1df2..65406c9391 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -1376,14 +1376,14 @@ inline const QString &qQmlPropertyCacheToString(const QString &string)
return string;
}
-inline QString qQmlPropertyCacheToString(const QHashedV4String &string)
+inline QString qQmlPropertyCacheToString(const QV4::String *string)
{
- return string.toString();
+ return string->toQString();
}
template<typename T>
QQmlPropertyData *
-qQmlPropertyCacheProperty(QQmlEngine *engine, QObject *obj, const T &name,
+qQmlPropertyCacheProperty(QQmlEngine *engine, QObject *obj, T name,
QQmlContextData *context, QQmlPropertyData &local)
{
QQmlPropertyCache *cache = 0;
@@ -1417,17 +1417,17 @@ qQmlPropertyCacheProperty(QQmlEngine *engine, QObject *obj, const T &name,
}
QQmlPropertyData *
-QQmlPropertyCache::property(QQmlEngine *engine, QObject *obj, const QHashedV4String &name,
+QQmlPropertyCache::property(QQmlEngine *engine, QObject *obj, const QV4::String *name,
QQmlContextData *context, QQmlPropertyData &local)
{
- return qQmlPropertyCacheProperty<QHashedV4String>(engine, obj, name, context, local);
+ return qQmlPropertyCacheProperty<const QV4::String *>(engine, obj, name, context, local);
}
QQmlPropertyData *
QQmlPropertyCache::property(QQmlEngine *engine, QObject *obj,
const QString &name, QQmlContextData *context, QQmlPropertyData &local)
{
- return qQmlPropertyCacheProperty<QString>(engine, obj, name, context, local);
+ return qQmlPropertyCacheProperty<const QString &>(engine, obj, name, context, local);
}
static inline const QMetaObjectPrivate *priv(const uint* data)
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 737b39c199..7bc7c4674f 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -304,7 +304,7 @@ public:
inline QQmlEngine *qmlEngine() const;
static QQmlPropertyData *property(QQmlEngine *, QObject *, const QString &,
QQmlContextData *, QQmlPropertyData &);
- static QQmlPropertyData *property(QQmlEngine *, QObject *, const QHashedV4String &,
+ static QQmlPropertyData *property(QQmlEngine *, QObject *, const QV4::String *,
QQmlContextData *, QQmlPropertyData &);
static int *methodParameterTypes(QObject *, int index, QVarLengthArray<int, 9> &dummy,
QByteArray *unknownTypeError);
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
index 8c522c2ffa..38466aa20d 100644
--- a/src/qml/qml/qqmltypenamecache.cpp
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -91,7 +91,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
return typeSearch(i->modules, name);
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedV4String &name)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name)
{
Result result = query(m_namedImports, name);
@@ -101,7 +101,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedV4String &name)
return result;
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedV4String &name, const void *importNamespace)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, const void *importNamespace)
{
Q_ASSERT(importNamespace);
const Import *i = static_cast<const Import *>(importNamespace);
diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h
index 33c01211ed..094bd5c777 100644
--- a/src/qml/qml/qqmltypenamecache_p.h
+++ b/src/qml/qml/qqmltypenamecache_p.h
@@ -90,8 +90,8 @@ public:
};
Result query(const QHashedStringRef &);
Result query(const QHashedStringRef &, const void *importNamespace);
- Result query(const QHashedV4String &);
- Result query(const QHashedV4String &, const void *importNamespace);
+ Result query(const QV4::String *);
+ Result query(const QV4::String *, const void *importNamespace);
private:
friend class QQmlImports;
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 241d1f42a3..f4e9d9b406 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -129,8 +129,6 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
QObject *object = w->object;
- QHashedV4String propertystring(Value::fromString(name));
-
if (w->type) {
QQmlType *type = w->type;
@@ -174,7 +172,7 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
if (name->startsWithUpper()) {
bool ok = false;
- int value = type->enumValue(propertystring, &ok);
+ int value = type->enumValue(name, &ok);
if (ok)
return QV4::Value::fromInt32(value);
@@ -195,7 +193,7 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
} else if (w->typeNamespace) {
Q_ASSERT(w->importNamespace);
- QQmlTypeNameCache::Result r = w->typeNamespace->query(propertystring,
+ QQmlTypeNameCache::Result r = w->typeNamespace->query(name,
w->importNamespace);
if (r.isValid()) {
@@ -236,8 +234,6 @@ void QmlTypeWrapper::put(Managed *m, String *name, const Value &value)
QV8Engine *v8engine = v4->v8Engine;
QQmlContextData *context = v8engine->callingContext();
- QHashedV4String propertystring(Value::fromString(name));
-
QQmlType *type = w->type;
if (type && !type->isSingleton() && w->object) {
QObject *object = w->object;
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 388025dbc4..7355e0df02 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -251,8 +251,6 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
if (!r)
v4->current->throwTypeError();
- QHashedV4String propertystring(Value::fromString(name));
-
// Note: readReferenceValue() can change the reference->type.
if (r->objectType == QmlValueTypeWrapper::Reference) {
QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(r);
@@ -273,9 +271,9 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
{
QQmlData *ddata = QQmlData::get(r->type, false);
if (ddata && ddata->propertyCache)
- result = ddata->propertyCache->property(propertystring, 0, 0);
+ result = ddata->propertyCache->property(name, 0, 0);
else
- result = QQmlPropertyCache::property(r->v8->engine(), r->type, propertystring, 0, local);
+ result = QQmlPropertyCache::property(r->v8->engine(), r->type, name, 0, local);
}
if (!result)
diff --git a/src/qml/qml/v4/qv4qobjectwrapper.cpp b/src/qml/qml/v4/qv4qobjectwrapper.cpp
index a267c4a894..92fa220aa5 100644
--- a/src/qml/qml/v4/qv4qobjectwrapper.cpp
+++ b/src/qml/qml/v4/qv4qobjectwrapper.cpp
@@ -261,16 +261,14 @@ void QObjectWrapper::initializeBindings(ExecutionEngine *engine)
QQmlPropertyData *QObjectWrapper::findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const
{
- QHashedV4String propertystring(QV4::Value::fromString(name));
-
QQmlData *ddata = QQmlData::get(m_object, false);
if (!ddata)
return 0;
QQmlPropertyData *result = 0;
if (ddata && ddata->propertyCache)
- result = ddata->propertyCache->property(propertystring, m_object, qmlContext);
+ result = ddata->propertyCache->property(name, m_object, qmlContext);
if (!result)
- result = QQmlPropertyCache::property(engine->v8Engine->engine(), m_object, propertystring, qmlContext, *local);
+ result = QQmlPropertyCache::property(engine->v8Engine->engine(), m_object, name, qmlContext, *local);
return result;
}
@@ -297,8 +295,7 @@ Value QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextData *qml
if (includeImports && name->startsWithUpper()) {
// Check for attached properties
if (qmlContext && qmlContext->imports) {
- QHashedV4String propertystring(QV4::Value::fromString(name));
- QQmlTypeNameCache::Result r = qmlContext->imports->query(propertystring);
+ QQmlTypeNameCache::Result r = qmlContext->imports->query(name);
if (hasProperty)
*hasProperty = true;
@@ -418,8 +415,7 @@ bool QObjectWrapper::setQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlC
QQmlPropertyData local;
QQmlPropertyData *result = 0;
{
- QHashedV4String property(Value::fromString(name));
- result = QQmlPropertyCache::property(ctx->engine->v8Engine->engine(), object, property, qmlContext, local);
+ result = QQmlPropertyCache::property(ctx->engine->v8Engine->engine(), object, name, qmlContext, local);
}
if (!result)
diff --git a/src/qml/qml/v4/qv4string_p.h b/src/qml/qml/v4/qv4string_p.h
index 205bcec3b0..81108c61e0 100644
--- a/src/qml/qml/v4/qv4string_p.h
+++ b/src/qml/qml/v4/qv4string_p.h
@@ -113,6 +113,9 @@ struct Q_QML_EXPORT String : public Managed {
bool startsWithUpper() const {
return _text.length() && _text.at(0).isUpper();
}
+ int length() const {
+ return _text.length();
+ }
QString _text;
mutable uint stringHash;