/* @file pyutil.hpp * * utility stuff to be used across multiple pybind11 .cpp files */ #pragma once #include "xo/refcnt/Refcounted.hpp" #include "xo/refcnt/Unowned.hpp" #include /* xo::ref::intrusive_ptr is an intrusively-reference-counted pointer. * always safe to create one from a T* p * (since refcount is directly accessible from p) * * Need declaration like this before any pybind11 bindings * that expose an object of types like * (a) intrusive_ptr or * (b) T * / T const * / T & / T const & to python. * If this were not done, pybind11 would by default use unique_ptr> * (ok but inefficient) or unique_ptr (fatal!) */ PYBIND11_DECLARE_HOLDER_TYPE(T, xo::ref::intrusive_ptr, true); /* xo::ref::unowned_ptr is an unmanaged pointer. * use this for immortal objects that pybind11 must not delete. */ PYBIND11_DECLARE_HOLDER_TYPE(T, xo::ref::unowned_ptr, true); /* end pyutil.hpp */