rs_bindings_from_cc: Use an attribute to dynamically specify type mapping.
---
This Cl allows you to override Crubit's type-mapping, so that instead of generating bindings for a type `X`, it instead looks up an already-existing type `Y`. This is useful, for example:
* For specialty types like `rs_char`, where the other language's equivalent is a builtin type.
* For types with native language support, like protocol buffers, where we want to use the native languages' proto rather than generated bindings
* For types which are themselves bindings: the bindings for the bindings for `X` should be `X` again, not an infinite-turtle bindings-of-bindings situation.
This is the first step to all of those: for calling C++ from Rust, we allow C++ types to override which Rust type they are.
A rough TODO list of next steps:
1. suppress bindings generation for the record itself, when annotated with `crubit_rust_type`.
2. apply `crubit_rust_type` annotations to generated bindings, so that bindings-of-bindings can DTRT.
3. do ~something about crubit features. Currently they would block round-tripped bindings.
4. rinse and repeat for cc_bindings_from_rs.
PiperOrigin-RevId: 529212737
diff --git a/support/rs_std/rs_char.h b/support/rs_std/rs_char.h
index 8bec775..a13101e 100644
--- a/support/rs_std/rs_char.h
+++ b/support/rs_std/rs_char.h
@@ -9,13 +9,14 @@
#include <optional>
#include "absl/base/optimization.h"
+#include "support/internal/attribute_macros.h"
namespace rs_std {
// `rs_std::rs_char` is a C++ representation of the `char` type from Rust.
-// `rust_builtin_type_abi_assumptions.md` documents the ABI compatiblity of
+// `rust_builtin_type_abi_assumptions.md` documents the ABI compatibility of
// these types.
-class rs_char final {
+class CRUBIT_INTERNAL_RUST_TYPE("char") rs_char final {
public:
// Creates a default `rs_char` - one that represents ASCII NUL character.
//