jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=753304c69d27a5303e742dffaaff6f6230c3211b

commit 753304c69d27a5303e742dffaaff6f6230c3211b
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Wed Nov 22 17:17:04 2017 +0900

    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)
---
 src/bindings/cxx/eo_cxx/eo_concrete.hh             |  6 ++++++
 src/bindings/cxx/eo_cxx/eo_wref.hh                 |  2 +-
 src/examples/elementary/bg_cxx_example_02.cc       |  4 +++-
 src/examples/elementary/button_cxx_example_00.cc   |  2 +-
 src/examples/elementary/button_cxx_example_01.cc   |  2 +-
 src/examples/elementary/calendar_cxx_example_02.cc |  8 ++++----
 src/examples/elementary/radio_cxx_example_01.cc    |  2 +-
 src/lib/eolian_cxx/grammar/class_definition.hpp    | 12 ++++++++++--
 8 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/bindings/cxx/eo_cxx/eo_concrete.hh 
b/src/bindings/cxx/eo_cxx/eo_concrete.hh
index adc33985b7..47013dcbc6 100644
--- a/src/bindings/cxx/eo_cxx/eo_concrete.hh
+++ b/src/bindings/cxx/eo_cxx/eo_concrete.hh
@@ -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.
 ///
diff --git a/src/bindings/cxx/eo_cxx/eo_wref.hh 
b/src/bindings/cxx/eo_cxx/eo_wref.hh
index e28409c513..aed6d699d0 100644
--- a/src/bindings/cxx/eo_cxx/eo_wref.hh
+++ b/src/bindings/cxx/eo_cxx/eo_wref.hh
@@ -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));
diff --git a/src/examples/elementary/bg_cxx_example_02.cc 
b/src/examples/elementary/bg_cxx_example_02.cc
index 34016b6c9c..8ef33a8816 100644
--- a/src/examples/elementary/bg_cxx_example_02.cc
+++ b/src/examples/elementary/bg_cxx_example_02.cc
@@ -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);
diff --git a/src/examples/elementary/button_cxx_example_00.cc 
b/src/examples/elementary/button_cxx_example_00.cc
index 5e899e1591..d44f18a924 100644
--- a/src/examples/elementary/button_cxx_example_00.cc
+++ b/src/examples/elementary/button_cxx_example_00.cc
@@ -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>
 
diff --git a/src/examples/elementary/button_cxx_example_01.cc 
b/src/examples/elementary/button_cxx_example_01.cc
index e6b5147af5..7de67d3abb 100644
--- a/src/examples/elementary/button_cxx_example_01.cc
+++ b/src/examples/elementary/button_cxx_example_01.cc
@@ -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;
diff --git a/src/examples/elementary/calendar_cxx_example_02.cc 
b/src/examples/elementary/calendar_cxx_example_02.cc
index d6cb766f9b..fd001f7184 100644
--- a/src/examples/elementary/calendar_cxx_example_02.cc
+++ b/src/examples/elementary/calendar_cxx_example_02.cc
@@ -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());
diff --git a/src/examples/elementary/radio_cxx_example_01.cc 
b/src/examples/elementary/radio_cxx_example_01.cc
index 71507947ad..6fb410c89c 100644
--- a/src/examples/elementary/radio_cxx_example_01.cc
+++ b/src/examples/elementary/radio_cxx_example_01.cc
@@ -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>
 
diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp 
b/src/lib/eolian_cxx/grammar/class_definition.hpp
index 295662f94d..d5810da033 100644
--- a/src/lib/eolian_cxx/grammar/class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/class_definition.hpp
@@ -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"

-- 


Reply via email to