aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4mathobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-15 21:54:12 +0100
committerLars Knoll <lars.knoll@digia.com>2015-01-23 12:30:38 +0100
commitef6b4938b9ec309d5faf0c966cb2b58f3de2ca77 (patch)
tree3d946ad66defb1ec5c60a50e16b6e7883ec33862 /src/qml/jsruntime/qv4mathobject.cpp
parent3dbf4e9a6979802fff55e2f5e6aa54a14280e128 (diff)
Cleanups
Simplify some code in BooleanObject Simplify access to call arguments and thisObject Change-Id: I2f8e844019bc587385608beb02f05b15f827535c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4mathobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4mathobject.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp
index b0b50499d5..88097b212a 100644
--- a/src/qml/jsruntime/qv4mathobject.cpp
+++ b/src/qml/jsruntime/qv4mathobject.cpp
@@ -96,15 +96,15 @@ static double copySign(double x, double y)
ReturnedValue MathObject::method_abs(CallContext *context)
{
- if (!context->d()->callData->argc)
+ if (!context->argc())
return Encode(qSNaN());
- if (context->d()->callData->args[0].isInteger()) {
- int i = context->d()->callData->args[0].integerValue();
+ if (context->args()[0].isInteger()) {
+ int i = context->args()[0].integerValue();
return Encode(i < 0 ? - i : i);
}
- double v = context->d()->callData->args[0].toNumber();
+ double v = context->args()[0].toNumber();
if (v == 0) // 0 | -0
return Encode(0);
@@ -113,7 +113,7 @@ ReturnedValue MathObject::method_abs(CallContext *context)
ReturnedValue MathObject::method_acos(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2;
+ double v = context->argc() ? context->args()[0].toNumber() : 2;
if (v > 1)
return Encode(qSNaN());
@@ -122,7 +122,7 @@ ReturnedValue MathObject::method_acos(CallContext *context)
ReturnedValue MathObject::method_asin(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2;
+ double v = context->argc() ? context->args()[0].toNumber() : 2;
if (v > 1)
return Encode(qSNaN());
else
@@ -131,7 +131,7 @@ ReturnedValue MathObject::method_asin(CallContext *context)
ReturnedValue MathObject::method_atan(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v == 0.0)
return Encode(v);
else
@@ -140,8 +140,8 @@ ReturnedValue MathObject::method_atan(CallContext *context)
ReturnedValue MathObject::method_atan2(CallContext *context)
{
- double v1 = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
- double v2 = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN();
+ double v1 = context->argc() ? context->args()[0].toNumber() : qSNaN();
+ double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qSNaN();
if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0))
return Encode(copySign(0, -1.0));
@@ -158,7 +158,7 @@ ReturnedValue MathObject::method_atan2(CallContext *context)
ReturnedValue MathObject::method_ceil(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v < 0.0 && v > -1.0)
return Encode(copySign(0, -1.0));
else
@@ -167,13 +167,13 @@ ReturnedValue MathObject::method_ceil(CallContext *context)
ReturnedValue MathObject::method_cos(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::cos(v));
}
ReturnedValue MathObject::method_exp(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (qIsInf(v)) {
if (copySign(1.0, v) == -1.0)
return Encode(0);
@@ -186,13 +186,13 @@ ReturnedValue MathObject::method_exp(CallContext *context)
ReturnedValue MathObject::method_floor(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::floor(v));
}
ReturnedValue MathObject::method_log(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v < 0)
return Encode(qSNaN());
else
@@ -202,8 +202,8 @@ ReturnedValue MathObject::method_log(CallContext *context)
ReturnedValue MathObject::method_max(CallContext *context)
{
double mx = -qInf();
- for (int i = 0; i < context->d()->callData->argc; ++i) {
- double x = context->d()->callData->args[i].toNumber();
+ for (int i = 0; i < context->argc(); ++i) {
+ double x = context->args()[i].toNumber();
if (x > mx || std::isnan(x))
mx = x;
}
@@ -213,8 +213,8 @@ ReturnedValue MathObject::method_max(CallContext *context)
ReturnedValue MathObject::method_min(CallContext *context)
{
double mx = qInf();
- for (int i = 0; i < context->d()->callData->argc; ++i) {
- double x = context->d()->callData->args[i].toNumber();
+ for (int i = 0; i < context->argc(); ++i) {
+ double x = context->args()[i].toNumber();
if ((x == 0 && mx == x && copySign(1.0, x) == -1.0)
|| (x < mx) || std::isnan(x)) {
mx = x;
@@ -225,8 +225,8 @@ ReturnedValue MathObject::method_min(CallContext *context)
ReturnedValue MathObject::method_pow(CallContext *context)
{
- double x = context->d()->callData->argc > 0 ? context->d()->callData->args[0].toNumber() : qSNaN();
- double y = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN();
+ double x = context->argc() > 0 ? context->args()[0].toNumber() : qSNaN();
+ double y = context->argc() > 1 ? context->args()[1].toNumber() : qSNaN();
if (std::isnan(y))
return Encode(qSNaN());
@@ -286,26 +286,26 @@ ReturnedValue MathObject::method_random(CallContext *context)
ReturnedValue MathObject::method_round(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
v = copySign(::floor(v + 0.5), v);
return Encode(v);
}
ReturnedValue MathObject::method_sin(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::sin(v));
}
ReturnedValue MathObject::method_sqrt(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
return Encode(::sqrt(v));
}
ReturnedValue MathObject::method_tan(CallContext *context)
{
- double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v = context->argc() ? context->args()[0].toNumber() : qSNaN();
if (v == 0.0)
return Encode(v);
else