Functions.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef FUNCTIONS_H
  2. #define FUNCTIONS_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdbool.h>
  7. #include "DataType.h"
  8. #include "vm/Script.h"
  9. #define FUNCTION_ARGUMENTS 9
  10. typedef void (*ScriptFunction)(Script*);
  11. typedef struct {
  12. const char* name;
  13. ScriptFunction scriptFunction;
  14. int arguments;
  15. DataType argumentTypes[FUNCTION_ARGUMENTS];
  16. DataType returnType;
  17. int address;
  18. int size;
  19. int16 line;
  20. bool global;
  21. char padding[1];
  22. } Function;
  23. typedef struct {
  24. int capacity;
  25. int entries;
  26. Function* data;
  27. } Functions;
  28. void fInit(Function* f, const char* name, int16 line);
  29. bool fAddArgument(Function* f, DataType type, Structs* sts);
  30. void fsInit(Functions* fs);
  31. void fsDelete(Functions* fs);
  32. Function* fsSearch(Functions* fs, Function* f);
  33. void fsAdd(Functions* fs, Function* f);
  34. void gfInit(Function* f, const char* name, DataType r, ScriptFunction sf);
  35. bool gfAddArgument(Function* f, DataType type);
  36. void gfsInit(void);
  37. bool gfsAdd(Function* f);
  38. bool gfsCall(Script* sc, int id);
  39. void gfsDelete(void);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif