Math.c 949 B

1234567891011121314151617181920212223242526272829
  1. #include <math.h>
  2. #include "libraries/Math.h"
  3. #include "utils/Functions.h"
  4. #define FLOAT_FUNCTION(Name, Function) \
  5. static void l##Name(Script* sc) { \
  6. float f; \
  7. if(sPopFloat(sc, &f)) { \
  8. sPushFloat(sc, Function(f)); \
  9. } \
  10. }
  11. FLOAT_FUNCTION(Sin, sinf)
  12. FLOAT_FUNCTION(Cos, cosf)
  13. FLOAT_FUNCTION(Tan, tanf)
  14. void lAddFloatFunction(const char* name, ScriptFunction sf) {
  15. Function f;
  16. gfInit(&f, name, dtFloat(), sf);
  17. gfAddArgument(&f, dtFloat());
  18. gfsAdd(&f);
  19. }
  20. void lMathRegister() {
  21. lAddFloatFunction("sin", lSin);
  22. lAddFloatFunction("cos", lCos);
  23. lAddFloatFunction("tan", lTan);
  24. }