You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments