summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/function_definition.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/function_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 5a78bc7..915b12e 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -22,6 +22,8 @@
22#include "generation_contexts.hh" 22#include "generation_contexts.hh"
23#include "blacklist.hh" 23#include "blacklist.hh"
24 24
25#include <iostream>
26
25namespace eolian_mono { 27namespace eolian_mono {
26 28
27struct native_function_definition_generator 29struct native_function_definition_generator
@@ -32,7 +34,8 @@ struct native_function_definition_generator
32 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const 34 bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
33 { 35 {
34 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl; 36 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. 37 std::cout << "native_function_definition_generator: " << f.c_name << " F: return type " << f.return_type << std::endl;
38 if(blacklist::is_function_blacklisted(f, context)/* || f.is_static*/) // Only Concrete classes implement static methods.
36 return true; 39 return true;
37 else 40 else
38 { 41 {
@@ -51,14 +54,14 @@ struct native_function_definition_generator
51 << ");\n") 54 << ");\n")
52 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 55 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
53 return false; 56 return false;
54
55 if(!as_generator 57 if(!as_generator
56 (scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")] " 58 ("\n\n" << scope_tab
57 << eolian_mono::marshall_native_annotation(true) 59 << eolian_mono::marshall_native_annotation(true)
58 << " private static extern " 60 << " public delegate "
59 << eolian_mono::marshall_type(true) 61 << eolian_mono::marshall_type(true)
60 << " " << string 62 << " "
61 << "(System.IntPtr obj" 63 << string
64 << "_api_delegate(System.IntPtr obj"
62 << *grammar::attribute_reorder<-1, -1> 65 << *grammar::attribute_reorder<-1, -1>
63 ( 66 (
64 (", " << marshall_native_annotation << " " << marshall_parameter) 67 (", " << marshall_native_annotation << " " << marshall_parameter)
@@ -67,6 +70,13 @@ struct native_function_definition_generator
67 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 70 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
68 return false; 71 return false;
69 72
73 if(!as_generator
74 (scope_tab
75 << " public static Efl.Eo.FunctionWrapper<" << string << "_api_delegate> " << string << "_ptr = new Efl.Eo.FunctionWrapper<"
76 << string << "_api_delegate>(_Module, \"" << string << "\");\n")
77 .generate(sink, std::make_tuple(f.c_name, f.c_name, f.c_name, f.c_name), context))
78 return false;
79
70 std::string return_type; 80 std::string return_type;
71 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 81 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
72 return false; 82 return false;
@@ -93,7 +103,8 @@ struct native_function_definition_generator
93 << scope_tab << scope_tab << "if(wrapper != null) {\n" 103 << scope_tab << scope_tab << "if(wrapper != null) {\n"
94 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() 104 << scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
95 << scope_tab << scope_tab << scope_tab << "try {\n" 105 << 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 106 << scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "")
107 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")wrapper).") << string
97 << "(" << (native_argument_invocation % ", ") << ");\n" 108 << "(" << (native_argument_invocation % ", ") << ");\n"
98 << scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n" 109 << 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" 110 << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
@@ -102,7 +113,7 @@ struct native_function_definition_generator
102 << eolian_mono::native_function_definition_epilogue(*klass) 113 << eolian_mono::native_function_definition_epilogue(*klass)
103 << scope_tab << scope_tab << "} else {\n" 114 << scope_tab << scope_tab << "} else {\n"
104 << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string 115 << 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" 116 << "_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, " << "Efl.Eo.Globals.efl_class_get(obj))" << *(", " << argument) << ");\n"
106 << scope_tab << scope_tab << "}\n" 117 << scope_tab << scope_tab << "}\n"
107 << scope_tab << "}\n" 118 << scope_tab << "}\n"
108 ) 119 )
@@ -141,20 +152,20 @@ struct function_definition_generator
141 if(blacklist::is_function_blacklisted(f, context)) 152 if(blacklist::is_function_blacklisted(f, context))
142 return true; 153 return true;
143 154
144 if(!as_generator 155 // if(!as_generator
145 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n" 156 // ("\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) 157 // << scope_tab << eolian_mono::marshall_annotation(true)
147 << (do_super ? " protected " : " private ") << "static extern " 158 // << (do_super ? " protected " : " private ") << "static extern "
148 << eolian_mono::marshall_type(true) 159 // << eolian_mono::marshall_type(true)
149 << " " << string 160 // << " " << string
150 << "(System.IntPtr obj" 161 // << "(System.IntPtr obj"
151 << *grammar::attribute_reorder<-1, -1> 162 // << *grammar::attribute_reorder<-1, -1>
152 ( 163 // (
153 (", " << marshall_annotation << " " << marshall_parameter) 164 // (", " << marshall_annotation << " " << marshall_parameter)
154 ) 165 // )
155 << ");\n") 166 // << ");\n")
156 .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context)) 167 // .generate(sink, std::make_tuple(f.return_type, f.return_type, f.c_name, f.parameters), context))
157 return false; 168 // return false;
158 169
159 std::string return_type; 170 std::string return_type;
160 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context)) 171 if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
@@ -175,8 +186,9 @@ struct function_definition_generator
175 if(!as_generator 186 if(!as_generator
176 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ") 187 (scope_tab << ((do_super && !f.is_static) ? "virtual " : "") << "public " << (f.is_static ? "static " : "") << return_type << " " << string << "(" << (parameter % ", ")
177 << ") {\n " 188 << ") {\n "
178 << eolian_mono::function_definition_preamble() << string << "(" 189 << eolian_mono::function_definition_preamble()
179 << self 190 << klass_full_native_inherit_name(f.klass) << "." << string << "_ptr.Value.Delegate("
191 << self
180 << *(", " << argument_invocation ) << ");\n" 192 << *(", " << argument_invocation ) << ");\n"
181 << eolian_mono::function_definition_epilogue() 193 << eolian_mono::function_definition_epilogue()
182 << " }\n") 194 << " }\n")