summaryrefslogtreecommitdiff
path: root/src/lib/efl
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-05-03 16:34:17 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-24 16:02:18 -0700
commit8a513a522e90253ce7ec85e92c7bc58dfb22a2bc (patch)
treeabeafb5e5bce67ed685e4e82f0d756de46ef60ec /src/lib/efl
parentc28eb28728c280d3fd19ef46790fce6f9465d4f5 (diff)
efl: major rewrite of efl_part.
The interface efl_part_get should not be directly called from C, but the efl_part wrapper should. It rely on efl_noref to properly destroy the object. Binding can control the lifecycle of the reference the way they want by either calling the wrapper or efl_part_get directly. It also means that the ugly ___efl_auto_unref_set doesn't need to be exposed outside of EFL anymore. Differential Revision: https://phab.enlightenment.org/D6098
Diffstat (limited to 'src/lib/efl')
-rw-r--r--src/lib/efl/Efl.h29
-rw-r--r--src/lib/efl/Efl.hh2
-rw-r--r--src/lib/efl/cxx/efl_part_impl.hh3
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c24
-rw-r--r--src/lib/efl/interfaces/efl_part.eo9
5 files changed, 61 insertions, 6 deletions
diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h
index e9b00b1d50..6cebb21dae 100644
--- a/src/lib/efl/Efl.h
+++ b/src/lib/efl/Efl.h
@@ -10,6 +10,12 @@ extern "C" {
10#ifdef EAPI 10#ifdef EAPI
11# undef EAPI 11# undef EAPI
12#endif 12#endif
13#ifdef EWAPI
14# undef EWAPI
15#endif
16#ifdef EOAPI
17# undef EOAPI
18#endif
13 19
14#ifdef _WIN32 20#ifdef _WIN32
15# ifdef EFL_BUILD 21# ifdef EFL_BUILD
@@ -21,18 +27,25 @@ extern "C" {
21# else 27# else
22# define EAPI __declspec(dllimport) 28# define EAPI __declspec(dllimport)
23# endif 29# endif
30# define EAPI_WEAK
24#else 31#else
25# ifdef __GNUC__ 32# ifdef __GNUC__
26# if __GNUC__ >= 4 33# if __GNUC__ >= 4
27# define EAPI __attribute__ ((visibility("default"))) 34# define EAPI __attribute__ ((visibility("default")))
35# define EAPI_WEAK __attribute__ ((weak))
28# else 36# else
29# define EAPI 37# define EAPI
38# define EAPI_WEAK
30# endif 39# endif
31# else 40# else
32# define EAPI 41# define EAPI
42# define EAPI_WEAK
33# endif 43# endif
34#endif 44#endif
35 45
46#define EWAPI EAPI EAPI_WEAK
47#define EOAPI EAPI EAPI_WEAK
48
36#define EFL_VERSION_1_18 1 49#define EFL_VERSION_1_18 1
37#define EFL_VERSION_1_19 1 50#define EFL_VERSION_1_19 1
38#define EFL_VERSION_1_20 1 51#define EFL_VERSION_1_20 1
@@ -167,6 +180,22 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
167#include "interfaces/efl_text_markup.eo.h" 180#include "interfaces/efl_text_markup.eo.h"
168#include "interfaces/efl_text_markup_util.eo.h" 181#include "interfaces/efl_text_markup_util.eo.h"
169 182
183/**
184 * @brief Get a proxy object referring to a part of an object.
185 *
186 * The returned object is valid for only a single function call.
187 * Of course, if the first call is @ref efl_ref, it will last
188 * until @ref efl_unref.
189 *
190 * @param[in] obj The object.
191 * @param[in] name The part name.
192 *
193 * @return A (proxy) object, valid for a single call.
194 *
195 * @since 1.21
196 */
197EAPI Efl_Object *efl_part(const Eo *obj, const char *name);
198
170#else 199#else
171 200
172#ifndef EFL_NOLEGACY_API_SUPPORT 201#ifndef EFL_NOLEGACY_API_SUPPORT
diff --git a/src/lib/efl/Efl.hh b/src/lib/efl/Efl.hh
index e6473eafce..19cfb37c60 100644
--- a/src/lib/efl/Efl.hh
+++ b/src/lib/efl/Efl.hh
@@ -1,6 +1,8 @@
1#ifndef EFL_EFL_HH 1#ifndef EFL_EFL_HH
2#define EFL_EFL_HH 2#define EFL_EFL_HH
3 3
4#define EFL_PART_PROTECTED
5
4#include "cxx/efl_part_impl.hh" 6#include "cxx/efl_part_impl.hh"
5 7
6#include <Eo.hh> 8#include <Eo.hh>
diff --git a/src/lib/efl/cxx/efl_part_impl.hh b/src/lib/efl/cxx/efl_part_impl.hh
index b97dda1457..6a0b9ead60 100644
--- a/src/lib/efl/cxx/efl_part_impl.hh
+++ b/src/lib/efl/cxx/efl_part_impl.hh
@@ -7,8 +7,7 @@
7#define EOLIAN_CXX_EFL_PART_IMPLEMENTATION \ 7#define EOLIAN_CXX_EFL_PART_IMPLEMENTATION \
8inline ::efl::Object Part::part(::efl::eina::string_view const& name) const \ 8inline ::efl::Object Part::part(::efl::eina::string_view const& name) const \
9{ \ 9{ \
10 ::Eo *handle = ::efl_part(_eo_ptr(), name.c_str()); \ 10 ::Eo *handle = ::efl_part_get(_eo_ptr(), name.c_str()); \
11 ::___efl_auto_unref_set(handle, false); \
12 return ::efl::Object{handle}; \ 11 return ::efl::Object{handle}; \
13} 12}
14 13
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index 4e02e1e5e1..d9b10e89d2 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -5,6 +5,9 @@
5#define EFL_CANVAS_SCENE_BETA 5#define EFL_CANVAS_SCENE_BETA
6#define EFL_UI_SCROLLBAR_PROTECTED 6#define EFL_UI_SCROLLBAR_PROTECTED
7#define EFL_UI_SCROLLBAR_BETA 7#define EFL_UI_SCROLLBAR_BETA
8#define EFL_PART_PROTECTED
9
10#include "eo_internal.h"
8 11
9#include <Efl.h> 12#include <Efl.h>
10 13
@@ -77,6 +80,27 @@
77#include "interfaces/efl_ui_multi_selectable.eo.c" 80#include "interfaces/efl_ui_multi_selectable.eo.c"
78#include "interfaces/efl_ui_zoom.eo.c" 81#include "interfaces/efl_ui_zoom.eo.c"
79 82
83static void
84_noref_death(void *data EINA_UNUSED, const Efl_Event *event)
85{
86 efl_event_callback_del(event->object, EFL_EVENT_NOREF, _noref_death, NULL);
87 efl_del(event->object);
88}
89
90EAPI Efl_Object *
91efl_part(const Eo *obj, const char *name)
92{
93 Efl_Object *r;
94
95 r = efl_part_get(obj, name);
96 if (!r) return NULL;
97
98 efl_event_callback_add(r, EFL_EVENT_NOREF, _noref_death, NULL);
99 ___efl_auto_unref_set(r, EINA_TRUE);
100
101 return efl_ref(r);
102}
103
80EAPI void 104EAPI void
81__efl_internal_init(void) 105__efl_internal_init(void)
82{ 106{
diff --git a/src/lib/efl/interfaces/efl_part.eo b/src/lib/efl/interfaces/efl_part.eo
index 124dad121e..1f37e7e4ab 100644
--- a/src/lib/efl/interfaces/efl_part.eo
+++ b/src/lib/efl/interfaces/efl_part.eo
@@ -10,7 +10,10 @@ interface Efl.Part
10 theme. 10 theme.
11 11
12 Part proxy objects have a special lifetime that 12 Part proxy objects have a special lifetime that
13 is limited to one and only one function call. 13 is limited to one and only one function call. This
14 behavior is implemented in efl_part() which call
15 Efl.Part.part_get(). Calling Efl.Part.part_get() directly
16 should be avoided.
14 17
15 In other words, the caller does not hold a reference 18 In other words, the caller does not hold a reference
16 to this proxy object. It may be possible, in languages 19 to this proxy object. It may be possible, in languages
@@ -32,10 +35,8 @@ interface Efl.Part
32 unref(part) 35 unref(part)
33 ]] 36 ]]
34 methods { 37 methods {
35 part @const { 38 part_get @protected @const {
36 [[Get a proxy object referring to a part of an object. 39 [[Get a proxy object referring to a part of an object.
37
38 The returned object is valid for only a single function call.
39 ]] 40 ]]
40 params { 41 params {
41 name: string; [[The part name.]] 42 name: string; [[The part name.]]