diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2017-06-04 21:23:03 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2017-06-04 21:23:03 +0800 |
commit | 0b9fd0014c8f32ecf299dae2ad1811dfb484af46 (patch) | |
tree | 609eff961f07d7562a2b5a1ffb4a43905f5e98fb /src/include/synext_macro.hpp | |
parent | 7a267995c7cfd6b68849079dc4ecae4ebe74e6fa (diff) | |
download | mrust-0b9fd0014c8f32ecf299dae2ad1811dfb484af46.tar.gz |
All - Compile and run fixes in MSVC
Diffstat (limited to 'src/include/synext_macro.hpp')
-rw-r--r-- | src/include/synext_macro.hpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/include/synext_macro.hpp b/src/include/synext_macro.hpp index 400016d9..c109b56e 100644 --- a/src/include/synext_macro.hpp +++ b/src/include/synext_macro.hpp @@ -25,14 +25,25 @@ public: virtual ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) = 0; }; -#define STATIC_MACRO(ident, _handler_class) \ - struct register_##_handler_class##_c {\ - register_##_handler_class##_c() {\ - Register_Synext_Macro( ident, ::std::unique_ptr<ExpandProcMacro>(new _handler_class()) ); \ - } \ - } s_register_##_handler_class; - +struct MacroDef; extern void Register_Synext_Macro(::std::string name, ::std::unique_ptr<ExpandProcMacro> handler); +extern void Register_Synext_Macro_Static(MacroDef* def); + +struct MacroDef +{ + MacroDef* prev; + ::std::string name; + ::std::unique_ptr<ExpandProcMacro> def; + MacroDef(::std::string name, ::std::unique_ptr<ExpandProcMacro> def) : + name(::std::move(name)), + def(::std::move(def)), + prev(nullptr) + { + Register_Synext_Macro_Static(this); + } +}; + +#define STATIC_MACRO(ident, _handler_class) static MacroDef s_register_##_handler_class(ident, ::std::unique_ptr<ExpandProcMacro>(new _handler_class())); #endif |