summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-04-27 18:08:25 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2018-05-03 18:04:41 -0300
commitc9dd86579f1e4b585e5dadbc9f69df0abd263917 (patch)
treeba8b38e3600b15dec828e170dbe070dfd2bcb654 /src/bin/eolian_mono
parentf39baf1e82d7571225ac6429f7486e60abcf604f (diff)
efl_mono: More uniformization of the handling of names
Summary: Uses a common helper to open and close namespaces, to get the managed and unmanaged name of things, the interface, concrete and inherit class names, etc. eolian_cxx: Add namespace information to func_def, as it'll avoid eolian-cxx clients dealing with the eolian C api directly when trying to access a function pointer namespace. Depends on D6048 Reviewers: felipealmeida, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D6049
Diffstat (limited to 'src/bin/eolian_mono')
-rw-r--r--src/bin/eolian_mono/eolian/mono/blacklist.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/enum_definition.hh12
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh25
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh20
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh24
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_registration.hh6
-rw-r--r--src/bin/eolian_mono/eolian/mono/helpers.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh110
-rw-r--r--src/bin/eolian_mono/eolian/mono/logging.hh12
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_annotation.hh12
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh187
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh45
-rw-r--r--src/bin/eolian_mono/eolian/mono/part_definition.hh7
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh18
-rw-r--r--src/bin/eolian_mono/eolian/mono/type_impl.hh47
-rw-r--r--src/bin/eolian_mono/eolian_mono.cc62
17 files changed, 284 insertions, 313 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/blacklist.hh b/src/bin/eolian_mono/eolian/mono/blacklist.hh
index 863d23d9f6..fe1640ea67 100644
--- a/src/bin/eolian_mono/eolian/mono/blacklist.hh
+++ b/src/bin/eolian_mono/eolian/mono/blacklist.hh
@@ -65,12 +65,12 @@ inline bool is_struct_blacklisted(std::string const& full_name)
65 65
66inline bool is_struct_blacklisted(attributes::struct_def const& struct_) 66inline bool is_struct_blacklisted(attributes::struct_def const& struct_)
67{ 67{
68 return is_struct_blacklisted(name_helpers::struct_full_name(struct_)); 68 return is_struct_blacklisted(name_helpers::struct_full_eolian_name(struct_));
69} 69}
70 70
71inline bool is_struct_blacklisted(attributes::regular_type_def const& struct_) 71inline bool is_struct_blacklisted(attributes::regular_type_def const& struct_)
72{ 72{
73 return is_struct_blacklisted(name_helpers::type_full_name(struct_)); 73 return is_struct_blacklisted(name_helpers::type_full_eolian_name(struct_));
74} 74}
75 75
76} 76}
diff --git a/src/bin/eolian_mono/eolian/mono/enum_definition.hh b/src/bin/eolian_mono/eolian/mono/enum_definition.hh
index da8505aedf..f7c40d7201 100644
--- a/src/bin/eolian_mono/eolian/mono/enum_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/enum_definition.hh
@@ -17,10 +17,8 @@ struct enum_definition_generator
17 template <typename OutputIterator, typename Context> 17 template <typename OutputIterator, typename Context>
18 bool generate(OutputIterator sink, attributes::enum_def const& enum_, Context const& context) const 18 bool generate(OutputIterator sink, attributes::enum_def const& enum_, Context const& context) const
19 { 19 {
20 std::vector<std::string> cpp_namespaces = name_helpers::escape_namespace(attributes::cpp_namespaces(enum_.namespaces)); 20 if(!name_helpers::open_namespaces(sink, enum_.namespaces, context))
21 21 return false;
22 auto open_namespace = *("namespace " << string << " { ") << "\n";
23 if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false;
24 22
25 if(!as_generator(documentation).generate(sink, enum_, context)) 23 if(!as_generator(documentation).generate(sink, enum_, context))
26 return false; 24 return false;
@@ -49,9 +47,9 @@ struct enum_definition_generator
49 47
50 if(!as_generator("}\n").generate(sink, attributes::unused, context)) return false; 48 if(!as_generator("}\n").generate(sink, attributes::unused, context)) return false;
51 49
52 auto close_namespace = *(lit("} ")) << "\n"; 50 if(!name_helpers::close_namespaces(sink, enum_.namespaces, context))
53 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false; 51 return false;
54 52
55 return true; 53 return true;
56 } 54 }
57}; 55};
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index b73e7d5bbd..1d56db7dd2 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -16,7 +16,6 @@ struct unpack_event_args_visitor
16{ 16{
17 mutable OutputIterator sink; 17 mutable OutputIterator sink;
18 Context const* context; 18 Context const* context;
19 std::string arg_type;
20 attributes::type_def const& type; 19 attributes::type_def const& type;
21 20
22 typedef unpack_event_args_visitor<OutputIterator, Context> visitor_type; 21 typedef unpack_event_args_visitor<OutputIterator, Context> visitor_type;
@@ -24,6 +23,7 @@ struct unpack_event_args_visitor
24 bool operator()(grammar::attributes::regular_type_def const& regular) const 23 bool operator()(grammar::attributes::regular_type_def const& regular) const
25 { 24 {
26 std::string const& arg = "evt.Info"; 25 std::string const& arg = "evt.Info";
26 std::string arg_type = name_helpers::type_full_managed_name(regular);
27 27
28 // Structs are usually passed by pointer to events, like having a ptr<> modifier 28 // Structs are usually passed by pointer to events, like having a ptr<> modifier
29 if (type.is_ptr || regular.is_struct()) 29 if (type.is_ptr || regular.is_struct())
@@ -45,7 +45,7 @@ struct unpack_event_args_visitor
45 , {"Eina.Error", [&arg] { return "(eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(eina.Error))"; }} 45 , {"Eina.Error", [&arg] { return "(eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(eina.Error))"; }}
46 }; 46 };
47 47
48 std::string full_type_name = name_helpers::type_full_name(regular); 48 std::string full_type_name = name_helpers::type_full_eolian_name(regular);
49 auto filter_func = [&regular, &full_type_name] (match const& m) 49 auto filter_func = [&regular, &full_type_name] (match const& m)
50 { 50 {
51 return (!m.name || *m.name == regular.base_type || *m.name == full_type_name); 51 return (!m.name || *m.name == regular.base_type || *m.name == full_type_name);
@@ -61,9 +61,9 @@ struct unpack_event_args_visitor
61 else 61 else
62 return as_generator("default(" + arg_type + ")").generate(sink, attributes::unused, *context); 62 return as_generator("default(" + arg_type + ")").generate(sink, attributes::unused, *context);
63 } 63 }
64 bool operator()(grammar::attributes::klass_name const&) const 64 bool operator()(grammar::attributes::klass_name const& cls) const
65 { 65 {
66 return as_generator("new " + arg_type + "Concrete(evt.Info)").generate(sink, attributes::unused, *context); 66 return as_generator("new " + name_helpers::klass_full_concrete_name(cls) + "(evt.Info)").generate(sink, attributes::unused, *context);
67 } 67 }
68 bool operator()(attributes::complex_type_def const&) const 68 bool operator()(attributes::complex_type_def const&) const
69 { 69 {
@@ -160,9 +160,9 @@ struct event_definition_generator
160 160
161 std::string klass_name; 161 std::string klass_name;
162 if (is_inherited_event) 162 if (is_inherited_event)
163 klass_name = name_helpers::klass_get_full_name(klass); 163 klass_name = name_helpers::klass_full_interface_name(klass);
164 else 164 else
165 klass_name = klass.eolian_name; 165 klass_name = name_helpers::klass_interface_name(klass);
166 166
167 167
168 std::string upper_c_name = utils::to_uppercase(evt.c_name); 168 std::string upper_c_name = utils::to_uppercase(evt.c_name);
@@ -177,19 +177,18 @@ struct event_definition_generator
177 { 177 {
178 wrapper_args_type = name_helpers::managed_event_args_name(evt); 178 wrapper_args_type = name_helpers::managed_event_args_name(evt);
179 wrapper_args_template = "<" + wrapper_args_type + ">"; 179 wrapper_args_template = "<" + wrapper_args_type + ">";
180 std::string arg_type = wrapper_args_type + " args = new " + wrapper_args_type + "();\n"; // = (*etype).original_type.visit(get_csharp_type_visitor{}); 180 std::string arg_initializer = wrapper_args_type + " args = new " + wrapper_args_type + "();\n"; // = (*etype).original_type.visit(get_csharp_type_visitor{});
181 std::string actual_arg_type = (*etype).original_type.visit(name_helpers::get_csharp_type_visitor{});
182 181
183 arg_type += " args.arg = "; 182 arg_initializer += " args.arg = ";
184 183
185 auto arg_type_sink = std::back_inserter(arg_type); 184 auto arg_initializer_sink = std::back_inserter(arg_initializer);
186 185
187 if (!(*etype).original_type.visit(unpack_event_args_visitor<decltype(arg_type_sink), Context>{arg_type_sink, &context, actual_arg_type, *etype})) 186 if (!(*etype).original_type.visit(unpack_event_args_visitor<decltype(arg_initializer_sink), Context>{arg_initializer_sink, &context, *etype}))
188 return false; 187 return false;
189 188
190 arg_type += ";\n"; 189 arg_initializer += ";\n";
191 190
192 event_args = arg_type; 191 event_args = arg_initializer;
193 } 192 }
194 193
195 // Wrapper event declaration 194 // Wrapper event declaration
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index bf7d15e36a..b5553489c8 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -10,6 +10,7 @@
10#include "grammar/list.hpp" 10#include "grammar/list.hpp"
11#include "grammar/alternative.hpp" 11#include "grammar/alternative.hpp"
12#include "grammar/attribute_reorder.hpp" 12#include "grammar/attribute_reorder.hpp"
13#include "logging.hh"
13#include "type.hh" 14#include "type.hh"
14#include "name_helpers.hh" 15#include "name_helpers.hh"
15#include "helpers.hh" 16#include "helpers.hh"
@@ -30,6 +31,7 @@ struct native_function_definition_generator
30 template <typename OutputIterator, typename Context> 31 template <typename OutputIterator, typename Context>
31 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
32 { 33 {
34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
33 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods. 35 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods.
34 return true; 36 return true;
35 else 37 else
@@ -69,6 +71,8 @@ struct native_function_definition_generator
69 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 71 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
70 return false; 72 return false;
71 73
74 std::string klass_inherit_name = name_helpers::klass_inherit_name(*klass);
75
72 if(!as_generator 76 if(!as_generator
73 (scope_tab 77 (scope_tab
74 << " private static " 78 << " private static "
@@ -85,7 +89,7 @@ struct native_function_definition_generator
85 << scope_tab << scope_tab << "if(wrapper != null) {\n" 89 << scope_tab << scope_tab << "if(wrapper != null) {\n"
86 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() 90 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
87 << scope_tab << scope_tab << scope_tab << "try {\n" 91 << scope_tab << scope_tab << scope_tab << "try {\n"
88 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << string << "Inherit)wrapper)." << string 92 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << klass_inherit_name << ")wrapper)." << string
89 << "(" << (native_argument_invocation % ", ") << ");\n" 93 << "(" << (native_argument_invocation % ", ") << ");\n"
90 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" 94 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
91 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 95 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
@@ -94,18 +98,18 @@ struct native_function_definition_generator
94 << eolian_mono::native_function_definition_epilogue(*klass) 98 << eolian_mono::native_function_definition_epilogue(*klass)
95 << scope_tab << scope_tab << "} else {\n" 99 << scope_tab << scope_tab << "} else {\n"
96 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string 100 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string
97 << "(efl.eo.Globals.efl_super(obj, " << string << "Inherit.klass)" << *(", " << argument) << ");\n" 101 << "(efl.eo.Globals.efl_super(obj, " << klass_inherit_name << ".klass)" << *(", " << argument) << ");\n"
98 << scope_tab << scope_tab << "}\n" 102 << scope_tab << scope_tab << "}\n"
99 << scope_tab << "}\n" 103 << scope_tab << "}\n"
100 ) 104 )
101 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters 105 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters
102 , /***/f.c_name/***/ 106 , /***/f.c_name/***/
103 , f 107 , f
104 , klass->cxx_name, managed_method_name(f.name) 108 , managed_method_name(f.name)
105 , f.parameters 109 , f.parameters
106 , f 110 , f
107 , f.c_name 111 , f.c_name
108 , klass->cxx_name, f.parameters 112 , f.parameters
109 ) 113 )
110 , context)) 114 , context))
111 return false; 115 return false;
@@ -114,10 +118,9 @@ struct native_function_definition_generator
114 (scope_tab << "private static " 118 (scope_tab << "private static "
115 << string 119 << string
116 << "_delegate " 120 << "_delegate "
117 << string << "_static_delegate = new " << string << "_delegate(" << string << "NativeInherit." << string << ");\n" 121 << string << "_static_delegate = new " << string << "_delegate(" << name_helpers::klass_native_inherit_name(*klass) << "." << string << ");\n"
118 ) 122 )
119 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, klass->cxx_name 123 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, escape_keyword(f.name)), context))
120 , escape_keyword(f.name)), context))
121 return false; 124 return false;
122 return true; 125 return true;
123 } 126 }
@@ -133,6 +136,7 @@ struct function_definition_generator
133 template <typename OutputIterator, typename Context> 136 template <typename OutputIterator, typename Context>
134 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 137 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
135 { 138 {
139 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl;
136 if(do_super && f.is_static) // Static methods goes only on Concrete classes. 140 if(do_super && f.is_static) // Static methods goes only on Concrete classes.
137 return true; 141 return true;
138 if(blacklist::is_function_blacklisted(f.c_name)) 142 if(blacklist::is_function_blacklisted(f.c_name))
@@ -166,7 +170,7 @@ struct function_definition_generator
166 << ") {\n " 170 << ") {\n "
167 << eolian_mono::function_definition_preamble() << string << "(" 171 << eolian_mono::function_definition_preamble() << string << "("
168 << (do_super ? "efl.eo.Globals.efl_super(" : "") 172 << (do_super ? "efl.eo.Globals.efl_super(" : "")
169 << (f.is_static ? name_helpers::klass_get_name(f.klass) + "()": "this.raw_handle") 173 << (f.is_static ? name_helpers::klass_get_full_name(f.klass) + "()": "this.raw_handle")
170 << (do_super ? ", this.raw_klass)" : "") 174 << (do_super ? ", this.raw_klass)" : "")
171 << *(", " << argument_invocation ) << ");\n" 175 << *(", " << argument_invocation ) << ");\n"
172 << eolian_mono::function_definition_epilogue() 176 << eolian_mono::function_definition_epilogue()
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 44c7458fcc..f373a13121 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -13,36 +13,30 @@
13namespace eolian_mono { 13namespace eolian_mono {
14 14
15// Blacklist structs that require some kind of manual binding. 15// Blacklist structs that require some kind of manual binding.
16static bool is_function_ptr_blacklisted(attributes::function_def const& func, std::vector<std::string> const &namesp) 16static bool is_function_ptr_blacklisted(attributes::function_def const& func)
17{ 17{
18 std::stringstream full_name; 18 std::string name = name_helpers::function_ptr_full_eolian_name(func);
19
20 for (auto&& i : namesp)
21 full_name << i << ".";
22 full_name << func.name;
23
24 std::string name = full_name.str();
25 19
26 return false; 20 return false;
27} 21}
28 22
29struct function_pointer { 23struct function_pointer {
30 template <typename OutputIterator, typename Context> 24 template <typename OutputIterator, typename Context>
31 bool generate(OutputIterator sink, attributes::function_def const& f, std::vector<std::string> const &namesp, Context const& context) const 25 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
32 { 26 {
27 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_pointer_generator: " << f.name << std::endl;
33 // FIXME export Typedecl in eolian_cxx API 28 // FIXME export Typedecl in eolian_cxx API
34 std::vector<std::string> namespaces = name_helpers::escape_namespace(namesp);
35 auto funcptr_ctx = context_add_tag(class_context{class_context::function_ptr}, context); 29 auto funcptr_ctx = context_add_tag(class_context{class_context::function_ptr}, context);
36 30
37 std::string return_type; 31 std::string return_type;
38 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 32 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
39 return false; 33 return false;
40 34
41 if (is_function_ptr_blacklisted(f, namesp)) 35 if (is_function_ptr_blacklisted(f))
42 return true; 36 return true;
43 37
44 auto open_namespace = *("namespace " << string << " {") << "\n"; 38 if (!name_helpers::open_namespaces(sink, f.namespaces, funcptr_ctx))
45 if(!as_generator(open_namespace).generate(sink, namespaces, add_lower_case_context(funcptr_ctx))) return false; 39 return false;
46 40
47 // C# visible delegate 41 // C# visible delegate
48 if (!as_generator(documentation 42 if (!as_generator(documentation
@@ -103,8 +97,8 @@ struct function_pointer {
103 ).generate(sink, std::make_tuple(f.return_type, f.parameters, f, f.parameters, f, f.return_type, f.return_type, f.parameters, f_name, f_name, f, f.parameters, f), funcptr_ctx)) 97 ).generate(sink, std::make_tuple(f.return_type, f.parameters, f, f.parameters, f, f.return_type, f.return_type, f.parameters, f_name, f_name, f, f.parameters, f), funcptr_ctx))
104 return false; 98 return false;
105 99
106 auto close_namespace = *(lit("} ")) << "\n"; 100 if (!name_helpers::close_namespaces(sink, f.namespaces, funcptr_ctx))
107 if(!as_generator(close_namespace).generate(sink, namespaces, funcptr_ctx)) return false; 101 return false;
108 102
109 return true; 103 return true;
110 } 104 }
diff --git a/src/bin/eolian_mono/eolian/mono/function_registration.hh b/src/bin/eolian_mono/eolian/mono/function_registration.hh
index a653a3d98c..22fc42599b 100644
--- a/src/bin/eolian_mono/eolian/mono/function_registration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_registration.hh
@@ -10,6 +10,7 @@
10#include "grammar/list.hpp" 10#include "grammar/list.hpp"
11#include "grammar/alternative.hpp" 11#include "grammar/alternative.hpp"
12#include "grammar/attribute_reorder.hpp" 12#include "grammar/attribute_reorder.hpp"
13#include "logging.hh"
13#include "type.hh" 14#include "type.hh"
14#include "marshall_type.hh" 15#include "marshall_type.hh"
15#include "parameter.hh" 16#include "parameter.hh"
@@ -28,6 +29,7 @@ struct function_registration_generator
28 template <typename OutputIterator, typename Context> 29 template <typename OutputIterator, typename Context>
29 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 30 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
30 { 31 {
32 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_registration_generator: " << f.name << std::endl;
31 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Static methods aren't overrideable 33 if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Static methods aren't overrideable
32 return true; 34 return true;
33 else 35 else
@@ -40,9 +42,9 @@ struct function_registration_generator
40#else 42#else
41 (scope_tab << scope_tab << "descs[" << index << "].api_func = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, \"" << string << "\");\n" 43 (scope_tab << scope_tab << "descs[" << index << "].api_func = efl.eo.Globals.dlsym(efl.eo.Globals.RTLD_DEFAULT, \"" << string << "\");\n"
42#endif 44#endif
43 << scope_tab << scope_tab << "descs[" << index << "].func = Marshal.GetFunctionPointerForDelegate(" << string << "NativeInherit." << string << "_static_delegate);\n" 45 << scope_tab << scope_tab << "descs[" << index << "].func = Marshal.GetFunctionPointerForDelegate(" << name_helpers::klass_native_inherit_name(*klass) << "." << string << "_static_delegate);\n"
44 ) 46 )
45 .generate(sink, std::make_tuple(f.c_name, klass->cxx_name, f.c_name), context)) 47 .generate(sink, std::make_tuple(f.c_name, f.c_name), context))
46 return false; 48 return false;
47 return true; 49 return true;
48 } 50 }
diff --git a/src/bin/eolian_mono/eolian/mono/helpers.hh b/src/bin/eolian_mono/eolian/mono/helpers.hh
index 9af594191d..40a99915ab 100644
--- a/src/bin/eolian_mono/eolian/mono/helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/helpers.hh
@@ -48,7 +48,7 @@ inline bool need_pointer_conversion(attributes::regular_type_def const* regular)
48 return false; 48 return false;
49 49
50 if (regular->is_enum() 50 if (regular->is_enum()
51 || (regular->is_struct() && name_helpers::type_full_name(*regular) != "Eina.Binbuf") 51 || (regular->is_struct() && name_helpers::type_full_eolian_name(*regular) != "Eina.Binbuf")
52 ) 52 )
53 return true; 53 return true;
54 54
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index cc347b7765..7f67dddc08 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -30,15 +30,15 @@
30namespace eolian_mono { 30namespace eolian_mono {
31 31
32template <typename OutputIterator, typename Context> 32template <typename OutputIterator, typename Context>
33static bool generate_static_cast_method(OutputIterator sink, const std::string &class_name, Context const &context) 33static bool generate_static_cast_method(OutputIterator sink, grammar::attributes::klass_def const& cls, Context const &context)
34{ 34{
35 return as_generator( 35 return as_generator(
36 scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n" 36 scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n"
37 << scope_tab << "public static " << class_name << " static_cast(efl.Object obj)\n" 37 << scope_tab << "public static " << name_helpers::klass_interface_name(cls) << " static_cast(efl.Object obj)\n"
38 << scope_tab << "{\n" 38 << scope_tab << "{\n"
39 << scope_tab << scope_tab << "if (obj == null)\n" 39 << scope_tab << scope_tab << "if (obj == null)\n"
40 << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n" 40 << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n"
41 << scope_tab << scope_tab << "return new " << class_name << "Concrete(obj.raw_handle);\n" 41 << scope_tab << scope_tab << "return new " << name_helpers::klass_concrete_name(cls) << "(obj.raw_handle);\n"
42 << scope_tab << "}\n" 42 << scope_tab << "}\n"
43 ).generate(sink, nullptr, context); 43 ).generate(sink, nullptr, context);
44} 44}
@@ -91,6 +91,7 @@ struct klass
91 template <typename OutputIterator, typename Context> 91 template <typename OutputIterator, typename Context>
92 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const 92 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const
93 { 93 {
94 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "klass_generator: " << cls.eolian_name << std::endl;
94 std::string suffix, class_type; 95 std::string suffix, class_type;
95 switch(cls.type) 96 switch(cls.type)
96 { 97 {
@@ -109,9 +110,9 @@ struct klass
109 break; 110 break;
110 } 111 }
111 112
112 std::vector<std::string> namespaces = name_helpers::escape_namespace(cls.namespaces); 113 if (!name_helpers::open_namespaces(sink, cls.namespaces, context))
113 auto open_namespace = *("namespace " << string << " { ") << "\n"; 114 return false;
114 if(!as_generator(open_namespace).generate(sink, namespaces, add_lower_case_context(context))) return false; 115
115 auto methods = cls.get_all_methods(); 116 auto methods = cls.get_all_methods();
116 117
117 // Interface class 118 // Interface class
@@ -130,25 +131,25 @@ struct klass
130 for(auto first = std::begin(cls.immediate_inherits) 131 for(auto first = std::begin(cls.immediate_inherits)
131 , last = std::end(cls.immediate_inherits); first != last; ++first) 132 , last = std::end(cls.immediate_inherits); first != last; ++first)
132 { 133 {
133 if(!as_generator("\n" << scope_tab << *(lower_case[string] << ".") << string << " ,") 134 if(!as_generator("\n" << scope_tab << string << " ,").generate(sink, name_helpers::klass_full_interface_name(*first), iface_cxt))
134 .generate(sink, std::make_tuple(name_helpers::escape_namespace(first->namespaces), first->eolian_name), iface_cxt))
135 return false; 135 return false;
136 // if(std::next(first) != last)
137 // *sink++ = ',';
138 } 136 }
139 // if(cls.immediate_inherits.empty())
140 if(!as_generator("\n" << scope_tab << "efl.eo.IWrapper, IDisposable").generate(sink, attributes::unused, iface_cxt)) return false;
141 if(!as_generator("\n{\n").generate(sink, attributes::unused, iface_cxt)) return false;
142
143 if(!as_generator(*(scope_tab << function_declaration))
144 .generate(sink, cls.functions, iface_cxt)) return false;
145 137
146 if (!as_generator(*(event_declaration)).generate(sink, cls.events, iface_cxt)) 138 if(!as_generator("\n" << scope_tab << "efl.eo.IWrapper, IDisposable").generate(sink, attributes::unused, iface_cxt))
139 return false;
140
141 if(!as_generator("\n{\n").generate(sink, attributes::unused, iface_cxt))
142 return false;
143
144 if(!as_generator(*(scope_tab << function_declaration)).generate(sink, cls.functions, iface_cxt))
145 return false;
146
147 if(!as_generator(*(event_declaration)).generate(sink, cls.events, iface_cxt))
147 return false; 148 return false;
148 149
149 for (auto &&p : cls.parts) 150 for (auto &&p : cls.parts)
150 if (!as_generator( 151 if (!as_generator(
151 name_helpers::klass_name_to_csharp(p.klass) << " " << utils::capitalize(p.name) << "{ get;}\n" 152 name_helpers::klass_full_interface_name(p.klass) << " " << utils::capitalize(p.name) << "{ get;}\n"
152 ).generate(sink, attributes::unused, iface_cxt)) 153 ).generate(sink, attributes::unused, iface_cxt))
153 return false; 154 return false;
154 155
@@ -156,15 +157,16 @@ struct klass
156 if(!as_generator("}\n").generate(sink, attributes::unused, iface_cxt)) return false; 157 if(!as_generator("}\n").generate(sink, attributes::unused, iface_cxt)) return false;
157 } 158 }
158 159
159 auto class_get_name = *(lower_case[string] << "_") << lower_case[string] << "_class_get";
160 // Concrete class 160 // Concrete class
161 // if(class_type == "class") 161 // if(class_type == "class")
162 { 162 {
163 auto concrete_cxt = context_add_tag(class_context{class_context::concrete}, context); 163 auto concrete_cxt = context_add_tag(class_context{class_context::concrete}, context);
164 auto concrete_name = name_helpers::klass_concrete_name(cls);
165 auto interface_name = name_helpers::klass_interface_name(cls);
164 if(!as_generator 166 if(!as_generator
165 ( 167 (
166 documentation 168 documentation
167 << "sealed public class " << string << "Concrete : " << string << "\n{\n" 169 << "sealed public class " << concrete_name << " : " << interface_name << "\n{\n"
168 << scope_tab << "System.IntPtr handle;\n" 170 << scope_tab << "System.IntPtr handle;\n"
169 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n" 171 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n"
170 << scope_tab << "public System.IntPtr raw_handle {\n" 172 << scope_tab << "public System.IntPtr raw_handle {\n"
@@ -175,18 +177,18 @@ struct klass
175 << scope_tab << scope_tab << "get { return efl.eo.Globals.efl_class_get(handle); }\n" 177 << scope_tab << scope_tab << "get { return efl.eo.Globals.efl_class_get(handle); }\n"
176 << scope_tab << "}\n" 178 << scope_tab << "}\n"
177 << scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n" 179 << scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
178 << scope_tab << "public delegate void ConstructingMethod(" << string << " obj);\n" 180 << scope_tab << "public delegate void ConstructingMethod(" << interface_name << " obj);\n"
179 << scope_tab << "///<summary>Returns the pointer the unerlying Eo class object. Used internally on class methods.</summary>\n" 181 << scope_tab << "///<summary>Returns the pointer the unerlying Eo class object. Used internally on class methods.</summary>\n"
180 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename) 182 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename)
181 << ")] public static extern System.IntPtr\n" 183 << ")] public static extern System.IntPtr\n"
182 << scope_tab << scope_tab << class_get_name << "();\n" 184 << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
183 << (class_type == "class" ? "" : "/*") 185 << (class_type == "class" ? "" : "/*")
184 << scope_tab << "///<summary>Creates a new instance.</summary>\n" 186 << scope_tab << "///<summary>Creates a new instance.</summary>\n"
185 << scope_tab << "///<param>Parent instance.</param>\n" 187 << scope_tab << "///<param>Parent instance.</param>\n"
186 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n" 188 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n"
187 << scope_tab << "public " << string << "Concrete(efl.Object parent = null, ConstructingMethod init_cb=null)\n" 189 << scope_tab << "public " << concrete_name << "(efl.Object parent = null, ConstructingMethod init_cb=null)\n"
188 << scope_tab << "{\n" 190 << scope_tab << "{\n"
189 << scope_tab << scope_tab << "System.IntPtr klass = " << class_get_name << "();\n" 191 << scope_tab << scope_tab << "System.IntPtr klass = " << name_helpers::klass_get_name(cls) << "();\n"
190 << scope_tab << scope_tab << "System.IntPtr parent_ptr = System.IntPtr.Zero;\n" 192 << scope_tab << scope_tab << "System.IntPtr parent_ptr = System.IntPtr.Zero;\n"
191 << scope_tab << scope_tab << "if(parent != null)\n" 193 << scope_tab << scope_tab << "if(parent != null)\n"
192 << scope_tab << scope_tab << scope_tab << "parent_ptr = parent.raw_handle;\n" 194 << scope_tab << scope_tab << scope_tab << "parent_ptr = parent.raw_handle;\n"
@@ -200,13 +202,13 @@ struct klass
200 << scope_tab << "}\n" 202 << scope_tab << "}\n"
201 << (class_type == "class" ? "" : "*/") 203 << (class_type == "class" ? "" : "*/")
202 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n" 204 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
203 << scope_tab << "public " << string << "Concrete(System.IntPtr raw)\n" 205 << scope_tab << "public " << concrete_name << "(System.IntPtr raw)\n"
204 << scope_tab << "{\n" 206 << scope_tab << "{\n"
205 << scope_tab << scope_tab << "handle = raw;\n" 207 << scope_tab << scope_tab << "handle = raw;\n"
206 << scope_tab << scope_tab << "register_event_proxies();\n" 208 << scope_tab << scope_tab << "register_event_proxies();\n"
207 << scope_tab << "}\n" 209 << scope_tab << "}\n"
208 << scope_tab << "///<summary>Destructor.</summary>\n" 210 << scope_tab << "///<summary>Destructor.</summary>\n"
209 << scope_tab << "~" << string << "Concrete()\n" 211 << scope_tab << "~" << concrete_name << "()\n"
210 << scope_tab << "{\n" 212 << scope_tab << "{\n"
211 << scope_tab << scope_tab << "Dispose(false);\n" 213 << scope_tab << scope_tab << "Dispose(false);\n"
212 << scope_tab << "}\n" 214 << scope_tab << "}\n"
@@ -225,15 +227,10 @@ struct klass
225 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n" 227 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
226 << scope_tab << "}\n" 228 << scope_tab << "}\n"
227 ) 229 )
228 .generate(sink 230 .generate(sink, cls, concrete_cxt))
229 , std::make_tuple( cls,
230 cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name
231 , cls.cxx_name, cls.namespaces, cls.eolian_name, cls.cxx_name
232 , cls.cxx_name)
233 , concrete_cxt))
234 return false; 231 return false;
235 232
236 if (!generate_static_cast_method(sink, cls.cxx_name, concrete_cxt)) 233 if (!generate_static_cast_method(sink, cls, concrete_cxt))
237 return false; 234 return false;
238 235
239 if (!generate_equals_method(sink, concrete_cxt)) 236 if (!generate_equals_method(sink, concrete_cxt))
@@ -266,10 +263,15 @@ struct klass
266 bool cls_has_string_return = has_string_return(cls); 263 bool cls_has_string_return = has_string_return(cls);
267 bool cls_has_stringshare_return = has_stringshare_return(cls); 264 bool cls_has_stringshare_return = has_stringshare_return(cls);
268 265
266 auto interface_name = name_helpers::klass_interface_name(cls);
267 auto inherit_name = name_helpers::klass_inherit_name(cls);
268 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
269
270
269 if(!as_generator 271 if(!as_generator
270 ( 272 (
271 documentation 273 documentation
272 << "public " << class_type << " " << string << "Inherit : " << string << "\n{\n" 274 << "public " << class_type << " " << inherit_name << " : " << interface_name << "\n{\n"
273 << scope_tab << "System.IntPtr handle;\n" 275 << scope_tab << "System.IntPtr handle;\n"
274 << scope_tab << "internal static System.IntPtr klass = System.IntPtr.Zero;\n" 276 << scope_tab << "internal static System.IntPtr klass = System.IntPtr.Zero;\n"
275 << scope_tab << "private static readonly object klassAllocLock = new object();\n" 277 << scope_tab << "private static readonly object klassAllocLock = new object();\n"
@@ -284,20 +286,19 @@ struct klass
284 << scope_tab << scope_tab << "get { return klass; }\n" 286 << scope_tab << scope_tab << "get { return klass; }\n"
285 << scope_tab << "}\n" 287 << scope_tab << "}\n"
286 << scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n" 288 << scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
287 << scope_tab << "public delegate void ConstructingMethod(" << string << " obj);\n" 289 << scope_tab << "public delegate void ConstructingMethod(" << interface_name << " obj);\n"
288 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(inherit_cxt).actual_library_name(cls.filename) 290 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(inherit_cxt).actual_library_name(cls.filename)
289 << ")] private static extern System.IntPtr\n" 291 << ")] private static extern System.IntPtr\n"
290 << scope_tab << scope_tab << class_get_name << "();\n" 292 << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
291 << scope_tab << "///<summary>Creates a new instance.</summary>\n" 293 << scope_tab << "///<summary>Creates a new instance.</summary>\n"
292 << scope_tab << "///<param>Parent instance.</param>\n" 294 << scope_tab << "///<param>Parent instance.</param>\n"
293 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n" 295 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n"
294 << scope_tab << "public " << string << "Inherit(efl.Object parent = null, ConstructingMethod init_cb=null)\n" 296 << scope_tab << "public " << inherit_name << "(efl.Object parent = null, ConstructingMethod init_cb=null)\n"
295 << scope_tab << "{\n" 297 << scope_tab << "{\n"
296 << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n" 298 << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n"
297 << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n" 299 << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n"
298 << scope_tab << scope_tab << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n" 300 << scope_tab << scope_tab << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n"
299 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "klass = efl.eo.Globals.register_class(new efl.eo.Globals.class_initializer(" << string << "NativeInherit.class_initializer), \"" << string << "\", " << class_get_name << "());\n" 301 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "klass = efl.eo.Globals.register_class(new efl.eo.Globals.class_initializer(" << native_inherit_name << ".class_initializer), \"" << cls.eolian_name << "\", " << name_helpers::klass_get_name(cls) << "());\n"
300 //<< scope_tab << scope_tab << "klass = efl.eo.Globals.register_class(null/*new efl.eo.Globals.class_initializer(" << string << "NativeInherit.class_initializer)*/, " << class_get_name << "());\n"
301 << scope_tab << scope_tab << scope_tab << scope_tab << "}\n" 302 << scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
302 << scope_tab << scope_tab << scope_tab << "}\n" 303 << scope_tab << scope_tab << scope_tab << "}\n"
303 << scope_tab << scope_tab << "}\n" 304 << scope_tab << scope_tab << "}\n"
@@ -311,7 +312,7 @@ struct klass
311 << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" 312 << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
312 << scope_tab << "}\n" 313 << scope_tab << "}\n"
313 << scope_tab << "///<summary>Destructor.</summary>\n" 314 << scope_tab << "///<summary>Destructor.</summary>\n"
314 << scope_tab << "~" << string << "Inherit()\n" 315 << scope_tab << "~" << inherit_name << "()\n"
315 << scope_tab << "{\n" 316 << scope_tab << "{\n"
316 << scope_tab << scope_tab << "Dispose(false);\n" 317 << scope_tab << scope_tab << "Dispose(false);\n"
317 << scope_tab << "}\n" 318 << scope_tab << "}\n"
@@ -332,15 +333,7 @@ struct klass
332 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n" 333 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
333 << scope_tab << "}\n" 334 << scope_tab << "}\n"
334 ) 335 )
335 .generate(sink 336 .generate(sink, cls, inherit_cxt))
336 , std::make_tuple(
337 cls, cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name
338 , cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name, cls.cxx_name
339 , cls.cxx_name)
340 , inherit_cxt))
341 return false;
342
343 if (!generate_static_cast_method(sink, cls.cxx_name, inherit_cxt))
344 return false; 337 return false;
345 338
346 if (!generate_equals_method(sink, inherit_cxt)) 339 if (!generate_equals_method(sink, inherit_cxt))
@@ -375,14 +368,15 @@ struct klass
375 if(class_type == "class") 368 if(class_type == "class")
376 { 369 {
377 auto inative_cxt = context_add_tag(class_context{class_context::inherit_native}, context); 370 auto inative_cxt = context_add_tag(class_context{class_context::inherit_native}, context);
371 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
378 if(!as_generator 372 if(!as_generator
379 ( 373 (
380 "internal " << class_type << " " << string << "NativeInherit {\n" 374 "internal " << class_type << " " << native_inherit_name << " {\n"
381 << scope_tab << "public static byte class_initializer(IntPtr klass)\n" 375 << scope_tab << "public static byte class_initializer(IntPtr klass)\n"
382 << scope_tab << "{\n" 376 << scope_tab << "{\n"
383 << scope_tab << scope_tab << "Efl_Op_Description[] descs = new Efl_Op_Description[" << grammar::int_ << "];\n" 377 << scope_tab << scope_tab << "Efl_Op_Description[] descs = new Efl_Op_Description[" << grammar::int_ << "];\n"
384 ) 378 )
385 .generate(sink, std::make_tuple(cls.cxx_name, function_count), inative_cxt)) 379 .generate(sink, function_count, inative_cxt))
386 return false; 380 return false;
387 381
388 // Native wrapper registration 382 // Native wrapper registration
@@ -404,22 +398,22 @@ struct klass
404 << scope_tab << scope_tab << "Marshal.StructureToPtr(ops, ops_ptr, false);\n" 398 << scope_tab << scope_tab << "Marshal.StructureToPtr(ops, ops_ptr, false);\n"
405 << scope_tab << scope_tab << "efl.eo.Globals.efl_class_functions_set(klass, ops_ptr, IntPtr.Zero);\n" 399 << scope_tab << scope_tab << "efl.eo.Globals.efl_class_functions_set(klass, ops_ptr, IntPtr.Zero);\n"
406 ).generate(sink, attributes::unused, inative_cxt)) return false; 400 ).generate(sink, attributes::unused, inative_cxt)) return false;
407 401
408 402
409 if(!as_generator(scope_tab << scope_tab << "return 1;\n" 403 if(!as_generator(scope_tab << scope_tab << "return 1;\n"
410 << scope_tab << "}\n") 404 << scope_tab << "}\n")
411 .generate(sink, attributes::unused, inative_cxt)) return false; 405 .generate(sink, attributes::unused, inative_cxt)) return false;
412 406 //
413 // Native method definitions 407 // Native method definitions
414 if(!as_generator(*(native_function_definition(cls))) 408 if(!as_generator(*(native_function_definition(cls)))
415 .generate(sink, methods, inative_cxt)) return false; 409 .generate(sink, methods, inative_cxt)) return false;
416 410
417 if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false; 411 if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false;
418 } 412 }
419 413
420 auto close_namespace = *(lit("} ")) << "\n"; 414 if(!name_helpers::close_namespaces(sink, cls.namespaces, context))
421 if(!as_generator(close_namespace).generate(sink, namespaces, context)) return false; 415 return false;
422 416
423 return true; 417 return true;
424 } 418 }
425 419
diff --git a/src/bin/eolian_mono/eolian/mono/logging.hh b/src/bin/eolian_mono/eolian/mono/logging.hh
new file mode 100644
index 0000000000..d13c3957ad
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/logging.hh
@@ -0,0 +1,12 @@
1#ifndef EOLIAN_MONO_LOGGING_HH
2#define EOLIAN_MONO_LOGGING_HH
3
4#include <Eina.hh>
5
6namespace eolian_mono {
7
8efl::eina::log_domain domain("eolian_mono");
9
10}
11
12#endif
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
index 4516b97453..576ccdb4c9 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
@@ -144,12 +144,10 @@ struct marshall_annotation_visitor_generate
144 { 144 {
145 const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; 145 const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<";
146 const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; 146 const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<";
147 std::vector<std::string> namespaces = name_helpers::escape_namespace(klass_name.namespaces);
148 return as_generator 147 return as_generator
149 ((is_return ? return_prefix : no_return_prefix) 148 ((is_return ? return_prefix : no_return_prefix)
150 << *(lower_case[string] << ".") << string 149 << string << ", efl.eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
151 << "Concrete, efl.eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]" 150 ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
152 ).generate(sink, std::make_tuple(namespaces, klass_name.eolian_name), *context);
153 } 151 }
154 bool operator()(attributes::complex_type_def const&) const 152 bool operator()(attributes::complex_type_def const&) const
155 { 153 {
@@ -251,12 +249,10 @@ struct marshall_native_annotation_visitor_generate
251 { 249 {
252 const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; 250 const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<";
253 const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<"; 251 const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(efl.eo.MarshalTest<";
254 std::vector<std::string> namespaces = name_helpers::escape_namespace(klass_name.namespaces);
255 return as_generator 252 return as_generator
256 ((is_return ? return_prefix : no_return_prefix) 253 ((is_return ? return_prefix : no_return_prefix)
257 << *(lower_case[string] << ".") << string 254 << string << ", efl.eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
258 << "Concrete, efl.eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]" 255 ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
259 ).generate(sink, std::make_tuple(namespaces, klass_name.eolian_name), *context);
260 } 256 }
261 bool operator()(attributes::complex_type_def const&) const 257 bool operator()(attributes::complex_type_def const&) const
262 { 258 {
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
index ee9659c6b1..38dbbcb48c 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
@@ -160,8 +160,8 @@ struct marshall_type_visitor_generate
160 { 160 {
161 if ((is_out || is_return) && is_ptr) 161 if ((is_out || is_return) && is_ptr)
162 return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context); 162 return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
163 return as_generator(*(lower_case[string] << ".") << string << "_StructInternal") 163 return as_generator(string << "_StructInternal")
164 .generate(sink, std::make_tuple(name_helpers::escape_namespace(regular.namespaces), regular.base_type), *context); 164 .generate(sink, name_helpers::type_full_managed_name(regular), *context);
165 } 165 }
166 else if (eina::optional<bool> b = call_match 166 else if (eina::optional<bool> b = call_match
167 (match_table 167 (match_table
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 4dffb9893a..59d6b59b18 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -12,6 +12,14 @@
12#include "grammar/integral.hpp" 12#include "grammar/integral.hpp"
13#include "grammar/generator.hpp" 13#include "grammar/generator.hpp"
14#include "grammar/klass_def.hpp" 14#include "grammar/klass_def.hpp"
15#include "grammar/list.hpp"
16#include "grammar/string.hpp"
17#include "grammar/integral.hpp"
18
19using efl::eolian::grammar::as_generator;
20using efl::eolian::grammar::string;
21using efl::eolian::grammar::lit;
22using efl::eolian::grammar::operator*;
15 23
16namespace eolian_mono { 24namespace eolian_mono {
17 25
@@ -30,6 +38,11 @@ inline bool is_iequal(std::string const& lhs, std::string const& rhs)
30} 38}
31} 39}
32 40
41inline std::string identity(std::string const& str)
42{
43 return str;
44}
45
33inline std::string escape_keyword(std::string const& name) 46inline std::string escape_keyword(std::string const& name)
34{ 47{
35 using detail::is_iequal; 48 using detail::is_iequal;
@@ -51,20 +64,10 @@ inline std::string escape_keyword(std::string const& name)
51 return name; 64 return name;
52} 65}
53 66
54inline std::vector<std::string> escape_namespace(std::vector<std::string> namespaces) 67typedef std::function<std::string(std::string const&)> string_transform_func;
55{
56 // if(namespaces.empty())
57 // namespaces.push_back("nonamespace");
58 // else
59 {
60 for(auto&& i : namespaces)
61 i = escape_keyword(i);
62 }
63 return namespaces;
64}
65 68
66inline std::string get_namespaces(std::vector<std::string> const& namespaces, char separator, 69inline std::string join_namespaces(std::vector<std::string> const& namespaces, char separator,
67 std::function<std::string(std::string const&)> func=[] (std::string const& c) { return c; }) 70 string_transform_func func=identity)
68{ 71{
69 std::stringstream s; 72 std::stringstream s;
70 for (auto&& n : namespaces) 73 for (auto&& n : namespaces)
@@ -73,12 +76,6 @@ inline std::string get_namespaces(std::vector<std::string> const& namespaces, ch
73 return s.str(); 76 return s.str();
74} 77}
75 78
76inline std::string get_namespaces(attributes::klass_def const& klass, char separator,
77 std::function<std::string(std::string const&)> func=[] (std::string const& c) { return c; })
78{
79 return get_namespaces(klass.namespaces, separator, func);
80}
81
82static const std::vector<std::string> verbs = 79static const std::vector<std::string> verbs =
83 { 80 {
84 "add", 81 "add",
@@ -170,16 +167,9 @@ void reorder_verb(std::vector<std::string> &names)
170 } 167 }
171} 168}
172 169
173inline std::string klass_name_to_csharp(attributes::klass_name const& clsname) 170inline std::string managed_namespace(std::string const& ns)
174{ 171{
175 std::ostringstream output; 172 return utils::to_lowercase(escape_keyword(ns));
176
177 for (auto namesp : clsname.namespaces)
178 output << utils::to_lowercase(namesp) << ".";
179
180 output << clsname.eolian_name;
181
182 return output.str();
183} 173}
184 174
185inline std::string managed_method_name(std::string const& underscore_name) 175inline std::string managed_method_name(std::string const& underscore_name)
@@ -191,110 +181,112 @@ inline std::string managed_method_name(std::string const& underscore_name)
191 return escape_keyword(utils::to_pascal_case(names)); 181 return escape_keyword(utils::to_pascal_case(names));
192} 182}
193 183
194inline std::string managed_event_name(std::string const& name) 184inline std::string function_ptr_full_eolian_name(attributes::function_def const& func)
195{ 185{
196 return utils::to_pascal_case(utils::split(name, ','), "") + "Evt"; 186 return join_namespaces(func.namespaces, '.') + func.name;
197} 187}
198 188
199inline std::string managed_event_args_short_name(attributes::event_def evt) 189inline std::string type_full_eolian_name(attributes::regular_type_def const& type)
200{ 190{
201 return name_helpers::managed_event_name(evt.name) + "_Args"; 191 return join_namespaces(type.namespaces, '.') + type.base_type;
202} 192}
203 193
204inline std::string managed_event_args_name(attributes::event_def evt) 194inline std::string type_full_managed_name(attributes::regular_type_def const& type)
205{ 195{
206 std::string prefix = name_helpers::klass_name_to_csharp(evt.klass); 196 return join_namespaces(type.namespaces, '.', managed_namespace) + type.base_type;
207 return prefix + "Concrete." + managed_event_args_short_name(evt);
208} 197}
209 198
210inline std::string translate_inherited_event_name(const attributes::event_def &evt, const attributes::klass_def &klass) 199inline std::string struct_full_eolian_name(attributes::struct_def const& struct_)
211{ 200{
212 std::stringstream s; 201 return join_namespaces(struct_.namespaces, '.') + struct_.cxx_name;
202}
213 203
214 for (auto&& n : klass.namespaces) 204inline std::string to_field_name(std::string const& in)
215 { 205{
216 s << n; 206 return utils::capitalize(in);
217 s << '_';
218 }
219 s << klass.cxx_name << '_' << managed_event_name(evt.name);
220 return s.str();
221} 207}
222 208
223inline std::string type_full_name(attributes::regular_type_def const& type) 209// Class name translation (interface/concrete/inherit/etc)
210template<typename T>
211inline std::string klass_interface_name(T const& klass)
224{ 212{
225 std::string full_name; 213 return klass.eolian_name;
226 for (auto& name : type.namespaces)
227 {
228 full_name += name + ".";
229 }
230 full_name += type.base_type;
231 return full_name;
232} 214}
233 215
234inline std::string struct_full_name(attributes::struct_def const& struct_) 216template<typename T>
217inline std::string klass_full_interface_name(T const& klass)
235{ 218{
236 std::string full_name; 219 return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_interface_name(klass);
237 for (auto& name : struct_.namespaces)
238 {
239 full_name += name + ".";
240 }
241 full_name += struct_.cxx_name;
242 return full_name;
243} 220}
244 221
245inline std::string to_field_name(std::string const& in) 222template<typename T>
223inline std::string klass_concrete_name(T const& klass)
246{ 224{
247 return utils::capitalize(in); 225 return klass.eolian_name + "Concrete";
248} 226}
249 227
250inline std::string klass_get_full_name(attributes::klass_def const& klass) 228template<typename T>
229inline std::string klass_full_concrete_name(T const& klass)
251{ 230{
252 std::ostringstream output; 231 return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_concrete_name(klass);
232}
253 233
254 for(auto namesp : klass.namespaces) 234template<typename T>
255 output << utils::to_lowercase(escape_keyword(namesp)) << "."; 235inline std::string klass_inherit_name(T const& klass)
236{
237 return klass.eolian_name + "Inherit";
238}
256 239
257 output << klass.eolian_name; 240template<typename T>
241inline std::string klass_native_inherit_name(T const& klass)
242{
243 return klass.eolian_name + "NativeInherit";
244}
245
246template<typename T>
247inline std::string klass_get_name(T const& clsname)
248{
249 return utils::to_lowercase(join_namespaces(clsname.namespaces, '_') + clsname.eolian_name + "_class_get");
250}
258 251
259 return output.str(); 252inline std::string klass_get_full_name(attributes::klass_name const& clsname)
253{
254 return klass_full_concrete_name(clsname) + "." + klass_get_name(clsname);
260} 255}
261 256
262inline std::string klass_get_name(attributes::klass_name const &clsname) 257// Events
258inline std::string managed_event_name(std::string const& name)
263{ 259{
264 std::ostringstream output; 260 return utils::to_pascal_case(utils::split(name, ','), "") + "Evt";
261}
265 262
266 output << klass_name_to_csharp(clsname); 263inline std::string managed_event_args_short_name(attributes::event_def const& evt)
267 output << "Concrete."; 264{
265 return name_helpers::managed_event_name(evt.name) + "_Args";
266}
268 267
269 for (auto namesp : clsname.namespaces) 268inline std::string managed_event_args_name(attributes::event_def evt)
270 output << utils::to_lowercase(namesp) << "_"; 269{
271 output << utils::to_lowercase(clsname.eolian_name); 270 return klass_full_concrete_name(evt.klass) + "." + managed_event_args_short_name(evt);
272 output << "_class_get"; 271}
273 272
274 return output.str(); 273inline std::string translate_inherited_event_name(const attributes::event_def &evt, const attributes::klass_def &klass)
274{
275 return join_namespaces(klass.namespaces, '_') + klass.cxx_name + "_" + managed_event_name(evt.name);
275} 276}
276 277
278// Type visistor
277struct get_csharp_type_visitor 279struct get_csharp_type_visitor
278{ 280{
279 typedef get_csharp_type_visitor visitor_type; 281 typedef get_csharp_type_visitor visitor_type;
280 typedef std::string result_type; 282 typedef std::string result_type;
281 std::string operator()(attributes::regular_type_def const& type) const 283 std::string operator()(attributes::regular_type_def const& type) const
282 { 284 {
283 std::stringstream csharp_name; 285 return type_full_managed_name(type);
284 for (auto&& i : escape_namespace(type.namespaces))
285 csharp_name << utils::to_lowercase(i) << ".";
286 csharp_name << type.base_type;
287
288 return csharp_name.str();
289 } 286 }
290 std::string operator()(attributes::klass_name const& name) const 287 std::string operator()(attributes::klass_name const& name) const
291 { 288 {
292 std::stringstream csharp_name; 289 return klass_full_interface_name(name);
293 for (auto&& i : escape_namespace(name.namespaces))
294 csharp_name << utils::to_lowercase(i) << ".";
295 csharp_name << name.eolian_name;
296
297 return csharp_name.str();
298 } 290 }
299 std::string operator()(attributes::complex_type_def const&) const 291 std::string operator()(attributes::complex_type_def const&) const
300 { 292 {
@@ -302,6 +294,23 @@ struct get_csharp_type_visitor
302 } 294 }
303}; 295};
304 296
297// Open/close namespaces
298template<typename OutputIterator, typename Context>
299bool open_namespaces(OutputIterator sink, std::vector<std::string> namespaces, Context context)
300{
301 std::transform(namespaces.begin(), namespaces.end(), namespaces.begin(), managed_namespace);
302
303 auto open_namespace = *("namespace " << string << " { ") << "\n";
304 return as_generator(open_namespace).generate(sink, namespaces, context);
305}
306
307template<typename OutputIterator, typename Context>
308bool close_namespaces(OutputIterator sink, std::vector<std::string> const& namespaces, Context context)
309{
310 auto close_namespace = *(lit("} ")) << "\n";
311 return as_generator(close_namespace).generate(sink, namespaces, context);
312}
313
305 314
306 315
307} // namespace name_helpers 316} // namespace name_helpers
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index 2cf472c12d..f7c97b723f 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -413,11 +413,7 @@ struct type_name_visitor
413 413
414 std::string operator()(grammar::attributes::regular_type_def const &type) const 414 std::string operator()(grammar::attributes::regular_type_def const &type) const
415 { 415 {
416 std::stringstream type_name; 416 return name_helpers::type_full_eolian_name(type);
417 for (auto&& i : escape_namespace(type.namespaces))
418 type_name << i << ".";
419 type_name << type.base_type;
420 return type_name.str();
421 } 417 }
422 418
423 template<typename T> 419 template<typename T>
@@ -1077,6 +1073,7 @@ struct native_convert_out_assign_generator
1077 template <typename OutputIterator, typename Context> 1073 template <typename OutputIterator, typename Context>
1078 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 1074 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
1079 { 1075 {
1076 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_convert_out_assign_generator: " << param.param_name << std::endl;
1080 if (param.direction == attributes::parameter_direction::in) 1077 if (param.direction == attributes::parameter_direction::in)
1081 return true; 1078 return true;
1082 1079
@@ -1095,15 +1092,25 @@ struct native_convert_out_assign_generator
1095 } 1092 }
1096 else if (param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT)) 1093 else if (param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT))
1097 { 1094 {
1095 if (klass == nullptr)
1096 {
1097 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain) << "Null class found when trying to assign out stringshare from native wrapper." << std::endl;
1098 return false;
1099 }
1098 return as_generator( 1100 return as_generator(
1099 string << "= efl.eo.Globals.cached_stringshare_to_intptr(((" << string << "Inherit)wrapper).cached_stringshares, " << string << ");\n" 1101 string << "= efl.eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, " << string << ");\n"
1100 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), klass->cxx_name, out_variable_name(param.param_name)), context); 1102 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
1101 } 1103 }
1102 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT)) 1104 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT))
1103 { 1105 {
1106 if (klass == nullptr)
1107 {
1108 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain) << "Null class found when trying to assign out string from native wrapper." << std::endl;
1109 return false;
1110 }
1104 return as_generator( 1111 return as_generator(
1105 string << "= efl.eo.Globals.cached_string_to_intptr(((" << string << "Inherit)wrapper).cached_strings, " << string << ");\n" 1112 string << "= efl.eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, " << string << ");\n"
1106 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), klass->cxx_name, out_variable_name(param.param_name)), context); 1113 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
1107 } 1114 }
1108 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT) 1115 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
1109 || param_is_acceptable(param, "Eina_Binbuf *", !WANT_OWN, WANT_OUT) 1116 || param_is_acceptable(param, "Eina_Binbuf *", !WANT_OWN, WANT_OUT)
@@ -1230,9 +1237,14 @@ struct native_convert_return_generator
1230 { 1237 {
1231 if(!ret_type.has_own) 1238 if(!ret_type.has_own)
1232 { 1239 {
1240 if (klass == nullptr)
1241 {
1242 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain) << "Null class found when trying to return string from native wrapper." << std::endl;
1243 return false;
1244 }
1233 return as_generator( 1245 return as_generator(
1234 "return efl.eo.Globals.cached_string_to_intptr(((" << string << "Inherit)wrapper).cached_strings, _ret_var);\n" 1246 "return efl.eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, _ret_var);\n"
1235 ).generate(sink, klass->cxx_name, context); 1247 ).generate(sink, attributes::unused, context);
1236 } 1248 }
1237 else 1249 else
1238 { 1250 {
@@ -1243,9 +1255,14 @@ struct native_convert_return_generator
1243 else if (ret_type.c_type == "Eina_Stringshare *") { // Correct check for string? 1255 else if (ret_type.c_type == "Eina_Stringshare *") { // Correct check for string?
1244 if (!ret_type.has_own) 1256 if (!ret_type.has_own)
1245 { 1257 {
1258 if (klass == nullptr)
1259 {
1260 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain) << "Null class found when trying to return stringshare from native wrapper." << std::endl;
1261 return false;
1262 }
1246 return as_generator( 1263 return as_generator(
1247 "return efl.eo.Globals.cached_stringshare_to_intptr(((" << string << "Inherit)wrapper).cached_stringshares, _ret_var);\n" 1264 "return efl.eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, _ret_var);\n"
1248 ).generate(sink, klass->cxx_name, context); 1265 ).generate(sink, attributes::unused, context);
1249 } 1266 }
1250 else 1267 else
1251 { 1268 {
@@ -1375,7 +1392,7 @@ struct native_convert_function_pointer_generator
1375 EINA_LOG_ERR("Failed to get function pointer info for c type [%s]", param.type.c_type.c_str()); 1392 EINA_LOG_ERR("Failed to get function pointer info for c type [%s]", param.type.c_type.c_str());
1376 return false; 1393 return false;
1377 } 1394 }
1378 attributes::function_def f(fd, EOLIAN_FUNCTION_POINTER, param.unit); 1395 attributes::function_def f(fd, EOLIAN_FUNCTION_POINTER, tpd, param.unit);
1379 1396
1380 std::string param_name = escape_keyword(param.param_name); 1397 std::string param_name = escape_keyword(param.param_name);
1381 // Allocate GCHandle in "param_name"_handle for param; 1398 // Allocate GCHandle in "param_name"_handle for param;
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh
index bb2e50f6c9..2a54ceb961 100644
--- a/src/bin/eolian_mono/eolian/mono/part_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh
@@ -18,14 +18,15 @@ struct part_definition_generator
18 template <typename OutputIterator, typename Context> 18 template <typename OutputIterator, typename Context>
19 bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const 19 bool generate(OutputIterator sink, attributes::part_def const& part, Context const& context) const
20 { 20 {
21 std::string part_klass_name = name_helpers::klass_name_to_csharp(part.klass); 21 auto part_interface_name = name_helpers::klass_full_interface_name(part.klass);
22 auto part_klass_name = name_helpers::klass_full_concrete_name(part.klass);
22 return as_generator(scope_tab << documentation 23 return as_generator(scope_tab << documentation
23 << scope_tab << "public " << part_klass_name << " " << utils::capitalize(part.name) << "\n" 24 << scope_tab << "public " << part_interface_name << " " << utils::capitalize(part.name) << "\n"
24 << scope_tab << "{\n" 25 << scope_tab << "{\n"
25 << scope_tab << scope_tab << "get\n" 26 << scope_tab << scope_tab << "get\n"
26 << scope_tab << scope_tab << "{\n" 27 << scope_tab << scope_tab << "{\n"
27 << scope_tab << scope_tab << scope_tab << "efl.Object obj = efl_part(raw_handle, \"" << part.name << "\");\n" 28 << scope_tab << scope_tab << scope_tab << "efl.Object obj = efl_part(raw_handle, \"" << part.name << "\");\n"
28 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << "Concrete.static_cast(obj);\n" 29 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
29 << scope_tab << scope_tab << "}\n" 30 << scope_tab << scope_tab << "}\n"
30 << scope_tab << "}\n" 31 << scope_tab << "}\n"
31 ).generate(sink, part.documentation, context); 32 ).generate(sink, part.documentation, context);
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index ab5db8f180..79e6ec6f1b 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -31,7 +31,7 @@ struct struct_definition_generator
31 template <typename OutputIterator, typename Context> 31 template <typename OutputIterator, typename Context>
32 bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const 32 bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const
33 { 33 {
34 34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "struct_definition_generator: " << struct_.cxx_name << std::endl;
35 if(!as_generator(documentation).generate(sink, struct_, context)) 35 if(!as_generator(documentation).generate(sink, struct_, context))
36 return false; 36 return false;
37 if(!as_generator 37 if(!as_generator
@@ -267,13 +267,15 @@ struct to_external_field_convert_generator
267 267
268 if (klass) 268 if (klass)
269 { 269 {
270 auto interface_name = name_helpers::klass_full_interface_name(*klass);
271 auto concrete_name = name_helpers::klass_full_concrete_name(*klass);
270 if (!as_generator( 272 if (!as_generator(
271 "\n" 273 "\n"
272 << scope_tab << scope_tab << "_external_struct." << string 274 << scope_tab << scope_tab << "_external_struct." << string
273 << " = (" << type << ") System.Activator.CreateInstance(typeof(" 275 << " = (" << interface_name << ") System.Activator.CreateInstance(typeof("
274 << type << "Concrete), new System.Object[] {_internal_struct." << string << "});\n" 276 << concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n"
275 << scope_tab << scope_tab << "efl.eo.Globals.efl_ref(_internal_struct." << string << ");\n\n") 277 << scope_tab << scope_tab << "efl.eo.Globals.efl_ref(_internal_struct." << string << ");\n\n")
276 .generate(sink, std::make_tuple(field_name, field.type, field.type, field_name, field_name), context)) 278 .generate(sink, std::make_tuple(field_name, field_name, field_name), context))
277 return false; 279 return false;
278 } 280 }
279 else if (field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *") 281 else if (field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
@@ -443,10 +445,8 @@ struct struct_entities_generator
443 if (blacklist::is_struct_blacklisted(struct_)) 445 if (blacklist::is_struct_blacklisted(struct_))
444 return true; 446 return true;
445 447
446 std::vector<std::string> cpp_namespaces = name_helpers::escape_namespace(attributes::cpp_namespaces(struct_.namespaces));
447 448
448 auto open_namespace = *("namespace " << string << " { ") << "\n"; 449 if (!name_helpers::open_namespaces(sink, struct_.namespaces, context))
449 if (!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context)))
450 return false; 450 return false;
451 451
452 if (!struct_definition.generate(sink, struct_, context)) 452 if (!struct_definition.generate(sink, struct_, context))
@@ -458,10 +458,8 @@ struct struct_entities_generator
458 if (!struct_binding_conversion_functions.generate(sink, struct_, context)) 458 if (!struct_binding_conversion_functions.generate(sink, struct_, context))
459 return false; 459 return false;
460 460
461 auto close_namespace = *(lit("} ")) << "\n"; 461 return name_helpers::close_namespaces(sink, struct_.namespaces, context);
462 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false;
463 462
464 return true;
465 } 463 }
466} const struct_entities {}; 464} const struct_entities {};
467 465
diff --git a/src/bin/eolian_mono/eolian/mono/type_impl.hh b/src/bin/eolian_mono/eolian/mono/type_impl.hh
index edd6cc80ed..ee44460169 100644
--- a/src/bin/eolian_mono/eolian/mono/type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/type_impl.hh
@@ -151,20 +151,7 @@ struct visitor_generate
151 { return regular_type_def{" eina.Value", regular.base_qualifier, {}}; 151 { return regular_type_def{" eina.Value", regular.base_qualifier, {}};
152 }} // FIXME add proper support for any_value_ptr 152 }} // FIXME add proper support for any_value_ptr
153 }; 153 };
154 // if(regular.base_type == "void_ptr") 154 std::string full_type_name = name_helpers::type_full_eolian_name(regular);
155 // {
156 // if(regular.base_qualifier & qualifier_info::is_ref)
157 // throw std::runtime_error("ref of void_ptr is invalid");
158 // return as_generator
159 // (
160 // lit("void") << (regular.base_qualifier & qualifier_info::is_const ? " const" : "")
161 // << "*"
162 // << (is_out ? "&" : "")
163 // )
164 // .generate(sink, attributes::unused, *context);
165 // }
166 // else
167 std::string full_type_name = name_helpers::type_full_name(regular);
168 if(eina::optional<bool> b = call_match 155 if(eina::optional<bool> b = call_match
169 (match_table 156 (match_table
170 , [&] (match const& m) 157 , [&] (match const& m)
@@ -245,40 +232,12 @@ struct visitor_generate
245 // } 232 // }
246 else 233 else
247 { 234 {
248 // as_generator(" Generating: " << *(lower_case[string] << ".") << string << "\n") 235 return as_generator(string).generate(sink, name_helpers::type_full_managed_name(regular), *context);
249 // .generate(std::ostream_iterator<char>(std::cerr), std::make_tuple(eolian_mono::escape_namespace(regular.namespaces), regular.base_type), *context);
250 if(as_generator
251 (
252 *(lower_case[string] << ".")
253 << string
254 // << (regular.base_qualifier & qualifier_info::is_const
255 // || (regular.base_qualifier & qualifier_info::is_ref
256 // && !is_return && !is_out)
257 // ? /*" const"*/ "" : "")
258 /*<< (regular.base_qualifier & qualifier_info::is_ref? "&" : "")*/
259 )
260 .generate(sink, std::make_tuple(name_helpers::escape_namespace(regular.namespaces), regular.base_type), *context))
261 return true;
262 else
263 return false;
264 } 236 }
265 } 237 }
266 bool operator()(attributes::klass_name klass) const 238 bool operator()(attributes::klass_name klass) const
267 { 239 {
268 // as_generator(" Generating: " << *(lower_case[string] << ".") << string << "\n") 240 return as_generator(string).generate(sink, name_helpers::klass_full_interface_name(klass), *context);
269 // .generate(std::ostream_iterator<char>(std::cerr), std::make_tuple(attributes::cpp_namespaces(klass.namespaces), klass.eolian_name), *context);
270 // if(klass.namespaces.size() == 1
271 // && klass.namespaces[0] == "Eina"
272 // && klass.eolian_name == "Error")
273 // return
274 // as_generator(" System.IntPtr")
275 // .generate(sink, attributes::unused, *context);
276 return
277 as_generator(*(lower_case[string] << ".") << string)
278 .generate(sink, std::make_tuple(name_helpers::escape_namespace(klass.namespaces), klass.eolian_name), *context)
279 // && (!(klass.base_qualifier & qualifier_info::is_ref)
280 // || as_generator("&").generate(sink, attributes::unused, *context))
281 ;
282 } 241 }
283 bool operator()(attributes::complex_type_def const& complex) const 242 bool operator()(attributes::complex_type_def const& complex) const
284 { 243 {
diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc
index e1b53d95ad..7f65a4fcaa 100644
--- a/src/bin/eolian_mono/eolian_mono.cc
+++ b/src/bin/eolian_mono/eolian_mono.cc
@@ -23,6 +23,7 @@
23#include <Eina.hh> 23#include <Eina.hh>
24#include <Eolian_Cxx.hh> 24#include <Eolian_Cxx.hh>
25 25
26#include <eolian/mono/logging.hh>
26#include <eolian/mono/name_helpers.hh> 27#include <eolian/mono/name_helpers.hh>
27#include <eolian/mono/klass.hh> 28#include <eolian/mono/klass.hh>
28#include <eolian/mono/enum_definition.hh> 29#include <eolian/mono/enum_definition.hh>
@@ -48,8 +49,6 @@ struct options_type
48 std::map<const std::string, std::string> references_map; 49 std::map<const std::string, std::string> references_map;
49}; 50};
50 51
51efl::eina::log_domain domain("eolian_mono");
52
53// Parses a CSV file in the format 'filename,library' (without trimming spaces around ',') 52// Parses a CSV file in the format 'filename,library' (without trimming spaces around ',')
54static std::vector<std::pair<std::string, std::string> > 53static std::vector<std::pair<std::string, std::string> >
55parse_reference(std::string filename) 54parse_reference(std::string filename)
@@ -142,19 +141,9 @@ run(options_type const& opts)
142 continue; 141 continue;
143 142
144 const Eolian_Function *fp = eolian_typedecl_function_pointer_get(tp); 143 const Eolian_Function *fp = eolian_typedecl_function_pointer_get(tp);
145 efl::eolian::grammar::attributes::function_def function_def(fp, EOLIAN_FUNCTION_POINTER, opts.unit); 144 efl::eolian::grammar::attributes::function_def function_def(fp, EOLIAN_FUNCTION_POINTER, tp, opts.unit);
146 std::vector<std::string> namespaces; 145 if (!eolian_mono::function_pointer.generate(iterator, function_def, context))
147 146 throw std::runtime_error("Failed to generate function pointer wrapper");
148 for (efl::eina::iterator<const char> namespace_iterator(::eolian_typedecl_namespaces_get(tp)), namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
149 {
150 namespaces.push_back(&*namespace_iterator);
151 }
152
153 if (!eolian_mono::function_pointer
154 .generate(iterator, function_def, eolian_mono::name_helpers::escape_namespace(namespaces), context))
155 {
156 throw std::runtime_error("Failed to generate function pointer wrapper");
157 }
158 } 147 }
159 148
160 if (klass) 149 if (klass)
@@ -168,30 +157,29 @@ run(options_type const& opts)
168 throw std::runtime_error("Failed to generate class"); 157 throw std::runtime_error("Failed to generate class");
169 } 158 }
170 } 159 }
171 //else
172 {
173 for (efl::eina::iterator<const Eolian_Typedecl> enum_iterator( ::eolian_state_enums_by_file_get(opts.state, basename_input.c_str()))
174 , enum_last; enum_iterator != enum_last; ++enum_iterator)
175 {
176 efl::eolian::grammar::attributes::enum_def enum_(&*enum_iterator, opts.unit);
177 if (!eolian_mono::enum_definition.generate(iterator, enum_, efl::eolian::grammar::context_null()))
178 {
179 throw std::runtime_error("Failed to generate enum");
180 }
181 }
182 160
183 for (efl::eina::iterator<const Eolian_Typedecl> struct_iterator( ::eolian_state_structs_by_file_get(opts.state, basename_input.c_str())) 161 // Enums
184 , struct_last; struct_iterator != struct_last; ++struct_iterator) 162 for (efl::eina::iterator<const Eolian_Typedecl> enum_iterator( ::eolian_state_enums_by_file_get(opts.state, basename_input.c_str()))
185 { 163 , enum_last; enum_iterator != enum_last; ++enum_iterator)
186 efl::eolian::grammar::attributes::struct_def struct_(&*struct_iterator, opts.unit); 164 {
187 auto structs_cxt = context_add_tag(class_context{class_context::structs}, context); 165 efl::eolian::grammar::attributes::enum_def enum_(&*enum_iterator, opts.unit);
188 if (!eolian_mono::struct_entities.generate(iterator, struct_, structs_cxt)) 166 if (!eolian_mono::enum_definition.generate(iterator, enum_, efl::eolian::grammar::context_null()))
189 { 167 {
190 throw std::runtime_error("Failed to generate struct"); 168 throw std::runtime_error("Failed to generate enum");
191 } 169 }
192 } 170 }
193 171
194 } 172 // Structs
173 for (efl::eina::iterator<const Eolian_Typedecl> struct_iterator( ::eolian_state_structs_by_file_get(opts.state, basename_input.c_str()))
174 , struct_last; struct_iterator != struct_last; ++struct_iterator)
175 {
176 efl::eolian::grammar::attributes::struct_def struct_(&*struct_iterator, opts.unit);
177 auto structs_cxt = context_add_tag(class_context{class_context::structs}, context);
178 if (!eolian_mono::struct_entities.generate(iterator, struct_, structs_cxt))
179 {
180 throw std::runtime_error("Failed to generate struct");
181 }
182 }
195} 183}
196 184
197static void 185static void