diff --git a/include/pocketpy/bindings.h b/include/pocketpy/bindings.h index f3a6f53d..46aca56a 100644 --- a/include/pocketpy/bindings.h +++ b/include/pocketpy/bindings.h @@ -69,7 +69,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, Ret(*func)(Params...), BindTy } template -PyObject* VM::bind(VM* vm, PyObject* obj, const char* sig, Ret(T::*func)(Params...), BindType bt){ +PyObject* VM::bind(PyObject* obj, const char* sig, Ret(T::*func)(Params...), BindType bt){ auto proxy = new NativeProxyMethodC(func); return vm->bind(obj, sig, __proxy_wrapper, proxy, bt); } @@ -81,7 +81,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, const char* docstring, Ret(*f } template -PyObject* VM::bind(VM* vm, PyObject* obj, const char* sig, const char* docstring, Ret(T::*func)(Params...), BindType bt){ +PyObject* VM::bind(PyObject* obj, const char* sig, const char* docstring, Ret(T::*func)(Params...), BindType bt){ auto proxy = new NativeProxyMethodC(func); return vm->bind(obj, sig, docstring, __proxy_wrapper, proxy, bt); } diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 5bb2d2af..9f68f76f 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -300,22 +300,21 @@ public: PyObject* bind_func(Type type, StrName name, int argc, NativeFuncC fn, UserData userdata={}, BindType bt=BindType::DEFAULT){ return bind_func(_t(type), name, argc, fn, userdata, bt); } - PyObject* bind(PyObject*, const char*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT); - PyObject* bind(PyObject*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT); - - template - PyObject* bind(PyObject* obj, const char* sig, Ret(*func)(Params...), BindType bt=BindType::DEFAULT); - template - PyObject* bind(VM* vm, PyObject* obj, const char* sig, Ret(T::*func)(Params...), BindType bt=BindType::DEFAULT); - template - PyObject* bind(PyObject* obj, const char* sig, const char* docstring, Ret(*func)(Params...), BindType bt=BindType::DEFAULT); - template - PyObject* bind(VM* vm, PyObject* obj, const char* sig, const char* docstring, Ret(T::*func)(Params...), BindType bt=BindType::DEFAULT); - PyObject* bind_property(PyObject*, const char*, NativeFuncC fget, NativeFuncC fset=nullptr); template PyObject* bind_field(PyObject*, const char*, F T::*); - + // without docstring + PyObject* bind(PyObject*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT); + template + PyObject* bind(PyObject*, const char*, Ret(*)(Params...), BindType bt=BindType::DEFAULT); + template + PyObject* bind(PyObject*, const char*, Ret(T::*)(Params...), BindType bt=BindType::DEFAULT); + // with docstring + PyObject* bind(PyObject*, const char*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT); + template + PyObject* bind(PyObject*, const char*, const char*, Ret(*)(Params...), BindType bt=BindType::DEFAULT); + template + PyObject* bind(PyObject*, const char*, const char*, Ret(T::*)(Params...), BindType bt=BindType::DEFAULT); /********** error **********/ void _error(PyObject*); void StackOverflowError() { __builtin_error("StackOverflowError"); } diff --git a/src/pocketpy_c.cpp b/src/pocketpy_c.cpp index f0222ce3..005ba852 100644 --- a/src/pocketpy_c.cpp +++ b/src/pocketpy_c.cpp @@ -361,13 +361,7 @@ bool pkpy_push_function(pkpy_vm* vm_handle, const char* sig, pkpy_CFunction f) { PK_ASSERT_NO_ERROR() PyObject* f_obj; PK_PROTECTED( - f_obj = vm->bind( - nullptr, - sig, - nullptr, - c_function_wrapper, - f - ); + f_obj = vm->bind(nullptr, sig, c_function_wrapper, f); ) vm->s_data.push(f_obj); return true;