summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-08-23 14:00:26 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-08-23 14:07:09 -0300
commit1aa05ab41be00da32fcc3cc83a95c605dbeb9a58 (patch)
treefb46f24e81ef1f8f0f9b129c768e9a39df2bb02d /src/lib/eolian_cxx
parent8aae656b8003f3f3cf4dd0dbed9aae92eee521ef (diff)
eolian-mono: Add support for multi-value properties with tuples
Summary: T8133 Reviewers: woohyun, segfaultxavi, felipealmeida Reviewed By: felipealmeida Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9577
Diffstat (limited to '')
-rw-r--r--src/lib/eolian_cxx/grammar/counter.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/lib/eolian_cxx/grammar/counter.hpp b/src/lib/eolian_cxx/grammar/counter.hpp
new file mode 100644
index 0000000000..d5af50681d
--- /dev/null
+++ b/src/lib/eolian_cxx/grammar/counter.hpp
@@ -0,0 +1,59 @@
1#ifndef EOLIAN_CXX_COUNTER_HH_HH
2#define EOLIAN_CXX_COUNTER_HH_HH
3
4#include <cstdlib>
5#include <cstring>
6
7#include "grammar/generator.hpp"
8#include "grammar/attributes.hpp"
9#include "grammar/case.hpp"
10#include "grammar/integral.hpp"
11
12namespace efl { namespace eolian { namespace grammar {
13
14namespace detail {
15
16}
17
18struct counter_generator
19{
20 std::shared_ptr<std::size_t> count;
21
22 template <typename OutputIterator, typename Attribute, typename Context>
23 bool generate(OutputIterator sink, Attribute const&, Context const&) const
24 {
25 detail::generate_integral(sink, *count);
26 ++*count;
27 return true;
28 }
29};
30
31struct counter_terminal
32{
33 counter_generator operator()(std::size_t initial) const
34 {
35 return {std::shared_ptr<std::size_t>{new std::size_t{initial}}};
36 }
37} const counter = {};
38
39counter_generator as_generator(counter_terminal) { return {std::shared_ptr<std::size_t>{new std::size_t{0u}}}; }
40
41template <>
42struct is_eager_generator<counter_generator> : std::true_type {};
43template <>
44struct is_eager_generator<counter_terminal> : std::true_type {};
45template <>
46struct is_generator<counter_terminal> : std::true_type {};
47template <>
48struct is_generator<counter_generator> : std::true_type {};
49
50namespace type_traits {
51template <>
52struct attributes_needed<counter_generator> : std::integral_constant<int, 0> {};
53template <>
54struct attributes_needed<counter_terminal> : std::integral_constant<int, 0> {};
55}
56
57} } }
58
59#endif