| 370 | |
| 371 | template <typename... Args> |
| 372 | void* allocHelper(const char* pyFuncName, bool showWarning, Args&&... args) noexcept |
| 373 | { |
| 374 | try |
| 375 | { |
| 376 | py::gil_scoped_acquire gil{}; |
| 377 | py::function pyAllocFunc = utils::getOverride(static_cast<IGpuAllocator*>(this), pyFuncName, showWarning); |
| 378 | |
| 379 | if (!pyAllocFunc) |
| 380 | { |
| 381 | return nullptr; |
| 382 | } |
| 383 | |
| 384 | py::object ptr = pyAllocFunc(std::forward<Args>(args)...); |
| 385 | try |
| 386 | { |
| 387 | return reinterpret_cast<void*>(ptr.cast<size_t>()); |
| 388 | } |
| 389 | catch (const py::cast_error& e) |
| 390 | { |
| 391 | std::cerr << "[ERROR] Return value of allocate() could not be interpreted as an int" << std::endl; |
| 392 | } |
| 393 | } |
| 394 | catch (std::exception const& e) |
| 395 | { |
| 396 | std::cerr << "[ERROR] Exception caught in allocate(): " << e.what() << std::endl; |
| 397 | } |
| 398 | catch (...) |
| 399 | { |
| 400 | std::cerr << "[ERROR] Exception caught in allocate()" << std::endl; |
| 401 | return nullptr; |
| 402 | } |
| 403 | |
| 404 | return nullptr; |
| 405 | } |
| 406 | |
| 407 | void* allocate(uint64_t size, uint64_t alignment, AllocatorFlags flags) noexcept override |
| 408 | { |
nothing calls this directly
no test coverage detected