Add support for (explicit?) keep_alive semantics?
Relates #72
In Drake, we unfortunately heavily rely on keep_alive
semantics:
https://gitlab.kitware.com/autopybind11/autopybind11/-/blob/717b60a8b813fa3e654299d196b638d9eafb2187/example/drake_features/README.md#current-features-used-as-of-mar-10
https://drake.mit.edu/doxygen_cxx/group__python__bindings.html#PydrakeKeepAlive
I'm not yet sure how to design this aspect.
At present, we are able to make Doxygen annotations that are passed to mkdoc.py
, e.g. @exclude_from_pydrake_mkdoc{Explanation}
, @pydrake_mkdoc_identifier{foobar}
.
My preference would be to somehow add a hook (or maybe something a little less free-form) that allows use to make customizations based on attributes the given the given declaration_t
(e.g. comments, GCC attributes, etc.).
It could look like any of these:
@autopybind11_keep_alive{return, builder, "Ownership"}
@pybind11_keep_alive{builder, system, "Ownership"}
@py_keep_alive{return, builder, "Transitive"}