From 4b22e2093f08fb66107af4dbd8138cf9526c5786 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Nov 2016 13:15:49 +0100 Subject: qmlimportscanner: Output application name in generic error messages This makes it easier to spot issues in build logs. Amends change a23bcdf91971510b79c541fdff4a9467ead08751. Change-Id: I68e440c2ce79504fb5f5fa08392a91d39e631e25 Reviewed-by: Andy Shaw --- tools/qmlimportscanner/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index 0f8eca34e1..1e5f7a9921 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -519,7 +519,8 @@ int main(int argc, char *argv[]) std::cerr << "-importPath requires an argument\n"; argReceiver = &qmlImportPaths; } else { - std::cerr << "Invalid argument: \"" << qPrintable(arg) << "\"\n"; + std::cerr << qPrintable(appName) << ": Invalid argument: \"" + << qPrintable(arg) << "\"\n"; return 1; } @@ -529,7 +530,8 @@ int main(int argc, char *argv[]) break; ++i; if (!QFile::exists(arg)) { - std::cerr << "No such file or directory: \"" << qPrintable(arg) << "\"\n"; + std::cerr << qPrintable(appName) << ": No such file or directory: \"" + << qPrintable(arg) << "\"\n"; return 1; } else { *argReceiver += arg; -- cgit v1.2.3 From 8bf579d8d4feb13ca8651e98dd762b28483abe9e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 22 Oct 2016 05:24:20 +0200 Subject: Cleanup of builtin JS helpers for qmljs Replace the hand-written gc and print functions with the print and gc functions also used in Qml and QJSEngine. And while we're at it, this also adds the console object. Change-Id: Ia3a0ff24936b7ed5149cb689838b987f9178131e Reviewed-by: Erik Verbruggen Reviewed-by: Mitch Curtis --- tools/qmljs/qmljs.cpp | 57 ++------------------------------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) (limited to 'tools') diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp index b0079dcf49..dd1898a88a 100644 --- a/tools/qmljs/qmljs.cpp +++ b/tools/qmljs/qmljs.cpp @@ -42,6 +42,7 @@ #include "private/qv4context_p.h" #include "private/qv4script_p.h" #include "private/qv4string_p.h" +#include "private/qqmlbuiltinfunctions_p.h" #ifdef V4_ENABLE_JIT # include "private/qv4isel_masm_p.h" @@ -60,57 +61,6 @@ QT_REQUIRE_CONFIG(qml_interpreter); #include -namespace builtins { - -using namespace QV4; - -struct Print: FunctionObject -{ - struct Data : Heap::FunctionObject { - void init(ExecutionContext *scope) - { - Heap::FunctionObject::init(scope, QStringLiteral("print")); - } - }; - V4_OBJECT(FunctionObject) - - static void call(const Managed *, Scope &scope, CallData *callData) - { - for (int i = 0; i < callData->argc; ++i) { - QString s = callData->args[i].toQStringNoThrow(); - if (i) - std::cout << ' '; - std::cout << qPrintable(s); - } - std::cout << std::endl; - scope.result = Encode::undefined(); - } -}; - -DEFINE_OBJECT_VTABLE(Print); - -struct GC: public FunctionObject -{ - struct Data : Heap::FunctionObject { - void init(ExecutionContext *scope) - { - Heap::FunctionObject::init(scope, QStringLiteral("gc")); - } - - }; - V4_OBJECT(FunctionObject) - - static void call(const Managed *m, Scope &scope, CallData *) - { - static_cast(m)->engine()->memoryManager->runGC(); - scope.result = Encode::undefined(); - } -}; - -DEFINE_OBJECT_VTABLE(GC); - -} // builtins - static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exception, const QV4::StackTrace &trace) { QV4::Scope scope(ctx); @@ -200,10 +150,7 @@ int main(int argc, char *argv[]) QV4::Scope scope(&vm); QV4::ScopedContext ctx(scope, vm.rootContext()); - QV4::ScopedObject print(scope, vm.memoryManager->allocObject(vm.rootContext())); - vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print); - QV4::ScopedObject gc(scope, vm.memoryManager->allocObject(ctx)); - vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc); + QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension); for (const QString &fn : qAsConst(args)) { QFile file(fn); -- cgit v1.2.3