summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-10-29 18:39:26 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-10-29 18:39:26 -0200
commit2c88016ef1ca383b8285e049964e530d2e4fde48 (patch)
treeaadf9c18887fe2229fda0a75359750419fa2b974
parentb2f427eadf4f4c951cedc8e4d8c14a599c294c94 (diff)
mono: Parameters, marshalling, etc
-rw-r--r--src/Makefile_Eolian_Mono.am32
-rw-r--r--src/bin/eolian_mono/eolian_mono.cc2
-rw-r--r--src/bin/eolian_mono/eolian_mono/function_declaration.hh6
-rw-r--r--src/bin/eolian_mono/eolian_mono/function_definition.hh31
-rw-r--r--src/bin/eolian_mono/eolian_mono/keyword.hh15
-rw-r--r--src/bin/eolian_mono/eolian_mono/klass.hh29
-rw-r--r--src/bin/eolian_mono/eolian_mono/marshall_annotation.hh85
-rw-r--r--src/bin/eolian_mono/eolian_mono/marshall_type.hh113
-rw-r--r--src/bin/eolian_mono/eolian_mono/marshall_type_impl.hh102
-rw-r--r--src/bin/eolian_mono/eolian_mono/namespace.hh27
-rw-r--r--src/bin/eolian_mono/eolian_mono/parameter.hh73
-rw-r--r--src/bin/eolian_mono/eolian_mono/type_impl.hh69
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs44
-rw-r--r--src/bindings/mono/eo_mono/object.cs13
-rw-r--r--src/bindings/mono/eo_mono/workaround.cs34
-rw-r--r--src/lib/evas/canvas/evas_box.eo2
-rw-r--r--src/tests/eo_mono/Main.cs27
17 files changed, 623 insertions, 81 deletions
diff --git a/src/Makefile_Eolian_Mono.am b/src/Makefile_Eolian_Mono.am
index db6031d9e6..dadcef96fc 100644
--- a/src/Makefile_Eolian_Mono.am
+++ b/src/Makefile_Eolian_Mono.am
@@ -35,13 +35,39 @@ lib/evas/canvas/efl_vg_gradient_linear.eo.cs \
35lib/evas/canvas/efl_vg_root_node.eo.cs \ 35lib/evas/canvas/efl_vg_root_node.eo.cs \
36lib/evas/canvas/efl_vg_shape.eo.cs 36lib/evas/canvas/efl_vg_shape.eo.cs
37 37
38efl_eolian_blacklisted_files = \
39lib/efl/interfaces/efl_io_buffer.eo.cs \
40lib/efl/interfaces/efl_io_closer.eo.cs \
41lib/efl/interfaces/efl_io_positioner.eo.cs \
42lib/efl/interfaces/efl_io_queue.eo.cs \
43lib/efl/interfaces/efl_io_reader.eo.cs \
44lib/efl/interfaces/efl_io_sizer.eo.cs \
45lib/efl/interfaces/efl_io_writer.eo.cs \
46lib/efl/interfaces/efl_text_properties.eo.cs \
47lib/efl/interfaces/efl_gfx_buffer.eo.cs \
48lib/efl/interfaces/efl_gfx_shape.eo.cs
49
50ecore_eolian_blacklisted_files = \
51lib/ecore/efl_io_closer_fd.eo.cs \
52lib/ecore/efl_io_positioner_fd.eo.cs \
53lib/ecore/efl_io_reader_fd.eo.cs \
54lib/ecore/efl_io_writer_fd.eo.cs \
55lib/ecore/efl_io_copier_fd.eo.cs \
56lib/ecore/efl_io_sizer_fd.eo.cs \
57lib/ecore/efl_io_stdin.eo.cs \
58lib/ecore/efl_io_stdout.eo.cs \
59lib/ecore/efl_io_stderr.eo.cs \
60lib/ecore/efl_io_file.eo.cs \
61lib/ecore/efl_io_copier.eo.cs
62
38efl_eolian_mono_files = \ 63efl_eolian_mono_files = \
39$(filter-out lib/eo/efl_object_override.eo.cs, $(eo_eolian_files:%.eo=%.eo.cs)) \ 64$(filter-out lib/eo/efl_object.eo.cs lib/eo/efl_object_override.eo.cs, $(eo_eolian_files:%.eo=%.eo.cs)) \
40$(ecore_eolian_files_public:%.eo=%.eo.cs) \ 65$(filter-out $(ecore_eolian_blacklisted_files),$(ecore_eolian_files_public:%.eo=%.eo.cs)) \
41$(ecore_eolian_type_files:%.eot=%.eot.cs) \ 66$(ecore_eolian_type_files:%.eot=%.eot.cs) \
42$(efl_eolian_files:%.eo=%.eo.cs) \ 67$(filter-out $(efl_eolian_blacklisted_files),$(efl_eolian_files:%.eo=%.eo.cs)) \
43$(efl_eolian_type_files:%.eot=%.eot.cs) \ 68$(efl_eolian_type_files:%.eot=%.eot.cs) \
44$(filter-out $(evas_eolian_blacklisted_files),$(evas_eolian_pub_files:%.eo=%.eo.cs)) \ 69$(filter-out $(evas_eolian_blacklisted_files),$(evas_eolian_pub_files:%.eo=%.eo.cs)) \
70lib/evas/canvas/evas_box.eo.cs \
45$(evas_eolian_type_files:%.eot=%.eot.cs) 71$(evas_eolian_type_files:%.eot=%.eot.cs)
46 72
47### Efl C++ 73### Efl C++
diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc
index 84c2562d1d..f63b2249a7 100644
--- a/src/bin/eolian_mono/eolian_mono.cc
+++ b/src/bin/eolian_mono/eolian_mono.cc
@@ -25,6 +25,8 @@
25#include <eolian_mono/klass.hh> 25#include <eolian_mono/klass.hh>
26#include <eolian_mono/enum_definition.hh> 26#include <eolian_mono/enum_definition.hh>
27#include <eolian_mono/type_impl.hh> 27#include <eolian_mono/type_impl.hh>
28#include <eolian_mono/marshall_type_impl.hh>
29#include <eolian_mono/marshall_annotation.hh>
28 30
29namespace eolian_mono { 31namespace eolian_mono {
30 32
diff --git a/src/bin/eolian_mono/eolian_mono/function_declaration.hh b/src/bin/eolian_mono/eolian_mono/function_declaration.hh
index 6c8c7ae916..848e648569 100644
--- a/src/bin/eolian_mono/eolian_mono/function_declaration.hh
+++ b/src/bin/eolian_mono/eolian_mono/function_declaration.hh
@@ -8,7 +8,7 @@
8#include "grammar/list.hpp" 8#include "grammar/list.hpp"
9#include "grammar/alternative.hpp" 9#include "grammar/alternative.hpp"
10#include "type.hh" 10#include "type.hh"
11//#include "grammar/parameter.hpp" 11#include "parameter.hh"
12#include "keyword.hh" 12#include "keyword.hh"
13#include "using_decl.hh" 13#include "using_decl.hh"
14 14
@@ -20,8 +20,8 @@ struct function_declaration_generator
20 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 20 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
21 { 21 {
22 return as_generator 22 return as_generator
23 (eolian_mono::type(true) << " " << string << "(" /*<< (parameter % ", ")*/ << ");\n") 23 (eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n")
24 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name)/*, f.parameters*/), context); 24 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context);
25 } 25 }
26}; 26};
27 27
diff --git a/src/bin/eolian_mono/eolian_mono/function_definition.hh b/src/bin/eolian_mono/eolian_mono/function_definition.hh
index 1ca2401209..548b1b138e 100644
--- a/src/bin/eolian_mono/eolian_mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian_mono/function_definition.hh
@@ -7,8 +7,10 @@
7#include "grammar/indentation.hpp" 7#include "grammar/indentation.hpp"
8#include "grammar/list.hpp" 8#include "grammar/list.hpp"
9#include "grammar/alternative.hpp" 9#include "grammar/alternative.hpp"
10#include "grammar/attribute_reorder.hpp"
10#include "type.hh" 11#include "type.hh"
11//#include "grammar/parameter.hpp" 12#include "marshall_type.hh"
13#include "parameter.hh"
12#include "keyword.hh" 14#include "keyword.hh"
13#include "using_decl.hh" 15#include "using_decl.hh"
14#include "library_context.hh" 16#include "library_context.hh"
@@ -20,26 +22,29 @@ struct function_definition_generator
20 template <typename OutputIterator, typename Context> 22 template <typename OutputIterator, typename Context>
21 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 23 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
22 { 24 {
23 //using namespace System;
24 //using namespace System::Runtime::InteropServices;
25 std::string return_type;
26 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
27 return false;
28
29 if(!as_generator 25 if(!as_generator
30 (scope_tab << "[System.Runtime.InteropServices.DllImport(\"" << context_find_tag<library_context>(context).library_name << "\")] static extern " 26 (scope_tab << "[System.Runtime.InteropServices.DllImport(\"" << context_find_tag<library_context>(context).library_name << "\")] static extern "
31 << return_type << " " 27 << eolian_mono::marshall_annotation(true) << " " << eolian_mono::marshall_type(true) << " "
32 << string 28 << string
33 << "(System.IntPtr obj" /*<< (parameter % ", ")*/ << ");\n") 29 << "(System.IntPtr obj"
34 .generate(sink, std::make_tuple(f.c_name/*, f.parameters*/), context)) 30 << *grammar::attribute_reorder<1, -1>
31 (
32 (", " << marshall_annotation << " " << marshall_parameter)
33 )
34 << ");\n")
35 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
35 return false; 36 return false;
36 37
38 std::string return_type;
39 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
40 return false;
41
37 if(!as_generator 42 if(!as_generator
38 (scope_tab << "public " << return_type << " " << string << "(" /*<< (parameter % ", ")*/ 43 (scope_tab << "public " << return_type << " " << string << "(" << (parameter % ", ")
39 << ") { " 44 << ") { "
40 << (return_type == "void" ? "":"return ") << string << "(handle);" 45 << (return_type == "void" ? "":"return ") << string << "(handle" << *(", " << argument) << ");"
41 << " }\n") 46 << " }\n")
42 .generate(sink, std::make_tuple(escape_keyword(f.name), f.c_name/*, f.parameters*/), context)) 47 .generate(sink, std::make_tuple(escape_keyword(f.name), f.parameters, f.c_name, f.parameters), context))
43 return false; 48 return false;
44 49
45 return true; 50 return true;
diff --git a/src/bin/eolian_mono/eolian_mono/keyword.hh b/src/bin/eolian_mono/eolian_mono/keyword.hh
index 0d556fff58..a73e013c9b 100644
--- a/src/bin/eolian_mono/eolian_mono/keyword.hh
+++ b/src/bin/eolian_mono/eolian_mono/keyword.hh
@@ -2,11 +2,22 @@
2#define EOLIAN_CXX_KEYWORD_HH 2#define EOLIAN_CXX_KEYWORD_HH
3 3
4namespace eolian_mono { 4namespace eolian_mono {
5namespace detail {
6inline bool is_iequal(std::string const& lhs, std::string const& rhs)
7{
8 return strcasecmp(lhs.c_str(), rhs.c_str()) == 0;
9}
10}
5 11
6inline std::string escape_keyword(std::string const& name) 12inline std::string escape_keyword(std::string const& name)
7{ 13{
8 if(name == "delete" || name == "register" || name == "do" || name == "lock") 14 using detail::is_iequal;
9 return "mono_" + name; 15 if(is_iequal(name, "delete")
16 || is_iequal(name, "register")
17 || is_iequal(name, "do")
18 || is_iequal(name, "lock")
19 || is_iequal(name, "event"))
20 return "kw_" + name;
10 return name; 21 return name;
11} 22}
12 23
diff --git a/src/bin/eolian_mono/eolian_mono/klass.hh b/src/bin/eolian_mono/eolian_mono/klass.hh
index b5daa5d803..c4e625c701 100644
--- a/src/bin/eolian_mono/eolian_mono/klass.hh
+++ b/src/bin/eolian_mono/eolian_mono/klass.hh
@@ -8,7 +8,7 @@
8#include "grammar/list.hpp" 8#include "grammar/list.hpp"
9#include "grammar/alternative.hpp" 9#include "grammar/alternative.hpp"
10#include "type.hh" 10#include "type.hh"
11//#include "grammar/parameter.hpp" 11#include "namespace.hh"
12#include "function_definition.hh" 12#include "function_definition.hh"
13#include "function_declaration.hh" 13#include "function_declaration.hh"
14#include "grammar/string.hpp" 14#include "grammar/string.hpp"
@@ -44,9 +44,9 @@ struct klass
44 break; 44 break;
45 } 45 }
46 46
47 std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces); 47 std::vector<std::string> namespaces = escape_namespace(cls.namespaces);
48 auto open_namespace = *("namespace " << string << " { ") << "\n"; 48 auto open_namespace = *("namespace " << string << " { ") << "\n";
49 if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false; 49 if(!as_generator(open_namespace).generate(sink, namespaces, add_lower_case_context(context))) return false;
50 50
51 // Interface class 51 // Interface class
52 if(!as_generator 52 if(!as_generator
@@ -58,13 +58,13 @@ struct klass
58 for(auto first = std::begin(cls.immediate_inherits) 58 for(auto first = std::begin(cls.immediate_inherits)
59 , last = std::end(cls.immediate_inherits); first != last; ++first) 59 , last = std::end(cls.immediate_inherits); first != last; ++first)
60 { 60 {
61 if(!as_generator("\n" << scope_tab << *(lower_case[string] << ".") << string) 61 if(!as_generator("\n" << scope_tab << *(lower_case[string] << ".") << string << " ,")
62 .generate(sink, std::make_tuple(attributes::cpp_namespaces(first->namespaces), first->eolian_name), context)) 62 .generate(sink, std::make_tuple(escape_namespace(first->namespaces), first->eolian_name), context))
63 return false; 63 return false;
64 if(std::next(first) != last) 64 // if(std::next(first) != last)
65 *sink++ = ','; 65 // *sink++ = ',';
66 } 66 }
67 if(cls.immediate_inherits.empty()) 67 // if(cls.immediate_inherits.empty())
68 if(!as_generator("\n" << scope_tab << "efl.eo.IWrapper").generate(sink, attributes::unused, context)) return false; 68 if(!as_generator("\n" << scope_tab << "efl.eo.IWrapper").generate(sink, attributes::unused, context)) return false;
69 if(!as_generator("\n{\n").generate(sink, attributes::unused, context)) return false; 69 if(!as_generator("\n{\n").generate(sink, attributes::unused, context)) return false;
70 70
@@ -81,6 +81,9 @@ struct klass
81 ( 81 (
82 "public " << class_type << " " << string << "Concrete : " << string << "\n{\n" 82 "public " << class_type << " " << string << "Concrete : " << string << "\n{\n"
83 << scope_tab << "System.IntPtr handle;\n" 83 << scope_tab << "System.IntPtr handle;\n"
84 << scope_tab << "public System.IntPtr raw_handle {\n"
85 << scope_tab << scope_tab << "get { return handle; }\n"
86 << scope_tab << "}\n"
84 << scope_tab << "[System.Runtime.InteropServices.DllImport(\"eo\")] static extern System.IntPtr\n" 87 << scope_tab << "[System.Runtime.InteropServices.DllImport(\"eo\")] static extern System.IntPtr\n"
85 << scope_tab << "_efl_add_internal_start([System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)] System.String file, int line,\n" 88 << scope_tab << "_efl_add_internal_start([System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)] System.String file, int line,\n"
86 << scope_tab << scope_tab << "System.IntPtr klass, System.IntPtr parent, byte is_ref, byte is_fallback);\n" 89 << scope_tab << scope_tab << "System.IntPtr klass, System.IntPtr parent, byte is_ref, byte is_fallback);\n"
@@ -89,11 +92,13 @@ struct klass
89 << scope_tab << "[System.Runtime.InteropServices.DllImport(\"" << context_find_tag<library_context>(context).library_name 92 << scope_tab << "[System.Runtime.InteropServices.DllImport(\"" << context_find_tag<library_context>(context).library_name
90 << "\")] static extern System.IntPtr\n" 93 << "\")] static extern System.IntPtr\n"
91 << scope_tab << scope_tab << class_get_name << "();\n" 94 << scope_tab << scope_tab << class_get_name << "();\n"
92 << scope_tab << "public " << string << "Concrete()\n" 95 << scope_tab << "public " << string << "Concrete(efl.Object parent = null)\n"
93 << scope_tab << "{\n" 96 << scope_tab << "{\n"
94 << scope_tab << scope_tab << "System.IntPtr klass = " << class_get_name << "();\n" 97 << scope_tab << scope_tab << "System.IntPtr klass = " << class_get_name << "();\n"
95 << scope_tab << scope_tab << "System.IntPtr parent = System.IntPtr.Zero;\n" 98 << scope_tab << scope_tab << "System.IntPtr parent_ptr = System.IntPtr.Zero;\n"
96 << scope_tab << scope_tab << "System.IntPtr eo = _efl_add_internal_start(\"file\", 0, klass, parent, 0, 0);\n" 99 << scope_tab << scope_tab << "if(parent != null)\n"
100 << scope_tab << scope_tab << scope_tab << "parent_ptr = parent.raw_handle;\n"
101 << scope_tab << scope_tab << "System.IntPtr eo = _efl_add_internal_start(\"file\", 0, klass, parent_ptr, 0, 0);\n"
97 << scope_tab << scope_tab << "handle = _efl_add_end(eo, 0, 0);\n" 102 << scope_tab << scope_tab << "handle = _efl_add_end(eo, 0, 0);\n"
98 << scope_tab << "}\n" 103 << scope_tab << "}\n"
99 << scope_tab << "public " << string << "Concrete(System.IntPtr raw)\n" 104 << scope_tab << "public " << string << "Concrete(System.IntPtr raw)\n"
@@ -121,7 +126,7 @@ struct klass
121 } 126 }
122 127
123 auto close_namespace = *(lit("} ")) << "\n"; 128 auto close_namespace = *(lit("} ")) << "\n";
124 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false; 129 if(!as_generator(close_namespace).generate(sink, namespaces, context)) return false;
125 130
126 return true; 131 return true;
127 } 132 }
diff --git a/src/bin/eolian_mono/eolian_mono/marshall_annotation.hh b/src/bin/eolian_mono/eolian_mono/marshall_annotation.hh
new file mode 100644
index 0000000000..af196d7588
--- /dev/null
+++ b/src/bin/eolian_mono/eolian_mono/marshall_annotation.hh
@@ -0,0 +1,85 @@
1#ifndef EOLIAN_MONO_MARSHALL_ANNOTATION_IMPL_HH
2#define EOLIAN_MONO_MARSHALL_ANNOTATION_IMPL_HH
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/case.hpp"
7#include "namespace.hh"
8#include "type_impl.hh"
9
10namespace eolian_mono {
11
12namespace eina = efl::eina;
13
14namespace detail {
15
16template <typename OutputIterator, typename Context>
17struct marshall_annotation_visitor_generate
18{
19 mutable OutputIterator sink;
20 Context const* context;
21 std::string c_type;
22 bool is_out;
23 bool is_return;
24
25 typedef marshall_type_visitor_generate<OutputIterator, Context> visitor_type;
26 typedef bool result_type;
27
28 bool operator()(attributes::regular_type_def const& regular) const
29 {
30 using attributes::regular_type_def;
31 struct match
32 {
33 eina::optional<std::string> name;
34 eina::optional<bool> has_own;
35 std::function<attributes::type_def::variant_type()> function;
36 };
37 match const parameter_match_table[] =
38 {
39 // signed primitives
40 {"bool", nullptr, [&] { return replace_base_type(regular, " [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I1)]"); }}
41 };
42 match const return_match_table[] =
43 {
44 // signed primitives
45 {"bool", nullptr, [&] { return replace_base_type(regular, " [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I1)]"); }}
46 };
47
48 if(eina::optional<bool> b = call_match
49 ((is_return ? return_match_table : parameter_match_table)
50 , [&] (match const& m)
51 {
52 return (!m.name || *m.name == regular.base_type)
53 && (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
54 ;
55 }
56 , [&] (attributes::type_def::variant_type const& v)
57 {
58 return v.visit(*this); // we want to keep is_out info
59 }))
60 {
61 return *b;
62 }
63 else
64 {
65 return true;
66 }
67 }
68 bool operator()(attributes::klass_name) const
69 {
70 if(!is_return)
71 {
72 const char marshal[] = "[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.CustomMarshaler, /*System.Runtime.InteropServices.*/MarshalTypeRef = typeof(efl.eo.MarshalTest))]";
73 std::copy(&marshal[0], &marshal[0] + sizeof(marshal) - 1, sink);
74 }
75 return true;
76 }
77 bool operator()(attributes::complex_type_def const&) const
78 {
79 return true;
80 }
81};
82
83} }
84
85#endif
diff --git a/src/bin/eolian_mono/eolian_mono/marshall_type.hh b/src/bin/eolian_mono/eolian_mono/marshall_type.hh
new file mode 100644
index 0000000000..c7253855c9
--- /dev/null
+++ b/src/bin/eolian_mono/eolian_mono/marshall_type.hh
@@ -0,0 +1,113 @@
1#ifndef EOLIAN_MONO_MARSHALL_TYPE_HH
2#define EOLIAN_MONO_MARSHALL_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;
11namespace detail {
12template <typename OutputIterator, typename Context>
13struct marshall_type_visitor_generate;
14template <typename OutputIterator, typename Context>
15struct marshall_annotation_visitor_generate;
16}
17struct marshall_type_generator
18{
19 marshall_type_generator(bool is_return = false)
20 : is_return(is_return) {}
21
22 template <typename OutputIterator, typename Context>
23 bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
24 {
25 return type.original_type.visit(detail::marshall_type_visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return});
26 }
27 template <typename OutputIterator, typename Context>
28 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
29 {
30 return param.type.original_type.visit(detail::marshall_type_visitor_generate<OutputIterator, Context>{sink, &context, param.c_type
31 , param.direction != attributes::parameter_direction::in, false});
32 }
33
34 bool is_return;
35};
36
37struct marshall_annotation_generator
38{
39 marshall_annotation_generator(bool is_return = false)
40 : is_return(is_return) {}
41
42 template <typename OutputIterator, typename Context>
43 bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
44 {
45 return type.original_type.visit(detail::marshall_annotation_visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return});
46 }
47 template <typename OutputIterator, typename Context>
48 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
49 {
50 return param.type.original_type.visit(detail::marshall_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.c_type
51 , param.direction != attributes::parameter_direction::in, false});
52 }
53
54 bool is_return;
55};
56
57struct marshall_type_terminal
58{
59 marshall_type_generator const operator()(bool is_return) const
60 {
61 return marshall_type_generator(is_return);
62 }
63} const marshall_type = {};
64
65marshall_type_generator const as_generator(marshall_type_terminal)
66{
67 return marshall_type_generator{};
68}
69
70struct marshall_annotation_terminal
71{
72 marshall_annotation_generator const operator()(bool is_return) const
73 {
74 return marshall_annotation_generator(is_return);
75 }
76} const marshall_annotation = {};
77
78marshall_annotation_generator const as_generator(marshall_annotation_terminal)
79{
80 return marshall_annotation_generator{};
81}
82
83}
84
85namespace efl { namespace eolian { namespace grammar {
86
87template <>
88struct is_eager_generator< ::eolian_mono::marshall_type_generator> : std::true_type {};
89template <>
90struct is_generator< ::eolian_mono::marshall_type_terminal> : std::true_type {};
91
92namespace type_traits {
93template <>
94struct attributes_needed< ::eolian_mono::marshall_type_generator> : std::integral_constant<int, 1> {};
95template <>
96struct attributes_needed< ::eolian_mono::marshall_type_terminal> : std::integral_constant<int, 1> {};
97}
98
99template <>
100struct is_eager_generator< ::eolian_mono::marshall_annotation_generator> : std::true_type {};
101template <>
102struct is_generator< ::eolian_mono::marshall_annotation_terminal> : std::true_type {};
103
104namespace type_traits {
105template <>
106struct attributes_needed< ::eolian_mono::marshall_annotation_generator> : std::integral_constant<int, 1> {};
107template <>
108struct attributes_needed< ::eolian_mono::marshall_annotation_terminal> : std::integral_constant<int, 1> {};
109}
110
111} } }
112
113#endif
diff --git a/src/bin/eolian_mono/eolian_mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian_mono/marshall_type_impl.hh
new file mode 100644
index 0000000000..7753ce7e04
--- /dev/null
+++ b/src/bin/eolian_mono/eolian_mono/marshall_type_impl.hh
@@ -0,0 +1,102 @@
1#ifndef EOLIAN_MONO_MARSHALL_TYPE_IMPL_HH
2#define EOLIAN_MONO_MARSHALL_TYPE_IMPL_HH
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/case.hpp"
7#include "namespace.hh"
8#include "type_impl.hh"
9
10namespace eolian_mono {
11
12namespace eina = efl::eina;
13
14namespace detail {
15
16template <typename OutputIterator, typename Context>
17struct marshall_type_visitor_generate
18{
19 mutable OutputIterator sink;
20 Context const* context;
21 std::string c_type;
22 bool is_out;
23 bool is_return;
24
25 typedef marshall_type_visitor_generate<OutputIterator, Context> visitor_type;
26 typedef bool result_type;
27
28 bool operator()(attributes::regular_type_def const& regular) const
29 {
30 using attributes::regular_type_def;
31 struct match
32 {
33 eina::optional<std::string> name;
34 eina::optional<bool> has_own;
35 std::function<attributes::type_def::variant_type()> function;
36 }
37 const match_table[] =
38 {
39 // signed primitives
40 {"string", true, [&]
41 {
42 regular_type_def r = regular;
43 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
44 // if(is_out || is_return)
45 return replace_base_type(r, " System.String");
46 // else return replace_base_type(r, " ::efl::eina::string_view");
47 }}
48 , {"string", false, [&]
49 {
50 regular_type_def r = regular;
51 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
52 return replace_base_type(r, " System.String");
53 }}
54 , {"stringshare", nullptr, [&]
55 {
56 regular_type_def r = regular;
57 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
58 return replace_base_type(r, " System.String");
59 }}
60 // , {"generic_value", true, [&]
61 // { return regular_type_def{" int", regular.base_qualifier, {}};
62 // }}
63 // , {"generic_value", false, [&]
64 // { return regular_type_def{" int", regular.base_qualifier, {}};
65 // }}
66 };
67
68 if(eina::optional<bool> b = call_match
69 (match_table
70 , [&] (match const& m)
71 {
72 return (!m.name || *m.name == regular.base_type)
73 && (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
74 ;
75 }
76 , [&] (attributes::type_def::variant_type const& v)
77 {
78 return v.visit(*this); // we want to keep is_out info
79 }))
80 {
81 return *b;
82 }
83 else
84 {
85 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return}(regular);
86 }
87 }
88 bool operator()(attributes::klass_name klass_name) const
89 {
90 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return}(klass_name);
91 // return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
92 }
93 bool operator()(attributes::complex_type_def const& complex) const
94 {
95 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return}(complex);
96 // return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
97 }
98};
99
100} }
101
102#endif
diff --git a/src/bin/eolian_mono/eolian_mono/namespace.hh b/src/bin/eolian_mono/eolian_mono/namespace.hh
new file mode 100644
index 0000000000..b0f1ddb0b3
--- /dev/null
+++ b/src/bin/eolian_mono/eolian_mono/namespace.hh
@@ -0,0 +1,27 @@
1#ifndef EOLIAN_MONO_NAMESPACE_HH
2#define EOLIAN_MONO_NAMESPACE_HH
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/case.hpp"
7#include "grammar/type.hpp"
8#include "using_decl.hh"
9#include "keyword.hh"
10
11namespace eolian_mono {
12
13std::vector<std::string> escape_namespace(std::vector<std::string> namespaces)
14{
15 // if(namespaces.empty())
16 // namespaces.push_back("nonamespace");
17 // else
18 {
19 for(auto&& i : namespaces)
20 i = escape_keyword(i);
21 }
22 return namespaces;
23}
24
25}
26
27#endif
diff --git a/src/bin/eolian_mono/eolian_mono/parameter.hh b/src/bin/eolian_mono/eolian_mono/parameter.hh
new file mode 100644
index 0000000000..d8215229ab
--- /dev/null
+++ b/src/bin/eolian_mono/eolian_mono/parameter.hh
@@ -0,0 +1,73 @@
1#ifndef EOLIAN_MONO_PARAMETER_HH
2#define EOLIAN_MONO_PARAMETER_HH
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/case.hpp"
7#include "marshall_type.hh"
8#include "type.hh"
9#include "using_decl.hh"
10
11namespace eolian_mono {
12
13namespace attributes = efl::eolian::grammar::attributes;
14
15struct parameter_generator
16{
17 template <typename OutputIterator, typename Context>
18 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
19 {
20 return as_generator(type << " " << string).generate(sink, std::make_tuple(param.type, param.param_name), context);
21 }
22} const parameter {};
23
24struct marshall_parameter_generator
25{
26 template <typename OutputIterator, typename Context>
27 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
28 {
29 return as_generator(marshall_type << " " << string).generate(sink, std::make_tuple(param.type, param.param_name), context);
30 }
31} const marshall_parameter {};
32
33struct argument_generator
34{
35 template <typename OutputIterator, typename Context>
36 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
37 {
38 return as_generator(param.param_name).generate(sink, attributes::unused, context);
39 }
40
41} const argument {};
42
43}
44
45namespace efl { namespace eolian { namespace grammar {
46
47template <>
48struct is_eager_generator< ::eolian_mono::parameter_generator> : std::true_type {};
49
50namespace type_traits {
51template <>
52struct attributes_needed< ::eolian_mono::parameter_generator> : std::integral_constant<int, 1> {};
53}
54
55template <>
56struct is_eager_generator< ::eolian_mono::marshall_parameter_generator> : std::true_type {};
57
58namespace type_traits {
59template <>
60struct attributes_needed< ::eolian_mono::marshall_parameter_generator> : std::integral_constant<int, 1> {};
61}
62
63template <>
64struct is_eager_generator< ::eolian_mono::argument_generator> : std::true_type {};
65
66namespace type_traits {
67template <>
68struct attributes_needed< ::eolian_mono::argument_generator> : std::integral_constant<int, 1> {};
69}
70
71} } }
72
73#endif
diff --git a/src/bin/eolian_mono/eolian_mono/type_impl.hh b/src/bin/eolian_mono/eolian_mono/type_impl.hh
index 8c54106fa8..c8c466c77a 100644
--- a/src/bin/eolian_mono/eolian_mono/type_impl.hh
+++ b/src/bin/eolian_mono/eolian_mono/type_impl.hh
@@ -4,6 +4,7 @@
4#include "grammar/generator.hpp" 4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp" 5#include "grammar/klass_def.hpp"
6#include "grammar/case.hpp" 6#include "grammar/case.hpp"
7#include "namespace.hh"
7 8
8namespace eolian_mono { 9namespace eolian_mono {
9 10
@@ -156,36 +157,36 @@ struct visitor_generate
156 // out A @optional -> optional<A&> 157 // out A @optional -> optional<A&>
157 // out A& @optional -> optional<A&> 158 // out A& @optional -> optional<A&>
158 // out own(A&) @optional -> optional<A*&> 159 // out own(A&) @optional -> optional<A*&>
159 else if(regular.base_qualifier & qualifier_info::is_optional) 160 // else if(regular.base_qualifier & qualifier_info::is_optional)
160 { 161 // {
161 attributes::regular_type_def no_optional_regular = regular; 162 // attributes::regular_type_def no_optional_regular = regular;
162 no_optional_regular.base_qualifier.qualifier ^= qualifier_info::is_optional; 163 // no_optional_regular.base_qualifier.qualifier ^= qualifier_info::is_optional;
163 if(is_out) 164 // if(is_out)
164 { 165 // {
165 if(no_optional_regular.base_qualifier & qualifier_info::is_own) 166 // if(no_optional_regular.base_qualifier & qualifier_info::is_own)
166 { 167 // {
167 return as_generator(" ::efl::eina::optional<").generate(sink, attributes::unused, *context) 168 // return as_generator(" ::efl::eina::optional<").generate(sink, attributes::unused, *context)
168 && (*this)(no_optional_regular) 169 // && (*this)(no_optional_regular)
169 && as_generator("&>").generate(sink, attributes::unused, *context); 170 // && as_generator("&>").generate(sink, attributes::unused, *context);
170 } 171 // }
171 else if(no_optional_regular.base_qualifier & qualifier_info::is_ref) 172 // else if(no_optional_regular.base_qualifier & qualifier_info::is_ref)
172 { 173 // {
173 no_optional_regular.base_qualifier.qualifier ^= qualifier_info::is_ref; 174 // no_optional_regular.base_qualifier.qualifier ^= qualifier_info::is_ref;
174 return (*this)(no_optional_regular) 175 // return (*this)(no_optional_regular)
175 && as_generator("**").generate(sink, attributes::unused, *context); 176 // && as_generator("**").generate(sink, attributes::unused, *context);
176 } 177 // }
177 else 178 // else
178 return (*this)(no_optional_regular) 179 // return (*this)(no_optional_regular)
179 && as_generator("*").generate(sink, attributes::unused, *context); 180 // && as_generator("*").generate(sink, attributes::unused, *context);
180 } 181 // }
181 else 182 // else
182 { 183 // {
183 // regular.base_qualifier & qualifier_info::is_ref 184 // // regular.base_qualifier & qualifier_info::is_ref
184 return as_generator(" ::efl::eina::optional<").generate(sink, attributes::unused, *context) 185 // return as_generator(" ::efl::eina::optional<").generate(sink, attributes::unused, *context)
185 && (*this)(no_optional_regular) 186 // && (*this)(no_optional_regular)
186 && as_generator(">").generate(sink, attributes::unused, *context); 187 // && as_generator(">").generate(sink, attributes::unused, *context);
187 } 188 // }
188 } 189 // }
189 // else if((is_return || is_out) && regular.base_qualifier & qualifier_info::is_ref 190 // else if((is_return || is_out) && regular.base_qualifier & qualifier_info::is_ref
190 // && regular.base_qualifier & qualifier_info::is_own) 191 // && regular.base_qualifier & qualifier_info::is_own)
191 // { 192 // {
@@ -213,8 +214,8 @@ struct visitor_generate
213 // } 214 // }
214 else 215 else
215 { 216 {
216 as_generator(" Generating: " << *(lower_case[string] << ".") << string << "\n") 217 // as_generator(" Generating: " << *(lower_case[string] << ".") << string << "\n")
217 .generate(std::ostream_iterator<char>(std::cerr), std::make_tuple(regular.namespaces, regular.base_type), *context); 218 // .generate(std::ostream_iterator<char>(std::cerr), std::make_tuple(eolian_mono::escape_namespace(regular.namespaces), regular.base_type), *context);
218 if(as_generator 219 if(as_generator
219 ( 220 (
220 *(lower_case[string] << ".") 221 *(lower_case[string] << ".")
@@ -225,7 +226,7 @@ struct visitor_generate
225 // ? /*" const"*/ "" : "") 226 // ? /*" const"*/ "" : "")
226 /*<< (regular.base_qualifier & qualifier_info::is_ref? "&" : "")*/ 227 /*<< (regular.base_qualifier & qualifier_info::is_ref? "&" : "")*/
227 ) 228 )
228 .generate(sink, std::make_tuple(regular.namespaces, regular.base_type), *context)) 229 .generate(sink, std::make_tuple(eolian_mono::escape_namespace(regular.namespaces), regular.base_type), *context))
229 return true; 230 return true;
230 else 231 else
231 return false; 232 return false;
@@ -243,7 +244,7 @@ struct visitor_generate
243 // .generate(sink, attributes::unused, *context); 244 // .generate(sink, attributes::unused, *context);
244 return 245 return
245 as_generator(" " << *(lower_case[string] << ".") << string) 246 as_generator(" " << *(lower_case[string] << ".") << string)
246 .generate(sink, std::make_tuple(attributes::cpp_namespaces(klass.namespaces), klass.eolian_name), *context) 247 .generate(sink, std::make_tuple(eolian_mono::escape_namespace(klass.namespaces), klass.eolian_name), *context)
247 // && (!(klass.base_qualifier & qualifier_info::is_ref) 248 // && (!(klass.base_qualifier & qualifier_info::is_ref)
248 // || as_generator("&").generate(sink, attributes::unused, *context)) 249 // || as_generator("&").generate(sink, attributes::unused, *context))
249 ; 250 ;
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 81d55affa1..eaae5aa15c 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -1,8 +1,50 @@
1 1
2using System;
3using System.Runtime.InteropServices;
4
2namespace efl { namespace eo { 5namespace efl { namespace eo {
3 6
4public interface IWrapper 7public interface IWrapper
5{ 8{
9 System.IntPtr raw_handle
10 {
11 get;
12 }
6} 13}
7 14
15class MarshalTest : ICustomMarshaler
16{
17 public static ICustomMarshaler GetInstance(string cookie)
18 {
19 return new MarshalTest();
20 }
21 public void CleanUpManagedData(object ManagedObj)
22 {
23 //throw new NotImplementedException();
24 }
25
26 public void CleanUpNativeData(IntPtr pNativeData)
27 {
28 //throw new NotImplementedException();
29 }
30
31 public int GetNativeDataSize()
32 {
33 System.Console.WriteLine("GetNativeDataSize");
34 return 0;
35 //return 8;
36 }
37
38 public IntPtr MarshalManagedToNative(object ManagedObj)
39 {
40 System.Console.WriteLine("MarshallManagedToNative");
41 return ((IWrapper)ManagedObj).raw_handle;
42 }
43
44 public object MarshalNativeToManaged(IntPtr pNativeData)
45 {
46 return null;
47 }
48}
49
8} } 50} }
diff --git a/src/bindings/mono/eo_mono/object.cs b/src/bindings/mono/eo_mono/object.cs
index 7472f345ab..6d8c65b908 100644
--- a/src/bindings/mono/eo_mono/object.cs
+++ b/src/bindings/mono/eo_mono/object.cs
@@ -3,17 +3,8 @@ namespace efl {
3 3
4using System; 4using System;
5 5
6 /*public interface Object : efl.eo.IWrapper 6public interface Object : efl.eo.IWrapper
7{ 7{
8 IntPtr handle; 8}
9 public Object()
10 {
11 handle = (IntPtr)0;
12 }
13 public Object(IntPtr raw)
14 {
15 handle = raw;
16 }
17}*/
18 9
19} 10}
diff --git a/src/bindings/mono/eo_mono/workaround.cs b/src/bindings/mono/eo_mono/workaround.cs
index bbf2928c6a..4dc022038d 100644
--- a/src/bindings/mono/eo_mono/workaround.cs
+++ b/src/bindings/mono/eo_mono/workaround.cs
@@ -1,4 +1,38 @@
1 1
2public struct Evas_Object_Box_Layout {};
3public struct Eina_Free_Cb {};
4public struct Evas_Object_Box_Option {};
5
6namespace eina {
7
8public struct Rw_Slice {}
9public struct Slice {}
10
11}
12
13namespace efl { namespace kw_event {
14
15public struct Description {};
16
17}
18
19public struct Callback_Priority {};
20public struct Event_Cb {};
21public struct Callback_Array_Item {};
22public struct Dbg_Info {};
23
24}
25
26namespace efl { namespace gfx {
27
28public interface Buffer {}
29
30namespace buffer {
31public struct Access_Mode {}
32}
33
34} }
35
2namespace evas { namespace font { 36namespace evas { namespace font {
3 37
4public struct Hinting_Flags {} 38public struct Hinting_Flags {}
diff --git a/src/lib/evas/canvas/evas_box.eo b/src/lib/evas/canvas/evas_box.eo
index 66fdb40cc8..d593ec2c76 100644
--- a/src/lib/evas/canvas/evas_box.eo
+++ b/src/lib/evas/canvas/evas_box.eo
@@ -277,7 +277,7 @@ class Evas.Box (Efl.Canvas.Group.Clipped)
277 Note: This call will trigger the box's _Evas_Object_Box_Api.append 277 Note: This call will trigger the box's _Evas_Object_Box_Api.append
278 smart function.]] 278 smart function.]]
279 279
280 return: Evas_Object_Box_Option *; [[A box option bound to the recently added box item or 280 return: ref(Evas_Object_Box_Option); [[A box option bound to the recently added box item or
281 $null, on errors.]] 281 $null, on errors.]]
282 params { 282 params {
283 @in child: Efl.Canvas.Object @nonull; [[A child Evas object to be made a member of $o.]] 283 @in child: Efl.Canvas.Object @nonull; [[A child Evas object to be made a member of $o.]]
diff --git a/src/tests/eo_mono/Main.cs b/src/tests/eo_mono/Main.cs
index 59cecf27ad..fe6b190fb8 100644
--- a/src/tests/eo_mono/Main.cs
+++ b/src/tests/eo_mono/Main.cs
@@ -6,6 +6,7 @@ class TestMain
6 [DllImport("eo")] static extern void efl_object_init(); 6 [DllImport("eo")] static extern void efl_object_init();
7 [DllImport("ecore")] static extern void ecore_init(); 7 [DllImport("ecore")] static extern void ecore_init();
8 [DllImport("evas")] static extern void evas_init(); 8 [DllImport("evas")] static extern void evas_init();
9
9 static void Main(string[] args) 10 static void Main(string[] args)
10 { 11 {
11 efl_object_init(); 12 efl_object_init();
@@ -19,7 +20,31 @@ class TestMain
19 System.Console.WriteLine("Hello World"); 20 System.Console.WriteLine("Hello World");
20 21
21 efl.canvas.Object canvas = ecore_evas.canvas; 22 efl.canvas.Object canvas = ecore_evas.canvas;
22 canvas.visible_set(); 23 canvas.visible_set(true);
24
25 efl.canvas.Rectangle rect = new efl.canvas.RectangleConcrete(canvas);
26 rect.color_set(255, 255, 255, 255);
27 rect.size_set(640, 480);
28 rect.visible_set(true);
29
30 evas.Box box = new evas.BoxConcrete(canvas);
31 // rect.position_set(160, 120);
32 rect.size_set(320, 240);
33 box.visible_set(true);
34
35 efl.canvas.Image image1 = new efl.canvas.ImageConcrete(canvas);
36 image1.file_set("/home/felipe/dev/samsung/upstream/efl/src/examples/elementary/sphere_hunter/score.jpg", "");
37 image1.hint_min_set(160, 120);
38 image1.visible_set(true);
39
40 efl.canvas.Image image2 = new efl.canvas.ImageConcrete(canvas);
41 image2.file_set("/home/felipe/dev/samsung/upstream/efl/src/examples/evas/shooter/assets/images/bricks.jpg", "");
42 image2.hint_min_set(160, 120);
43 image2.visible_set(true);
44
45 box.append(image1);
46 box.append(image2);
47
23 loop.begin(); 48 loop.begin();
24 } 49 }
25} 50}