aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/eolian_cxx/grammar/eo_class_generator.hh
blob: 2b2233bdb71e1298137f38871e980751374ae599 (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

#ifndef EOLIAN_CXX_EO_CLASS_GENERATOR_HH
#define EOLIAN_CXX_EO_CLASS_GENERATOR_HH

#include <iosfwd>
#include <string>

#include "eo_types.hh"
#include "tab.hh"
#include "comment.hh"
#include "eo_class_constructors_generator.hh"
#include "eo_class_functions_generator.hh"
#include "eo_class_events_generator.hh"

namespace efl { namespace eolian { namespace grammar {

struct eo_class_getter
{
   eo_class const& _cls;
   eo_class_getter(eo_class const& cls) : _cls(cls) {}
};

inline std::ostream&
operator<<(std::ostream& out, eo_class_getter const& x)
{
   out << tab(1) << "static Eo_Class const* _eo_class()" << endl
       << tab(1) << "{" << endl
       << tab(2) << "return("<< x._cls.eo_name << ");" << endl
       << tab(1) << "}" << endl << endl;
   return out;
}

inline void
eo_class_generator(std::ostream& out, eo_class const& cls)
{
   out << comment(cls.comment)
       << "struct " << cls.name << endl
       << tab(2) << ": " << class_inheritance(cls)
       << '{' << endl
       << constructor_eo(cls)
       << constructors(cls)
       << copy_constructor(cls)
       << destructor(cls)
       << functions(cls.functions)
       << events(cls)
       << eo_class_getter(cls)
        << "private:" << endl
       << eo_class_constructors(cls)
       << "};" << endl;
}

} } } // namespace efl { namespace eolian { namespace grammar {

#endif // EOLIAN_CXX_EO_CLASS_GENERATOR_HH