20void Heap::MathObject::init()
23 Scope scope(internalClass->engine);
24 ScopedObject m(scope,
this);
26 m->defineReadonlyProperty(QStringLiteral(
"E"), Value::fromDouble(
M_E));
27 m->defineReadonlyProperty(QStringLiteral(
"LN2"), Value::fromDouble(
M_LN2));
28 m->defineReadonlyProperty(QStringLiteral(
"LN10"), Value::fromDouble(
M_LN10));
29 m->defineReadonlyProperty(QStringLiteral(
"LOG2E"), Value::fromDouble(
M_LOG2E));
30 m->defineReadonlyProperty(QStringLiteral(
"LOG10E"), Value::fromDouble(
M_LOG10E));
31 m->defineReadonlyProperty(QStringLiteral(
"PI"), Value::fromDouble(
M_PI));
32 m->defineReadonlyProperty(QStringLiteral(
"SQRT1_2"), Value::fromDouble(
M_SQRT1_2));
33 m->defineReadonlyProperty(QStringLiteral(
"SQRT2"), Value::fromDouble(
M_SQRT2));
35 m->defineDefaultProperty(QStringLiteral(
"abs"), QV4::MathObject::method_abs, 1);
36 m->defineDefaultProperty(QStringLiteral(
"acos"), QV4::MathObject::method_acos, 1);
37 m->defineDefaultProperty(QStringLiteral(
"acosh"), QV4::MathObject::method_acosh, 1);
38 m->defineDefaultProperty(QStringLiteral(
"asin"), QV4::MathObject::method_asin, 1);
39 m->defineDefaultProperty(QStringLiteral(
"asinh"), QV4::MathObject::method_asinh, 1);
40 m->defineDefaultProperty(QStringLiteral(
"atan"), QV4::MathObject::method_atan, 1);
41 m->defineDefaultProperty(QStringLiteral(
"atanh"), QV4::MathObject::method_atanh, 1);
42 m->defineDefaultProperty(QStringLiteral(
"atan2"), QV4::MathObject::method_atan2, 2);
43 m->defineDefaultProperty(QStringLiteral(
"cbrt"), QV4::MathObject::method_cbrt, 1);
44 m->defineDefaultProperty(QStringLiteral(
"ceil"), QV4::MathObject::method_ceil, 1);
45 m->defineDefaultProperty(QStringLiteral(
"clz32"), QV4::MathObject::method_clz32, 1);
46 m->defineDefaultProperty(QStringLiteral(
"cos"), QV4::MathObject::method_cos, 1);
47 m->defineDefaultProperty(QStringLiteral(
"cosh"), QV4::MathObject::method_cosh, 1);
48 m->defineDefaultProperty(QStringLiteral(
"exp"), QV4::MathObject::method_exp, 1);
49 m->defineDefaultProperty(QStringLiteral(
"expm1"), QV4::MathObject::method_expm1, 1);
50 m->defineDefaultProperty(QStringLiteral(
"floor"), QV4::MathObject::method_floor, 1);
51 m->defineDefaultProperty(QStringLiteral(
"fround"), QV4::MathObject::method_fround, 1);
52 m->defineDefaultProperty(QStringLiteral(
"hypot"), QV4::MathObject::method_hypot, 2);
53 m->defineDefaultProperty(QStringLiteral(
"imul"), QV4::MathObject::method_imul, 2);
54 m->defineDefaultProperty(QStringLiteral(
"log"), QV4::MathObject::method_log, 1);
55 m->defineDefaultProperty(QStringLiteral(
"log10"), QV4::MathObject::method_log10, 1);
56 m->defineDefaultProperty(QStringLiteral(
"log1p"), QV4::MathObject::method_log1p, 1);
57 m->defineDefaultProperty(QStringLiteral(
"log2"), QV4::MathObject::method_log2, 1);
58 m->defineDefaultProperty(QStringLiteral(
"max"), QV4::MathObject::method_max, 2);
59 m->defineDefaultProperty(QStringLiteral(
"min"), QV4::MathObject::method_min, 2);
60 m->defineDefaultProperty(QStringLiteral(
"pow"), QV4::MathObject::method_pow, 2);
61 m->defineDefaultProperty(QStringLiteral(
"random"), QV4::MathObject::method_random, 0);
62 m->defineDefaultProperty(QStringLiteral(
"round"), QV4::MathObject::method_round, 1);
63 m->defineDefaultProperty(QStringLiteral(
"sign"), QV4::MathObject::method_sign, 1);
64 m->defineDefaultProperty(QStringLiteral(
"sin"), QV4::MathObject::method_sin, 1);
65 m->defineDefaultProperty(QStringLiteral(
"sinh"), QV4::MathObject::method_sinh, 1);
66 m->defineDefaultProperty(QStringLiteral(
"sqrt"), QV4::MathObject::method_sqrt, 1);
67 m->defineDefaultProperty(QStringLiteral(
"tan"), QV4::MathObject::method_tan, 1);
68 m->defineDefaultProperty(QStringLiteral(
"tanh"), QV4::MathObject::method_tanh, 1);
69 m->defineDefaultProperty(QStringLiteral(
"trunc"), QV4::MathObject::method_trunc, 1);
71 ScopedString name(scope, scope.engine->newString(QStringLiteral(
"Math")));
72 m->defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), name);