eolian-cxx: Fix Eolian C++ constructing methods with new eo_add

Also fix Eolian C++ examples using the new "eo_super".
This commit is contained in:
Vitor Sousa 2016-03-03 15:10:13 -03:00
parent 5c7d78d104
commit 9cbda57bf0
7 changed files with 23 additions and 27 deletions

View File

@ -472,9 +472,9 @@ F* alloc_static_callback(F&& f)
template <typename... Fs> template <typename... Fs>
inline inline
void call_ctors(Fs&&... fs) void call_ctors(Eo* _obj_eoid, Fs&&... fs)
{ {
std::initializer_list<int const> const v {(fs(), 0)...}; std::initializer_list<int const> const v {(fs(_obj_eoid), 0)...};
(void) v; (void) v;
} }

View File

@ -22,8 +22,15 @@ namespace detail {
template <typename D, typename... E, std::size_t... S> template <typename D, typename... E, std::size_t... S>
Eo_Class const* create_class(eina::index_sequence<S...>); Eo_Class const* create_class(eina::index_sequence<S...>);
inline /// @internal
void inherit_constructor(void* this_); ///
/// @brief Find the correct function for the <em>"constructor"</em>
/// operation and invoke it.
///
/// @param this_ The <em>user data</em> to be passed to the resolved function.
/// @param args An heterogeneous sequence of arguments.
///
inline EOAPI EO_VOID_FUNC_BODYV(inherit_constructor, EO_FUNC_CALL(this_), void* this_);
} }
@ -78,7 +85,7 @@ struct inherit
inherit(efl::eo::parent_type _p, Args&& ... args) inherit(efl::eo::parent_type _p, Args&& ... args)
{ {
_eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>()); _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>());
_eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(this), ::efl::eolian::call_ctors(args...)); _eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(eoid, this), ::efl::eolian::call_ctors(eoid, args...));
::efl::eolian::register_ev_del_free_callback(_eo_raw, args...); ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...);
} }

View File

@ -53,18 +53,6 @@ void inherit_constructor_impl(Eo*, Inherit_Private_Data* self, void* this_)
self->this_ = this_; self->this_ = this_;
} }
/// @internal
///
/// @brief Find the correct function for the <em>"constructor"</em>
/// operation and invoke it.
///
/// @param this_ The <em>user data</em> to be passed to the resolved function.
/// @param args An heterogeneous sequence of arguments.
///
// inline EOAPI EO_VOID_FUNC_BODYV(inherit_constructor, EO_FUNC_CALL(this_), void* this_);
inline
void inherit_constructor(void* this_);
template <typename T> template <typename T>
int initialize_operation_description(detail::tag<void>, void*); int initialize_operation_description(detail::tag<void>, void*);

View File

@ -24,14 +24,14 @@ _colourable_eo_base_constructor(Eo *obj, Colourable_Data *self)
{ {
EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl; EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl;
self->r = self->g = self->b = 0; self->r = self->g = self->b = 0;
return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor()); return eo_constructor(eo_super(obj, MY_CLASS));
} }
void void
_colourable_eo_base_destructor(Eo *obj, Colourable_Data *self EINA_UNUSED) _colourable_eo_base_destructor(Eo *obj, Colourable_Data *self EINA_UNUSED)
{ {
EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl; EINA_CXX_DOM_LOG_DBG(domain) << __func__ << std::endl;
eo_do_super(obj, MY_CLASS, eo_destructor()); eo_destructor(eo_super(obj, MY_CLASS));
} }
void void
@ -42,7 +42,7 @@ _colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb)
self->r = (rgb & 0x00ff0000) >> 16; self->r = (rgb & 0x00ff0000) >> 16;
self->g = (rgb & 0x0000ff00) >> 8; self->g = (rgb & 0x0000ff00) >> 8;
self->b = rgb & 0x000000ff; self->b = rgb & 0x000000ff;
eo_do_super(obj, MY_CLASS, eo_constructor()); eo_constructor(eo_super(obj, MY_CLASS));
} }
void void

View File

@ -25,7 +25,7 @@ _colourablesquare_size_constructor(Eo *obj, ColourableSquare_Data *self, int siz
{ {
self->size = size; self->size = size;
EINA_CXX_DOM_LOG_DBG(domain) << __func__ << " [ size = " << size << " ]" << std::endl; EINA_CXX_DOM_LOG_DBG(domain) << __func__ << " [ size = " << size << " ]" << std::endl;
eo_do_super(obj, MY_CLASS, eo_constructor()); eo_constructor(eo_super(obj, MY_CLASS));
} }
int int

View File

@ -23,7 +23,7 @@ struct ColourableCircle
int colour_get() int colour_get()
{ {
int rgb = 0; int rgb = 0;
eo_do_super(_eo_ptr(), _eo_class(), rgb = ::colourable_colour_get()); rgb = ::colourable_colour_get(eo_super(_eo_ptr(), _eo_class()));
std::cout << "ColourableCircle::colour_get(" << this << ") ==> " std::cout << "ColourableCircle::colour_get(" << this << ") ==> "
<< std::hex << rgb << std::endl; << std::hex << rgb << std::endl;
return rgb; return rgb;
@ -52,7 +52,7 @@ struct ColourableBar
int colour_get() int colour_get()
{ {
int rgb = 0; int rgb = 0;
eo_do_super(_eo_ptr(), _eo_class(), rgb = ::colourable_colour_get()); rgb = ::colourable_colour_get(eo_super(_eo_ptr(), _eo_class()));
std::cout << "ColourableBar::colour_get(" << this << ") ==> " std::cout << "ColourableBar::colour_get(" << this << ") ==> "
<< std::hex << rgb << std::endl; << std::hex << rgb << std::endl;
return rgb; return rgb;

View File

@ -158,9 +158,10 @@ operator<<(std::ostream& out, functors_constructor_methods const& x)
<< tab(2) << "{}" << endl; << tab(2) << "{}" << endl;
// Struct operator() // Struct operator()
out << tab(2) << "void operator()()" << endl out << tab(2) << "void operator()(Eo* _obj_eoid)" << endl
<< tab(2) << "{" << endl << tab(2) << "{" << endl
<< tab(3) << "::" << c.impl << "(" << parameters_forward_to_c(c.params) << ");" << endl << tab(3) << "::" << c.impl << "(_obj_eoid" << (c.params.empty() ? "" : ", ")
<< parameters_forward_to_c(c.params) << ");" << endl
<< tab(2) << "}" << endl; << tab(2) << "}" << endl;
// Register event to free allocated callbacks when the Eo* is deleted // 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)
<< tab(2) << "Eo* _ret_eo = eo_add_ref(" << x._cls.eo_name << ", _p._eo_raw"; << tab(2) << "Eo* _ret_eo = eo_add_ref(" << x._cls.eo_name << ", _p._eo_raw";
for (it = first; it != last; ++it) for (it = first; it != last; ++it)
{ {
out << ", _c" << (it-first) << "()"; out << ", _c" << (it-first) << "(eoid)";
} }
if (!x._cls.optional_constructors.empty()) if (!x._cls.optional_constructors.empty())
out << ", ::efl::eolian::call_ctors(_opts...)"; out << ", ::efl::eolian::call_ctors(eoid, _opts...)";
out << ");" << endl << endl; out << ");" << endl << endl;
for (it = first; it != last; ++it) for (it = first; it != last; ++it)