summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-02 18:39:47 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-07 09:57:24 +0900
commite7009b77a235ece2bbcba24c4fc6e2b719a2ab8d (patch)
treec3c56f591ba9769c45078f74125e93722d330b46
parent73ec85aeffc2eddfe81673344ed22bb21461aaa7 (diff)
downloadefl-e7009b77a235ece2bbcba24c4fc6e2b719a2ab8d.tar.gz
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;
-rw-r--r--src/bindings/cxx/eo_cxx/eo_wref.hh12
-rw-r--r--src/lib/eolian_cxx/grammar/class_definition.hpp7
2 files changed, 19 insertions, 0 deletions
diff --git a/src/bindings/cxx/eo_cxx/eo_wref.hh b/src/bindings/cxx/eo_cxx/eo_wref.hh
index e0f9c7bf82..124b1da3b7 100644
--- a/src/bindings/cxx/eo_cxx/eo_wref.hh
+++ b/src/bindings/cxx/eo_cxx/eo_wref.hh
@@ -123,6 +123,18 @@ struct wref
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:
void _add()
{
diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp
index 320d806398..54df3301a6 100644
--- a/src/lib/eolian_cxx/grammar/class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/class_definition.hpp
@@ -174,6 +174,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;
+ 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"
<< scope_tab << "::efl::eo::concrete& _get_concrete() { return *this; }\n"
).generate(sink, attributes::unused, context)) return false;