Browse Source

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

tags/2021-05-28
jules 11 years ago
parent
commit
e12823a10f
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      modules/juce_core/javascript/juce_Javascript.cpp

+ 3
- 0
modules/juce_core/javascript/juce_Javascript.cpp 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); }


Loading…
Cancel
Save