summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJohn Hodge (bugs) <tpg@mutabah.net>2017-06-04 21:23:03 +0800
committerJohn Hodge (bugs) <tpg@mutabah.net>2017-06-04 21:23:03 +0800
commit0b9fd0014c8f32ecf299dae2ad1811dfb484af46 (patch)
tree609eff961f07d7562a2b5a1ffb4a43905f5e98fb /src/include
parent7a267995c7cfd6b68849079dc4ecae4ebe74e6fa (diff)
downloadmrust-0b9fd0014c8f32ecf299dae2ad1811dfb484af46.tar.gz
All - Compile and run fixes in MSVC
Diffstat (limited to 'src/include')
-rw-r--r--src/include/synext_decorator.hpp25
-rw-r--r--src/include/synext_macro.hpp25
2 files changed, 36 insertions, 14 deletions
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<ExpandDecorator>(new _handler_class()) ); \
- } \
- } s_register_##_handler_class;
-
+struct DecoratorDef;
extern void Register_Synext_Decorator(::std::string name, ::std::unique_ptr<ExpandDecorator> handler);
+extern void Register_Synext_Decorator_Static(DecoratorDef* def);
+
+struct DecoratorDef
+{
+ DecoratorDef* prev;
+ ::std::string name;
+ ::std::unique_ptr<ExpandDecorator> def;
+ DecoratorDef(::std::string name, ::std::unique_ptr<ExpandDecorator> 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<ExpandDecorator>(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<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