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
{
}
}
- 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 {
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; };
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()); }
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(); }
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>
}
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;
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)
{
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)
while (context) {
// Search context properties
if (context->propertyNames) {
- int propertyIdx = context->propertyNames->value(propertystring);
+ int propertyIdx = context->propertyNames->value(name);
if (propertyIdx != -1) {
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
void reserve(int);
int value(const QString &);
- inline int value(const QHashedV4String &);
+ inline int value(const QV4::String *);
QString findId(int value) const;
StringCache stringCache;
};
-int QQmlIntegerCache::value(const QHashedV4String &name)
+int QQmlIntegerCache::value(const QV4::String *name)
{
int *result = stringCache.value(name);
return result?*result:-1;
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;
return 0;
}
-QQmlType *QQmlTypeModule::type(const QHashedV4String &name, int minor)
+QQmlType *QQmlTypeModule::type(const QV4::String *name, int minor)
{
QReadLocker lock(metaTypeDataLock());
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;
#include <QtCore/qbitarray.h>
#include <QtQml/qjsvalue.h>
+#include <private/qv4string_p.h>
+
QT_BEGIN_NAMESPACE
class QQmlType;
struct QQmlMetaTypeData;
class QHashedCStringRef;
-class QHashedV4String;
class Q_QML_PRIVATE_EXPORT QQmlType
{
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;
int maximumMinorVersion() const;
QQmlType *type(const QHashedStringRef &, int);
- QQmlType *type(const QHashedV4String &, int);
+ QQmlType *type(const QV4::String *, int);
QList<QQmlType*> singletonTypes(int) const;
int minorVersion() const;
QQmlType *type(const QHashedStringRef &) const;
- QQmlType *type(const QHashedV4String &) const;
+ QQmlType *type(const QV4::String *) const;
private:
QQmlTypeModule *m_module;
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;
}
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)
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);
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);
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);
};
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;
QObject *object = w->object;
- QHashedV4String propertystring(Value::fromString(name));
-
if (w->type) {
QQmlType *type = w->type;
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);
} 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()) {
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;
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);
{
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)
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;
}
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;
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)
bool startsWithUpper() const {
return _text.length() && _text.at(0).isUpper();
}
+ int length() const {
+ return _text.length();
+ }
QString _text;
mutable uint stringHash;
return createRole(key, type);
}
-const ListLayout::Role &ListLayout::getRoleOrCreate(const QV4::Value &key, Role::DataType type)
+const ListLayout::Role &ListLayout::getRoleOrCreate(const QV4::String *key, Role::DataType type)
{
- QHashedV4String hashedKey(key);
- QStringHash<Role *>::Node *node = roleHash.findNode(hashedKey);
+ QStringHash<Role *>::Node *node = roleHash.findNode(key);
if (node) {
const Role &r = *node->value;
if (type != r.type)
return r;
}
- QString qkey = key.toQString();
+ QString qkey = key->toQString();
return createRole(qkey, type);
}
return r;
}
-const ListLayout::Role *ListLayout::getExistingRole(const QV4::Value &key)
+const ListLayout::Role *ListLayout::getExistingRole(const QV4::String *key)
{
Role *r = 0;
- QHashedV4String hashedKey(key);
- QStringHash<Role *>::Node *node = roleHash.findNode(hashedKey);
+ QStringHash<Role *>::Node *node = roleHash.findNode(key);
if (node)
r = node->value;
return r;
QV4::ObjectIterator it(object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly);
while (1) {
QV4::Value propertyValue;
- QV4::Value propertyName = it.nextPropertyNameAsString(&propertyValue);
- if (propertyName.isNull())
+ QV4::String *propertyName = it.nextPropertyNameAsString(&propertyValue).asString();
+ if (!propertyName)
break;
// Check if this key exists yet
QV4::ObjectIterator it(object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly);
while (1) {
QV4::Value propertyValue;
- QV4::Value propertyName = it.nextPropertyNameAsString(&propertyValue);
- if (propertyName.isNull())
+ QV4::String *propertyName = it.nextPropertyNameAsString(&propertyValue).asString();
+ if (!propertyName)
break;
// Add the value now
};
const Role *getRoleOrCreate(const QString &key, const QVariant &data);
- const Role &getRoleOrCreate(const QV4::Value &key, Role::DataType type);
+ const Role &getRoleOrCreate(const QV4::String *key, Role::DataType type);
const Role &getRoleOrCreate(const QString &key, Role::DataType type);
const Role &getExistingRole(int index) { return *roles.at(index); }
const Role *getExistingRole(const QString &key);
- const Role *getExistingRole(const QV4::Value &key);
+ const Role *getExistingRole(const QV4::String *key);
int roleCount() const { return roles.count(); }