-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include namespace in all identifiers.
This change is the first step towards including a namespace into all(*) C++ identifiers. In this commit, there is no intentional functional difference: a single namespace continues to apply to the entire #[cxx::bridge]; it just happens to be stored differently. (*) = This change aims to include a namespace for: * C++ types * C++ functions but not for: * C++ fields * C++ enum variants * Rust types/functions/anything. A 'QualifiedIdent' struct is used for the first category of things; plain old proc_macro2::Ident for the latter. It may be that methods are being treated incorrectly, because they're functions yet should not have a globally-scoped name. A subsequent commit may need to fix that. At the moment, the Namespace (included in each QualifiedIdent) is ruthlessly cloned all over the place. As a given namespace is likely to be applicable to many types and functions, it may save significant memory in future to use Rc<> here. But let's not optimise too early. This commit does not currently output the namespace name in any different ways or different places (intentionally). syntax/mod.rs has a Boolean constant USE_FULLY_QUALIFIED_NAMES which will enable that, and it completely breaks everything. Substantial changes to both Rust and C++ code generation will be required to use this. It may be desirable to move the QualifiedIdent code out of mod.rs. The rough sequence of commits in mind are: 1) This commit (just stores the namespaces) 2) Use them when writing Rust and C++ code as necessary 3) Allow the current namespace attribute to be overridden by finer-grained namespace attributes on individual functions 4) Consider allowing sub-mods which can also have a namespace attribute. 5) Future: Introduce a resolution pass which tries to resolve a given identifier to a target symbol, after all symbols have been read. Support 'use' statements.
- Loading branch information
Showing
12 changed files
with
330 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.