autocxx
autocxx copied to clipboard
Remove need for generated code to require cxx as well as autocxx
Or at least, add an error message to make it clear. See comments in #33.
Here's the plan here.
autocxx_enginedepends oncxxin its dependencies not just dev-dependencies. It has apub use cxx.src/lib.rsin the root (containing the macro) moves into a newautocxx_macrosub-project.- The root project has a
pub usefor the macro, and apub usefor cxx. - The generated code gets a
pub use autocxx::cxx.
I think I have concluded this is (nearly) impossible.
The code generated by the #[cxx::bridge] macro is full of references to types qualified as ::cxx::..., for instance ::cxx::UniquePtr.
As far as I know, there is no way to populate the root namespace short of actually having a crate called cxx.
Any solution here would require significant changes to cxx. Either:
- In
gen/libprovide an API to qualify the path tocxxevery time it's mentioned. Or, - Expose an API from
gen/libto expand the macro token stream, then we could post-process it. Even more disruptive.
I'll keep this issue open, because I do regard it as an actual bug, but it won't be a quick fix.
Abandoned work: https://github.com/google/autocxx/compare/re-export-cxx
https://github.com/dtolnay/cxx/issues/697 is a good step forward here.
Even with the above change, we're not particularly close to solving this. The expanded cxx::bridge mod still contains references to ::cxx::UniquePtr and ::cxx::private::Opaque, etc.
Next steps here: raise a pull request against cxx which adds the ability to override the prefix for cxx in its generated code.
Very early work towards cxx change (about 10% finished) https://github.com/adetaylor/cxx/pull/new/cxx-path-prefix