diff options
Diffstat (limited to 'src/qml/jsruntime/qv4string.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 0e43d03987..e5633eb06f 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -108,7 +108,6 @@ const ManagedVTable String::static_vtbl = markObjects, destroy, 0 /*collectDeletables*/, - hasInstance, get, getIndexed, put, @@ -150,7 +149,7 @@ ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty) return Primitive::fromInt32(that->_text->size).asReturnedValue(); } PropertyAttributes attrs; - Property *pd = v4->stringClass->prototype->__getPropertyDescriptor__(name, &attrs); + Property *pd = v4->stringObjectClass->prototype->__getPropertyDescriptor__(name, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; @@ -158,7 +157,7 @@ ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty) } if (hasProperty) *hasProperty = true; - return v4->stringClass->prototype->getValue(that, pd, attrs); + return v4->stringObjectClass->prototype->getValue(that, pd, attrs); } ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) @@ -173,7 +172,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) return Encode(engine->newString(that->toQString().mid(index, 1))); } PropertyAttributes attrs; - Property *pd = engine->stringClass->prototype->__getPropertyDescriptor__(index, &attrs); + Property *pd = engine->stringObjectClass->prototype->__getPropertyDescriptor__(index, &attrs); if (!pd || attrs.isGeneric()) { if (hasProperty) *hasProperty = false; @@ -181,7 +180,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) } if (hasProperty) *hasProperty = true; - return engine->stringClass->prototype->getValue(that, pd, attrs); + return engine->stringObjectClass->prototype->getValue(that, pd, attrs); } void String::put(Managed *m, const StringRef name, const ValueRef value) @@ -252,24 +251,22 @@ bool String::isEqualTo(Managed *t, Managed *o) String::String(ExecutionEngine *engine, const QString &text) - : Managed(engine ? engine->emptyClass : 0), _text(const_cast<QString &>(text).data_ptr()) + : Managed(engine->stringClass), _text(const_cast<QString &>(text).data_ptr()) , identifier(0), stringHash(UINT_MAX) , largestSubLength(0) { _text->ref.ref(); len = _text->size; - vtbl = &static_vtbl; type = Type_String; subtype = StringType_Unknown; } String::String(ExecutionEngine *engine, String *l, String *r) - : Managed(engine ? engine->emptyClass : 0) + : Managed(engine->stringClass) , left(l), right(r) , stringHash(UINT_MAX), largestSubLength(qMax(l->largestSubLength, r->largestSubLength)) , len(l->len + r->len) { - vtbl = &static_vtbl; type = Type_String; subtype = StringType_Unknown; @@ -360,7 +357,7 @@ void String::createHashValue() const // array indices get their number as hash value bool ok; - stringHash = toArrayIndex(ch, end, &ok); + stringHash = ::toArrayIndex(ch, end, &ok); if (ok) { subtype = (stringHash == UINT_MAX) ? StringType_UInt : StringType_ArrayIndex; return; @@ -382,7 +379,7 @@ uint String::createHashValue(const QChar *ch, int length) // array indices get their number as hash value bool ok; - uint stringHash = toArrayIndex(ch, end, &ok); + uint stringHash = ::toArrayIndex(ch, end, &ok); if (ok) return stringHash; @@ -401,7 +398,7 @@ uint String::createHashValue(const char *ch, int length) // array indices get their number as hash value bool ok; - uint stringHash = toArrayIndex(ch, end, &ok); + uint stringHash = ::toArrayIndex(ch, end, &ok); if (ok) return stringHash; @@ -415,3 +412,9 @@ uint String::createHashValue(const char *ch, int length) return h; } + +uint String::toArrayIndex(const QString &str) +{ + bool ok; + return ::toArrayIndex(str.constData(), str.constData() + str.length(), &ok); +} |