mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
cleanup
This commit is contained in:
parent
7e35fa2d56
commit
13b1fbe17a
@ -28,15 +28,7 @@ typedef struct PyVar{
|
||||
};
|
||||
} PyVar;
|
||||
|
||||
|
||||
#define PyVar__as(T, self) _Generic((T), \
|
||||
int64_t: self->_i64, \
|
||||
double: self->_f64, \
|
||||
PyObject*: self->_obj, \
|
||||
void*: self->_ptr, \
|
||||
)
|
||||
|
||||
static_assert(sizeof(PyVar) == 16, "sizeof(PyVar) != 16");
|
||||
static_assert(sizeof(PyVar) <= 16, "!sizeof(PyVar) <= 16");
|
||||
|
||||
/* predefined vars */
|
||||
static const py_Type tp_object = {1}, tp_type = {2};
|
||||
@ -52,24 +44,6 @@ static const py_Type tp_ellipsis = {26};
|
||||
static const py_Type tp_op_call = {27}, tp_op_yield = {28};
|
||||
static const py_Type tp_syntax_error = {29}, tp_stop_iteration = {30};
|
||||
|
||||
PK_INLINE bool PyVar__is_null(const PyVar* self) { return self->type == 0; }
|
||||
PK_INLINE int64_t PyVar__hash(const PyVar* self) { return self->extra + self->_i64; }
|
||||
|
||||
PK_INLINE void PyVar__ctor(PyVar* self, py_Type type, PyObject* obj){
|
||||
self->type = type;
|
||||
self->is_ptr = true;
|
||||
self->_obj = obj;
|
||||
}
|
||||
|
||||
void PyVar__ctor3(PyVar* self, PyObject* existing);
|
||||
|
||||
PK_INLINE bool PyVar__IS_OP(const PyVar* a, const PyVar* b){
|
||||
return a->is_ptr && b->is_ptr && a->_obj == b->_obj;
|
||||
}
|
||||
|
||||
#define pkpy_Var__is_null(self) ((self)->type == 0)
|
||||
#define pkpy_Var__set_null(self) do { (self)->type = 0; } while(0)
|
||||
|
||||
extern PyVar PY_NULL, PY_OP_CALL, PY_OP_YIELD;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define DICT_HASH_NEXT(h) ((h) * 5 + 1)
|
||||
#define DICT_HASH_TRANS(h) ((int)((h) & 0xffffffff)) // used for tansform value from __hash__
|
||||
#define PK_DICT_COMPACT_MODE 1
|
||||
#define pkpy_Var__is_null(self) ((self)->type == 0)
|
||||
#define pkpy_Var__set_null(self) do { (self)->type = 0; } while(0)
|
||||
|
||||
struct pkpy_DictEntry {
|
||||
PyVar key;
|
||||
|
@ -2,13 +2,6 @@
|
||||
#include "pocketpy/pocketpy.h"
|
||||
#include <assert.h>
|
||||
|
||||
void PyVar__ctor3(PyVar* self, PyObject* existing){
|
||||
assert(existing);
|
||||
self->type = existing->type;
|
||||
self->is_ptr = true;
|
||||
self->_obj = existing;
|
||||
}
|
||||
|
||||
void* PyObject__value(PyObject* self){
|
||||
return (char*)self + PK_OBJ_HEADER_SIZE(self->slots);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user