blueloveTH 1 год назад
Родитель
Сommit
dd734f71dc
3 измененных файлов с 13 добавлено и 20 удалено
  1. 2 2
      include/pocketpy/bindings.h
  2. 10 11
      include/pocketpy/vm.h
  3. 1 7
      src/pocketpy_c.cpp

+ 2 - 2
include/pocketpy/bindings.h

@@ -69,7 +69,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, Ret(*func)(Params...), BindTy
 }
 
 template<typename Ret, typename T, typename... Params>
-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<Ret, T, Params...>(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<typename Ret, typename T, typename... Params>
-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<Ret, T, Params...>(func);
     return vm->bind(obj, sig, docstring, __proxy_wrapper, proxy, bt);
 }

+ 10 - 11
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_property(PyObject*, const char*, NativeFuncC fget, NativeFuncC fset=nullptr);
+    template<typename T, typename F, bool ReadOnly=false>
+    PyObject* bind_field(PyObject*, const char*, F T::*);
+    // without docstring
     PyObject* bind(PyObject*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
-
     template<typename Ret, typename... Params>
-    PyObject* bind(PyObject* obj, const char* sig, Ret(*func)(Params...), BindType bt=BindType::DEFAULT);
+    PyObject* bind(PyObject*, const char*, Ret(*)(Params...), BindType bt=BindType::DEFAULT);
     template<typename Ret, typename T, typename... Params>
-    PyObject* bind(VM* vm, PyObject* obj, const char* sig, Ret(T::*func)(Params...), BindType bt=BindType::DEFAULT);
+    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<typename Ret, typename... Params>
-    PyObject* bind(PyObject* obj, const char* sig, const char* docstring, Ret(*func)(Params...), BindType bt=BindType::DEFAULT);
+    PyObject* bind(PyObject*, const char*, const char*, Ret(*)(Params...), BindType bt=BindType::DEFAULT);
     template<typename Ret, typename T, typename... Params>
-    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<typename T, typename F, bool ReadOnly=false>
-    PyObject* bind_field(PyObject*, const char*, F T::*);
-
+    PyObject* bind(PyObject*, const char*, const char*, Ret(T::*)(Params...), BindType bt=BindType::DEFAULT);
     /********** error **********/
     void _error(PyObject*);
     void StackOverflowError() { __builtin_error("StackOverflowError"); }

+ 1 - 7
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;