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

RFC: Cross-bridge dependencies #1189

Open
schreter opened this issue Mar 2, 2023 · 0 comments
Open

RFC: Cross-bridge dependencies #1189

schreter opened this issue Mar 2, 2023 · 0 comments

Comments

@schreter
Copy link
Contributor

schreter commented Mar 2, 2023

Currently, there is no way to "communicate" between C++ bridges depending on each other except for static compile-time checks, which verify that the types indeed fulfil the requirements in the dependent bridge (see for example #1181, which verifies that the destination is indeed a RustType). This works, but of course places an additional burden on the developer (e.g., specifying correct namespace).

The bridge compilation already generates C++ code before generating Rust code and the bridges are compiled/generated in the dependency order.

The idea is to generate an additional piece of information for each bridge with serialized type information, which can be used by dependent bridges to get information about existing types and allow using them directly.

The information would reside in the target directory somewhere at a well-known location.

The information can then be used in a dependent bridge for example by the means of an use statement in the bridge, which would load type information from that file.

Although currently there is not much information to pass, we already have further changes to cxx prepared, which allow value passing of Rust objects to C++. The layout information can then be propagated to dependent bridges using the same mechanism, instead of re-specifying it each time. Likely the same can be done in the other direction (C++ types value-passed to Rust) and likely it would also help greatly simplifying implementation of "standard" C++ types wrapping Rust types (and likely vice-versa) by auto-generating bridge functions instead of manual coding for each type as done today.

Ideas/opinions?

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

1 participant