mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
remove custom marker
This commit is contained in:
parent
b3084a5c87
commit
2572ddd982
@ -23,7 +23,6 @@ typedef struct py_TypeInfo {
|
||||
py_TValue annotations; // type annotations
|
||||
|
||||
void (*on_end_subclass)(struct py_TypeInfo*); // backdoor for enum module
|
||||
void (*gc_mark)(void* ud);
|
||||
|
||||
/* Magic Slots */
|
||||
py_TValue magic_0[PK_MAGIC_SLOTS_COMMON_LENGTH]; // common magic slots
|
||||
|
@ -23,3 +23,6 @@ typedef struct {
|
||||
} Dict;
|
||||
|
||||
typedef c11_vector List;
|
||||
|
||||
void c11_chunked_array2d__mark(void* ud);
|
||||
void function__gc_mark(void* ud);
|
@ -59,7 +59,7 @@ bool pk__parse_int_slice(py_Ref slice, int length, int* restrict start, int* res
|
||||
bool pk__normalize_index(int* index, int length);
|
||||
|
||||
#define pk__mark_value(val) if((val)->is_ptr && !(val)->_obj->gc_marked) PyObject__mark((val)->_obj)
|
||||
void pk__tp_set_marker(py_Type type, void (*gc_mark)(void*));
|
||||
|
||||
bool pk__object_new(int argc, py_Ref argv);
|
||||
py_TypeInfo* pk__type_info(py_Type type);
|
||||
|
||||
|
@ -604,12 +604,6 @@ void PyObject__dtor(PyObject* self) {
|
||||
if(self->slots == -1) NameDict__dtor(PyObject__dict(self));
|
||||
}
|
||||
|
||||
void pk__tp_set_marker(py_Type type, void (*gc_mark)(void*)) {
|
||||
py_TypeInfo* ti = pk__type_info(type);
|
||||
assert(ti->gc_mark == NULL);
|
||||
ti->gc_mark = gc_mark;
|
||||
}
|
||||
|
||||
void PyObject__mark(PyObject* obj) {
|
||||
assert(!obj->gc_marked);
|
||||
|
||||
@ -651,10 +645,19 @@ void PyObject__mark(PyObject* obj) {
|
||||
if(self->frame) Frame__gc_mark(self->frame);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
py_TypeInfo* ti = pk__type_info(obj->type);
|
||||
if(ti->gc_mark) ti->gc_mark(ud);
|
||||
case tp_function: {
|
||||
function__gc_mark(ud);
|
||||
break;
|
||||
}
|
||||
case tp_code: {
|
||||
CodeObject* self = ud;
|
||||
CodeObject__gc_mark(self);
|
||||
break;
|
||||
}
|
||||
case tp_chunked_array2d: {
|
||||
c11_chunked_array2d__mark(ud);
|
||||
}
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1211,7 +1211,7 @@ void c11_chunked_array2d__dtor(c11_chunked_array2d* self) {
|
||||
c11_chunked_array2d_chunks__dtor(&self->chunks);
|
||||
}
|
||||
|
||||
static void c11_chunked_array2d__mark(void* ud) {
|
||||
void c11_chunked_array2d__mark(void* ud) {
|
||||
c11_chunked_array2d* self = ud;
|
||||
pk__mark_value(&self->default_T);
|
||||
pk__mark_value(&self->context_builder);
|
||||
@ -1291,7 +1291,6 @@ static bool chunked_array2d_view_chunks(int argc, py_Ref argv) {
|
||||
static void register_chunked_array2d(py_Ref mod) {
|
||||
py_Type type =
|
||||
py_newtype("chunked_array2d", tp_object, mod, (py_Dtor)c11_chunked_array2d__dtor);
|
||||
pk__tp_set_marker(type, c11_chunked_array2d__mark);
|
||||
assert(type == tp_chunked_array2d);
|
||||
|
||||
py_bind(py_tpobject(type),
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
py_Type pk_code__register() {
|
||||
py_Type type = pk_newtype("code", tp_object, NULL, (py_Dtor)CodeObject__dtor, false, true);
|
||||
pk__tp_set_marker(type, (void (*)(void*))CodeObject__gc_mark);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -773,7 +773,7 @@ py_TValue pk_builtins__register() {
|
||||
return *builtins;
|
||||
}
|
||||
|
||||
static void function__gc_mark(void* ud) {
|
||||
void function__gc_mark(void* ud) {
|
||||
Function* func = ud;
|
||||
if(func->globals) pk__mark_value(func->globals);
|
||||
if(func->closure) {
|
||||
@ -800,9 +800,6 @@ static bool function__doc__(int argc, py_Ref argv) {
|
||||
py_Type pk_function__register() {
|
||||
py_Type type =
|
||||
pk_newtype("function", tp_object, NULL, (void (*)(void*))Function__dtor, false, true);
|
||||
|
||||
pk__tp_set_marker(type, function__gc_mark);
|
||||
|
||||
py_bindproperty(type, "__doc__", function__doc__, NULL);
|
||||
return type;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user