summaryrefslogtreecommitdiff
path: root/src/include/synext.hpp
blob: d40269301908b33f72a4c3f4dfd92734016fa23e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 */
#ifndef _SYNEXT_HPP_
#define _SYNEXT_HPP_

#include "../common.hpp"   // for mv$ and other things
#include <string>
#include <memory>

namespace AST {
    class Crate;
    class MetaItem;
    class Path;
    
    class Module;
    
    class Struct;
    class Trait;
}

class CDecoratorHandler
{
public:
    virtual void handle_item(AST::Crate&, AST::Module&, const AST::MetaItem&, const AST::Path&, AST::Struct& ) const
    {
    }
    virtual void handle_item(AST::Crate&, AST::Module&, const AST::MetaItem&, const AST::Path&, AST::Trait& ) const
    {
    }
};

#define STATIC_SYNEXT(_type, ident, _typename) \
    struct register_##_typename##_c {\
        register_##_typename##_c() {\
            Register_Synext_##_type( ident, ::std::unique_ptr<C##_type##Handler>(new _typename()) ); \
        } \
    } s_register_##_typename;

extern void Register_Synext_Decorator(::std::string name, ::std::unique_ptr<CDecoratorHandler> handler);

#endif