diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-11-23 13:51:10 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-12-05 10:14:03 +0900 |
commit | 63725d71fda340986345725e2df3fcbaaa573649 (patch) | |
tree | 30c2990dc88b3252bac4221f5f9442e03d628d10 /src | |
parent | 0f5d40e6d4628cc38305fe0a72702f58817c9e69 (diff) |
cxx: Implement proper part support (wrt. refs)
It's VERY hacky, but works as expected: no leak, no extra unref. This is
a lucky case of simply overriding efl_part() implementation in C++,
without having to modify the declaration.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile_Cxx.am | 2 | ||||
-rw-r--r-- | src/examples/elementary/bg_cxx_example_02.cc | 4 | ||||
-rw-r--r-- | src/lib/efl/Efl.hh | 5 | ||||
-rw-r--r-- | src/lib/efl/cxx/efl_part_impl.hh | 26 |
4 files changed, 32 insertions, 5 deletions
diff --git a/src/Makefile_Cxx.am b/src/Makefile_Cxx.am index cf99ea3db3..74ac8f7183 100644 --- a/src/Makefile_Cxx.am +++ b/src/Makefile_Cxx.am | |||
@@ -34,7 +34,7 @@ CLEANFILES += $(elementary_eolian_cxx_hh) $(elementary_eolian_cxx_impl_hh) lib/e | |||
34 | ### Efl C++ | 34 | ### Efl C++ |
35 | installed_eflcxxmainheadersdir = $(includedir)/efl-cxx-@VMAJ@/ | 35 | installed_eflcxxmainheadersdir = $(includedir)/efl-cxx-@VMAJ@/ |
36 | nodist_installed_eflcxxmainheaders_DATA = $(efl_eolian_cxx_hh) $(efl_eolian_cxx_impl_hh) lib/efl/Efl.eo.hh | 36 | nodist_installed_eflcxxmainheaders_DATA = $(efl_eolian_cxx_hh) $(efl_eolian_cxx_impl_hh) lib/efl/Efl.eo.hh |
37 | dist_installed_eflcxxmainheaders_DATA = lib/efl/Efl.hh | 37 | dist_installed_eflcxxmainheaders_DATA = lib/efl/Efl.hh lib/efl/cxx/efl_part_impl.hh |
38 | 38 | ||
39 | lib/efl/Efl.eo.hh: $(efl_eolian_files) $(_EOLIAN_CXX_DEP) | 39 | lib/efl/Efl.eo.hh: $(efl_eolian_files) $(_EOLIAN_CXX_DEP) |
40 | $(AM_V_EOLCXX) \ | 40 | $(AM_V_EOLCXX) \ |
diff --git a/src/examples/elementary/bg_cxx_example_02.cc b/src/examples/elementary/bg_cxx_example_02.cc index 8ef33a8816..eb71693242 100644 --- a/src/examples/elementary/bg_cxx_example_02.cc +++ b/src/examples/elementary/bg_cxx_example_02.cc | |||
@@ -23,10 +23,6 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) | |||
23 | win.text_set("Bg Image"); | 23 | win.text_set("Bg Image"); |
24 | win.autohide_set(true); | 24 | win.autohide_set(true); |
25 | 25 | ||
26 | // FIXME: Part API needs some fixing to be nice in C++ :) | ||
27 | //efl::eo::downcast<efl::ui::win::Part>(win.part("background")) | ||
28 | // .file_set("performance/background.png", nullptr); | ||
29 | |||
30 | efl::ui::Bg bg(instantiate, win); | 26 | efl::ui::Bg bg(instantiate, win); |
31 | bg.scale_type_set(EFL_UI_IMAGE_SCALE_TYPE_FILL); | 27 | bg.scale_type_set(EFL_UI_IMAGE_SCALE_TYPE_FILL); |
32 | bg.file_set("performance/background.png", nullptr); | 28 | bg.file_set("performance/background.png", nullptr); |
diff --git a/src/lib/efl/Efl.hh b/src/lib/efl/Efl.hh index 20dfc1a90d..a7efc5f8f6 100644 --- a/src/lib/efl/Efl.hh +++ b/src/lib/efl/Efl.hh | |||
@@ -3,7 +3,12 @@ | |||
3 | 3 | ||
4 | #ifdef EFL_BETA_API_SUPPORT | 4 | #ifdef EFL_BETA_API_SUPPORT |
5 | 5 | ||
6 | #define EFL_PART_IMPL_HH | ||
7 | #define EFL_OBJECT_BETA | ||
8 | #define EFL_OBJECT_PROTECTED | ||
9 | |||
6 | #include <Efl.eo.hh> | 10 | #include <Efl.eo.hh> |
11 | #include "cxx/efl_part_impl.hh" | ||
7 | 12 | ||
8 | #endif | 13 | #endif |
9 | #endif | 14 | #endif |
diff --git a/src/lib/efl/cxx/efl_part_impl.hh b/src/lib/efl/cxx/efl_part_impl.hh new file mode 100644 index 0000000000..c1c99e785a --- /dev/null +++ b/src/lib/efl/cxx/efl_part_impl.hh | |||
@@ -0,0 +1,26 @@ | |||
1 | //#ifndef EFL_PART_IMPL_HH | ||
2 | //#define EFL_PART_IMPL_HH | ||
3 | |||
4 | namespace efl { | ||
5 | inline ::efl::eolian::return_traits< ::efl::Object>::type Part::part( ::efl::eolian::in_traits< ::efl::eina::string_view>::type name) const | ||
6 | { | ||
7 | Eo *handle = ::efl_part(this->_eo_ptr(), name.c_str()); | ||
8 | ::efl_auto_unref_set(handle, false); | ||
9 | return ::efl::Object{handle}; | ||
10 | } | ||
11 | } | ||
12 | |||
13 | namespace eo_cxx { | ||
14 | namespace efl { | ||
15 | inline ::efl::eolian::return_traits< ::efl::Object>::type Part::part( ::efl::eolian::in_traits< ::efl::eina::string_view>::type name) const | ||
16 | { | ||
17 | Eo *handle = ::efl_part(this->_eo_ptr(), name.c_str()); | ||
18 | ::efl_auto_unref_set(handle, false); | ||
19 | return ::efl::Object{handle}; | ||
20 | } | ||
21 | inline efl::Part::operator ::efl::Part() const { return *static_cast< ::efl::Part const*>(static_cast<void const*>(this)); } | ||
22 | inline efl::Part::operator ::efl::Part&() { return *static_cast< ::efl::Part*>(static_cast<void*>(this)); } | ||
23 | inline efl::Part::operator ::efl::Part const&() const { return *static_cast< ::efl::Part const*>(static_cast<void const*>(this)); } | ||
24 | } } | ||
25 | |||
26 | //#endif | ||