cxx
cxx copied to clipboard
Add support for renamed type aliases
A single Rust type may map to multiple C++ types - an example of this is the various Win32 type aliases that exist for primitive types (e.g., DWORD
, LONG
).
Currently the cxx crate can't handle this (#254) as the verify_extern_type
check ensures that the name of the type used in an extern "C++"
block matches the Id
of the ExternType
implementation.
This change adds a new #[renamed]
attribute which can be used to mark a type alias in an extern "C++"
block as renaming the type, thus bypassing the Id
check in verify_extern_type
(a new verify_extern_type_renamed
check is emitted instead).
NOTE: #529 is an alternative to this PR, but it not usable for the Win32 type aliases case as the orphan rule would prevent a dependent crate from implementing ExternTypeAlias
for the primitive types.