aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2013-03-01 14:39:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-12 09:30:19 +0100
commit74878ba417e7db9fe8f68a55d69a3cc7ee804422 (patch)
tree761114160518a5407e554c214cd05a9cfaf627f0 /src/qml
parent687603406a1f548eec57b031aafe5bb31eaae278 (diff)
Use official V8 string manipulation methods in QML
The QtJSBackend's String::GetCharacter and String::Equals methods are Qt specific and they are not supported by official V8. These methods can be replaced by more "V8-friendly" implementations in QtDeclarative. Thus the mentioned methods can be removed from QtJSBackend to reduce the difference between QtJSBackend and the official V8 source. Change-Id: I5590ca62dc667e64a7f54a7e47a02d350ba0c077 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h10
-rw-r--r--src/qml/qml/qqmllocale.cpp7
-rw-r--r--src/qml/qml/v8/qv8engine_p.h6
3 files changed, 16 insertions, 7 deletions
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index 5fc8443ecd..cdf0717e3a 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -262,8 +262,9 @@ public:
inline uint16_t *utf16Data() const { return (uint16_t *)strData->data(); }
inline bool equals(v8::Handle<v8::String> string) const {
- return isQString()?string->Equals(utf16Data(), length):
- string->Equals(cStrData(), length);
+ v8::Local<v8::String> data = isQString() ? v8::String::New(utf16Data(), length)
+ : v8::String::New(cStrData(), length);
+ return string->Equals(data);
}
inline bool symbolEquals(const QHashedV8String &string) const {
@@ -1183,8 +1184,11 @@ QString QHashedV8String::toString() const
QString result;
result.reserve(m_hash.length);
+ v8::String::Value value(m_string);
+ Q_ASSERT(*value != NULL);
+ uint16_t* string = *value;
for (int i = 0; i < m_hash.length; ++i)
- result.append(m_string->GetCharacter(i));
+ result.append(string[i]);
return result;
}
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index e1ac75f5f0..c9ce4773c3 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -464,8 +464,11 @@ v8::Handle<v8::Value> QQmlNumberExtension::toLocaleString(const v8::Arguments& a
if (!args[1]->IsString())
V8THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
v8::Local<v8::String> fs = args[1]->ToString();
- if (!fs.IsEmpty() && fs->Length())
- format = fs->GetCharacter(0);
+ if (!fs.IsEmpty() && fs->Length()) {
+ v8::String::Value value(fs);
+ Q_ASSERT(*value != NULL);
+ format = **value;
+ }
}
int prec = 2;
if (args.Length() > 2) {
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 090ffaa353..5ae0963178 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -629,8 +629,10 @@ v8::Handle<v8::String> QV8Engine::bindingFlagKey() const
// unqualified name in QV8ContextWrapper.
bool QV8Engine::startsWithUpper(v8::Handle<v8::String> string)
{
- uint16_t c = string->GetCharacter(0);
- return (c >= 'A' && c <= 'Z') ||
+ v8::String::Value value(string);
+ Q_ASSERT(*value != NULL);
+ uint16_t c = **value;
+ return (c >= 'A' && c <= 'Z') ||
(c > 127 && QChar::category(c) == QChar::Letter_Uppercase);
}