aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-10-31 22:18:47 +0100
committerLars Knoll <lars.knoll@qt.io>2017-11-13 08:56:33 +0000
commit5c268e5b3a0af4e516e87cadc5904eeefafe4aa2 (patch)
tree7c2627d9f312178309b847e824699fbdfbec205a
parent0e5c17dda3ef037ad4625191f65918603f78c608 (diff)
Convert methods of BooleanObject to new calling convention
Change-Id: I8677025b26a77109d2c60601d25980c8d065b21c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp43
-rw-r--r--src/qml/jsruntime/qv4booleanobject_p.h4
2 files changed, 28 insertions, 19 deletions
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index 2d89366e74..eb83f902db 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -73,30 +73,39 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(engine->id_valueOf(), method_valueOf);
}
-ReturnedValue BooleanPrototype::method_toString(const BuiltinFunction *b, CallData *callData)
+static bool value(const Value *thisObject, bool *exception)
{
- ExecutionEngine *v4 = b->engine();
- bool result;
- if (callData->thisObject.isBoolean()) {
- result = callData->thisObject.booleanValue();
+ *exception = false;
+ if (thisObject->isBoolean()) {
+ return thisObject->booleanValue();
} else {
- const BooleanObject *thisObject = callData->thisObject.as<BooleanObject>();
- if (!thisObject)
- return v4->throwTypeError();
- result = thisObject->value();
+ const BooleanObject *that = thisObject->as<BooleanObject>();
+ if (that)
+ return that->value();
}
+ *exception = true;
+ return false;
+}
+
+ReturnedValue BooleanPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ bool exception;
+ bool result = ::value(thisObject, &exception);
+ ExecutionEngine *v4 = b->engine();
+ if (exception)
+ return v4->throwTypeError();
return Encode(result ? v4->id_true() : v4->id_false());
}
-ReturnedValue BooleanPrototype::method_valueOf(const BuiltinFunction *b, CallData *callData)
+ReturnedValue BooleanPrototype::method_valueOf(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
- if (callData->thisObject.isBoolean())
- return callData->thisObject.asReturnedValue();
-
- const BooleanObject *thisObject = callData->thisObject.as<BooleanObject>();
- if (!thisObject)
- return b->engine()->throwTypeError();
+ bool exception;
+ bool result = ::value(thisObject, &exception);
+ if (exception) {
+ ExecutionEngine *v4 = b->engine();
+ return v4->throwTypeError();
+ }
- return Encode(thisObject->value());
+ return Encode(result);
}
diff --git a/src/qml/jsruntime/qv4booleanobject_p.h b/src/qml/jsruntime/qv4booleanobject_p.h
index 7a686e0d53..3cf09b2667 100644
--- a/src/qml/jsruntime/qv4booleanobject_p.h
+++ b/src/qml/jsruntime/qv4booleanobject_p.h
@@ -79,8 +79,8 @@ struct BooleanPrototype: BooleanObject
V4_PROTOTYPE(objectPrototype)
void init(ExecutionEngine *engine, Object *ctor);
- static ReturnedValue method_toString(const BuiltinFunction *, CallData *callData);
- static ReturnedValue method_valueOf(const BuiltinFunction *, CallData *callData);
+ static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};