summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2020-01-30 16:49:04 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2020-02-18 16:47:38 -0300
commit595cb754b3aa280cdbebcb5fa0c51f287099b713 (patch)
tree49ce2ed6e0e25b7268267d8255dddf46266dfe71 /src/bindings
parentd00dadb79ab1c216ecc0519716ca25a1f92c3632 (diff)
eolian-mono: Make Get/Set internal for generated properties
Make Get and Set methods internal for properties that get the property syntax generated. Reviewed-by: João Paulo Taylor Ienczak Zanette <joao.tiz@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D11252
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/cxx/eina_cxx/eina_variant.hh239
-rw-r--r--src/bindings/mono/efl_mono/GenericModel.cs24
-rw-r--r--src/bindings/mono/eo_mono/EoWrapper.cs2
3 files changed, 244 insertions, 21 deletions
diff --git a/src/bindings/cxx/eina_cxx/eina_variant.hh b/src/bindings/cxx/eina_cxx/eina_variant.hh
index a337f2e211..112549020f 100644
--- a/src/bindings/cxx/eina_cxx/eina_variant.hh
+++ b/src/bindings/cxx/eina_cxx/eina_variant.hh
@@ -24,9 +24,21 @@
24#include <iosfwd> 24#include <iosfwd>
25 25
26#include <eina_aligned_union.hh> 26#include <eina_aligned_union.hh>
27#include <eina_tuple.hh>
27 28
28namespace efl { namespace eina { 29namespace efl { namespace eina {
29 30
31template <typename... Args>
32struct variant;
33
34template <typename...Args>
35struct variant_size : std::tuple_size<std::tuple<Args...>>::type
36{
37};
38
39template <typename V>
40struct variant_as_tuple;
41
30namespace _impl { 42namespace _impl {
31 43
32template <typename T, typename U, typename...Others> 44template <typename T, typename U, typename...Others>
@@ -51,7 +63,57 @@ template <typename T, typename U, typename...Args>
51struct find : find_impl<0u, T, U, Args...> 63struct find : find_impl<0u, T, U, Args...>
52{}; 64{};
53 65
66template <std::size_t NT, std::size_t NV, typename TupleVariant, typename TypesFound>
67struct visit_impl_meta_args
68{
69 typedef std::integral_constant<std::size_t, NT> current_type_index;
70 typedef std::integral_constant<std::size_t, NV> current_variant_index;
71 typedef TupleVariant variants;
72 // typedef typename std::tuple_element<NV, variants>::type current_variant;
73 // typedef typename variant_as_tuple<current_variant>::type current_variant_types;
74 // typedef typename std::tuple_element<NT, current_variant_types>::type current_type;
75 typedef TypesFound types_found;
76};
77
78template <typename T> struct current_variant_types
79{
80 typedef typename std::tuple_element<T::current_variant_index::value, typename T::variants>::type current_variant;
81 typedef typename variant_as_tuple<current_variant>::type type;
82};
54} 83}
84
85// template <typename FoundTypes, std::size_t N, typename...Tuples>
86// struct call_n_visitor;
87
88// template <typename FoundTypes, std::size_t N, typename Tuple, typename...Tuples>
89// struct call_n_visitor<FoundTypes, N, Tuple, Tuples...>
90// {
91
92 /*
93 template <typename F>
94 static typename F::result_type call(int type, void* buffer, F f)
95 {
96 if(type == N)
97 {
98 using std::tuple_element;
99 typedef typename tuple_element<N, Tuple>::type type;
100 type* o = static_cast<type*>(buffer);
101 return f(*o);
102 }
103 else
104 return call_visitor<N+1, L, Tuple>::call(type, buffer, f);
105 }
106 */
107
108// template <typename FoundTypes, std::size_t L, typename Tuple>
109// struct call_n_visitor<FoundTypes, L, L, Tuple>
110// {
111// template <typename F, typename...Variants>
112// static typename F::result_type call(int, void const*, F, Variants&&... variants)
113// {
114// std::abort();
115// }
116// };
55 117
56template <std::size_t N, std::size_t L, typename Tuple> 118template <std::size_t N, std::size_t L, typename Tuple>
57struct call_visitor 119struct call_visitor
@@ -306,6 +368,11 @@ struct variant
306 { 368 {
307 return call_visitor<0u, sizeof...(Args), std::tuple<Args...>>::call(type, static_cast<void*>(&buffer), f); 369 return call_visitor<0u, sizeof...(Args), std::tuple<Args...>>::call(type, static_cast<void*>(&buffer), f);
308 } 370 }
371
372 constexpr std::size_t index() const
373 {
374 return type;
375 }
309 376
310private: 377private:
311 template <typename T> 378 template <typename T>
@@ -332,6 +399,103 @@ private:
332 * Member variable for holding the contained value. 399 * Member variable for holding the contained value.
333 */ 400 */
334 buffer_type buffer; 401 buffer_type buffer;
402
403 template <typename V>
404 friend struct variant_as_tuple;
405
406 // template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
407 // friend typename F::result_type visit_impl2
408 // (std::false_type, std::false_type
409 // , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants, index_sequence<I...>);
410
411 // template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
412 // friend typename F::result_type visit_impl2
413 // (std::true_type, std::false_type
414 // , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants, index_sequence<I...>);
415 // template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
416 // friend typename F::result_type visit_impl2
417 // (std::false_type, std::true_type
418 // , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants, index_sequence<I...>);
419
420 // // template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant>
421 // // friend typename F::result_type visit_impl2
422 // // (std::true_type, std::false_type
423 // // , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants)
424 // // {
425 // // }
426
427 // // template <typename F, typename...AllVariants, typename...Variants>
428 // // friend typename F::result_type call
429 // // (std::true_type, int, F &&, Variants&&... variants)
430 // // {
431 // // std::abort();
432 // // }
433
434 // // template <typename F, typename Variant, typename...Variants>
435 // // friend typename F::result_type call (F&&f, Variant&& variant, Variants&&... variants)
436 // // {
437 // // return call (std::integral_constant<bool, (N == variant_size<Variant>::value)>{}
438 // // , variant.type, std::forward<F>(f), std::forward<Variant>(variant), std::forward<Variants>(variants)...);
439 // // }
440
441 // // template <typename F, typename Variant, typename...Variants>
442 // // friend typename F::result_type call (F&&f, Variant&& variant, Variants&&... variants)
443 // // {
444 // // return call (std::integral_constant<bool, (N == variant_size<Variant>::value)>{}
445 // // , variant.type, std::forward<F>(f), std::forward<Variant>(variant), std::forward<Variants>(variants)...);
446 // // }
447
448 // template <typename F, typename...Variants>
449 // friend typename F::result_type visit_impl (F&& f, Variants&&... variants);
450};
451
452
453template <typename...VArgs>
454struct variant_as_tuple<variant<VArgs...>>
455{
456 typedef std::tuple<VArgs...> type;
457};
458
459template <typename...VArgs>
460struct variant_as_tuple<const variant<VArgs...>>
461{
462 typedef std::tuple<VArgs...> type;
463};
464
465template <typename...VArgs>
466struct variant_as_tuple<volatile variant<VArgs...>>
467{
468 typedef std::tuple<VArgs...> type;
469};
470
471template <typename...VArgs>
472struct variant_as_tuple<const volatile variant<VArgs...>>
473{
474 typedef std::tuple<VArgs...> type;
475};
476
477template <typename...VArgs>
478struct variant_as_tuple<variant<VArgs...>&>
479{
480 typedef std::tuple<VArgs...> type;
481};
482
483template <typename...VArgs>
484struct variant_as_tuple<const variant<VArgs...>&>
485{
486 typedef std::tuple<VArgs...> type;
487};
488
489template <typename...VArgs>
490struct variant_as_tuple<volatile variant<VArgs...>&>
491{
492 typedef std::tuple<VArgs...> type;
493};
494
495template <typename...VArgs>
496struct variant_as_tuple<const volatile variant<VArgs...>&>
497{
498 typedef std::tuple<VArgs...> type;
335}; 499};
336 500
337template <typename...Args> 501template <typename...Args>
@@ -372,7 +536,80 @@ T const& get(variant<Args...>const& variant, typename std::enable_if<_impl::is_o
372 else 536 else
373 throw std::logic_error(""); 537 throw std::logic_error("");
374} 538}
375 539
540template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
541 typename F::result_type visit_impl2
542 (std::false_type, std::true_type
543 , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants
544 , eina::index_sequence<I...>)
545 {
546 return f (eina::get<typename std::tuple_element<I, Types>::type>(std::get<I>(variants))...);
547 }
548
549 template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant, std::size_t...I>
550 typename F::result_type visit_impl2
551 (std::true_type, std::false_type
552 , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&&, TupleVariant&&, eina::index_sequence<I...>)
553 {
554 std::abort();
555 }
556
557
558 template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant
559 , std::size_t...I>
560 typename F::result_type visit_impl2 (std::false_type, std::false_type
561 , _impl::visit_impl_meta_args<NT, NV, Tuple, Types>, F&& f, TupleVariant&& variants
562 , index_sequence<I...>)
563 {
564 using std::tuple_element;
565 typedef _impl::visit_impl_meta_args<NT, NV, Tuple, Types> meta_args;
566 if(std::get<NV>(variants).index() == NT)
567 {
568 typedef typename _impl::current_variant_types<meta_args>::type variant_types;
569 typedef typename tuple_element<NT, variant_types>::type type;
570 std::integral_constant<bool, (std::tuple_size<Tuple>::value == NV+1)> is_true {};
571 return visit_impl2( std::false_type{}
572 , is_true
573 , _impl::visit_impl_meta_args<0u, NV+1, Tuple, typename _mpl::push_back<Types, type>::type>{}
574 , std::forward<F>(f), std::forward<TupleVariant>(variants)
575 , make_index_sequence<std::tuple_size<TupleVariant>::value>{});
576 }
577 else
578 {
579 typedef typename _impl::current_variant_types<meta_args>::type variant_types;
580 return visit_impl2 (std::integral_constant<bool, (std::tuple_size<variant_types>::value == NT+1)>{}
581 , std::false_type{}
582 , _impl::visit_impl_meta_args<NT+1, NV, Tuple, Types>{}, std::forward<F>(f), std::forward<TupleVariant>(variants)
583 , make_index_sequence<std::tuple_size<TupleVariant>::value>{});
584 }
585 }
586
587 template <std::size_t NT, std::size_t NV, typename F, typename Tuple, typename Types, typename TupleVariant>
588 typename F::result_type visit_impl_aux (std::false_type fals, std::false_type
589 , _impl::visit_impl_meta_args<NT, NV, Tuple, Types> args, F&& f, TupleVariant&& variants)
590 {
591 return visit_impl2 (fals, fals, args, std::forward<F>(f), std::forward<TupleVariant>(variants)
592 , make_index_sequence<std::tuple_size<TupleVariant>::value>{});
593 }
594
595 template <typename F, typename...Variants>
596 typename F::result_type visit_impl (F&& f, Variants&&... variants)
597 {
598 return visit_impl_aux
599 (std::false_type{}
600 , std::false_type{}
601 , _impl::visit_impl_meta_args
602 <0u, 0u
603 , std::tuple<typename std::remove_cv<Variants>::type...>, std::tuple<>>{}, std::forward<F>(f), std::forward_as_tuple(std::forward<Variants>(variants)...));
604 }
605
606template <typename F, typename...Variants>
607auto visit (F&& function, Variants&& ... variants) -> typename F::result_type
608{
609 return visit_impl (std::forward<F>(function), std::forward<Variants>(variants)...);
610}
611
376} } 612} }
377 613
378#endif 614#endif
615
diff --git a/src/bindings/mono/efl_mono/GenericModel.cs b/src/bindings/mono/efl_mono/GenericModel.cs
index ae1b69cf3e..c23eeb64ab 100644
--- a/src/bindings/mono/efl_mono/GenericModel.cs
+++ b/src/bindings/mono/efl_mono/GenericModel.cs
@@ -33,20 +33,13 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
33 /// <summary>The list of properties available in the wrapped model.</summary> 33 /// <summary>The list of properties available in the wrapped model.</summary>
34 public IEnumerable<System.String> Properties 34 public IEnumerable<System.String> Properties
35 { 35 {
36 get { return GetProperties(); } 36 get { return model.Properties; }
37 } 37 }
38 38
39 /// <summary>The number of children in the wrapped model.</summary> 39 /// <summary>The number of children in the wrapped model.</summary>
40 public uint ChildrenCount 40 public uint ChildrenCount
41 { 41 {
42 get { return GetChildrenCount(); } 42 get { return model.ChildrenCount; }
43 }
44
45 /// <summary>The list of properties available in the wrapped model.</summary>
46 /// <returns>The list of properties in the model.</returns>
47 public IEnumerable<System.String> GetProperties()
48 {
49 return model.GetProperties();
50 } 43 }
51 44
52 /// <summary>Gets the value of the given property in the wrapped model.</summary> 45 /// <summary>Gets the value of the given property in the wrapped model.</summary>
@@ -67,13 +60,6 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
67 return model.SetProperty(property, value); 60 return model.SetProperty(property, value);
68 } 61 }
69 62
70 /// <summary>Returns the number of children in the wrapped model.</summary>
71 /// <returns>The number of children.</returns>
72 public uint GetChildrenCount()
73 {
74 return model.GetChildrenCount();
75 }
76
77 /// <summary>Returns an <see cref="Eina.Future" /> that will resolve when the property is ready to be read.</summary> 63 /// <summary>Returns an <see cref="Eina.Future" /> that will resolve when the property is ready to be read.</summary>
78 /// <param name="property">The property of the model.</param> 64 /// <param name="property">The property of the model.</param>
79 /// <returns>An <see cref="Eina.Future" /> that resolves when the property is ready.</returns> 65 /// <returns>An <see cref="Eina.Future" /> that resolves when the property is ready.</returns>
@@ -169,10 +155,10 @@ public class GenericModel<T> : Efl.Object, Efl.IModel
169 155
170 /// <summary>Get children as specified by iterator. 156 /// <summary>Get children as specified by iterator.
171 /// 157 ///
172 /// Provided index have to be between 0 and <see cref="Efl.IModel.GetChildrenCount"/>. 158 /// Provided index have to be between 0 and <see cref="Efl.IModel.ChildrenCount"/>.
173 /// 159 ///
174 /// This function might rely on <see cref="Efl.IModel.GetChildrenSlice"/> as a fallback.</summary> 160 /// This function might rely on <see cref="Efl.IModel.GetChildrenSlice"/> as a fallback.<br/>Since EFL 1.23.</summary>
175 /// <param name="indices">Indices of the requested children.</param> 161 /// <param name="indices">Indices of the requested children.</param>
176 /// <returns>Array of children</returns> 162 /// <returns>Array of children</returns>
177 public Eina.Future GetChildrenIndex(IEnumerable<uint> indices) 163 public Eina.Future GetChildrenIndex(IEnumerable<uint> indices)
178 { 164 {
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index db618232c4..e4ff8669e6 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -227,7 +227,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
227 public void Del() 227 public void Del()
228 { 228 {
229 // FIXME Implement this 229 // FIXME Implement this
230 ((Efl.Object)this).SetParent(null); 230 ((Efl.Object)this).Parent = null;
231 Dispose(); 231 Dispose();
232 } 232 }
233 233