-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Smart holder] Support void pointer capsules #3633
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM — We're running global testing overnight to be on the safe side.
// Convert `a::b::c` to `a_b_c` | ||
replace_all(type_name, "::", '_'); | ||
|
||
std::string as_void_ptr_function_name = "as_" + type_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very tiny nit, this could be an allocation of "as_" and += type_name and remove an allocation.
This PR was globally tested. Merging now. (Skipping the CI rerun awaiting approval: very low risk.) |
Description
Make smart holder type casters support void pointer capsules.
The original motivation for this is to support passing SWIG objects to pybind11 wrapped functions. This is achieved by checking whether the object has a particular method defined. Suppose we have the following C++ code:
Then if an object has the method
as_pybind11_tests_void_ptr_capsule_Obj
defined, and the method returns a capsule with namepybind11_tests::void_ptr_capsule::Obj
, then we think this object can be converted topybind11_tests::void_ptr_capsule::Obj
, so we accept the object as a parameter.