summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono')
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh12
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh5
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh75
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh8
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_registration.hh7
-rw-r--r--src/bin/eolian_mono/eolian/mono/generation_contexts.hh1
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh57
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_annotation.hh134
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type.hh46
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh36
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh18
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh64
-rw-r--r--src/bin/eolian_mono/eolian/mono/part_definition.hh2
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh48
-rw-r--r--src/bin/eolian_mono/eolian/mono/type_impl.hh15
-rw-r--r--src/bin/eolian_mono/eolian/mono/utils.hh8
-rw-r--r--src/bin/eolian_mono/eolian/mono/variable_definition.hh99
17 files changed, 287 insertions, 348 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
index c00b449..764ecb8 100644
--- a/src/bin/eolian_mono/eolian/mono/documentation.hh
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -135,6 +135,18 @@ struct documentation_generator
135 case ::EOLIAN_OBJECT_FUNCTION: 135 case ::EOLIAN_OBJECT_FUNCTION:
136 ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail); 136 ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail);
137 break; 137 break;
138 case ::EOLIAN_OBJECT_VARIABLE:
139 if (::eolian_variable_type_get((::Eolian_Variable *)data) == ::EOLIAN_VAR_CONSTANT)
140 {
141 auto names = utils::split(name_helpers::managed_namespace(::eolian_object_name_get(data)), '.');
142 names.pop_back(); // Remove var name
143 ref = name_helpers::join_namespaces(names, '.');
144 ref += "Constants.";
145 ref += name_helpers::managed_name(::eolian_object_short_name_get(data));
146 }
147 // Otherwise, do nothing and no <see> tag will be generated. Because, who would
148 // reference a global (non-constant) variable in the docs?
149 break;
138 case ::EOLIAN_OBJECT_UNKNOWN: 150 case ::EOLIAN_OBJECT_UNKNOWN:
139 // If the reference cannot be resolved, just return an empty string and 151 // If the reference cannot be resolved, just return an empty string and
140 // it won't be converted into a <see> tag. 152 // it won't be converted into a <see> tag.
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 20225b4..2a2aa4c 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -301,12 +301,15 @@ struct event_definition_generator
301 bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const 301 bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const
302 { 302 {
303 std::string upper_c_name = utils::to_uppercase(evt.c_name); 303 std::string upper_c_name = utils::to_uppercase(evt.c_name);
304 auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state;
305 attributes::klass_def klass(get_klass(evt.klass, unit), unit);
306 auto library_name = context_find_tag<library_context>(context).actual_library_name(klass.filename);
304 return as_generator( 307 return as_generator(
305 scope_tab << "{\n" 308 scope_tab << "{\n"
306 << scope_tab << scope_tab << "add {\n" 309 << scope_tab << scope_tab << "add {\n"
307 << scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n" 310 << scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n"
308 << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n" 311 << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
309 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << event_name << "_delegate)) {\n" 312 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(" << library_name << ", key, this.evt_" << event_name << "_delegate)) {\n"
310 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.AddHandler(" << event_name << "Key , value);\n" 313 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.AddHandler(" << event_name << "Key , value);\n"
311 << scope_tab << scope_tab << scope_tab << scope_tab << "} else\n" 314 << scope_tab << scope_tab << scope_tab << scope_tab << "} else\n"
312 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error adding proxy for event {key}\");\n" 315 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error adding proxy for event {key}\");\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 9fef462..67dfcc0 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -32,41 +32,50 @@ struct native_function_definition_generator
32 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
33 { 33 {
34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl; 34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
35 if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Only Concrete classes implement static methods. 35 if(blacklist::is_function_blacklisted(f, context))
36 return true; 36 return true;
37 else 37 else
38 { 38 {
39 if(!as_generator 39 if(!as_generator
40 ("\n\n" << scope_tab 40 ("\n\n" << scope_tab
41 << eolian_mono::marshall_native_annotation(true) 41 << eolian_mono::marshall_annotation(true)
42 << " private delegate " 42 << " private delegate "
43 << eolian_mono::marshall_type(true) 43 << eolian_mono::marshall_type(true)
44 << " " 44 << " "
45 << string 45 << string
46 << "_delegate(System.IntPtr obj, System.IntPtr pd" 46 << "_delegate(" << (f.is_static ? "" : "System.IntPtr obj, System.IntPtr pd")
47 << *grammar::attribute_reorder<-1, -1> 47 << ((!f.is_static && f.parameters.size() > 0) ? ", " : "")
48 << (grammar::attribute_reorder<-1, -1>
48 ( 49 (
49 (", " << marshall_native_annotation << " " << marshall_parameter) 50 (marshall_annotation << " " << marshall_parameter)
50 ) 51 ) % ", ")
51 << ");\n") 52 << ");\n")
52 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 53 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
53 return false; 54 return false;
54 55
55 if(!as_generator 56 if(!as_generator
56 (scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")] " 57 ("\n\n" << scope_tab
57 << eolian_mono::marshall_native_annotation(true) 58 << eolian_mono::marshall_annotation(true)
58 << " private static extern " 59 << " public delegate "
59 << eolian_mono::marshall_type(true) 60 << eolian_mono::marshall_type(true)
60 << " " << string 61 << " "
61 << "(System.IntPtr obj" 62 << string << "_api_delegate(" << (f.is_static ? "" : "System.IntPtr obj")
62 << *grammar::attribute_reorder<-1, -1> 63 << ((!f.is_static && f.parameters.size() > 0) ? ", " : "")
64 << (grammar::attribute_reorder<-1, -1>
63 ( 65 (
64 (", " << marshall_native_annotation << " " << marshall_parameter) 66 (marshall_annotation << " " << marshall_parameter)
65 ) 67 ) % ", ")
66 << ");\n") 68 << ");\n")
67 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 69 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
68 return false; 70 return false;
69 71
72 if(!as_generator
73 (scope_tab
74 << " public static Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<"
75 << string << "_api_delegate>(_Module, \"" << string << "\");\n")
76 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context))
77 return false;
78
70 std::string return_type; 79 std::string return_type;
71 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 80 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
72 return false; 81 return false;
@@ -77,6 +86,11 @@ struct native_function_definition_generator
77 else 86 else
78 klass_cast_name = name_helpers::klass_interface_name(*klass); 87 klass_cast_name = name_helpers::klass_interface_name(*klass);
79 88
89 std::string self = "Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj))";
90
91 if (f.is_static)
92 self = "";
93
80 if(!as_generator 94 if(!as_generator
81 (scope_tab 95 (scope_tab
82 << " private static " 96 << " private static "
@@ -93,7 +107,8 @@ struct native_function_definition_generator
93 << scope_tab << scope_tab << "if(wrapper != null) {\n" 107 << scope_tab << scope_tab << "if(wrapper != null) {\n"
94 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() 108 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
95 << scope_tab << scope_tab << scope_tab << "try {\n" 109 << scope_tab << scope_tab << scope_tab << "try {\n"
96 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "((" << klass_cast_name << ")wrapper)." << string 110 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "")
111 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")wrapper).") << string
97 << "(" << (native_argument_invocation % ", ") << ");\n" 112 << "(" << (native_argument_invocation % ", ") << ");\n"
98 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" 113 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
99 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 114 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
@@ -102,7 +117,7 @@ struct native_function_definition_generator
102 << eolian_mono::native_function_definition_epilogue(*klass) 117 << eolian_mono::native_function_definition_epilogue(*klass)
103 << scope_tab << scope_tab << "} else {\n" 118 << scope_tab << scope_tab << "} else {\n"
104 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string 119 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string
105 << "(Efl.Eo.Globals.efl_super(obj, " << "Efl.Eo.Globals.efl_class_get(obj))" << *(", " << argument) << ");\n" 120 << "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n"
106 << scope_tab << scope_tab << "}\n" 121 << scope_tab << scope_tab << "}\n"
107 << scope_tab << "}\n" 122 << scope_tab << "}\n"
108 ) 123 )
@@ -118,9 +133,13 @@ struct native_function_definition_generator
118 , context)) 133 , context))
119 return false; 134 return false;
120 135
136 // Static functions do not need to be called from C
137 if (f.is_static)
138 return true;
139
121 // This is the delegate that will be passed to Eo to be called from C. 140 // This is the delegate that will be passed to Eo to be called from C.
122 if(!as_generator( 141 if(!as_generator(
123 scope_tab << "private " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n" 142 scope_tab << "private static " << f.c_name << "_delegate " << f.c_name << "_static_delegate;\n"
124 ).generate(sink, attributes::unused, context)) 143 ).generate(sink, attributes::unused, context))
125 return false; 144 return false;
126 return true; 145 return true;
@@ -141,22 +160,6 @@ struct function_definition_generator
141 if(blacklist::is_function_blacklisted(f, context)) 160 if(blacklist::is_function_blacklisted(f, context))
142 return true; 161 return true;
143 162
144 if(!as_generator
145 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n"
146 << scope_tab << eolian_mono::marshall_annotation(true)
147 << (do_super ? " protected " : " private ") << "static extern "
148 << eolian_mono::marshall_type(true)
149 << " " << string
150 << "(" << (f.is_static ? "" : "System.IntPtr obj")
151 << ((!f.is_static && (f.parameters.size() > 0)) ? ", " : "")
152 << (grammar::attribute_reorder<-1, -1>
153 (
154 (marshall_annotation << " " << marshall_parameter)
155 ) % ",")
156 << ");\n")
157 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
158 return false;
159
160 std::string return_type; 163 std::string return_type;
161 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 164 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
162 return false; 165 return false;
@@ -176,8 +179,10 @@ struct function_definition_generator
176 if(!as_generator 179 if(!as_generator
177 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") 180 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
178 << ") {\n " 181 << ") {\n "
179 << eolian_mono::function_definition_preamble() << string << "(" 182 << eolian_mono::function_definition_preamble()
180 << self << ((!f.is_static && (f.parameters.size() > 0)) ? "," : "") 183 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
184 << self
185 << ((!f.is_static && (f.parameters.size() > 0)) ? "," : "")
181 << (argument_invocation % ", ") << ");\n" 186 << (argument_invocation % ", ") << ");\n"
182 << eolian_mono::function_definition_epilogue() 187 << eolian_mono::function_definition_epilogue()
183 << " }\n") 188 << " }\n")
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 2c62abe..a7e692b 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -47,9 +47,9 @@ struct function_pointer {
47 .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx)) 47 .generate(sink, std::make_tuple(f, f.return_type, f_name, f.parameters), funcptr_ctx))
48 return false; 48 return false;
49 // "Internal" delegate, 1-to-1 with the Unamaged function type 49 // "Internal" delegate, 1-to-1 with the Unamaged function type
50 if (!as_generator(marshall_native_annotation(true) 50 if (!as_generator(marshall_annotation(true)
51 << "public delegate " << marshall_type(true) << " " << string // public? 51 << "public delegate " << marshall_type(true) << " " << string // public?
52 << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ");\n") 52 << "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ");\n")
53 .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx)) 53 .generate(sink, std::make_tuple(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx))
54 return false; 54 return false;
55 55
@@ -80,8 +80,8 @@ struct function_pointer {
80 << scope_tab << "}\n\n" 80 << scope_tab << "}\n\n"
81 81
82 82
83 << scope_tab << marshall_native_annotation(true) 83 << scope_tab << marshall_annotation(true)
84 << scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_native_annotation << " " << marshall_parameter)) << ")\n" 84 << scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ")\n"
85 << scope_tab << "{\n" 85 << scope_tab << "{\n"
86 << scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n" 86 << scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n"
87 << scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n" 87 << scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_registration.hh b/src/bin/eolian_mono/eolian/mono/function_registration.hh
index 90cbbc4..cc7534b 100644
--- a/src/bin/eolian_mono/eolian/mono/function_registration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_registration.hh
@@ -37,7 +37,8 @@ struct function_registration_generator
37 // auto index = index_generator(); 37 // auto index = index_generator();
38 38
39 if(!as_generator( 39 if(!as_generator(
40 scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" << 40 scope_tab << scope_tab << "if (" << f.c_name << "_static_delegate == null)\n"
41 << scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" <<
41 escape_keyword(f.name) << ");\n" 42 escape_keyword(f.name) << ");\n"
42 ).generate(sink, attributes::unused, context)) 43 ).generate(sink, attributes::unused, context))
43 return false; 44 return false;
@@ -47,9 +48,9 @@ struct function_registration_generator
47#ifdef _WIN32 48#ifdef _WIN32
48 << "api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\")" 49 << "api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\")"
49#else 50#else
50 << "api_func = Efl.Eo.Globals.dlsym(Efl.Eo.Globals.RTLD_DEFAULT, \"" << string << "\")" 51 << "api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, \"" << string << "\")"
51#endif 52#endif
52 ", func = Marshal.GetFunctionPointerForDelegate(" << string << "_static_delegate)});\n" 53 << ", func = Marshal.GetFunctionPointerForDelegate(" << string << "_static_delegate)});\n"
53 ) 54 )
54 .generate(sink, std::make_tuple(f.c_name, f.c_name), context)) 55 .generate(sink, std::make_tuple(f.c_name, f.c_name), context))
55 return false; 56 return false;
diff --git a/src/bin/eolian_mono/eolian/mono/generation_contexts.hh b/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
index 9a1493a..5cc57ef 100644
--- a/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
+++ b/src/bin/eolian_mono/eolian/mono/generation_contexts.hh
@@ -14,6 +14,7 @@ struct class_context
14 enums, 14 enums,
15 function_ptr, 15 function_ptr,
16 alias, 16 alias,
17 variables,
17 }; 18 };
18 wrapper_kind current_wrapper_kind; 19 wrapper_kind current_wrapper_kind;
19}; 20};
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 6c02de6..0689648 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -347,6 +347,15 @@ struct klass
347 return false; 347 return false;
348 } 348 }
349 349
350 // Copied from nativeinherit class, used when setting up providers.
351 if(!as_generator(
352 scope_tab << "private static IntPtr GetEflClassStatic()\n"
353 << scope_tab << "{\n"
354 << scope_tab << scope_tab << "return " << name_helpers::klass_get_full_name(cls) << "();\n"
355 << scope_tab << "}\n"
356 ).generate(sink, attributes::unused, inherit_cxt))
357 return false;
358
350 if(!as_generator("}\n").generate(sink, attributes::unused, inherit_cxt)) return false; 359 if(!as_generator("}\n").generate(sink, attributes::unused, inherit_cxt)) return false;
351 } 360 }
352 361
@@ -365,9 +374,10 @@ struct klass
365 374
366 if(!as_generator 375 if(!as_generator
367 ( 376 (
368 "public class " << native_inherit_name << " " << (root ? ": Efl.Eo.NativeClass" : (": " + base_name)) <<"{\n" 377 "public class " << native_inherit_name << " " << (root ? " : Efl.Eo.NativeClass" : (": " + base_name)) <<"{\n"
369 // << scope_tab << (root ? "protected IntPtr EoKlass { get; set; }\n" : "\n") 378 << scope_tab << "public " << (root ? "" : "new ") << " static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule("
370 << scope_tab << "public " << /*(root ? "" : "new ")*/ "override " << "System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)\n" 379 << context_find_tag<library_context>(context).actual_library_name(cls.filename) << ");\n"
380 << scope_tab << "public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)\n"
371 << scope_tab << "{\n" 381 << scope_tab << "{\n"
372 << scope_tab << scope_tab << "var descs = new System.Collections.Generic.List<Efl_Op_Description>();\n" 382 << scope_tab << scope_tab << "var descs = new System.Collections.Generic.List<Efl_Op_Description>();\n"
373 ) 383 )
@@ -454,7 +464,7 @@ struct klass
454 << scope_tab << scope_tab << scope_tab << "if (((object)this).GetType() == typeof (" << inherit_name << "))\n" 464 << scope_tab << scope_tab << scope_tab << "if (((object)this).GetType() == typeof (" << inherit_name << "))\n"
455 << scope_tab << scope_tab << scope_tab << scope_tab << "return " << native_inherit_full_name << ".GetEflClassStatic();\n" 465 << scope_tab << scope_tab << scope_tab << scope_tab << "return " << native_inherit_full_name << ".GetEflClassStatic();\n"
456 << scope_tab << scope_tab << scope_tab << "else\n" 466 << scope_tab << scope_tab << scope_tab << "else\n"
457 << scope_tab << scope_tab << scope_tab << scope_tab << "return Efl.Eo.Globals.klasses[((object)this).GetType()];\n" 467 << scope_tab << scope_tab << scope_tab << scope_tab << "return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];\n"
458 << scope_tab << scope_tab << "}\n" 468 << scope_tab << scope_tab << "}\n"
459 << scope_tab << "}\n" 469 << scope_tab << "}\n"
460 ).generate(sink, attributes::unused, context)) 470 ).generate(sink, attributes::unused, context))
@@ -471,16 +481,13 @@ struct klass
471 if (is_inherit) 481 if (is_inherit)
472 { 482 {
473 if (!as_generator( 483 if (!as_generator(
474 scope_tab << "private static readonly object klassAllocLock = new object();\n" 484 scope_tab << "protected bool inherited;\n"
475 << scope_tab << "protected bool inherited;\n"
476 ).generate(sink, attributes::unused, context)) 485 ).generate(sink, attributes::unused, context))
477 return false; 486 return false;
478 } 487 }
479 488
480 return as_generator( 489 return as_generator(
481 scope_tab << visibility << " System.IntPtr handle;\n" 490 scope_tab << visibility << " System.IntPtr handle;\n"
482 << scope_tab << "public Dictionary<String, IntPtr> cached_strings = new Dictionary<String, IntPtr>();" << "\n"
483 << scope_tab << "public Dictionary<String, IntPtr> cached_stringshares = new Dictionary<String, IntPtr>();" << "\n"
484 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n" 491 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n"
485 << scope_tab << "public System.IntPtr NativeHandle {\n" 492 << scope_tab << "public System.IntPtr NativeHandle {\n"
486 << scope_tab << scope_tab << "get { return handle; }\n" 493 << scope_tab << scope_tab << "get { return handle; }\n"
@@ -502,7 +509,12 @@ struct klass
502 ).generate(sink, attributes::unused, context)) 509 ).generate(sink, attributes::unused, context))
503 return false; 510 return false;
504 511
505 auto constructors = helpers::reorder_constructors(cls.get_all_constructors()); 512 auto all_constructors = helpers::reorder_constructors(cls.get_all_constructors());
513 decltype (all_constructors) constructors;
514
515 std::copy_if(all_constructors.cbegin(), all_constructors.cend(), std::back_inserter(constructors), [&context](attributes::constructor_def const& ctor) {
516 return !blacklist::is_function_blacklisted(ctor.function, context);
517 });
506 518
507 // Public (API) constructors 519 // Public (API) constructors
508 if (!as_generator( 520 if (!as_generator(
@@ -512,7 +524,7 @@ struct klass
512 // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters. 524 // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters.
513 << scope_tab << "public " << inherit_name << "(Efl.Object parent" << ((constructors.size() > 0) ? "" : "= null") << "\n" 525 << scope_tab << "public " << inherit_name << "(Efl.Object parent" << ((constructors.size() > 0) ? "" : "= null") << "\n"
514 << scope_tab << scope_tab << scope_tab << *(", " << constructor_param ) << ") :\n" 526 << scope_tab << scope_tab << scope_tab << *(", " << constructor_param ) << ") :\n"
515 << scope_tab << scope_tab << (root ? "this" : "base") << "(\"" << inherit_name << "\", " << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent)\n" 527 << scope_tab << scope_tab << (root ? "this" : "base") << "(" << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent)\n"
516 << scope_tab << "{\n" 528 << scope_tab << "{\n"
517 << *(scope_tab << scope_tab << constructor_invocation << "\n" ) 529 << *(scope_tab << scope_tab << constructor_invocation << "\n" )
518 << scope_tab << scope_tab << "FinishInstantiation();\n" 530 << scope_tab << scope_tab << "FinishInstantiation();\n"
@@ -531,7 +543,7 @@ struct klass
531 { 543 {
532 return as_generator( 544 return as_generator(
533 scope_tab << "///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>\n" 545 scope_tab << "///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>\n"
534 << scope_tab << "protected " << inherit_name << "(String klass_name, IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(klass_name, base_klass, managed_type, parent) {}\n" 546 << scope_tab << "protected " << inherit_name << "(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}\n"
535 ).generate(sink, attributes::unused, context); 547 ).generate(sink, attributes::unused, context);
536 548
537 } 549 }
@@ -539,22 +551,12 @@ struct klass
539 // Detailed constructors go only in root classes. 551 // Detailed constructors go only in root classes.
540 return as_generator( 552 return as_generator(
541 /// Actual root costructor that creates class and instantiates 553 /// Actual root costructor that creates class and instantiates
542 scope_tab << "protected " << inherit_name << "(String klass_name, IntPtr base_klass, System.Type managed_type, Efl.Object parent)\n" 554 scope_tab << "protected " << inherit_name << "(IntPtr base_klass, System.Type managed_type, Efl.Object parent)\n"
543 << scope_tab << "{\n" 555 << scope_tab << "{\n"
544 << scope_tab << scope_tab << "inherited = ((object)this).GetType() != managed_type;\n" 556 << scope_tab << scope_tab << "inherited = ((object)this).GetType() != managed_type;\n"
545 << scope_tab << scope_tab << "IntPtr actual_klass = base_klass;\n" 557 << scope_tab << scope_tab << "IntPtr actual_klass = base_klass;\n"
546 << scope_tab << scope_tab << "if (inherited) {\n" 558 << scope_tab << scope_tab << "if (inherited) {\n"
547 << scope_tab << scope_tab << scope_tab << "if (!Efl.Eo.Globals.klasses.ContainsKey(((object)this).GetType())) {\n" 559 << scope_tab << scope_tab << scope_tab << "actual_klass = Efl.Eo.ClassRegister.GetInheritKlassOrRegister(base_klass, ((object)this).GetType());\n"
548 << scope_tab << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n"
549 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "actual_klass = Efl.Eo.Globals.register_class(klass_name, base_klass, ((object)this).GetType());\n"
550 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (actual_klass == System.IntPtr.Zero) {\n"
551 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "throw new System.InvalidOperationException(\"Failed to initialize class '" << inherit_name << "'\");\n"
552 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
553 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.klasses[((object)this).GetType()] = actual_klass;\n"
554 << scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
555 << scope_tab << scope_tab << scope_tab << "}\n"
556 << scope_tab << scope_tab << scope_tab << "else\n"
557 << scope_tab << scope_tab << scope_tab << scope_tab << "actual_klass = Efl.Eo.Globals.klasses[((object)this).GetType()];\n"
558 << scope_tab << scope_tab << "}\n" 560 << scope_tab << scope_tab << "}\n"
559 << scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);\n" 561 << scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);\n"
560 << scope_tab << scope_tab << "register_event_proxies();\n" 562 << scope_tab << scope_tab << "register_event_proxies();\n"
@@ -604,8 +606,6 @@ struct klass
604 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n" 606 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
605 << scope_tab << "public void Dispose()\n" 607 << scope_tab << "public void Dispose()\n"
606 << scope_tab << "{\n" 608 << scope_tab << "{\n"
607 << scope_tab << "Efl.Eo.Globals.free_dict_values(cached_strings);" << "\n"
608 << scope_tab << "Efl.Eo.Globals.free_stringshare_values(cached_stringshares);" << "\n"
609 << scope_tab << scope_tab << "Dispose(true);\n" 609 << scope_tab << scope_tab << "Dispose(true);\n"
610 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n" 610 << scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
611 << scope_tab << "}\n" 611 << scope_tab << "}\n"
@@ -682,13 +682,13 @@ struct klass
682 682
683 // Callback registration functions 683 // Callback registration functions
684 if (!as_generator( 684 if (!as_generator(
685 scope_tab << visibility << "bool add_cpp_event_handler(string key, Efl.EventCb evt_delegate) {\n" 685 scope_tab << visibility << "bool add_cpp_event_handler(string lib, string key, Efl.EventCb evt_delegate) {\n"
686 << scope_tab << scope_tab << "int event_count = 0;\n" 686 << scope_tab << scope_tab << "int event_count = 0;\n"
687 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n" 687 << scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
688 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" 688 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
689 << scope_tab << scope_tab << "if (event_count == 0) {\n" 689 << scope_tab << scope_tab << "if (event_count == 0) {\n"
690 690
691 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(key);\n" 691 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(lib, key);\n"
692 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n" 692 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
693 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n" 693 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n"
694 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 694 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
@@ -710,7 +710,8 @@ struct klass
710 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n" 710 << scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
711 << scope_tab << scope_tab << "if (event_count == 1) {\n" 711 << scope_tab << scope_tab << "if (event_count == 1) {\n"
712 712
713 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative(key);\n" 713 << scope_tab << scope_tab << scope_tab << "IntPtr desc = Efl.EventDescription.GetNative("
714 << context_find_tag<library_context>(context).actual_library_name(cls.filename) << ", key);\n"
714 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n" 715 << scope_tab << scope_tab << scope_tab << "if (desc == IntPtr.Zero) {\n"
715 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n" 716 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Failed to get native event {key}\");\n"
716 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 717 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
index 6ddb990..4159b6a 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_annotation.hh
@@ -90,7 +90,7 @@ struct marshall_annotation_visitor_generate
90 {"string", true, [&] { 90 {"string", true, [&] {
91 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]"; 91 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
92 }}, 92 }},
93 {"string", false, [&] { 93 {"string", nullptr, [&] {
94 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]"; 94 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
95 }}, 95 }},
96 {"mstring", true, [&] { 96 {"mstring", true, [&] {
@@ -112,10 +112,10 @@ struct marshall_annotation_visitor_generate
112 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]"; 112 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.ValueMarshaler))]";
113 }}, 113 }},
114 {"strbuf", true, [&] { 114 {"strbuf", true, [&] {
115 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]"; 115 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
116 }}, 116 }},
117 {"strbuf", false, [&] { 117 {"strbuf", false, [&] {
118 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]"; 118 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
119 }}, 119 }},
120 }; 120 };
121 121
@@ -142,122 +142,22 @@ struct marshall_annotation_visitor_generate
142 } 142 }
143 bool operator()(attributes::klass_name const& klass_name) const 143 bool operator()(attributes::klass_name const& klass_name) const
144 { 144 {
145 const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<"; 145 const char *return_prefix = is_return ? "return:" : "";
146 const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<"; 146 const char *marshal_prefix = "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(";
147 return as_generator
148 ((is_return ? return_prefix : no_return_prefix)
149 << string << ", Efl.Eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
150 ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
151 }
152 bool operator()(attributes::complex_type_def const& c) const
153 {
154 if (c.outer.base_type == "future")
155 {
156 std::string prefix = is_return ? "return: " : "";
157 return as_generator("[" << prefix << "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Eina.FutureMarshaler))]").generate(sink, nullptr, *context);
158 }
159 return true;
160 }
161};
162
163template <typename OutputIterator, typename Context>
164struct marshall_native_annotation_visitor_generate
165{
166 mutable OutputIterator sink;
167 Context const* context;
168 std::string c_type;
169 bool is_out;
170 bool is_return;
171 bool is_ptr;
172 147
173 typedef marshall_type_visitor_generate<OutputIterator, Context> visitor_type; 148 std::string name = name_helpers::klass_full_concrete_name(klass_name);
174 typedef bool result_type;
175 149
176 bool operator()(attributes::regular_type_def const& regular) const 150 if (name == "Efl.Class")
177 { 151 name = "Efl.Eo.MarshalEflClass";
178 using attributes::regular_type_def; 152 else
179 struct match 153 {
180 { 154 auto own = klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag";
181 eina::optional<std::string> name; 155 name = "Efl.Eo.MarshalTest<" + name + ", Efl.Eo." + own + ">";
182 eina::optional<bool> has_own; 156 }
183 std::function<std::string()> function;
184 };
185 match const parameter_match_table[] =
186 {
187 // signed primitives
188 {"bool", nullptr, [&] { return " [MarshalAs(UnmanagedType.U1)]"; }},
189 {"string", true, [&] {
190 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
191 }},
192 {"string", false, [&] {
193 if (is_out)
194 return "";
195 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]";
196 }},
197 {"stringshare", true, [&] {
198 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
199 }},
200 {"stringshare", false, [&] {
201 if (is_out)
202 return "";
203 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringshareKeepOwnershipMarshaler))]";
204 }},
205 {"strbuf", true, [&] {
206 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
207 }},
208 {"strbuf", false, [&] {
209 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
210 }},
211 };
212 match const return_match_table[] =
213 {
214 // signed primitives
215 {"bool", nullptr, [&] { return " [return: MarshalAs(UnmanagedType.U1)]"; }},
216 {"string", true, [&] {
217 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringPassOwnershipMarshaler))]";
218 }},
219 {"string", false, [&] { return ""; }},
220 {"stringshare", true, [&] {
221 return " [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringsharePassOwnershipMarshaler))]";
222 }},
223 {"stringshare", false, [&] { return ""; }},
224 {"strbuf", true, [&] {
225 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufPassOwnershipMarshaler))]";
226 }},
227 {"strbuf", false, [&] {
228 return " [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StrbufKeepOwnershipMarshaler))]";
229 }},
230 };
231 157
232 if(eina::optional<bool> b = call_annotation_match 158 return as_generator(
233 ((is_return ? return_match_table : parameter_match_table) 159 lit("[") << return_prefix << marshal_prefix << name << "))]"
234 , [&] (match const& m) 160 ).generate(sink, name, *context);
235 {
236 return (!m.name || *m.name == regular.base_type)
237 && (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
238 ;
239 }
240 , [&] (std::string const& string)
241 {
242 std::copy(string.begin(), string.end(), sink);
243 return true;
244 }))
245 {
246 return *b;
247 }
248 else
249 {
250 return true;
251 }
252 }
253 bool operator()(attributes::klass_name const& klass_name) const
254 {
255 const char no_return_prefix[] = "[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
256 const char return_prefix[] = "[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Efl.Eo.MarshalTest<";
257 return as_generator
258 ((is_return ? return_prefix : no_return_prefix)
259 << string << ", Efl.Eo." << (klass_name.base_qualifier & qualifier_info::is_own ? "OwnTag" : "NonOwnTag") << ">))]"
260 ).generate(sink, name_helpers::klass_full_concrete_name(klass_name), *context);
261 } 161 }
262 bool operator()(attributes::complex_type_def const& c) const 162 bool operator()(attributes::complex_type_def const& c) const
263 { 163 {
@@ -269,8 +169,6 @@ struct marshall_native_annotation_visitor_generate
269 return true; 169 return true;
270 } 170 }
271}; 171};
272
273
274} } 172} }
275 173
276#endif 174#endif
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type.hh b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
index add954a..5c350ad 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
@@ -13,8 +13,6 @@ template <typename OutputIterator, typename Context>
13struct marshall_type_visitor_generate; 13struct marshall_type_visitor_generate;
14template <typename OutputIterator, typename Context> 14template <typename OutputIterator, typename Context>
15struct marshall_annotation_visitor_generate; 15struct marshall_annotation_visitor_generate;
16template <typename OutputIterator, typename Context>
17struct marshall_native_annotation_visitor_generate;
18} 16}
19 17
20/* 18/*
@@ -73,26 +71,6 @@ struct marshall_annotation_generator
73 bool is_return; 71 bool is_return;
74}; 72};
75 73
76struct marshall_native_annotation_generator
77{
78 marshall_native_annotation_generator(bool is_return = false)
79 : is_return(is_return) {}
80
81 template <typename OutputIterator, typename Context>
82 bool generate(OutputIterator sink, attributes::type_def const& type, Context const& context) const
83 {
84 return type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, type.c_type, false, is_return, type.is_ptr});
85 }
86 template <typename OutputIterator, typename Context>
87 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
88 {
89 return param.type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
90 , param.direction != attributes::parameter_direction::in, false, param.type.is_ptr});
91 }
92
93 bool is_return;
94};
95
96struct marshall_type_terminal 74struct marshall_type_terminal
97{ 75{
98 marshall_type_generator const operator()(bool is_return) const 76 marshall_type_generator const operator()(bool is_return) const
@@ -120,19 +98,6 @@ marshall_annotation_generator const as_generator(marshall_annotation_terminal)
120} 98}
121 99
122 100
123struct marshall_native_annotation_terminal
124{
125 marshall_native_annotation_generator const operator()(bool is_return) const
126 {
127 return marshall_native_annotation_generator(is_return);
128 }
129} const marshall_native_annotation = {};
130
131marshall_native_annotation_generator const as_generator(marshall_native_annotation_terminal)
132{
133 return marshall_native_annotation_generator{};
134}
135
136} 101}
137 102
138namespace efl { namespace eolian { namespace grammar { 103namespace efl { namespace eolian { namespace grammar {
@@ -158,23 +123,12 @@ struct is_generator< ::eolian_mono::marshall_annotation_generator> : std::true_t
158template <> 123template <>
159struct is_generator< ::eolian_mono::marshall_annotation_terminal> : std::true_type {}; 124struct is_generator< ::eolian_mono::marshall_annotation_terminal> : std::true_type {};
160 125
161template <>
162struct is_eager_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
163template <>
164struct is_generator< ::eolian_mono::marshall_native_annotation_generator> : std::true_type {};
165template <>
166struct is_generator< ::eolian_mono::marshall_native_annotation_terminal> : std::true_type {};
167
168namespace type_traits { 126namespace type_traits {
169template <> 127template <>
170struct attributes_needed< ::eolian_mono::marshall_annotation_generator> : std::integral_constant<int, 1> {}; 128struct attributes_needed< ::eolian_mono::marshall_annotation_generator> : std::integral_constant<int, 1> {};
171template <> 129template <>
172struct attributes_needed< ::eolian_mono::marshall_annotation_terminal> : std::integral_constant<int, 1> {}; 130struct attributes_needed< ::eolian_mono::marshall_annotation_terminal> : std::integral_constant<int, 1> {};
173 131
174template <>
175struct attributes_needed< ::eolian_mono::marshall_native_annotation_generator> : std::integral_constant<int, 1> {};
176template <>
177struct attributes_needed< ::eolian_mono::marshall_native_annotation_terminal> : std::integral_constant<int, 1> {};
178} 132}
179 133
180} } } 134} } }
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 e14369a..998ca0b 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
@@ -32,7 +32,6 @@ struct marshall_type_visitor_generate
32 bool operator()(attributes::regular_type_def const& regular) const 32 bool operator()(attributes::regular_type_def const& regular) const
33 { 33 {
34 using attributes::regular_type_def; 34 using attributes::regular_type_def;
35 bool is_inherit_native = context_find_tag<class_context>(*context).current_wrapper_kind == class_context::inherit_native;
36 35
37 struct match 36 struct match
38 { 37 {
@@ -47,32 +46,24 @@ struct marshall_type_visitor_generate
47 { 46 {
48 regular_type_def r = regular; 47 regular_type_def r = regular;
49 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 48 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
50 // if(is_out || is_return)
51 return replace_base_type(r, " System.String"); 49 return replace_base_type(r, " System.String");
52 // else return replace_base_type(r, " ::efl::eina::string_view");
53 }} 50 }}
54 , {"string", false, [&] 51 , {"string", false, [&]
55 { 52 {
56 regular_type_def r = regular; 53 regular_type_def r = regular;
57 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 54 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
58 if (is_inherit_native && (is_return || is_out))
59 return replace_base_type(r, " System.IntPtr");
60 return replace_base_type(r, " System.String"); 55 return replace_base_type(r, " System.String");
61 }} 56 }}
62 , {"mstring", true, [&] 57 , {"mstring", true, [&]
63 { 58 {
64 regular_type_def r = regular; 59 regular_type_def r = regular;
65 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 60 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
66 // if(is_out || is_return)
67 return replace_base_type(r, " System.String"); 61 return replace_base_type(r, " System.String");
68 // else return replace_base_type(r, " ::efl::eina::string_view");
69 }} 62 }}
70 , {"mstring", false, [&] 63 , {"mstring", false, [&]
71 { 64 {
72 regular_type_def r = regular; 65 regular_type_def r = regular;
73 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 66 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
74 if (is_inherit_native && (is_return || is_out))
75 return replace_base_type(r, " System.IntPtr");
76 return replace_base_type(r, " System.String"); 67 return replace_base_type(r, " System.String");
77 }} 68 }}
78 , {"stringshare", true, [&] 69 , {"stringshare", true, [&]
@@ -85,10 +76,7 @@ struct marshall_type_visitor_generate
85 { 76 {
86 regular_type_def r = regular; 77 regular_type_def r = regular;
87 r.base_qualifier.qualifier ^= qualifier_info::is_ref; 78 r.base_qualifier.qualifier ^= qualifier_info::is_ref;
88 if (is_inherit_native && (is_return || is_out)) 79 return replace_base_type(r, " System.String");
89 return replace_base_type(r, " System.IntPtr");
90 else
91 return replace_base_type(r, " System.String");
92 }} 80 }}
93 , {"strbuf", nullptr, [&] 81 , {"strbuf", nullptr, [&]
94 { 82 {
@@ -193,7 +181,6 @@ struct marshall_type_visitor_generate
193 bool operator()(attributes::klass_name klass_name) const 181 bool operator()(attributes::klass_name klass_name) const
194 { 182 {
195 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(klass_name); 183 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(klass_name);
196 // return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
197 } 184 }
198 bool operator()(attributes::complex_type_def const& complex) const 185 bool operator()(attributes::complex_type_def const& complex) const
199 { 186 {
@@ -212,21 +199,11 @@ struct marshall_type_visitor_generate
212 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}}; 199 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
213 } 200 }
214 } 201 }
215 ,{"inarray", nullptr, nullptr, [&]
216 {
217 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
218 }
219 }
220 ,{"list", nullptr, nullptr, [&] 202 ,{"list", nullptr, nullptr, [&]
221 { 203 {
222 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}}; 204 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
223 } 205 }
224 } 206 }
225 ,{"inlist", nullptr, nullptr, [&]
226 {
227 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
228 }
229 }
230 ,{"hash", nullptr, nullptr, [&] 207 ,{"hash", nullptr, nullptr, [&]
231 { 208 {
232 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}}; 209 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
@@ -247,14 +224,8 @@ struct marshall_type_visitor_generate
247 auto default_match = [&] (attributes::complex_type_def const& complex) 224 auto default_match = [&] (attributes::complex_type_def const& complex)
248 { 225 {
249 regular_type_def no_pointer_regular = complex.outer; 226 regular_type_def no_pointer_regular = complex.outer;
250 // std::vector<attributes::pointer_indirection> pointers;
251 // pointers.swap(no_pointer_regular.pointers);
252 // if(is_out)
253 // pointers.push_back({{attributes::qualifier_info::is_none, {}}, true});
254 return visitor_type{sink, context, c_type, false}(no_pointer_regular) 227 return visitor_type{sink, context, c_type, false}(no_pointer_regular)
255 && as_generator("<" << (type % ", ") << ">").generate(sink, complex.subtypes, *context) 228 && as_generator("<" << (type % ", ") << ">").generate(sink, complex.subtypes, *context);
256 ;
257 // && detail::generate_pointers(sink, pointers, *context, false);
258 }; 229 };
259 230
260 if(eina::optional<bool> b = call_match 231 if(eina::optional<bool> b = call_match
@@ -279,12 +250,9 @@ struct marshall_type_visitor_generate
279 return *b; 250 return *b;
280 } 251 }
281 252
282 //return default_match(complex);
283 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(complex); 253 return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(complex);
284 // return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
285 } 254 }
286}; 255};
287
288} } 256} }
289 257
290#endif 258#endif
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index ccbbfce..5fc1f18 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -364,13 +364,27 @@ inline std::string klass_inherit_name(T const& klass)
364template<typename T> 364template<typename T>
365inline std::string klass_native_inherit_name(T const& klass) 365inline std::string klass_native_inherit_name(T const& klass)
366{ 366{
367 return klass_concrete_name(klass) + "NativeInherit"; 367 switch(klass.type)
368 {
369 case attributes::class_type::abstract_:
370 case attributes::class_type::regular:
371 return klass_concrete_name(klass) + "NativeInherit";
372 default:
373 return klass_interface_name(klass) + "NativeInherit";
374 }
368} 375}
369 376
370template<typename T> 377template<typename T>
371inline std::string klass_full_native_inherit_name(T const& klass) 378inline std::string klass_full_native_inherit_name(T const& klass)
372{ 379{
373 return klass_full_concrete_name(klass) + "NativeInherit"; 380 switch(klass.type)
381 {
382 case attributes::class_type::abstract_:
383 case attributes::class_type::regular:
384 return klass_full_concrete_name(klass) + "NativeInherit";
385 default:
386 return klass_full_interface_name(klass) + "NativeInherit";
387 }
374} 388}
375 389
376template<typename T> 390template<typename T>
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index efb907f..1314c12 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -300,18 +300,10 @@ inline bool param_should_use_out_var(attributes::parameter_def const& param, boo
300 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, WANT_OUT) 300 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, WANT_OUT)
301 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 301 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
302 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 302 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
303 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
304 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
305 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
306 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
307 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 303 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
308 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 304 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
309 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 305 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
310 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 306 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
311 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
312 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
313 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
314 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
315 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT) 307 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
316 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT) 308 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
317 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT) 309 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
@@ -352,22 +344,14 @@ inline bool param_should_use_in_var(attributes::parameter_def const& param, bool
352 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, !WANT_OUT) 344 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, !WANT_OUT)
353 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, !WANT_OUT) 345 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, !WANT_OUT)
354 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, !WANT_OUT) 346 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, !WANT_OUT)
355 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, !WANT_OUT)
356 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, !WANT_OUT)
357 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, !WANT_OUT)
358 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, !WANT_OUT)
359 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, !WANT_OUT) 347 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, !WANT_OUT)
360 || param_is_acceptable(param, "Eina_List *", WANT_OWN, !WANT_OUT) 348 || param_is_acceptable(param, "Eina_List *", WANT_OWN, !WANT_OUT)
361 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, !WANT_OUT) 349 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, !WANT_OUT)
362 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, !WANT_OUT) 350 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, !WANT_OUT)
363 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, !WANT_OUT)
364 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, !WANT_OUT)
365 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, !WANT_OUT) 351 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, !WANT_OUT)
366 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, !WANT_OUT) 352 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, !WANT_OUT)
367 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, !WANT_OUT) 353 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, !WANT_OUT)
368 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, !WANT_OUT) 354 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, !WANT_OUT)
369 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, !WANT_OUT)
370 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, !WANT_OUT)
371 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, !WANT_OUT) 355 || param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, !WANT_OUT)
372 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, !WANT_OUT) 356 || param_is_acceptable(param, "Eina_Hash *", WANT_OWN, !WANT_OUT)
373 || param_is_acceptable(param, "const Eina_Hash *", !WANT_OWN, !WANT_OUT) 357 || param_is_acceptable(param, "const Eina_Hash *", !WANT_OWN, !WANT_OUT)
@@ -619,9 +603,7 @@ struct native_convert_in_variable_generator
619 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context); 603 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
620 } 604 }
621 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *" 605 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *"
622 || param.type.c_type == "Eina_Inarray *" || param.type.c_type == "const Eina_Inarray *"
623 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 606 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
624 || param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
625 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *" 607 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
626 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *" 608 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
627 ) 609 )
@@ -707,9 +689,7 @@ struct convert_in_variable_generator
707 return false; 689 return false;
708 } 690 }
709 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *" 691 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *"
710 || param.type.c_type == "Eina_Inarray *" || param.type.c_type == "const Eina_Inarray *"
711 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 692 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
712 || param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
713 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *" 693 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
714 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *" 694 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
715 ) 695 )
@@ -778,18 +758,10 @@ struct convert_out_variable_generator
778 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 758 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
779 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 759 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
780 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 760 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
781 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
782 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
783 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
784 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
785 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 761 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
786 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 762 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
787 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 763 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
788 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 764 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
789 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
790 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
791 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
792 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
793 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT) 765 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
794 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT) 766 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
795 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT) 767 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
@@ -857,18 +829,10 @@ struct native_convert_out_variable_generator
857 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 829 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
858 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 830 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
859 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 831 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
860 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
861 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
862 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
863 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
864 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 832 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
865 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 833 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
866 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 834 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
867 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 835 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
868 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
869 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
870 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
871 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
872 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT) 836 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
873 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT) 837 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
874 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT) 838 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
@@ -969,18 +933,10 @@ struct convert_out_assign_generator
969 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 933 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
970 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 934 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
971 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 935 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
972 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
973 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
974 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
975 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
976 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 936 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
977 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 937 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
978 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 938 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
979 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 939 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
980 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
981 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
982 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
983 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
984 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT) 940 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
985 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT) 941 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
986 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT) 942 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
@@ -1100,9 +1056,7 @@ struct convert_return_generator
1100 return false; 1056 return false;
1101 } 1057 }
1102 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *" 1058 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *"
1103 || ret_type.c_type == "Eina_Inarray *" || ret_type.c_type == "const Eina_Inarray *"
1104 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 1059 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
1105 || ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
1106 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *" 1060 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
1107 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *" 1061 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
1108 ) 1062 )
@@ -1158,7 +1112,7 @@ struct native_convert_out_assign_generator
1158 return false; 1112 return false;
1159 } 1113 }
1160 return as_generator( 1114 return as_generator(
1161 string << "= Efl.Eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, " << string << ");\n" 1115 string << "= " << string << ";\n"
1162 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); 1116 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
1163 } 1117 }
1164 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT)) 1118 else if (param_is_acceptable(param, "const char *", !WANT_OWN, WANT_OUT))
@@ -1169,7 +1123,7 @@ struct native_convert_out_assign_generator
1169 return false; 1123 return false;
1170 } 1124 }
1171 return as_generator( 1125 return as_generator(
1172 string << "= Efl.Eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, " << string << ");\n" 1126 string << " = " << string << ";\n"
1173 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context); 1127 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
1174 } 1128 }
1175 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT) 1129 else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
@@ -1219,18 +1173,10 @@ struct native_convert_out_assign_generator
1219 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 1173 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
1220 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 1174 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
1221 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 1175 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
1222 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
1223 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
1224 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
1225 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
1226 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 1176 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
1227 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 1177 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
1228 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 1178 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
1229 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 1179 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
1230 || param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
1231 || param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
1232 || param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
1233 || param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
1234 || param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT) 1180 || param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
1235 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT) 1181 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
1236 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT) 1182 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
@@ -1307,7 +1253,7 @@ struct native_convert_return_generator
1307 return false; 1253 return false;
1308 } 1254 }
1309 return as_generator( 1255 return as_generator(
1310 "return Efl.Eo.Globals.cached_string_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_strings, _ret_var);\n" 1256 "return _ret_var;\n"
1311 ).generate(sink, attributes::unused, context); 1257 ).generate(sink, attributes::unused, context);
1312 } 1258 }
1313 else 1259 else
@@ -1325,7 +1271,7 @@ struct native_convert_return_generator
1325 return false; 1271 return false;
1326 } 1272 }
1327 return as_generator( 1273 return as_generator(
1328 "return Efl.Eo.Globals.cached_stringshare_to_intptr(((" << name_helpers::klass_inherit_name(*klass) << ")wrapper).cached_stringshares, _ret_var);\n" 1274 "return _ret_var;\n"
1329 ).generate(sink, attributes::unused, context); 1275 ).generate(sink, attributes::unused, context);
1330 } 1276 }
1331 else 1277 else
@@ -1362,9 +1308,7 @@ struct native_convert_return_generator
1362 .generate(sink, attributes::unused, context); 1308 .generate(sink, attributes::unused, context);
1363 } 1309 }
1364 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *" 1310 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *"
1365 || ret_type.c_type == "Eina_Inarray *" || ret_type.c_type == "const Eina_Inarray *"
1366 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 1311 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
1367 || ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
1368 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *" 1312 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
1369 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *" 1313 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
1370 ) 1314 )
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh
index bd12ee2..47951f4 100644
--- a/src/bin/eolian_mono/eolian/mono/part_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh
@@ -24,7 +24,7 @@ struct part_definition_generator
24 << scope_tab << "{\n" 24 << scope_tab << "{\n"
25 << scope_tab << scope_tab << "get\n" 25 << scope_tab << scope_tab << "get\n"
26 << scope_tab << scope_tab << "{\n" 26 << scope_tab << scope_tab << "{\n"
27 << scope_tab << scope_tab << scope_tab << "Efl.Object obj = efl_part_get(NativeHandle, \"" << part.name << "\");\n" 27 << scope_tab << scope_tab << scope_tab << "Efl.Object obj = Efl.PartNativeInherit.efl_part_get_ptr.Value.Delegate(NativeHandle, \"" << part.name << "\");\n"
28 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n" 28 << scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
29 << scope_tab << scope_tab << "}\n" 29 << scope_tab << scope_tab << "}\n"
30 << scope_tab << "}\n" 30 << scope_tab << "}\n"
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 0eda387..17485d1 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -131,6 +131,22 @@ struct struct_internal_definition_generator
131 .generate(sink, nullptr, context)) 131 .generate(sink, nullptr, context))
132 return false; 132 return false;
133 } 133 }
134 else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
135 && regular->base_type == "bool")
136 {
137 if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
138 "public System.Byte " << field_name << ";\n")
139 .generate(sink, nullptr, context))
140 return false;
141 }
142 else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
143 && regular->base_type == "char")
144 {
145 if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
146 "public System.Byte " << field_name << ";\n")
147 .generate(sink, nullptr, context))
148 return false;
149 }
134 else if (!as_generator(scope_tab << eolian_mono::marshall_annotation(false) << "\n" 150 else if (!as_generator(scope_tab << eolian_mono::marshall_annotation(false) << "\n"
135 << scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n") 151 << scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
136 .generate(sink, std::make_tuple(field.type, field.type, field_name), context)) 152 .generate(sink, std::make_tuple(field.type, field.type, field_name), context))
@@ -192,9 +208,7 @@ struct to_internal_field_convert_generator
192 return false; 208 return false;
193 } 209 }
194 else if ((complex && (complex->outer.base_type == "array" 210 else if ((complex && (complex->outer.base_type == "array"
195 || complex->outer.base_type == "inarray"
196 || complex->outer.base_type == "list" 211 || complex->outer.base_type == "list"
197 || complex->outer.base_type == "inlist"
198 || complex->outer.base_type == "iterator" 212 || complex->outer.base_type == "iterator"
199 || complex->outer.base_type == "hash")) 213 || complex->outer.base_type == "hash"))
200 || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *") 214 || field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
@@ -257,6 +271,20 @@ struct to_internal_field_convert_generator
257 ).generate(sink, std::make_tuple(field_name, field_name), context)) 271 ).generate(sink, std::make_tuple(field_name, field_name), context))
258 return false; 272 return false;
259 } 273 }
274 else if (!field.type.is_ptr && regular && regular->base_type == "bool")
275 {
276 if (!as_generator(
277 scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << " ? (byte)1 : (byte)0;\n")
278 .generate(sink, std::make_tuple(field_name, field_name), context))
279 return false;
280 }
281 else if (!field.type.is_ptr && regular && regular->base_type == "char")
282 {
283 if (!as_generator(
284 scope_tab << scope_tab << "_internal_struct." << string << " = (byte)_external_struct." << string << ";\n")
285 .generate(sink, std::make_tuple(field_name, field_name), context))
286 return false;
287 }
260 else // primitives and enums 288 else // primitives and enums
261 { 289 {
262 if (!as_generator( 290 if (!as_generator(
@@ -299,9 +327,7 @@ struct to_external_field_convert_generator
299 return false; 327 return false;
300 } 328 }
301 else if (complex && (complex->outer.base_type == "array" 329 else if (complex && (complex->outer.base_type == "array"
302 || complex->outer.base_type == "inarray"
303 || complex->outer.base_type == "list" 330 || complex->outer.base_type == "list"
304 || complex->outer.base_type == "inlist"
305 || complex->outer.base_type == "iterator")) 331 || complex->outer.base_type == "iterator"))
306 { 332 {
307 // Always assumes pointer 333 // Always assumes pointer
@@ -362,6 +388,20 @@ struct to_external_field_convert_generator
362 ).generate(sink, std::make_tuple(field_name, field_name), context)) 388 ).generate(sink, std::make_tuple(field_name, field_name), context))
363 return false; 389 return false;
364 } 390 }
391 else if (!field.type.is_ptr && regular && regular->base_type == "bool")
392 {
393 if (!as_generator(
394 scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << " != 0;\n"
395 ).generate(sink, std::make_tuple(field_name, field_name), context))
396 return false;
397 }
398 else if (!field.type.is_ptr && regular && regular->base_type == "char")
399 {
400 if (!as_generator(
401 scope_tab << scope_tab << "_external_struct." << string << " = (char)_internal_struct." << string << ";\n"
402 ).generate(sink, std::make_tuple(field_name, field_name), context))
403 return false;
404 }
365 else // primitives and enums 405 else // primitives and enums
366 { 406 {
367 if (!as_generator( 407 if (!as_generator(
diff --git a/src/bin/eolian_mono/eolian/mono/type_impl.hh b/src/bin/eolian_mono/eolian/mono/type_impl.hh
index c449d21..f34c479 100644
--- a/src/bin/eolian_mono/eolian/mono/type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/type_impl.hh
@@ -309,6 +309,9 @@ struct visitor_generate
309 } 309 }
310 bool operator()(attributes::klass_name klass) const 310 bool operator()(attributes::klass_name klass) const
311 { 311 {
312 // Efl.Class is manually handled in a custom marshall to be represented by a System.Type.
313 if (name_helpers::klass_full_concrete_name(klass) == "Efl.Class")
314 return as_generator(lit("Type")).generate(sink, attributes::unused, *context);
312 if(klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_) 315 if(klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_)
313 return as_generator(string).generate(sink, name_helpers::klass_full_concrete_name(klass), *context); 316 return as_generator(string).generate(sink, name_helpers::klass_full_concrete_name(klass), *context);
314 else 317 else
@@ -333,24 +336,12 @@ struct visitor_generate
333 c.outer.base_type = "Eina.List"; 336 c.outer.base_type = "Eina.List";
334 return c; 337 return c;
335 }} 338 }}
336 , {"inlist", nullptr, nullptr, [&]
337 {
338 complex_type_def c = complex;
339 c.outer.base_type = "Eina.Inlist";
340 return c;
341 }}
342 , {"array", nullptr, nullptr, [&] 339 , {"array", nullptr, nullptr, [&]
343 { 340 {
344 complex_type_def c = complex; 341 complex_type_def c = complex;
345 c.outer.base_type = "Eina.Array"; 342 c.outer.base_type = "Eina.Array";
346 return c; 343 return c;
347 }} 344 }}
348 , {"inarray", nullptr, nullptr, [&]
349 {
350 complex_type_def c = complex;
351 c.outer.base_type = "Eina.Inarray";
352 return c;
353 }}
354 , {"hash", nullptr, nullptr 345 , {"hash", nullptr, nullptr
355 , [&] 346 , [&]
356 { 347 {
diff --git a/src/bin/eolian_mono/eolian/mono/utils.hh b/src/bin/eolian_mono/eolian/mono/utils.hh
index 0912db8..cbea48a 100644
--- a/src/bin/eolian_mono/eolian/mono/utils.hh
+++ b/src/bin/eolian_mono/eolian/mono/utils.hh
@@ -70,6 +70,14 @@ namespace eolian_mono { namespace utils {
70 name.erase(std::remove(name.begin(), name.end(), target), name.end()); 70 name.erase(std::remove(name.begin(), name.end(), target), name.end());
71 return name; 71 return name;
72 } 72 }
73
74 inline bool ends_with(std::string const& source, std::string suffix)
75 {
76 if (source.size() > suffix.size())
77 return (0 == source.compare(source.size() - suffix.size(), suffix.size(), suffix));
78 else
79 return false;
80 }
73} } 81} }
74 82
75#endif 83#endif
diff --git a/src/bin/eolian_mono/eolian/mono/variable_definition.hh b/src/bin/eolian_mono/eolian/mono/variable_definition.hh
new file mode 100644
index 0000000..d143d7e
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/variable_definition.hh
@@ -0,0 +1,99 @@
1#ifndef EOLIAN_MONO_VARIABLE_DEFINITION_HH
2#define EOLIAN_MONO_VARIABLE_DEFINITION_HH
3
4#include <Eina.hh>
5
6#include "grammar/generator.hpp"
7#include "grammar/klass_def.hpp"
8
9#include "grammar/indentation.hpp"
10#include "grammar/list.hpp"
11#include "grammar/alternative.hpp"
12#include "grammar/attribute_reorder.hpp"
13#include "logging.hh"
14#include "type.hh"
15#include "name_helpers.hh"
16#include "helpers.hh"
17#include "function_helpers.hh"
18#include "marshall_type.hh"
19#include "parameter.hh"
20#include "documentation.hh"
21#include "using_decl.hh"
22#include "generation_contexts.hh"
23#include "blacklist.hh"
24
25namespace eolian_mono {
26
27
28struct constant_definition_generator
29{
30 template<typename OutputIterator, typename Context>
31 bool generate(OutputIterator sink, attributes::variable_def constant, Context context) const
32 {
33 // Open partial class
34 if (!name_helpers::open_namespaces(sink, constant.namespaces, context))
35 return false;
36
37 if (!as_generator("public partial class Constants {\n").generate(sink, attributes::unused, context))
38 return false;
39
40 std::string literal;
41 if (constant.expression_value.type == EOLIAN_EXPR_NULL)
42 literal = "null";
43 else if (constant.expression_value.type == EOLIAN_EXPR_BOOL)
44 literal = (constant.expression_value.value.b ? "true" : "false");
45 else
46 {
47 auto lit = ::eolian_expression_value_to_literal(&constant.expression_value);
48 if (!lit)
49 return false;
50
51 literal = lit;
52 ::eina_stringshare_del(lit);
53
54 // Cleanup suffix. Roslyn does not accept ULL/LL as it has only longs.
55 if (utils::ends_with(literal, "LL") || utils::ends_with(literal, "ll"))
56 literal = literal.substr(0, literal.size() -1);
57
58 }
59
60 // declare variable
61 if (!as_generator(scope_tab(1)
62 << "public static readonly " << type
63 << " " << utils::remove_all(constant.name, '_')
64 << " = " << literal << ";\n")
65 .generate(sink, constant.base_type, context))
66 return false;
67
68 // FIXME missing documentation generator
69
70 // Close partial class
71 if (!as_generator("}\n").generate(sink, attributes::unused, context))
72 return false;
73
74 if (!name_helpers::close_namespaces(sink, constant.namespaces, context))
75 return false;
76
77 return true;
78
79
80 }
81} const constant_definition;
82
83}
84
85namespace efl { namespace eolian { namespace grammar {
86
87template <>
88struct is_eager_generator< ::eolian_mono::constant_definition_generator> : std::true_type {};
89template <>
90struct is_generator< ::eolian_mono::constant_definition_generator> : std::true_type {};
91
92namespace type_traits {
93template <>
94struct attributes_needed< ::eolian_mono::constant_definition_generator> : std::integral_constant<int, 1> {};
95}
96
97} } }
98
99#endif