base.h 768 B

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