forked from enlightenment/efl
cxx: Add experimental "easy" way to use wref
I hid it behind ifdef for now as I'm very much unsure of what I'm doing. This whole modern C++ thing is still weird to me :) Prerequisite: #define EFL_CXX_WREF_EASY This allows constructs such as: auto wobj = obj._get_wref(); std::cout << wobj->text_get() << std::endl;
This commit is contained in:
parent
73ec85aeff
commit
e7009b77a2
|
@ -123,6 +123,18 @@ struct wref
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EFL_CXX_WREF_EASY
|
||||||
|
T operator->() const {
|
||||||
|
if (!_eo_wref) return T(nullptr);
|
||||||
|
return T(detail::ref(_eo_wref));
|
||||||
|
}
|
||||||
|
|
||||||
|
T operator*() const {
|
||||||
|
if (!_eo_wref) return T(nullptr);
|
||||||
|
return T(detail::ref(_eo_wref));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _add()
|
void _add()
|
||||||
{
|
{
|
||||||
|
|
|
@ -174,6 +174,13 @@ struct class_definition_generator
|
||||||
"return ::efl::eo::wref<" << string << ">(*this); }\n"
|
"return ::efl::eo::wref<" << string << ">(*this); }\n"
|
||||||
).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false;
|
).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false;
|
||||||
|
|
||||||
|
if(!as_generator("#ifdef EFL_CXX_WREF_EASY\n").generate(sink, attributes::unused, context)) return false;
|
||||||
|
if(!as_generator( scope_tab << "const " << string << "* operator->() const { return this; }\n"
|
||||||
|
).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false;
|
||||||
|
if(!as_generator( scope_tab << string << "* operator->() { return this; }\n"
|
||||||
|
).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false;
|
||||||
|
if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false;
|
||||||
|
|
||||||
if(!as_generator( scope_tab << "::efl::eo::concrete const& _get_concrete() const { return *this; }\n"
|
if(!as_generator( scope_tab << "::efl::eo::concrete const& _get_concrete() const { return *this; }\n"
|
||||||
<< scope_tab << "::efl::eo::concrete& _get_concrete() { return *this; }\n"
|
<< scope_tab << "::efl::eo::concrete& _get_concrete() { return *this; }\n"
|
||||||
).generate(sink, attributes::unused, context)) return false;
|
).generate(sink, attributes::unused, context)) return false;
|
||||||
|
|
Loading…
Reference in New Issue