From 3ae17e00f2f946b1a6d101d4f274443bf91f3e5e Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 3 May 2024 15:23:16 +0800 Subject: [PATCH] some fix --- 3rd/lua_bridge/src/lua_bridge.cpp | 2 -- src/array2d.cpp | 1 - src/collections.cpp | 1 - src/iter.cpp | 6 ------ src/vm.cpp | 10 +++++----- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/3rd/lua_bridge/src/lua_bridge.cpp b/3rd/lua_bridge/src/lua_bridge.cpp index df99f9b2..70da825e 100644 --- a/3rd/lua_bridge/src/lua_bridge.cpp +++ b/3rd/lua_bridge/src/lua_bridge.cpp @@ -198,8 +198,6 @@ static PyObject* lua_popx_multi_to_python(VM* vm, int count){ struct PyLuaFunction: PyLuaObject{ static void _register(VM* vm, PyObject* mod, PyObject* type){ vm->bind_notimplemented_constructor(type); - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; - vm->bind_method<-1>(type, __call__, [](VM* vm, ArgsView args){ if(args.size() < 1) vm->TypeError("__call__ takes at least 1 argument"); const PyLuaFunction& self = _CAST(PyLuaFunction&, args[0]); diff --git a/src/array2d.cpp b/src/array2d.cpp index d6d03b53..c8974226 100644 --- a/src/array2d.cpp +++ b/src/array2d.cpp @@ -352,7 +352,6 @@ struct Array2dIter{ void _gc_mark() const{ PK_OBJ_MARK(ref); } static void _register(VM* vm, PyObject* mod, PyObject* type){ - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) { return _0; }); vm->bind__next__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) -> unsigned{ diff --git a/src/collections.cpp b/src/collections.cpp index d3b4a0ae..1f0a43b5 100644 --- a/src/collections.cpp +++ b/src/collections.cpp @@ -24,7 +24,6 @@ namespace pkpy void PyDequeIter::_register(VM *vm, PyObject *mod, PyObject *type) { // Iterator for the deque type - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM *vm, PyObject *obj) diff --git a/src/iter.cpp b/src/iter.cpp index 647dc009..c8ed0383 100644 --- a/src/iter.cpp +++ b/src/iter.cpp @@ -3,7 +3,6 @@ namespace pkpy{ void RangeIter::_register(VM* vm, PyObject* mod, PyObject* type){ - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0){ return _0; }); vm->bind__next__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) -> unsigned{ @@ -20,7 +19,6 @@ namespace pkpy{ } void ArrayIter::_register(VM* vm, PyObject* mod, PyObject* type){ - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0){ return _0; }); vm->bind__next__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) -> unsigned{ @@ -32,7 +30,6 @@ namespace pkpy{ } void StringIter::_register(VM* vm, PyObject* mod, PyObject* type){ - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0){ return _0; }); vm->bind__next__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) -> unsigned{ @@ -81,7 +78,6 @@ namespace pkpy{ } void Generator::_register(VM* vm, PyObject* mod, PyObject* type){ - vm->_all_types[PK_OBJ_GET(Type, type)].subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0){ return _0; }); vm->bind__next__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) -> unsigned{ @@ -94,8 +90,6 @@ namespace pkpy{ } void DictItemsIter::_register(VM *vm, PyObject *mod, PyObject *type){ - PyTypeInfo& info = vm->_all_types[PK_OBJ_GET(Type, type)]; - info.subclass_enabled = false; vm->bind_notimplemented_constructor(type); vm->bind__iter__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0){ return _0; }); vm->bind__next__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* _0) -> unsigned{ diff --git a/src/vm.cpp b/src/vm.cpp index f02f56d0..6b8d1743 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -1298,7 +1298,7 @@ StrName _type_name(VM *vm, Type type){ void VM::bind__getitem__(Type type, PyObject* (*f)(VM*, PyObject*, PyObject*)){ _all_types[type].m__getitem__ = f; - PyObject* nf = bind_method<1>(type, "__getitem__", [](VM* vm, ArgsView args){ + PyObject* nf = bind_method<1>(type, __getitem__, [](VM* vm, ArgsView args){ return lambda_get_userdata(args.begin())(vm, args[0], args[1]); }); PK_OBJ_GET(NativeFunc, nf).set_userdata(f); @@ -1306,7 +1306,7 @@ void VM::bind__getitem__(Type type, PyObject* (*f)(VM*, PyObject*, PyObject*)){ void VM::bind__setitem__(Type type, void (*f)(VM*, PyObject*, PyObject*, PyObject*)){ _all_types[type].m__setitem__ = f; - PyObject* nf = bind_method<2>(type, "__setitem__", [](VM* vm, ArgsView args){ + PyObject* nf = bind_method<2>(type, __setitem__, [](VM* vm, ArgsView args){ lambda_get_userdata(args.begin())(vm, args[0], args[1], args[2]); return vm->None; }); @@ -1315,7 +1315,7 @@ void VM::bind__setitem__(Type type, void (*f)(VM*, PyObject*, PyObject*, PyObjec void VM::bind__delitem__(Type type, void (*f)(VM*, PyObject*, PyObject*)){ _all_types[type].m__delitem__ = f; - PyObject* nf = bind_method<1>(type, "__delitem__", [](VM* vm, ArgsView args){ + PyObject* nf = bind_method<1>(type, __delitem__, [](VM* vm, ArgsView args){ lambda_get_userdata(args.begin())(vm, args[0], args[1]); return vm->None; }); @@ -1367,7 +1367,7 @@ void VM::bind__delitem__(Type type, void (*f)(VM*, PyObject*, PyObject*)){ void VM::bind__hash__(Type type, i64 (*f)(VM*, PyObject*)){ PyObject* obj = _t(type); _all_types[type].m__hash__ = f; - PyObject* nf = bind_method<0>(obj, "__hash__", [](VM* vm, ArgsView args){ + PyObject* nf = bind_method<0>(obj, __hash__, [](VM* vm, ArgsView args){ i64 ret = lambda_get_userdata(args.begin())(vm, args[0]); return VAR(ret); }); @@ -1377,7 +1377,7 @@ void VM::bind__hash__(Type type, i64 (*f)(VM*, PyObject*)){ void VM::bind__len__(Type type, i64 (*f)(VM*, PyObject*)){ PyObject* obj = _t(type); _all_types[type].m__len__ = f; - PyObject* nf = bind_method<0>(obj, "__len__", [](VM* vm, ArgsView args){ + PyObject* nf = bind_method<0>(obj, __len__, [](VM* vm, ArgsView args){ i64 ret = lambda_get_userdata(args.begin())(vm, args[0]); return VAR(ret); });