summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-08-05 10:17:52 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-08-05 10:18:18 -0400
commit40def3eac914138189163a895527705a1ffefcfd (patch)
treee77fc891713de50ca312b080474260d34d7d36df /src/bin
parent7c72f101532d61b00cd483b89ef86830526a82ba (diff)
efl-mono: Add Model manual implementation to C# and MVVM factories
Summary: Depends on D9273, D9270 Test Plan: Run added testcases. Reviewers: cedric, bu5hm4n, zmike, SanghyeonLee, felipealmeida, segfaultxavi Reviewed By: cedric Subscribers: cedric Tags: #expertise_solutions, #efl_language_bindings Differential Revision: https://phab.enlightenment.org/D8080
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh53
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh10
2 files changed, 63 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 8c43008c53..cf85f6844d 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -223,6 +223,52 @@ struct native_function_definition_parameterized
223 } 223 }
224} const native_function_definition; 224} const native_function_definition;
225 225
226struct property_extension_method_definition_generator
227{
228 template<typename OutputIterator, typename Context>
229 bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const
230 {
231 if (blacklist::is_property_blacklisted(property, context))
232 return true;
233
234 auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
235
236 if (!options.want_beta)
237 return true; // Bindable is a beta feature for now.
238
239 auto get_params = property.getter.is_engaged() ? property.getter->parameters.size() : 0;
240 auto set_params = property.setter.is_engaged() ? property.setter->parameters.size() : 0;
241
242 std::string managed_name = name_helpers::property_managed_name(property);
243
244 if (get_params > 0 || set_params > 1)
245 return true;
246
247 std::string dir_mod;
248 if (property.setter.is_engaged())
249 dir_mod = direction_modifier(property.setter->parameters[0]);
250
251 if (property.setter.is_engaged())
252 {
253 attributes::type_def prop_type = property.setter->parameters[0].type;
254 if (!as_generator("public static Efl.Bindable<" << type(true) << "> " << managed_name << "<T>(this Efl.Ui.ItemFactory<T> fac) where T : " << name_helpers::klass_full_concrete_or_interface_name(cls) << " {\n"
255 << scope_tab << scope_tab << "return new Efl.Bindable<" << type(true) << ">(\"" << property.name << "\", fac);\n"
256 << scope_tab << "}\n"
257 ).generate(sink, std::make_tuple(prop_type, prop_type), context))
258 return false;
259 }
260
261 return true;
262 }
263
264 grammar::attributes::klass_def const& cls;
265};
266
267property_extension_method_definition_generator property_extension_method_definition (grammar::attributes::klass_def const& cls)
268{
269 return {cls};
270}
271
226struct property_wrapper_definition_generator 272struct property_wrapper_definition_generator
227{ 273{
228 template<typename OutputIterator, typename Context> 274 template<typename OutputIterator, typename Context>
@@ -345,6 +391,8 @@ struct is_eager_generator< ::eolian_mono::function_definition_generator> : std::
345template <> 391template <>
346struct is_eager_generator< ::eolian_mono::native_function_definition_generator> : std::true_type {}; 392struct is_eager_generator< ::eolian_mono::native_function_definition_generator> : std::true_type {};
347template <> 393template <>
394struct is_eager_generator< ::eolian_mono::property_extension_method_definition_generator> : std::true_type {};
395template <>
348struct is_eager_generator< ::eolian_mono::property_wrapper_definition_generator> : std::true_type {}; 396struct is_eager_generator< ::eolian_mono::property_wrapper_definition_generator> : std::true_type {};
349template <> 397template <>
350struct is_eager_generator< ::eolian_mono::property_wrapper_definition_parameterized> : std::true_type {}; 398struct is_eager_generator< ::eolian_mono::property_wrapper_definition_parameterized> : std::true_type {};
@@ -355,6 +403,8 @@ struct is_generator< ::eolian_mono::native_function_definition_generator> : std:
355template <> 403template <>
356struct is_generator< ::eolian_mono::function_definition_parameterized> : std::true_type {}; 404struct is_generator< ::eolian_mono::function_definition_parameterized> : std::true_type {};
357template <> 405template <>
406struct is_generator< ::eolian_mono::property_extension_method_definition_generator> : std::true_type {};
407template <>
358struct is_generator< ::eolian_mono::property_wrapper_definition_generator> : std::true_type {}; 408struct is_generator< ::eolian_mono::property_wrapper_definition_generator> : std::true_type {};
359template <> 409template <>
360struct is_generator< ::eolian_mono::property_wrapper_definition_parameterized> : std::true_type {}; 410struct is_generator< ::eolian_mono::property_wrapper_definition_parameterized> : std::true_type {};
@@ -370,6 +420,9 @@ template <>
370struct attributes_needed< ::eolian_mono::native_function_definition_generator> : std::integral_constant<int, 1> {}; 420struct attributes_needed< ::eolian_mono::native_function_definition_generator> : std::integral_constant<int, 1> {};
371 421
372template <> 422template <>
423struct attributes_needed< ::eolian_mono::property_extension_method_definition_generator> : std::integral_constant<int, 1> {};
424
425template <>
373struct attributes_needed< ::eolian_mono::property_wrapper_definition_generator> : std::integral_constant<int, 1> {}; 426struct attributes_needed< ::eolian_mono::property_wrapper_definition_generator> : std::integral_constant<int, 1> {};
374template <> 427template <>
375struct attributes_needed< ::eolian_mono::property_wrapper_definition_parameterized> : std::integral_constant<int, 1> {}; 428struct attributes_needed< ::eolian_mono::property_wrapper_definition_parameterized> : std::integral_constant<int, 1> {};
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 80d4debc99..f118dea619 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -348,6 +348,16 @@ struct klass
348 if(!name_helpers::close_namespaces(sink, cls.namespaces, context)) 348 if(!name_helpers::close_namespaces(sink, cls.namespaces, context))
349 return false; 349 return false;
350 350
351 if(!as_generator
352 (lit("#pragma warning disable CS1591\n") // Disabling warnings as DocFx will hide these classes
353 <<"public static class " << (string % "_") << name_helpers::klass_inherit_name(cls)
354 << "_ExtensionMethods {\n"
355 << *((scope_tab << property_extension_method_definition(cls)) << "\n")
356 << "}\n"
357 << lit("#pragma warning restore CS1591\n"))
358 .generate(sink, std::make_tuple(cls.namespaces, cls.properties), context))
359 return false;
360
351 return true; 361 return true;
352 } 362 }
353 363