summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/part_definition.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-08-19 21:31:20 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-08-19 21:41:29 -0300
commitcc49c1034b1114e1ce9d10d8651ec6d24c1faaa1 (patch)
treefe13ff532336c143320afa99dcf7e937ee21d28e /src/bin/eolian_mono/eolian/mono/part_definition.hh
parent2a0eeba4e5fdd0de0c46000fa783cb59f7d716e7 (diff)
csharp: MVVM parts support
Summary: Parts binding will follow a similar approach to regular property binding: `var error = factory.PartName().PropertyName().Bind(modelProperty);` * Changed both `Bind()` overloads to return the error code from `efl_ui_property_bind` * Also properties from interfaces implemented didn't have their `Bindable` wrapper methds available. Depends on D9563 Reviewers: felipealmeida, cedric, SanghyeonLee, woohyun Reviewed By: cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9564
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/part_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/part_definition.hh40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh
index 484cd0d65a..ec6ef61551 100644
--- a/src/bin/eolian_mono/eolian/mono/part_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh
@@ -35,6 +35,39 @@ struct part_definition_generator
35 35
36} const part_definition {}; 36} const part_definition {};
37 37
38struct part_extension_method_definition_generator
39{
40 template<typename OutputIterator, typename Context>
41 bool generate(OutputIterator sink, attributes::part_def const& part, Context context) const
42 {
43 if (blacklist::is_class_blacklisted(part.klass, context))
44 return true;
45
46 auto part_klass_name = name_helpers::klass_full_concrete_or_interface_name(part.klass);
47 /* auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state; */
48 /* auto klass = get_klass(part.klass, unit); */
49
50 if (!as_generator(
51 scope_tab << "public static Efl.BindablePart<" << part_klass_name << "> " << name_helpers::managed_part_name(part) << "<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<"
52 << name_helpers::klass_full_concrete_or_interface_name(cls)
53 << ", T> x=null) where T : " << name_helpers::klass_full_concrete_or_interface_name(cls) << "\n"
54 << scope_tab << "{\n"
55 << scope_tab << scope_tab << "return new Efl.BindablePart<" << part_klass_name << ">(\"" << part.name << "\" ,fac);\n"
56 << scope_tab << "}\n"
57 ).generate(sink, attributes::unused, context))
58 return false;
59
60 return true;
61 }
62
63 grammar::attributes::klass_def const& cls;
64};
65
66part_extension_method_definition_generator part_extension_method_definition (grammar::attributes::klass_def const& cls)
67{
68 return {cls};
69}
70
38} 71}
39 72
40namespace efl { namespace eolian { namespace grammar { 73namespace efl { namespace eolian { namespace grammar {
@@ -44,10 +77,17 @@ struct is_eager_generator< ::eolian_mono::part_definition_generator> : std::true
44template <> 77template <>
45struct is_generator< ::eolian_mono::part_definition_generator> : std::true_type {}; 78struct is_generator< ::eolian_mono::part_definition_generator> : std::true_type {};
46 79
80template <>
81struct is_eager_generator< ::eolian_mono::part_extension_method_definition_generator> : std::true_type {};
82template <>
83struct is_generator< ::eolian_mono::part_extension_method_definition_generator> : std::true_type {};
84
47namespace type_traits { 85namespace type_traits {
48template <> 86template <>
49struct attributes_needed< ::eolian_mono::part_definition_generator> : std::integral_constant<int, 1> {}; 87struct attributes_needed< ::eolian_mono::part_definition_generator> : std::integral_constant<int, 1> {};
50 88
89template <>
90struct attributes_needed< ::eolian_mono::part_extension_method_definition_generator> : std::integral_constant<int, 1> {};
51} 91}
52} } } 92} } }
53 93