base.h 761 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include <string.h>
  5. #include "pocketpy/common/utils.h"
  6. #include "pocketpy/pocketpy.h"
  7. typedef struct PyObject PyObject;
  8. typedef struct VM VM;
  9. extern VM* pk_current_vm;
  10. typedef struct py_TValue {
  11. py_Type type;
  12. bool is_ptr;
  13. int extra;
  14. union {
  15. int64_t _i64;
  16. double _f64;
  17. bool _bool;
  18. py_CFunction _cfunc;
  19. PyObject* _obj;
  20. c11_vec2 _vec2;
  21. c11_vec2i _vec2i;
  22. };
  23. } py_TValue;
  24. // 16 bytes to make py_arg() macro work
  25. static_assert(sizeof(py_CFunction) <= 8, "sizeof(py_CFunction) > 8");
  26. static_assert(sizeof(py_TValue) == 16, "sizeof(py_TValue) != 16");
  27. static_assert(offsetof(py_TValue, extra) == 4, "offsetof(py_TValue, extra) != 4");