aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-21 21:23:01 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-22 06:21:29 +0200
commit70f8279338ee9f4df39e45403f9357359113ec0d (patch)
tree5853484d443a2ae37936ece9317f6e66e460fe03 /src/qml
parent3089c2c0fe681f2caec31326748ca9e03a7b32db (diff)
Get rid of v8::String::(Ascii)Value
Change-Id: I792a94590efbec852620d101b620b263a90e1d54 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
-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
4 files changed, 35 insertions, 99 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();