summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/function_registration.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/function_registration.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/function_registration.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_registration.hh78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_registration.hh b/src/bin/eolian_mono/eolian/mono/function_registration.hh
new file mode 100644
index 0000000000..a88c938924
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/function_registration.hh
@@ -0,0 +1,78 @@
1#ifndef EOLIAN_MONO_FUNCTION_REGISTRATION_HH
2#define EOLIAN_MONO_FUNCTION_REGISTRATION_HH
3
4#include <Eina.hh>
5
6#include "grammar/generator.hpp"
7#include "grammar/klass_def.hpp"
8
9#include "grammar/indentation.hpp"
10#include "grammar/list.hpp"
11#include "grammar/alternative.hpp"
12#include "grammar/attribute_reorder.hpp"
13#include "type.hh"
14#include "marshall_type.hh"
15#include "parameter.hh"
16#include "keyword.hh"
17#include "using_decl.hh"
18#include "generation_contexts.hh"
19
20namespace eolian_mono {
21
22template <typename I>
23struct function_registration_generator
24{
25 I index_generator;
26 attributes::klass_def const* klass;
27
28 template <typename OutputIterator, typename Context>
29 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
30 {
31 if(is_function_blacklisted(f.c_name))
32 return true;
33 else
34 {
35 auto index = index_generator();
36
37 if(!as_generator
38#ifdef _WIN32
39 (scope_tab << scope_tab << "descs[" << index << "].api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\");\n"
40#else
41 (scope_tab << scope_tab << "descs[" << index << "].api_func = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, \"" << string << "\");\n"
42#endif
43 << scope_tab << scope_tab << "descs[" << index << "].func = Marshal.GetFunctionPointerForDelegate(" << string << "NativeInherit." << string << "_static_delegate);\n"
44 )
45 .generate(sink, std::make_tuple(f.c_name, klass->cxx_name, f.c_name), context))
46 return false;
47 return true;
48 }
49 }
50};
51
52struct function_registration_parameterized
53{
54 template <typename I>
55 function_registration_generator<I> operator()(I i, attributes::klass_def const& klass) const
56 {
57 return {i, &klass};
58 }
59} const function_registration;
60
61}
62
63namespace efl { namespace eolian { namespace grammar {
64
65template <typename I>
66struct is_eager_generator< ::eolian_mono::function_registration_generator<I>> : std::true_type {};
67template <typename I>
68struct is_generator< ::eolian_mono::function_registration_generator<I>> : std::true_type {};
69
70namespace type_traits {
71
72template <typename I>
73struct attributes_needed< ::eolian_mono::function_registration_generator<I>> : std::integral_constant<int, 1> {};
74}
75
76} } }
77
78#endif