Basic macro support #752
Labels
A-bridge-UX
Area: UX improvements for people writing bridge modules
A-parsing
Improvements to Diplomat's parsing code
enhancement
New feature or request
For the purposes of cleanly writing code, it would be nice if the AST parser supported using macros. These could expand to types or methods, and would not support nested interpolation.
We'd only support:
This type of thing is relatively straightforward to parse and interpolate.
These macro definitions would be tagged with
diplomat::macro
and used in the source code.The main challenge is that the Diplomat macro would only be able to see macros defined in the same bridge module they are used in. In theory we could apply a
#[diplomat::macro_load = src/macros.rs]
attribute, and have a global cache ofmacro_load
paths to named Diplomat macros to avoid reparsing each time. It's not pretty, but it would work. We'd have to (at runtime) readCARGO_MANIFEST_DIR
.The text was updated successfully, but these errors were encountered: