summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-22 01:22:38 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-23 01:14:20 -0300
commit4523931a5b623eb4ae30a83470e47617485ceac8 (patch)
tree9de660590f1ff5c0f839e221bed0ebbf394b6fa5
parentfe2675035a300b90a9943d7b5f06d14769e608e7 (diff)
csharp: WIP - Replace property getset call with assignmentdevs/lauromoura/property_revamp
Still needs to unpack tuple params for conversion in the epilogue.
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh110
1 files changed, 68 insertions, 42 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 007581d..e30c979 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -107,49 +107,75 @@ struct native_function_definition_generator
107 if (f.is_static) 107 if (f.is_static)
108 self = ""; 108 self = "";
109 109
110 if(!as_generator 110 // Preamble
111 (indent << "private static " 111 if (!as_generator
112 << eolian_mono::marshall_type(true) << " " 112 (indent << "private static "
113 << string 113 << eolian_mono::marshall_type(true) << " "
114 << "(System.IntPtr obj, System.IntPtr pd" 114 << string
115 << *(", " << marshall_parameter) 115 << "(System.IntPtr obj, System.IntPtr pd"
116 << ")\n" 116 << *(", " << marshall_parameter)
117 << indent << "{\n" 117 << ")\n"
118 << indent << scope_tab << "Eina.Log.Debug(\"function " << string << " was called\");\n" 118 << indent << "{\n"
119 << indent << scope_tab << "var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);\n" 119 << indent << scope_tab << "Eina.Log.Debug(\"function " << string << " was called\");\n"
120 << indent << scope_tab << "if (ws != null)\n" 120 << indent << scope_tab << "var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);\n"
121 << indent << scope_tab << "{\n" 121 << indent << scope_tab << "if (ws != null)\n"
122 << indent << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() << "\n" 122 << indent << scope_tab << "{\n"
123 << indent << scope_tab << scope_tab << "try\n" 123 << indent << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble() << "\n"
124 << indent << scope_tab << scope_tab << "{\n" 124 << indent << scope_tab << scope_tab << "try\n"
125 << indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") 125 << indent << scope_tab << scope_tab << "{\n"
126 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string 126 ).generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters, f.c_name, f), context))
127 << "(" << (native_argument_invocation % ", ") << ");\n" 127 return false;
128 << indent << scope_tab << scope_tab << "}\n" 128
129 << indent << scope_tab << scope_tab << "catch (Exception e)\n" 129 // Actual call
130 << indent << scope_tab << scope_tab << "{\n" 130 // FIXME Replace with attribute assignment for properties
131 << indent << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n" 131 if (!helpers::is_property_wrapper(f, context))
132 << indent << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n" 132 {
133 << indent << scope_tab << scope_tab << "}\n\n" 133 if (!as_generator
134 << indent << eolian_mono::native_function_definition_epilogue(*klass) << "\n" 134 (indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
135 << indent << scope_tab << "}\n" 135 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
136 << indent << scope_tab << "else\n" 136 << "(" << (native_argument_invocation % ", ") << ");\n"
137 << indent << scope_tab << "{\n" 137 ).generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters), context))
138 << indent << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string 138 return false;
139 << "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n" 139 }
140 << indent << scope_tab << "}\n" 140 else if (f.type == attributes::function_type::prop_get)
141 << indent << "}\n\n" 141 {
142 if (!as_generator
143 (indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "return ")
144 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
145 << ";\n"
146 ).generate(sink, name_helpers::property_managed_name(f.klass, f.name.substr(0, f.name.size() - 3)), context))
147 return false;
148 }
149 else if (f.type == attributes::function_type::prop_get)
150 {
151 if (!as_generator
152 (indent << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
153 << (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")ws.Target).") << string
154 << "(" << (native_argument_invocation % ", ") << ");\n"
155 ).generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.parameters), context))
156 return false;
157 }
158 else
159 EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "Invalid type of native function for function " << f.c_name << std::endl;
160
161 // Epilogue
162 if (!as_generator(
163 indent << scope_tab << scope_tab << "}\n"
164 << indent << scope_tab << scope_tab << "catch (Exception e)\n"
165 << indent << scope_tab << scope_tab << "{\n"
166 << indent << scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
167 << indent << scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
168 << indent << scope_tab << scope_tab << "}\n\n"
169 << indent << eolian_mono::native_function_definition_epilogue(*klass) << "\n"
170 << indent << scope_tab << "}\n"
171 << indent << scope_tab << "else\n"
172 << indent << scope_tab << "{\n"
173 << indent << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string
174 << "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n"
175 << indent << scope_tab << "}\n"
176 << indent << "}\n\n"
142 ) 177 )
143 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters 178 .generate(sink, std::make_tuple(f, f.c_name, f.parameters), context))
144 , /***/f.c_name/***/
145 , f
146 , name_helpers::managed_method_name(f)
147 , f.parameters
148 , f
149 , f.c_name
150 , f.parameters
151 )
152 , context))
153 return false; 179 return false;
154 180
155 // Static functions do not need to be called from C 181 // Static functions do not need to be called from C