From 63cd0f745bb5a3baf47046b8453159cf34b0a23a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 14 Feb 2013 12:29:16 +0100 Subject: Fix print and gc in builtin v4 method Also removed unused TestHarness stuff. Change-Id: I6332d9a34f471df07cfa0e9709a203e99a48b524 Reviewed-by: Lars Knoll --- tools/v4/main.cpp | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'tools') diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp index 01d4f8fd..7a6e7361 100644 --- a/tools/v4/main.cpp +++ b/tools/v4/main.cpp @@ -77,10 +77,10 @@ struct Print: FunctionObject name = scope->engine->newString("print"); } - virtual Value call(ExecutionContext *ctx) + virtual Value call(ExecutionContext *ctx, Value, Value *args, int argc) { - for (unsigned int i = 0; i < ctx->argumentCount; ++i) { - String *s = ctx->argument(i).toString(ctx); + for (int i = 0; i < argc; ++i) { + String *s = args[i].toString(ctx); if (i) std::cout << ' '; std::cout << qPrintable(s->toQString()); @@ -90,29 +90,6 @@ struct Print: FunctionObject } }; -struct TestHarnessError: FunctionObject -{ - TestHarnessError(ExecutionContext *scope, bool &errorInTestHarness): FunctionObject(scope), errorOccurred(errorInTestHarness) { - name = scope->engine->newString("$ERROR"); - } - - virtual Value call(ExecutionContext *ctx) - { - errorOccurred = true; - - for (unsigned int i = 0; i < ctx->argumentCount; ++i) { - String *s = ctx->argument(i).toString(ctx); - if (i) - std::cerr << ' '; - std::cerr << qPrintable(s->toQString()); - } - std::cerr << std::endl; - return Value::undefinedValue(); - } - - bool &errorOccurred; -}; - struct GC: public FunctionObject { GC(ExecutionContext* scope) @@ -120,7 +97,7 @@ struct GC: public FunctionObject { name = scope->engine->newString("gc"); } - virtual Value call(ExecutionContext *ctx) + virtual Value call(ExecutionContext *ctx, Value, Value *, int) { ctx->engine->memoryManager->runGC(); return Value::undefinedValue(); @@ -376,11 +353,6 @@ int main(int argc, char *argv[]) globalObject->__put__(ctx, vm.newIdentifier(QStringLiteral("gc")), QQmlJS::VM::Value::fromObject(gc)); - bool errorInTestHarness = false; - if (!qgetenv("IN_TEST_HARNESS").isEmpty()) - globalObject->__put__(ctx, vm.newIdentifier(QStringLiteral("$ERROR")), - QQmlJS::VM::Value::fromObject(new (ctx->engine->memoryManager) builtins::TestHarnessError(ctx, errorInTestHarness))); - foreach (const QString &fn, args) { QFile file(fn); if (file.open(QFile::ReadOnly)) { @@ -411,8 +383,6 @@ int main(int argc, char *argv[]) std::cout << "exit value: " << qPrintable(result.toString(ctx)->toQString()) << std::endl; } - if (errorInTestHarness) - return EXIT_FAILURE; } else { std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl; return EXIT_FAILURE; -- cgit v1.2.3