This commit is contained in:
BLUELOVETH 2023-06-01 19:23:56 +08:00
parent 9906748e9c
commit acc8ab802f

View File

@ -1423,9 +1423,6 @@ inline void VM::setattr(PyObject* obj, StrName name, PyObject* value){
template<int ARGC> template<int ARGC>
PyObject* VM::bind_method(PyObject* obj, Str name, NativeFuncC fn) { PyObject* VM::bind_method(PyObject* obj, Str name, NativeFuncC fn) {
check_non_tagged_type(obj, tp_type); check_non_tagged_type(obj, tp_type);
if(obj->attr().contains(name)){
throw std::runtime_error(fmt("bind_method() failed: ", name.escape(), " already exists"));
}
PyObject* nf = VAR(NativeFunc(fn, ARGC, true)); PyObject* nf = VAR(NativeFunc(fn, ARGC, true));
obj->attr().set(name, nf); obj->attr().set(name, nf);
return nf; return nf;
@ -1433,9 +1430,6 @@ PyObject* VM::bind_method(PyObject* obj, Str name, NativeFuncC fn) {
template<int ARGC> template<int ARGC>
PyObject* VM::bind_func(PyObject* obj, Str name, NativeFuncC fn) { PyObject* VM::bind_func(PyObject* obj, Str name, NativeFuncC fn) {
if(obj->attr().contains(name)){
throw std::runtime_error(fmt("bind_func() failed: ", name.escape(), " already exists"));
}
PyObject* nf = VAR(NativeFunc(fn, ARGC, false)); PyObject* nf = VAR(NativeFunc(fn, ARGC, false));
obj->attr().set(name, nf); obj->attr().set(name, nf);
return nf; return nf;