summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/part_definition.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-03-19 20:35:36 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2018-03-20 16:50:30 -0300
commitf9586a831b8ba13542f59c9e1143c3d7b276bd51 (patch)
treebf1c81ace60441c4cf4007709ae32580db8ee58d /src/bin/eolian_mono/eolian/mono/part_definition.hh
parent9a6dd32cb1e8f5b1bcd23d32fc4b2d5fa425abbd (diff)
csharp: Add support for efl parts as Properties
Instead of var bg = efl.ui.Background.static_cast(myobj.Part("background")); Now do var bg = myobj.Background; Also a couple helper functions were added.
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/part_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/part_definition.hh52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh
new file mode 100644
index 0000000000..83222c9ed4
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh
@@ -0,0 +1,52 @@
1#ifndef EOLIAN_MONO_PART_DEFINITION_HH
2#define EOLIAN_MONO_PART_DEFINITION_HH
3
4#include <Eina.hh>
5
6#include "grammar/generator.hpp"
7#include "grammar/klass_def.hpp"
8#include "grammar/indentation.hpp"
9
10#include "utils.hh"
11#include "documentation.hh"
12
13namespace eolian_mono {
14
15struct part_definition_generator
16{
17 template <typename OutputIterator, typename Context>
18 bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const
19 {
20 std::string part_klass_name = klass_name_to_csharp(part.klass);
21 return as_generator(scope_tab << documentation
22 << scope_tab << "public " << part_klass_name << " " << utils::capitalize(part.name) << "\n"
23 << scope_tab << "{\n"
24 << scope_tab << scope_tab << "get\n"
25 << scope_tab << scope_tab << "{\n"
26 << scope_tab << scope_tab << scope_tab << "efl.Object obj = efl_part(raw_handle, \"" << part.name << "\");\n"
27 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << "Concrete.static_cast(obj);\n"
28 << scope_tab << scope_tab << "}\n"
29 << scope_tab << "}\n"
30 ).generate(sink, part.documentation, context);
31 }
32
33} const part_definition {};
34
35}
36
37namespace efl { namespace eolian { namespace grammar {
38
39template <>
40struct is_eager_generator< ::eolian_mono::part_definition_generator> : std::true_type {};
41template <>
42struct is_generator< ::eolian_mono::part_definition_generator> : std::true_type {};
43
44namespace type_traits {
45template <>
46struct attributes_needed< ::eolian_mono::part_definition_generator> : std::integral_constant<int, 1> {};
47
48}
49} } }
50
51#endif
52