diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2018-05-03 16:34:17 -0700 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2018-05-24 16:02:18 -0700 |
commit | 8a513a522e90253ce7ec85e92c7bc58dfb22a2bc (patch) | |
tree | abeafb5e5bce67ed685e4e82f0d756de46ef60ec /src/lib/efl/interfaces | |
parent | c28eb28728c280d3fd19ef46790fce6f9465d4f5 (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/interfaces')
-rw-r--r-- | src/lib/efl/interfaces/efl_interfaces_main.c | 24 | ||||
-rw-r--r-- | src/lib/efl/interfaces/efl_part.eo | 9 |
2 files changed, 29 insertions, 4 deletions
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 | ||
83 | static 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 | |||
90 | EAPI Efl_Object * | ||
91 | efl_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 | |||
80 | EAPI void | 104 | EAPI 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.]] |