cxx icon indicating copy to clipboard operation
cxx copied to clipboard

Add support for renamed type aliases

Open dpaoliello opened this issue 1 year ago • 0 comments

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.

dpaoliello avatar Mar 24 '23 22:03 dpaoliello