1234567891011121314151617181920212223242526272829 |
- #include <math.h>
- #include "libraries/Math.h"
- #include "utils/Functions.h"
- #define FLOAT_FUNCTION(Name, Function) \
- static void l##Name(Script* sc) { \
- float f; \
- if(sPopFloat(sc, &f)) { \
- sPushFloat(sc, Function(f)); \
- } \
- }
- FLOAT_FUNCTION(Sin, sinf)
- FLOAT_FUNCTION(Cos, cosf)
- FLOAT_FUNCTION(Tan, tanf)
- void lAddFloatFunction(const char* name, ScriptFunction sf) {
- Function f;
- gfInit(&f, name, dtFloat(), sf);
- gfAddArgument(&f, dtFloat());
- gfsAdd(&f);
- }
- void lMathRegister() {
- lAddFloatFunction("sin", lSin);
- lAddFloatFunction("cos", lCos);
- lAddFloatFunction("tan", lTan);
- }
|