Skip to content
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

Extensible "builtin" types for adding custom type interfaces #171

Open
rinon opened this issue Apr 30, 2020 · 2 comments
Open

Extensible "builtin" types for adding custom type interfaces #171

rinon opened this issue Apr 30, 2020 · 2 comments

Comments

@rinon
Copy link
Contributor

rinon commented Apr 30, 2020

As far as I can tell, the only types allowed to cross the ffi boundary by value are the builtin types or new shared types? This makes perfect sense from a safety perspective, but limits the usability of existing custom C++ ADTs across the boundary.

Would it be possible to make an extensible interface to define how new, custom C++ types should be handled? For example, some codebases have their own implementation of ref-counted pointers, which I don't currently see a good way to expose through cxx (although I may just be missing something). It would be nice to allow users to implement their own "builtin" types, perhaps by implementing a trait defining the new type, then providing C++ and Rust interfaces to it. I'm not familiar enough with the cxx codebase (yet) to know what the interface for extensions might have to look like, but I wanted to check and see if this was worth looking into further.

If a sufficiently generic type extension interface existed, it might be useful to rewrite the current builtin types to fit this interface and thus extract their implementation from the core of the code generators?

Sorry if this has been discussed elsewhere, I looked and didn't see anything.

@dtolnay
Copy link
Owner

dtolnay commented Apr 30, 2020

Extensibility has come up before in #16 (comment) but I think we're not quite in a position to tackle it yet. I agree that we want to though.

For now, two pieces of feature work that might help partially are:

@rinon
Copy link
Contributor Author

rinon commented May 13, 2020

Makes sense, thanks. I might be able to take a pass at #164, as I'd like to get more familiar with the codebase, but I can't promise how soon. I'm pretty slammed with other stuff for the moment.

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

No branches or pull requests

2 participants