summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/type.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-23 21:50:16 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-04 15:47:50 -0300
commitd93e9ff286ce1961f530d56b5536881f47104ebd (patch)
treed9fd8cd25a64b9ab6b23ae34b92c342dc8e6b543 /src/bin/eolian_mono/eolian/mono/type.hh
parent9391407319424c503a78479b407737ccead945b7 (diff)
eolian_mono: Added code for eolian_mono generator
Based on the eolian_cxx library generators. Buildsystem files will come in a future commmit.
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/type.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/type.hh68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/type.hh b/src/bin/eolian_mono/eolian/mono/type.hh
new file mode 100644
index 0000000000..b0e14516ce
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/type.hh
@@ -0,0 +1,68 @@
1#ifndef EOLIAN_MONO_TYPE_HH
2#define EOLIAN_MONO_TYPE_HH
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/case.hpp"
7
8namespace eolian_mono {
9
10namespace attributes = efl::eolian::grammar::attributes;
11
12template <typename OutputIterator, typename Context>
13struct visitor_generate;
14
15struct type_generator
16{
17 type_generator(bool is_return = false)
18 : is_return(is_return) {}
19
20 template <typename OutputIterator, typename Context>
21 bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
22 {
23 return type.original_type.visit(visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return});
24 }
25 template <typename OutputIterator, typename Context>
26 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
27 {
28 return param.type.original_type.visit(visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
29 , param.direction != attributes::parameter_direction::in, false});
30 }
31
32 bool is_return;
33};
34
35struct type_terminal
36{
37 type_generator const operator()(bool is_return) const
38 {
39 return type_generator(is_return);
40 }
41} const type = {};
42
43type_generator const as_generator(type_terminal)
44{
45 return type_generator{};
46}
47
48}
49
50namespace efl { namespace eolian { namespace grammar {
51
52template <>
53struct is_eager_generator< ::eolian_mono::type_generator> : std::true_type {};
54template <>
55struct is_generator< ::eolian_mono::type_generator> : std::true_type {};
56template <>
57struct is_generator< ::eolian_mono::type_terminal> : std::true_type {};
58
59namespace type_traits {
60template <>
61struct attributes_needed< ::eolian_mono::type_generator> : std::integral_constant<int, 1> {};
62template <>
63struct attributes_needed< ::eolian_mono::type_terminal> : std::integral_constant<int, 1> {};
64}
65
66} } }
67
68#endif