jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=73ec85aeffc2eddfe81673344ed22bb21461aaa7
commit 73ec85aeffc2eddfe81673344ed22bb21461aaa7 Author: Jean-Philippe Andre <[email protected]> Date: Thu Nov 2 18:14:59 2017 +0900 cxx: Add _get_wref() convenience to all classes This allows constructs like: auto w_obj = obj._get_wref(); auto cb = std::bind([w_obj]() { auto o = w_obj.lock(); if (!o) return; o->call(); }); event_add(..., obj, cb); Note: I don't like how those wref work. Close to c++ wref but far from EFL wref. --- src/lib/eolian_cxx/grammar/class_definition.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp index 15ef86d371..320d806398 100644 --- a/src/lib/eolian_cxx/grammar/class_definition.hpp +++ b/src/lib/eolian_cxx/grammar/class_definition.hpp @@ -170,6 +170,10 @@ struct class_definition_generator // /// @endcond if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false; + if(!as_generator( scope_tab << "::efl::eo::wref<" << string << "> _get_wref() const { " + "return ::efl::eo::wref<" << string << ">(*this); }\n" + ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; + 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" ).generate(sink, attributes::unused, context)) return false; --
