Skip to content

Allow type_casters to expose temporary dependencies #917

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

Closed
wants to merge 1 commit into from

Conversation

jagerman
Copy link
Member

The Eigen::Ref caster, in particular, requires that a temporary array be
kept alive in some cases. This allows a type caster to expose a
keep-alive dependency by providing a handle subcaster_keepalive()
method so that stl.h casters (which employ temporary subcasters during
loading) can hold onto any required extra dependencies.

Fixes #916

The Eigen::Ref caster, in particular, requires that a temporary array be
kept alive in some cases.  This allows a type_caster to expose a
keep-alive dependency by providing a `handle subcaster_keepalive()`
method so that stl.h casters (which employ temporary subcasters during
loading) can hold onto any required extra dependencies.
@dean0x7d
Copy link
Member

dean0x7d commented Jun 25, 2017

Perhaps this might work as an alternative: make the temporary object a patient of the original handle src which is being loaded (the simpler weakref variant of the keep_alive mechanism should be enough here). That should ensure correct lifetime with the upside that supercasters would not need to be aware of the extra dependencies. (This should also work for the string_view caster and remove the extra object from the struct.)

Edit: Ah, perhaps not. That might be too much lifetime, letting the temporary live far longer than the caster.

@jagerman
Copy link
Member Author

Closing in favour of #924.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants