| 283 | |
| 284 | template <typename funcType> |
| 285 | funcType ConvertFunc(const char *funcname, PyObject *func, ExceptionHandler exHandle) |
| 286 | { |
| 287 | // allow None to indicate no callback |
| 288 | if(Py_IsNone(func)) |
| 289 | return funcType(); |
| 290 | |
| 291 | // add a reference to the global object so it stays alive while we execute, in case this is an |
| 292 | // async call |
| 293 | PyObject *global_internal_handle = GetCurrentGlobalHandle(); |
| 294 | |
| 295 | // process any dangling functions that may need to be cleared up |
| 296 | ProcessDecRefQueue(); |
| 297 | |
| 298 | // create a copy that will keep the function object alive as long as the lambda is |
| 299 | PyObjectRefCounter funcptr(func); |
| 300 | |
| 301 | return [global_internal_handle, funcname, funcptr, exHandle](auto... param) { |
| 302 | ScopedFuncCall gil(global_internal_handle); |
| 303 | |
| 304 | varfunc<typename funcType::result_type, decltype(param)...> f(funcname, param...); |
| 305 | return f.call(funcname, funcptr.obj, global_internal_handle, exHandle); |
| 306 | }; |
| 307 | } |
nothing calls this directly
no test coverage detected