summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/struct_fields.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/struct_fields.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_fields.hh68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/struct_fields.hh b/src/bin/eolian_mono/eolian/mono/struct_fields.hh
new file mode 100644
index 0000000000..0cd018b06f
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/struct_fields.hh
@@ -0,0 +1,68 @@
1#ifndef EOLIAN_MONO_STRUCT_FIELDS_HH
2#define EOLIAN_MONO_STRUCT_FIELDS_HH
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/indentation.hpp"
7#include "grammar/list.hpp"
8#include "grammar/alternative.hpp"
9#include "helpers.hh"
10#include "type.hh"
11#include "keyword.hh"
12#include "using_decl.hh"
13#include "documentation.hh"
14
15namespace eolian_mono {
16
17struct field_argument_default_generator
18{
19 template<typename OutputIterator, typename Context>
20 bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const
21 {
22 if (!as_generator(type << " " << string << "=default(" << type << ")")
23 .generate(sink, std::make_tuple(field.type, to_field_name(field.name), field.type), context))
24 return false;
25 return true;
26 }
27} const field_argument_default {};
28
29struct field_argument_assignment_generator
30{
31 template<typename OutputIterator, typename Context>
32 bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const
33 {
34 if (!as_generator("this." << string << " = " << string)
35 .generate(sink, std::make_tuple(to_field_name(field.name), to_field_name(field.name)), context))
36 return false;
37 return true;
38 }
39} const field_argument_assignment {};
40
41}
42
43namespace efl { namespace eolian { namespace grammar {
44
45template<>
46struct is_eager_generator< ::eolian_mono::field_argument_default_generator> : std::true_type {};
47template<>
48struct is_generator< ::eolian_mono::field_argument_default_generator> : std::true_type {};
49
50template<>
51struct is_eager_generator< ::eolian_mono::field_argument_assignment_generator> : std::true_type {};
52template<>
53struct is_generator< ::eolian_mono::field_argument_assignment_generator> : std::true_type {};
54
55namespace type_traits {
56
57template <>
58struct attributes_needed< ::eolian_mono::field_argument_default_generator> : std::integral_constant<int, 1> {};
59
60template <>
61struct attributes_needed< ::eolian_mono::field_argument_assignment_generator> : std::integral_constant<int, 1> {};
62
63}
64
65} } }
66
67#endif
68