diff options
author | Lars Knoll <[email protected]> | 2017-01-05 15:14:37 +0100 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2017-01-25 08:31:21 +0000 |
commit | 119e2edb3ea52a6b3b9da6183dc0fcf350ba8431 (patch) | |
tree | 40de3542e30d2de31f336409a9030d76a5d34cc4 /src/qml/jsruntime/qv4jsonobject.cpp | |
parent | afc29a54791e70264f7c175b2da0a234f791f749 (diff) |
Convert more builtin functions
Change-Id: I2dc8797e2240fcfc4176cb08b982e3e98b879646
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index d79e6242ba..1d571f53f3 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -883,10 +883,9 @@ void Heap::JsonObject::init() } -ReturnedValue JsonObject::method_parse(CallContext *ctx) +void JsonObject::method_parse(const BuiltinFunction *, Scope &scope, CallData *callData) { - Scope scope(ctx); - ScopedValue v(scope, ctx->argument(0)); + ScopedValue v(scope, callData->argument(0)); QString jtext = v->toQString(); DEBUG << "parsing source = " << jtext; @@ -895,19 +894,17 @@ ReturnedValue JsonObject::method_parse(CallContext *ctx) ScopedValue result(scope, parser.parse(&error)); if (error.error != QJsonParseError::NoError) { DEBUG << "parse error" << error.errorString(); - return ctx->engine()->throwSyntaxError(QStringLiteral("JSON.parse: Parse error")); + RETURN_RESULT(scope.engine->throwSyntaxError(QStringLiteral("JSON.parse: Parse error"))); } - return result->asReturnedValue(); + scope.result = result; } -ReturnedValue JsonObject::method_stringify(CallContext *ctx) +void JsonObject::method_stringify(const BuiltinFunction *, Scope &scope, CallData *callData) { - Scope scope(ctx); - Stringify stringify(scope.engine); - ScopedObject o(scope, ctx->argument(1)); + ScopedObject o(scope, callData->argument(1)); if (o) { stringify.replacerFunction = o->as<FunctionObject>(); if (o->isArrayObject()) { @@ -932,7 +929,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) } } - ScopedValue s(scope, ctx->argument(2)); + ScopedValue s(scope, callData->argument(2)); if (NumberObject *n = s->as<NumberObject>()) s = Encode(n->value()); else if (StringObject *so = s->as<StringObject>()) @@ -945,11 +942,11 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) } - ScopedValue arg0(scope, ctx->argument(0)); + ScopedValue arg0(scope, callData->argument(0)); QString result = stringify.Str(QString(), arg0); if (result.isEmpty() || scope.engine->hasException) - return Encode::undefined(); - return ctx->d()->engine->newString(result)->asReturnedValue(); + RETURN_UNDEFINED(); + scope.result = scope.engine->newString(result); } |