10# if !defined (HPP_ALIB_EXPRESSIONS_PLUGINS_MATH)
18# define M_PI 3.14159265358979323846
21# define M_E 2.7182818284590452354
24# define M_LN10 2.30258509299404568402
30#define INT(box) (box).Unbox<integer>()
31#define FLT(box) (box).Unbox<double >()
32#define FUNC( name,...) Box name( Scope& scope, \
35 { (void) scope; (void) args; (void) end; __VA_ARGS__ }
37namespace alib {
namespace expressions {
namespace plugins {
51FUNC( max_I ,
return (std::max) (INT(*args),INT(*(args+1))); )
52FUNC( max_F ,
return (::fmax) (FLT(*args),FLT(*(args+1))); )
53FUNC( min_I ,
return (std::min) (INT(*args),INT(*(args+1))); )
54FUNC( min_F ,
return (::fmin) (FLT(*args),FLT(*(args+1))); )
55FUNC( abs_I ,
return std::abs (INT(*args)); )
56FUNC( abs , return ::fabs (FLT(*args)); )
57FUNC( ceil , return ::ceil (FLT(*args)); )
58FUNC( floor , return ::floor (FLT(*args)); )
59FUNC( trunc , return ::round (FLT(*args)); )
60FUNC( round , return ::round (FLT(*args)); )
61FUNC( rint ,
return static_cast<integer>(::llrint(FLT(*args))); )
62FUNC( remainder, return ::remainder(FLT(*args),FLT(*(args+1))); )
64FUNC( rand ,
return static_cast<double>(std::rand()) /
static_cast<double>(RAND_MAX); )
66FUNC( sin , return ::sin (FLT(*args)); )
67FUNC( asin , return ::asin (FLT(*args)); )
68FUNC( cos , return ::cos (FLT(*args)); )
69FUNC( acos , return ::acos (FLT(*args)); )
70FUNC( tan , return ::tan (FLT(*args)); )
71FUNC( atan , return ::atan (FLT(*args)); )
73FUNC( sinh , return ::sinh (FLT(*args)); )
74FUNC( asinh , return ::asinh (FLT(*args)); )
75FUNC( cosh , return ::cosh (FLT(*args)); )
76FUNC( acosh , return ::acosh (FLT(*args)); )
77FUNC( tanh , return ::tanh (FLT(*args)); )
78FUNC( atanh , return ::atanh (FLT(*args)); )
80FUNC( exp , return ::exp (FLT(*args)); )
81FUNC( exp2 , return ::exp2 (FLT(*args)); )
82#
if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID_NDK__)
83 FUNC(exp10 , return ::pow (10.0 ,FLT(*args)); )
85 FUNC(exp10 , return ::exp10 (FLT(*args)); )
89FUNC( log , return ::log (FLT(*args)); )
90FUNC( log2 , return ::log2 (FLT(*args)); )
92 FUNC( log10 , return ::log (FLT(*args)) / M_LN10; )
94 FUNC( log10 , return ::log10 (FLT(*args)); )
97FUNC( pow , return ::pow (FLT(*args++),FLT(*args)); )
98#
if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID_NDK__)
99 FUNC(pow10 , return ::pow (10.0 ,FLT(*args)); )
101 FUNC(pow10 , return ::exp10 (FLT(*args)); )
103FUNC( sqrt , return ::sqrt (FLT(*args)); )
104FUNC( cbrt , return ::cbrt (FLT(*args)); )
121 constexpr int tableSize= 34;
122 Token functionNames[tableSize];
123 Token::LoadResourcedTokens( EXPRESSIONS,
"CPM", functionNames
127 Token* descriptor= functionNames;
132 { *descriptor++, constPI },
133 { *descriptor++, constE },
176 "Descriptor table size mismatch: Consumed {} descriptors, {} available.",
177 descriptor - functionNames, tableSize )
#define ALIB_WARNINGS_RESTORE
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
expressions::plugins::Calculus Calculus
Type alias in namespace alib.
strings::util::Token Token
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
expressions::Compiler Compiler
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
ALIB_API Math(Compiler &compiler)