cxx: Add define EFL_CXXPERIMENTAL for testing
I'll hide some controversial features behind this, until we come to an agreement with @felipealmeida and people who actually know C++ (iow: not just me^^). Features protected: - easy wref (using -> without locking) - xxx_event_cb_add() functions in object classes - instantiate(obj) to create a new object - add as a synonym for instantiate (both in efl::eo)
This commit is contained in:
parent
425d8db90f
commit
753304c69d
|
@ -32,6 +32,7 @@ namespace efl { namespace eo {
|
|||
/// @{
|
||||
|
||||
struct instantiate_t {
|
||||
#ifdef EFL_CXXPERIMENTAL
|
||||
/// @brief A helper to create objects with a different syntax
|
||||
///
|
||||
/// @param obj The object to instantiate
|
||||
|
@ -49,6 +50,7 @@ struct instantiate_t {
|
|||
obj = T(*this);
|
||||
return obj;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/// @brief The handle to use to create real EFL objects
|
||||
|
@ -57,6 +59,10 @@ struct instantiate_t {
|
|||
/// to trigger a real EFL object creation. The following syntax is preferred:
|
||||
/// T obj(instantiate, ...);
|
||||
instantiate_t const instantiate = {};
|
||||
|
||||
#ifdef EFL_CXXPERIMENTAL
|
||||
instantiate_t const add = {};
|
||||
#endif
|
||||
|
||||
/// @brief Creates concrete versions for <em>Eo</em> wrappers.
|
||||
///
|
||||
|
|
|
@ -123,7 +123,7 @@ struct wref
|
|||
return *this;
|
||||
}
|
||||
|
||||
#ifdef EFL_CXX_WREF_EASY
|
||||
#ifdef EFL_CXXPERIMENTAL
|
||||
T operator->() const {
|
||||
if (!_eo_wref) return T(nullptr);
|
||||
return T(detail::ref(_eo_wref));
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* ./bg_cxx_example_02
|
||||
*/
|
||||
|
||||
#define EFL_CXXPERIMENTAL
|
||||
|
||||
#include <Elementary.hh>
|
||||
|
||||
#include <sstream>
|
||||
|
@ -16,7 +18,7 @@ efl::ui::Win win;
|
|||
EAPI_MAIN void
|
||||
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||
{
|
||||
instantiate(win);
|
||||
win = efl::ui::Win(instantiate);
|
||||
::efl_ref(win._eo_ptr()); // FIXME: Window is doing BAD THINGS™!
|
||||
win.text_set("Bg Image");
|
||||
win.autohide_set(true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` button_cxx_example_00.cc -o button_cxx_example_00
|
||||
|
||||
#define EFL_CXX_WREF_EASY
|
||||
#define EFL_CXXPERIMENTAL
|
||||
#include <Elementary.hh>
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` button_cxx_example_01.cc -o button_cxx_example_01
|
||||
|
||||
#define EFL_CXX_WREF_EASY
|
||||
#define EFL_CXXPERIMENTAL
|
||||
#include <Elementary.hh>
|
||||
|
||||
using efl::eo::instantiate;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#define EFL_CXX_WREF_EASY
|
||||
#define EFL_CXXPERIMENTAL
|
||||
|
||||
#include <Elementary.hh>
|
||||
|
||||
using efl::eo::instantiate;
|
||||
using namespace std::placeholders;
|
||||
using efl::eo::add;
|
||||
|
||||
struct appData
|
||||
{
|
||||
|
@ -16,11 +16,11 @@ struct appData
|
|||
void create() {
|
||||
std::cout << "Hello!" << std::endl;
|
||||
|
||||
instantiate(m_win);
|
||||
add(m_win);
|
||||
m_win.text_set("Calendar Layout Formatting Example");
|
||||
m_win.delete_request_event_cb_add([&](){ destroy(); });
|
||||
|
||||
efl::ui::Calendar cal(instantiate, m_win);
|
||||
efl::ui::Calendar cal(add, m_win);
|
||||
m_win.content_set(cal);
|
||||
|
||||
auto wcal(cal._get_wref());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` radio_cxx_example_01.cc -o radio_cxx_example_01
|
||||
|
||||
#define EFL_CXX_WREF_EASY
|
||||
#define EFL_CXXPERIMENTAL
|
||||
#include <Elementary.hh>
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -156,6 +156,10 @@ struct class_definition_generator
|
|||
<< scope_tab << "} const " << string_replace(',', '_') << "_event;\n"
|
||||
))).generate(sink, std::vector<attributes::event_def>{e}, context))
|
||||
return false;
|
||||
|
||||
/* EXPERIMENTAL: event_cb_add */
|
||||
if (!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
if (!as_generator(
|
||||
scope_tab << "template <typename F>\n"
|
||||
<< scope_tab << "typename std::enable_if<std::is_bind_expression<F>::value, ::efl::eolian::signal_connection>::type\n"
|
||||
|
@ -174,6 +178,9 @@ struct class_definition_generator
|
|||
<< scope_tab << "}\n")
|
||||
.generate(sink, std::make_tuple(e.name, e.name), context))
|
||||
return false;
|
||||
if (!as_generator("#endif\n").generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
|
||||
if (e.beta && !as_generator("#endif\n").generate(sink, attributes::unused, context))
|
||||
return false;
|
||||
if (e.protect && !as_generator("#endif\n").generate(sink, attributes::unused, context))
|
||||
|
@ -192,12 +199,13 @@ struct class_definition_generator
|
|||
"return ::efl::eo::wref<" << string << ">(*this); }\n"
|
||||
).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;
|
||||
// EXPERIMENTAL
|
||||
if(!as_generator("#ifdef EFL_CXXPERIMENTAL\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("#endif \n").generate(sink, attributes::unused, 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"
|
||||
|
|
Loading…
Reference in New Issue