summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/eo_class_events.generator.hh
blob: fdb3a317b70b33d3448cb99b5759b60eca8c66a5 (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

#ifndef EOLIAN_CXX_STD_EO_CLASS_EVENTS_GENERATOR_HH
#define EOLIAN_CXX_STD_EO_CLASS_EVENTS_GENERATOR_HH

#include <iosfwd>

#include <algorithm>  // std::transform()
#include <ctype.h>    // ::toupper()

#include "eo_types.hh"
#include "tab.hh"
#include "comment.hh"
#include "parameters_generator.hh"

namespace efl { namespace eolian { namespace grammar {

struct event_callback_add
{
   eo_event const& _event;
   std::string const& _ev_name;
   event_callback_add(eo_event const& event, std::string const& ev_name)
     : _event(event),
       _ev_name(ev_name)
   {}
};

inline std::ostream&
operator<<(std::ostream& out, event_callback_add const& x)
{
   // TODO implement
   return out;
}

struct event_callback_del
{
   eo_event const& _event;
   std::string const& _ev_name;
   event_callback_del(eo_event const& event, std::string const& ev_name)
     : _event(event),
       _ev_name(ev_name)
   {}
};

inline std::ostream&
operator<<(std::ostream& out, event_callback_del const& x)
{
   // TODO: implement
   return out;
}

struct event_callback_call
{
   eo_event const& _event;
   std::string const& _ev_name;
   event_callback_call(eo_event const& event, std::string const& ev_name)
     : _event(event),
       _ev_name(ev_name)
   {}
};

inline std::ostream&
operator<<(std::ostream& out, event_callback_call const& x)
{
   // TODO implement
   return out;
}

struct events
{
   events_container_type const& _events;
   events(events_container_type const& events) : _events(events) {}
};

inline std::ostream&
operator<<(std::ostream& out, events const& x)
{
   std::string prefix = x._cls.name + "_EVENT_";
   std::transform(prefix.begin(), prefix.end(), prefix.begin(), ::toupper());
   events_container_type::const_iterator it,
     first = x._events.begin(),
     last = x._events.end();
   for (it = first; it != last; ++it)
     {
        std::string ev_name = (*it).name;
        std::transform(ev_name.begin(), ev_name.end(), ev_name.begin(), ::toupper());
        out << event_callback_add((*it), prefix+ev_name)
            << event_callback_del((*it), prefix+ev_name)
            << event_callback_call((*it), prefix+ev_name);
     }
   return out;
}

} } }

#endif // EOLIAN_CXX_STD_EO_CLASS_EVENTS_GENERATOR_HH