This commit is contained in:
blueloveTH 2024-07-02 20:21:17 +08:00
parent 8fea101c8c
commit 8c41065258
2 changed files with 3 additions and 6 deletions

View File

@ -13,8 +13,9 @@
extern "C" { extern "C" {
#endif #endif
typedef int16_t py_Type;
typedef struct PyObject PyObject; typedef struct PyObject PyObject;
typedef struct pk_VM pk_VM;
extern pk_VM* pk_current_vm;
typedef struct py_TValue { typedef struct py_TValue {
py_Type type; py_Type type;

View File

@ -6,7 +6,6 @@
/************* Public Types *************/ /************* Public Types *************/
typedef struct py_TValue py_TValue; typedef struct py_TValue py_TValue;
typedef struct pk_VM pk_VM;
typedef uint16_t py_Name; typedef uint16_t py_Name;
typedef int16_t py_Type; typedef int16_t py_Type;
@ -36,8 +35,6 @@ typedef enum BindType {
BindType_CLASSMETHOD, BindType_CLASSMETHOD,
} BindType; } BindType;
extern pk_VM* pk_current_vm;
/************* Global VMs *************/ /************* Global VMs *************/
void py_initialize(); void py_initialize();
void py_finalize(); void py_finalize();
@ -142,18 +139,17 @@ void py_bindmethod2(py_Type type, const char* name, py_CFunction f, BindType bt)
void py_bindnativefunc(py_Ref obj, const char* name, py_CFunction f); void py_bindnativefunc(py_Ref obj, const char* name, py_CFunction f);
/// Get the reference to the i-th register. /// Get the reference to the i-th register.
/// All registers are located in a contiguous memory.
py_GlobalRef py_reg(int i); py_GlobalRef py_reg(int i);
/// Get the reference of the object's `__dict__`. /// Get the reference of the object's `__dict__`.
/// The object must have a `__dict__`. /// The object must have a `__dict__`.
/// Returns a reference to the value or NULL if not found. /// Returns a reference to the value or NULL if not found.
/// @lifespan: Object.
py_ObjectRef py_getdict(const py_Ref self, py_Name name); py_ObjectRef py_getdict(const py_Ref self, py_Name name);
void py_setdict(py_Ref self, py_Name name, const py_Ref val); void py_setdict(py_Ref self, py_Name name, const py_Ref val);
/// Get the reference of the i-th slot of the object. /// Get the reference of the i-th slot of the object.
/// The object must have slots and `i` must be in range. /// The object must have slots and `i` must be in range.
/// @lifespan: Object.
py_ObjectRef py_getslot(const py_Ref self, int i); py_ObjectRef py_getslot(const py_Ref self, int i);
void py_setslot(py_Ref self, int i, const py_Ref val); void py_setslot(py_Ref self, int i, const py_Ref val);