summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2016-03-03 15:10:13 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2016-03-03 16:05:40 -0300
commit9cbda57bf03bfdaa5c0379023a05868b2f0986aa (patch)
treedebe60f34d6352ae562a575693289c068fc689b3
parent5c7d78d1040b5bdfe6430e84c90d36ab8bf27064 (diff)
eolian-cxx: Fix Eolian C++ constructing methods with new eo_add
Also fix Eolian C++ examples using the new "eo_super".
-rw-r--r--src/bindings/eo_cxx/eo_cxx_interop.hh4
-rw-r--r--src/bindings/eo_cxx/eo_inherit.hh13
-rw-r--r--src/bindings/eo_cxx/eo_inherit_bindings.hh12
-rw-r--r--src/examples/eolian_cxx/colourable_cxx.cc6
-rw-r--r--src/examples/eolian_cxx/colourablesquare_cxx.cc2
-rw-r--r--src/examples/eolian_cxx/eolian_cxx_inherit_01.cc4
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh9
7 files changed, 23 insertions, 27 deletions
diff --git a/src/bindings/eo_cxx/eo_cxx_interop.hh b/src/bindings/eo_cxx/eo_cxx_interop.hh
index 7cd7b35..b1978a8 100644
--- a/src/bindings/eo_cxx/eo_cxx_interop.hh
+++ b/src/bindings/eo_cxx/eo_cxx_interop.hh
@@ -472,9 +472,9 @@ F* alloc_static_callback(F&& f)
472 472
473template <typename... Fs> 473template <typename... Fs>
474inline 474inline
475void call_ctors(Fs&&... fs) 475void call_ctors(Eo* _obj_eoid, Fs&&... fs)
476{ 476{
477 std::initializer_list<int const> const v {(fs(), 0)...}; 477 std::initializer_list<int const> const v {(fs(_obj_eoid), 0)...};
478 (void) v; 478 (void) v;
479} 479}
480 480
diff --git a/src/bindings/eo_cxx/eo_inherit.hh b/src/bindings/eo_cxx/eo_inherit.hh
index 3138d1e..9639e33 100644
--- a/src/bindings/eo_cxx/eo_inherit.hh
+++ b/src/bindings/eo_cxx/eo_inherit.hh
@@ -22,8 +22,15 @@ namespace detail {
22template <typename D, typename... E, std::size_t... S> 22template <typename D, typename... E, std::size_t... S>
23Eo_Class const* create_class(eina::index_sequence<S...>); 23Eo_Class const* create_class(eina::index_sequence<S...>);
24 24
25inline 25/// @internal
26void inherit_constructor(void* this_); 26///
27/// @brief Find the correct function for the <em>"constructor"</em>
28/// operation and invoke it.
29///
30/// @param this_ The <em>user data</em> to be passed to the resolved function.
31/// @param args An heterogeneous sequence of arguments.
32///
33inline EOAPI EO_VOID_FUNC_BODYV(inherit_constructor, EO_FUNC_CALL(this_), void* this_);
27 34
28} 35}
29 36
@@ -78,7 +85,7 @@ struct inherit
78 inherit(efl::eo::parent_type _p, Args&& ... args) 85 inherit(efl::eo::parent_type _p, Args&& ... args)
79 { 86 {
80 _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>()); 87 _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>());
81 _eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(this), ::efl::eolian::call_ctors(args...)); 88 _eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(eoid, this), ::efl::eolian::call_ctors(eoid, args...));
82 ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...); 89 ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...);
83 } 90 }
84 91
diff --git a/src/bindings/eo_cxx/eo_inherit_bindings.hh b/src/bindings/eo_cxx/eo_inherit_bindings.hh
index 458036d..bb29b9e 100644
--- a/src/bindings/eo_cxx/eo_inherit_bindings.hh
+++ b/src/bindings/eo_cxx/eo_inherit_bindings.hh
@@ -53,18 +53,6 @@ void inherit_constructor_impl(Eo*, Inherit_Private_Data* self, void* this_)
53 self->this_ = this_; 53 self->this_ = this_;
54} 54}
55 55
56/// @internal
57///
58/// @brief Find the correct function for the <em>"constructor"</em>
59/// operation and invoke it.
60///
61/// @param this_ The <em>user data</em> to be passed to the resolved function.
62/// @param args An heterogeneous sequence of arguments.
63///
64// inline EOAPI EO_VOID_FUNC_BODYV(inherit_constructor, EO_FUNC_CALL(this_), void* this_);
65inline
66void inherit_constructor(void* this_);
67
68template <typename T> 56template <typename T>
69int initialize_operation_description(detail::tag<void>, void*); 57int initialize_operation_description(detail::tag<void>, void*);
70 58
diff --git a/src/examples/eolian_cxx/colourable_cxx.cc b/src/examples/eolian_cxx/colourable_cxx.cc
index 934a5d0..f1f6bec 100644
--- a/src/examples/eolian_cxx/colourable_cxx.cc
+++ b/src/examples/eolian_cxx/colourable_cxx.cc
@@ -24,14 +24,14 @@ _colourable_eo_base_constructor(Eo *obj, Colourable_Data *self)
24{ 24{
25 EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl; 25 EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl;
26 self->r = self->g = self->b = 0; 26 self->r = self->g = self->b = 0;
27 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor()); 27 return eo_constructor(eo_super(obj, MY_CLASS));
28} 28}
29 29
30void 30void
31_colourable_eo_base_destructor(Eo *obj, Colourable_Data *self EINA_UNUSED) 31_colourable_eo_base_destructor(Eo *obj, Colourable_Data *self EINA_UNUSED)
32{ 32{
33 EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl; 33 EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl;
34 eo_do_super(obj, MY_CLASS, eo_destructor()); 34 eo_destructor(eo_super(obj, MY_CLASS));
35} 35}
36 36
37void 37void
@@ -42,7 +42,7 @@ _colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb)
42 self->r = (rgb & 0x00ff0000) >> 16; 42 self->r = (rgb & 0x00ff0000) >> 16;
43 self->g = (rgb & 0x0000ff00) >> 8; 43 self->g = (rgb & 0x0000ff00) >> 8;
44 self->b = rgb & 0x000000ff; 44 self->b = rgb & 0x000000ff;
45 eo_do_super(obj, MY_CLASS, eo_constructor()); 45 eo_constructor(eo_super(obj, MY_CLASS));
46} 46}
47 47
48void 48void
diff --git a/src/examples/eolian_cxx/colourablesquare_cxx.cc b/src/examples/eolian_cxx/colourablesquare_cxx.cc
index 906183a2..6908f73 100644
--- a/src/examples/eolian_cxx/colourablesquare_cxx.cc
+++ b/src/examples/eolian_cxx/colourablesquare_cxx.cc
@@ -25,7 +25,7 @@ _colourablesquare_size_constructor(Eo *obj, ColourableSquare_Data *self, int siz
25{ 25{
26 self->size = size; 26 self->size = size;
27 EINA_CXX_DOM_LOG_DBG(domain) << __func__ << " [ size = " << size << " ]" << std::endl; 27 EINA_CXX_DOM_LOG_DBG(domain) << __func__ << " [ size = " << size << " ]" << std::endl;
28 eo_do_super(obj, MY_CLASS, eo_constructor()); 28 eo_constructor(eo_super(obj, MY_CLASS));
29} 29}
30 30
31int 31int
diff --git a/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc b/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
index bdfa3ad..b0fb169 100644
--- a/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
+++ b/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
@@ -23,7 +23,7 @@ struct ColourableCircle
23 int colour_get() 23 int colour_get()
24 { 24 {
25 int rgb = 0; 25 int rgb = 0;
26 eo_do_super(_eo_ptr(), _eo_class(), rgb = ::colourable_colour_get()); 26 rgb = ::colourable_colour_get(eo_super(_eo_ptr(), _eo_class()));
27 std::cout << "ColourableCircle::colour_get(" << this << ") ==> " 27 std::cout << "ColourableCircle::colour_get(" << this << ") ==> "
28 << std::hex << rgb << std::endl; 28 << std::hex << rgb << std::endl;
29 return rgb; 29 return rgb;
@@ -52,7 +52,7 @@ struct ColourableBar
52 int colour_get() 52 int colour_get()
53 { 53 {
54 int rgb = 0; 54 int rgb = 0;
55 eo_do_super(_eo_ptr(), _eo_class(), rgb = ::colourable_colour_get()); 55 rgb = ::colourable_colour_get(eo_super(_eo_ptr(), _eo_class()));
56 std::cout << "ColourableBar::colour_get(" << this << ") ==> " 56 std::cout << "ColourableBar::colour_get(" << this << ") ==> "
57 << std::hex << rgb << std::endl; 57 << std::hex << rgb << std::endl;
58 return rgb; 58 return rgb;
diff --git a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
index 74c9c32..2a7091a 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
@@ -158,9 +158,10 @@ operator<<(std::ostream& out, functors_constructor_methods const& x)
158 << tab(2) << "{}" << endl; 158 << tab(2) << "{}" << endl;
159 159
160 // Struct operator() 160 // Struct operator()
161 out << tab(2) << "void operator()()" << endl 161 out << tab(2) << "void operator()(Eo* _obj_eoid)" << endl
162 << tab(2) << "{" << endl 162 << tab(2) << "{" << endl
163 << tab(3) << "::" << c.impl << "(" << parameters_forward_to_c(c.params) << ");" << endl 163 << tab(3) << "::" << c.impl << "(_obj_eoid" << (c.params.empty() ? "" : ", ")
164 << parameters_forward_to_c(c.params) << ");" << endl
164 << tab(2) << "}" << endl; 165 << tab(2) << "}" << endl;
165 166
166 // Register event to free allocated callbacks when the Eo* is deleted 167 // Register event to free allocated callbacks when the Eo* is deleted
@@ -579,10 +580,10 @@ operator<<(std::ostream& out, function_call_constructor_methods const& x)
579 << tab(2) << "Eo* _ret_eo = eo_add_ref(" << x._cls.eo_name << ", _p._eo_raw"; 580 << tab(2) << "Eo* _ret_eo = eo_add_ref(" << x._cls.eo_name << ", _p._eo_raw";
580 for (it = first; it != last; ++it) 581 for (it = first; it != last; ++it)
581 { 582 {
582 out << ", _c" << (it-first) << "()"; 583 out << ", _c" << (it-first) << "(eoid)";
583 } 584 }
584 if (!x._cls.optional_constructors.empty()) 585 if (!x._cls.optional_constructors.empty())
585 out << ", ::efl::eolian::call_ctors(_opts...)"; 586 out << ", ::efl::eolian::call_ctors(eoid, _opts...)";
586 out << ");" << endl << endl; 587 out << ");" << endl << endl;
587 588
588 for (it = first; it != last; ++it) 589 for (it = first; it != last; ++it)