From 0b9fd0014c8f32ecf299dae2ad1811dfb484af46 Mon Sep 17 00:00:00 2001 From: "John Hodge (bugs)" Date: Sun, 4 Jun 2017 21:23:03 +0800 Subject: All - Compile and run fixes in MSVC --- src/include/synext_decorator.hpp | 25 ++++++++++++++++++------- src/include/synext_macro.hpp | 25 ++++++++++++++++++------- 2 files changed, 36 insertions(+), 14 deletions(-) (limited to 'src/include') diff --git a/src/include/synext_decorator.hpp b/src/include/synext_decorator.hpp index c3985855..4988c624 100644 --- a/src/include/synext_decorator.hpp +++ b/src/include/synext_decorator.hpp @@ -57,14 +57,25 @@ public: virtual void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate, ::AST::ExprNode_Match_Arm& expr) const { unexpected(sp, mi, "match arm"); } }; -#define STATIC_DECORATOR(ident, _handler_class) \ - struct register_##_handler_class##_c {\ - register_##_handler_class##_c() {\ - Register_Synext_Decorator( ident, ::std::unique_ptr(new _handler_class()) ); \ - } \ - } s_register_##_handler_class; - +struct DecoratorDef; extern void Register_Synext_Decorator(::std::string name, ::std::unique_ptr handler); +extern void Register_Synext_Decorator_Static(DecoratorDef* def); + +struct DecoratorDef +{ + DecoratorDef* prev; + ::std::string name; + ::std::unique_ptr def; + DecoratorDef(::std::string name, ::std::unique_ptr def): + name(::std::move(name)), + def(::std::move(def)), + prev(nullptr) + { + Register_Synext_Decorator_Static(this); + } +}; + +#define STATIC_DECORATOR(ident, _handler_class) static DecoratorDef s_register_##_handler_class ( ident, ::std::unique_ptr(new _handler_class()) ); #endif 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 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(new _handler_class()) ); \ - } \ - } s_register_##_handler_class; - +struct MacroDef; extern void Register_Synext_Macro(::std::string name, ::std::unique_ptr handler); +extern void Register_Synext_Macro_Static(MacroDef* def); + +struct MacroDef +{ + MacroDef* prev; + ::std::string name; + ::std::unique_ptr def; + MacroDef(::std::string name, ::std::unique_ptr 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(new _handler_class())); #endif -- cgit v1.2.3