Split `Type` in half: separate `RsType` and `CcType`.
This is, I think, adequately motivated by the sheer impossibility of the original design working. Consider the following compound data type:
`int*` in C++ may be `Option<&i32>` in Rust.
This cannot be expressed in the old `Type` struct because it assumed the generic layout was the same: it assumed that if the C++ type was e.g. `*<int>`, then the rust type would be shaped like `a<b>` for some type names `a` and `b`. But in this case, `*<int>` becomes `Option<&<i32>>`. And anyway, `&` takes a lifetime parameter, so this is actually `Option<&<'_, i32>>`. Just not shaped the same at all!
There are many more cases beside. Here's an incomplete list of possible type maps which are incompatible with the old layout:
* `const char*` becomes `CStr`
* function pointers AND functions -- that is, `Identity<void()>` and `Identity<void()>*` -- both can become non-pointer functions in Rust: `extern "C" fn()->()`.
* `std::span<char, std::dynamic_extent>` (2 params) becomes `&mut [u8]` (1 param)
We should change this to do the right thing now, early on, rather than later when it will be even more annoying. :)
This is, in cool news, our first major divergence from [Clif's AST proto](http://google3/third_party/clif/protos/ast.proto;l=156-171;rcl=397117954).
PiperOrigin-RevId: 399622062
9 files changed
tree: 33128016f48e295c09c2c32f294e87f78304e075
- rs_bindings_from_cc/
- CODE_OF_CONDUCT
- CONTRIBUTING
- LICENSE
- README.md
README.md
Crubit: C++/Rust Bidirectional Interop Tool
Extremely experimental interop tooling for C++ and Rust.
Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.