aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h11
-rw-r--r--src/qml/qml/v4/qv4v8.cpp10
-rw-r--r--src/qml/qml/v4/qv4v8_p.h42
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp71
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp4
6 files changed, 38 insertions, 102 deletions
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index cce49709a7..9393e1fed0 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -1182,16 +1182,7 @@ v8::Handle<v8::String> QHashedV8String::string() const
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(string[i]);
-
- return result;
+ return m_string->v4Value().toQString();
}
QHashedStringRef::QHashedStringRef()
diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp
index e7ca797899..9902528a04 100644
--- a/src/qml/qml/v4/qv4v8.cpp
+++ b/src/qml/qml/v4/qv4v8.cpp
@@ -614,16 +614,6 @@ QV4::String *String::asV4String() const
return v->stringValue();
}
-String::AsciiValue::AsciiValue(Handle<v8::Value> obj)
-{
- str = obj->ToString()->asQString().toLatin1();
-}
-
-String::Value::Value(Handle<v8::Value> obj)
-{
- str = obj->ToString()->asQString();
-}
-
struct ExternalResourceWrapper : public QV4::Object::ExternalResource
{
diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h
index 11662b97f7..b73d26ef62 100644
--- a/src/qml/qml/v4/qv4v8_p.h
+++ b/src/qml/qml/v4/qv4v8_p.h
@@ -942,48 +942,6 @@ class V8EXPORT String : public Value {
*/
static Handle<String> NewExternal(ExternalStringResource* resource);
- /**
- * Converts an object to an ASCII string.
- * Useful if you want to print the object.
- * If conversion to a string fails (eg. due to an exception in the toString()
- * method of the object) then the length() method returns 0 and the * operator
- * returns NULL.
- */
- class V8EXPORT AsciiValue {
- public:
- explicit AsciiValue(Handle<v8::Value> obj);
- ~AsciiValue() {}
- char* operator*() { return str.data(); }
- const char* operator*() const { return str.constData(); }
- int length() const { return str.length(); }
- private:
- QByteArray str;
-
- // Disallow copying and assigning.
- AsciiValue(const AsciiValue&);
- void operator=(const AsciiValue&);
- };
-
- /**
- * Converts an object to a two-byte string.
- * If conversion to a string fails (eg. due to an exception in the toString()
- * method of the object) then the length() method returns 0 and the * operator
- * returns NULL.
- */
- class V8EXPORT Value {
- public:
- explicit Value(Handle<v8::Value> obj);
- ~Value() {}
- uint16_t* operator*() { return (uint16_t *)str.data(); }
- const uint16_t* operator*() const { return str.utf16(); }
- int length() const { return str.length(); }
- private:
- QString str;
-
- // Disallow copying and assigning.
- Value(const Value&);
- void operator=(const Value&);
- };
QString asQString() const;
QV4::String *asV4String() const;
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index c69ea9a8e1..a24fb5d25a 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -74,13 +74,13 @@ enum ConsoleLogTypes {
Error
};
-static void jsContext(v8::Handle<v8::Value> *file, int *line, v8::Handle<v8::Value> *function) {
+static void jsContext(QString &file, int *line, QString &function) {
v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(1);
if (stackTrace->GetFrameCount()) {
v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
- *file = frame->GetScriptName();
+ file = frame->GetScriptName()->v4Value().toQString();
*line = frame->GetLineNumber();
- *function = frame->GetFunctionName();
+ function = frame->GetFunctionName()->v4Value().toQString();
}
}
@@ -127,24 +127,22 @@ QV4::Value console(ConsoleLogTypes logType, const v8::Arguments &args,
result.append(jsStack());
}
- v8::Handle<v8::Value> fileHandle;
- v8::Handle<v8::Value> functionHandle;
+ QString file;
+ QString function;
int line;
- jsContext(&fileHandle, &line, &functionHandle);
+ jsContext(file, &line, function);
+ QMessageLogger logger(file.toUtf8().constData(), line, function.toUtf8().constData());
switch (logType) {
case Log:
- QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
- *v8::String::AsciiValue(functionHandle)).debug("%s", qPrintable(result));
+ logger.debug("%s", qPrintable(result));
break;
case Warn:
- QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
- *v8::String::AsciiValue(functionHandle)).warning("%s", qPrintable(result));
+ logger.warning("%s", qPrintable(result));
break;
case Error:
- QMessageLogger(*v8::String::AsciiValue(fileHandle), line,
- *v8::String::AsciiValue(functionHandle)).critical("%s", qPrintable(result));
+ logger.critical("%s", qPrintable(result));
break;
default:
break;
@@ -185,20 +183,18 @@ QV4::Value consoleProfile(const v8::Arguments &args)
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
+ QString file;
+ QString function;
int line;
- jsContext(&file, &line, &function);
+ jsContext(file, &line, function);
+ QMessageLogger logger(file.toUtf8().constData(), line, function.toUtf8().constData());
if (QQmlProfilerService::startProfiling()) {
QV8ProfilerService::instance()->startProfiling(title);
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).debug("Profiling started.");
+ logger.debug("Profiling started.");
} else {
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).warning(
- "Profiling is already in progress. First, end current profiling session.");
+ logger.warning("Profiling is already in progress. First, end current profiling session.");
}
return QV4::Value::undefinedValue();
@@ -212,10 +208,12 @@ QV4::Value consoleProfileEnd(const v8::Arguments &args)
Q_UNUSED(args);
QString title;
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
+ QString file;
+ QString function;
int line;
- jsContext(&file, &line, &function);
+ jsContext(file, &line, function);
+
+ QMessageLogger logger(file.toUtf8().constData(), line, function.toUtf8().constData());
if (QQmlProfilerService::stopProfiling()) {
QV8ProfilerService *profiler = QV8ProfilerService::instance();
@@ -223,11 +221,9 @@ QV4::Value consoleProfileEnd(const v8::Arguments &args)
QQmlProfilerService::sendProfilingData();
profiler->sendProfilingData();
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).debug("Profiling ended.");
+ logger.debug("Profiling ended.");
} else {
- QMessageLogger(*v8::String::AsciiValue(file), line,
- *v8::String::AsciiValue(function)).warning("Profiling was not started.");
+ logger.warning("Profiling was not started.");
}
return QV4::Value::undefinedValue();
@@ -290,13 +286,14 @@ QV4::Value consoleTrace(const v8::Arguments &args)
QString stack = jsStack();
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
+ QString file;
+ QString function;
int line;
- jsContext(&file, &line, &function);
+ jsContext(file, &line, function);
+
+ QMessageLogger logger(file.toUtf8().constData(), line, function.toUtf8().constData());
- QMessageLogger(*v8::String::AsciiValue(file), line, *v8::String::AsciiValue(function)).debug(
- "%s", qPrintable(stack));
+ logger.debug("%s", qPrintable(stack));
return QV4::Value::undefinedValue();
}
@@ -322,13 +319,13 @@ QV4::Value consoleAssert(const v8::Arguments &args)
QString stack = jsStack();
- v8::Handle<v8::Value> file;
- v8::Handle<v8::Value> function;
+ QString file;
+ QString function;
int line;
- jsContext(&file, &line, &function);
+ jsContext(file, &line, function);
- QMessageLogger(*v8::String::AsciiValue(file), line, *v8::String::AsciiValue(function)).critical(
- "%s\n%s", qPrintable(message), qPrintable(stack));
+ QMessageLogger logger(file.toUtf8().constData(), line, function.toUtf8().constData());
+ logger.critical("%s\n%s", qPrintable(message), qPrintable(stack));
}
return QV4::Value::undefinedValue();
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index b72d043879..3d272c6049 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -740,7 +740,7 @@ void QQuickCanvasItem::getContext(QQmlV4Function *args)
return;
}
- QString contextId = QString::fromUtf16(*v8::String::Value((*args)[0]));
+ QString contextId = (*args)[0].toQString();
if (d->context != 0) {
if (d->context->contextNames().contains(contextId, Qt::CaseInsensitive)) {
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 61d31f9633..80bcbe10f3 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -127,9 +127,9 @@ static const double Q_PI = 3.14159265358979323846; // pi
#define CHECK_RGBA(c) (c == '-' || c == '.' || (c >=0 && c <= 9))
QColor qt_color_from_string(v8::Handle<v8::Value> name)
{
- v8::String::AsciiValue str(name);
+ QByteArray str = name->v4Value().toQString().toUtf8();
- char *p = *str;
+ char *p = str.data();
int len = str.length();
//rgb/hsl color string has at least 7 characters
if (!p || len > 255 || len <= 7)