1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-17 00:44:19 +00:00

Added Math.ceil and Math.floor to the javascript parser.

This commit is contained in:
jules 2014-08-19 15:35:36 +01:00
parent a5fc9b34ec
commit e12823a10f

View file

@ -1561,6 +1561,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
setMethod ("log", Math_log); setMethod ("log10", Math_log10);
setMethod ("exp", Math_exp); setMethod ("pow", Math_pow);
setMethod ("sqr", Math_sqr); setMethod ("sqrt", Math_sqrt);
setMethod ("ceil", Math_ceil); setMethod ("floor", Math_floor);
}
static var Math_pi (Args) { return double_Pi; }
@ -1593,6 +1594,8 @@ struct JavascriptEngine::RootObject : public DynamicObject
static var Math_pow (Args a) { return pow (getDouble (a, 0), getDouble (a, 1)); }
static var Math_sqr (Args a) { double x = getDouble (a, 0); return x * x; }
static var Math_sqrt (Args a) { return std::sqrt (getDouble (a, 0)); }
static var Math_ceil (Args a) { return std::ceil (getDouble (a, 0)); }
static var Math_floor (Args a) { return std::floor (getDouble (a, 0)); }
static Identifier getClassName() { static const Identifier i ("Math"); return i; }
template <typename Type> static Type sign (Type n) noexcept { return n > 0 ? (Type) 1 : (n < 0 ? (Type) -1 : 0); }