summaryrefslogtreecommitdiff
path: root/src/synexts/derive.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-06 17:41:46 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-06 17:41:46 +0800
commit859d43ae7012da10a58de5926d096dc817596fce (patch)
tree66a0dc09e8be4e5c7763bfc4af0cfae488c2c595 /src/synexts/derive.cpp
parentf430222343e18fec9f97c9b9fdfdc17667b94505 (diff)
downloadmrust-859d43ae7012da10a58de5926d096dc817596fce.tar.gz
HUGE REFACTOR - Move named module items into a tagged union
- Item attributes now "owned" by the parent
Diffstat (limited to 'src/synexts/derive.cpp')
-rw-r--r--src/synexts/derive.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/synexts/derive.cpp b/src/synexts/derive.cpp
index b8741cfe..17fb0a96 100644
--- a/src/synexts/derive.cpp
+++ b/src/synexts/derive.cpp
@@ -83,7 +83,7 @@ public:
DEBUG("node = " << *node);
AST::Function fcn(
- AST::MetaItems(), AST::GenericParams(),
+ AST::GenericParams(),
ret_type,
vec$(
::std::make_pair( AST::Pattern(AST::Pattern::TagBind(), "self"), TypeRef(TypeRef::TagReference(), false, TypeRef("Self")) ),
@@ -145,14 +145,21 @@ static void derive_item(AST::Module& mod, const AST::MetaItem& attr, const AST::
}
class Decorator_Derive:
- public CDecoratorHandler
+ public ExpandDecorator
{
public:
- void handle_item(AST::Crate& , AST::Module& mod, const AST::MetaItem& attr, const AST::Path& path, AST::Struct& str) const override
+ bool expand_before_macros() const override { return false; }
+ void handle(const AST::MetaItem& attr, AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item& i) const override
{
- derive_item(mod, attr, path, str);
+ TU_MATCH_DEF(::AST::Item, (i), (e),
+ (
+ ),
+ (Struct,
+ derive_item(mod, attr, path, e.e);
+ )
+ )
}
};
-STATIC_SYNEXT(Decorator, "derive", Decorator_Derive)
+STATIC_DECORATOR("derive", Decorator_Derive)