mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
...
This commit is contained in:
parent
9906748e9c
commit
acc8ab802f
6
src/vm.h
6
src/vm.h
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user