diff options
author | Lars Knoll <[email protected]> | 2015-01-15 21:54:12 +0100 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2015-01-23 12:30:38 +0100 |
commit | ef6b4938b9ec309d5faf0c966cb2b58f3de2ca77 (patch) | |
tree | 3d946ad66defb1ec5c60a50e16b6e7883ec33862 /src/qml/jsruntime/qv4booleanobject.cpp | |
parent | 3dbf4e9a6979802fff55e2f5e6aa54a14280e128 (diff) |
Cleanups
Simplify some code in BooleanObject
Simplify access to call arguments and thisObject
Change-Id: I2f8e844019bc587385608beb02f05b15f827535c
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4booleanobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4booleanobject.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp index c606e37310..0287945700 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -47,8 +47,7 @@ ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData) { Scope scope(static_cast<BooleanCtor *>(m)->engine()); bool n = callData->argc ? callData->args[0].toBoolean() : false; - ScopedValue b(scope, QV4::Primitive::fromBoolean(n)); - return Encode(scope.engine->newBooleanObject(b)); + return Encode(scope.engine->newBooleanObject(n)); } ReturnedValue BooleanCtor::call(Managed *, CallData *callData) @@ -71,14 +70,13 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue BooleanPrototype::method_toString(CallContext *ctx) { bool result; - if (ctx->d()->callData->thisObject.isBoolean()) { - result = ctx->d()->callData->thisObject.booleanValue(); + if (ctx->thisObject().isBoolean()) { + result = ctx->thisObject().booleanValue(); } else { - Scope scope(ctx); - Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject); + BooleanObject *thisObject = ctx->thisObject().as<BooleanObject>(); if (!thisObject) return ctx->engine()->throwTypeError(); - result = thisObject->value().booleanValue(); + result = thisObject->value(); } return Encode(ctx->d()->engine->newString(QLatin1String(result ? "true" : "false"))); @@ -86,13 +84,12 @@ ReturnedValue BooleanPrototype::method_toString(CallContext *ctx) ReturnedValue BooleanPrototype::method_valueOf(CallContext *ctx) { - if (ctx->d()->callData->thisObject.isBoolean()) - return ctx->d()->callData->thisObject.asReturnedValue(); + if (ctx->thisObject().isBoolean()) + return ctx->thisObject().asReturnedValue(); - Scope scope(ctx); - Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject); + BooleanObject *thisObject = ctx->thisObject().as<BooleanObject>(); if (!thisObject) return ctx->engine()->throwTypeError(); - return thisObject->value().asReturnedValue(); + return Encode(thisObject->value()); } |