summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 16:00:33 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 18:50:58 +0900
commitb84c9cc376363576f893fd7b0b04cc50eb8fbb64 (patch)
tree22fd2dae9732c5f7d06400807515baf13edb1dd9
parentd0f141077ef57ecdd67106c26e3fcc778b318bff (diff)
Edje: Auto-unref proxy objects after calls
-rw-r--r--src/lib/edje/edje_containers.c126
1 files changed, 65 insertions, 61 deletions
diff --git a/src/lib/edje/edje_containers.c b/src/lib/edje/edje_containers.c
index 87ad635883..b4a134c1c4 100644
--- a/src/lib/edje/edje_containers.c
+++ b/src/lib/edje/edje_containers.c
@@ -32,6 +32,9 @@ struct _Part_Item_Iterator
32 Eo *object; 32 Eo *object;
33}; 33};
34 34
35#define RETURN_VAL(a) do { typeof(a) _ret = a; if (pd->temp) { pd->temp = 0; eo_unref(obj); } return _ret; } while(0)
36#define RETURN_VOID do { if (pd->temp) { pd->temp = 0; eo_unref(obj); } return; } while(0)
37
35Eo * 38Eo *
36_edje_box_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp) 39_edje_box_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp)
37{ 40{
@@ -59,53 +62,53 @@ _efl_canvas_layout_internal_box_eo_base_finalize(Eo *obj, Edje_Box_Data *pd)
59/* Legacy features */ 62/* Legacy features */
60 63
61EOLIAN static Eina_Bool 64EOLIAN static Eina_Bool
62_efl_canvas_layout_internal_box_efl_pack_pack_clear(Eo *obj EINA_UNUSED, Edje_Box_Data *pd) 65_efl_canvas_layout_internal_box_efl_pack_pack_clear(Eo *obj, Edje_Box_Data *pd)
63{ 66{
64 return _edje_part_box_remove_all(pd->ed, pd->part, EINA_TRUE); 67 RETURN_VAL(_edje_part_box_remove_all(pd->ed, pd->part, EINA_TRUE));
65} 68}
66 69
67EOLIAN static Eina_Bool 70EOLIAN static Eina_Bool
68_efl_canvas_layout_internal_box_efl_pack_unpack_all(Eo *obj EINA_UNUSED, Edje_Box_Data *pd) 71_efl_canvas_layout_internal_box_efl_pack_unpack_all(Eo *obj, Edje_Box_Data *pd)
69{ 72{
70 return _edje_part_box_remove_all(pd->ed, pd->part, EINA_FALSE); 73 RETURN_VAL(_edje_part_box_remove_all(pd->ed, pd->part, EINA_FALSE));
71} 74}
72 75
73EOLIAN static Eina_Bool 76EOLIAN static Eina_Bool
74_efl_canvas_layout_internal_box_efl_pack_unpack(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, Efl_Gfx *subobj) 77_efl_canvas_layout_internal_box_efl_pack_unpack(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj)
75{ 78{
76 Evas_Object *removed; 79 Evas_Object *removed;
77 removed = _edje_part_box_remove(pd->ed, pd->part, subobj); 80 removed = _edje_part_box_remove(pd->ed, pd->part, subobj);
78 return (removed == subobj); 81 RETURN_VAL((removed == subobj));
79} 82}
80 83
81EOLIAN static Eina_Bool 84EOLIAN static Eina_Bool
82_efl_canvas_layout_internal_box_efl_pack_pack(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, Efl_Gfx *subobj) 85_efl_canvas_layout_internal_box_efl_pack_pack(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj)
83{ 86{
84 return _edje_part_box_append(pd->ed, pd->part, subobj); 87 RETURN_VAL(_edje_part_box_append(pd->ed, pd->part, subobj));
85} 88}
86 89
87EOLIAN static Eina_Bool 90EOLIAN static Eina_Bool
88_efl_canvas_layout_internal_box_efl_pack_linear_pack_begin(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, Efl_Gfx *subobj) 91_efl_canvas_layout_internal_box_efl_pack_linear_pack_begin(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj)
89{ 92{
90 return _edje_part_box_prepend(pd->ed, pd->part, subobj); 93 RETURN_VAL(_edje_part_box_prepend(pd->ed, pd->part, subobj));
91} 94}
92 95
93EOLIAN static Eina_Bool 96EOLIAN static Eina_Bool
94_efl_canvas_layout_internal_box_efl_pack_linear_pack_end(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, Efl_Gfx *subobj) 97_efl_canvas_layout_internal_box_efl_pack_linear_pack_end(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj)
95{ 98{
96 return _edje_part_box_append(pd->ed, pd->part, subobj); 99 RETURN_VAL(_edje_part_box_append(pd->ed, pd->part, subobj));
97} 100}
98 101
99EOLIAN static Eina_Bool 102EOLIAN static Eina_Bool
100_efl_canvas_layout_internal_box_efl_pack_linear_pack_before(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, Efl_Gfx *subobj, const Efl_Gfx *existing) 103_efl_canvas_layout_internal_box_efl_pack_linear_pack_before(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj, const Efl_Gfx *existing)
101{ 104{
102 return _edje_part_box_insert_before(pd->ed, pd->part, subobj, existing); 105 RETURN_VAL(_edje_part_box_insert_before(pd->ed, pd->part, subobj, existing));
103} 106}
104 107
105EOLIAN static Eina_Bool 108EOLIAN static Eina_Bool
106_efl_canvas_layout_internal_box_efl_pack_linear_pack_after(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, Efl_Gfx *subobj, const Efl_Gfx *existing) 109_efl_canvas_layout_internal_box_efl_pack_linear_pack_after(Eo *obj, Edje_Box_Data *pd, Efl_Gfx *subobj, const Efl_Gfx *existing)
107{ 110{
108 return _edje_part_box_insert_after(pd->ed, pd->part, subobj, existing); 111 RETURN_VAL(_edje_part_box_insert_after(pd->ed, pd->part, subobj, existing));
109} 112}
110 113
111EOLIAN static Eina_Bool 114EOLIAN static Eina_Bool
@@ -115,35 +118,35 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_at(Eo *obj, Edje_Box_Data *
115 if ((index < 0) && ((-index) <= (cnt + 1))) 118 if ((index < 0) && ((-index) <= (cnt + 1)))
116 index = cnt + index + 1; 119 index = cnt + index + 1;
117 if ((index >= 0) && (index < cnt)) 120 if ((index >= 0) && (index < cnt))
118 return _edje_part_box_insert_at(pd->ed, pd->part, subobj, index); 121 RETURN_VAL(_edje_part_box_insert_at(pd->ed, pd->part, subobj, index));
119 else 122 else
120 return _edje_part_box_append(pd->ed, pd->part, subobj); 123 RETURN_VAL(_edje_part_box_append(pd->ed, pd->part, subobj));
121} 124}
122 125
123EOLIAN static Efl_Gfx * 126EOLIAN static Efl_Gfx *
124_efl_canvas_layout_internal_box_efl_pack_linear_pack_unpack_at(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, int index) 127_efl_canvas_layout_internal_box_efl_pack_linear_pack_unpack_at(Eo *obj, Edje_Box_Data *pd, int index)
125{ 128{
126 if (index < 0) index += efl_content_count(obj); 129 if (index < 0) index += efl_content_count(obj);
127 return _edje_part_box_remove_at(pd->ed, pd->part, index); 130 RETURN_VAL(_edje_part_box_remove_at(pd->ed, pd->part, index));
128} 131}
129 132
130/* New APIs with Eo */ 133/* New APIs with Eo */
131 134
132EOLIAN static Efl_Gfx * 135EOLIAN static Efl_Gfx *
133_efl_canvas_layout_internal_box_efl_pack_linear_pack_content_get(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, int index) 136_efl_canvas_layout_internal_box_efl_pack_linear_pack_content_get(Eo *obj, Edje_Box_Data *pd, int index)
134{ 137{
135 if (index < 0) index += efl_content_count(obj); 138 if (index < 0) index += efl_content_count(obj);
136 return _edje_part_box_content_at(pd->ed, pd->part, index); 139 RETURN_VAL(_edje_part_box_content_at(pd->ed, pd->part, index));
137} 140}
138 141
139EOLIAN static Eina_Bool 142EOLIAN static Eina_Bool
140_efl_canvas_layout_internal_box_efl_container_content_remove(Eo *obj, Edje_Box_Data *pd EINA_UNUSED, Efl_Gfx *subobj) 143_efl_canvas_layout_internal_box_efl_container_content_remove(Eo *obj, Edje_Box_Data *pd EINA_UNUSED, Efl_Gfx *subobj)
141{ 144{
142 return efl_pack_unpack(obj, subobj); 145 RETURN_VAL(efl_pack_unpack(obj, subobj));
143} 146}
144 147
145EOLIAN static int 148EOLIAN static int
146_efl_canvas_layout_internal_box_efl_pack_linear_pack_index_get(Eo *obj EINA_UNUSED, Edje_Box_Data *pd, const Efl_Gfx * subobj) 149_efl_canvas_layout_internal_box_efl_pack_linear_pack_index_get(Eo *obj, Edje_Box_Data *pd, const Efl_Gfx * subobj)
147{ 150{
148 Evas_Object_Box_Option *opt; 151 Evas_Object_Box_Option *opt;
149 Evas_Object_Box_Data *priv; 152 Evas_Object_Box_Data *priv;
@@ -151,14 +154,14 @@ _efl_canvas_layout_internal_box_efl_pack_linear_pack_index_get(Eo *obj EINA_UNUS
151 int k = 0; 154 int k = 0;
152 155
153 priv = eo_data_scope_get(pd->rp->object, EVAS_BOX_CLASS); 156 priv = eo_data_scope_get(pd->rp->object, EVAS_BOX_CLASS);
154 if (!priv) return -1; 157 if (!priv) RETURN_VAL(-1);
155 EINA_LIST_FOREACH(priv->children, l, opt) 158 EINA_LIST_FOREACH(priv->children, l, opt)
156 { 159 {
157 if (opt->obj == subobj) 160 if (opt->obj == subobj)
158 return k; 161 RETURN_VAL(k);
159 k++; 162 k++;
160 } 163 }
161 return -1; 164 RETURN_VAL(-1);
162} 165}
163 166
164/* this iterator is the same as efl_ui_box */ 167/* this iterator is the same as efl_ui_box */
@@ -214,34 +217,34 @@ _efl_canvas_layout_internal_box_efl_container_content_iterate(Eo *obj, Edje_Box_
214{ 217{
215 Eina_Iterator *it; 218 Eina_Iterator *it;
216 219
217 if (!pd->rp->typedata.container) return NULL; 220 if (!pd->rp->typedata.container) RETURN_VAL(NULL);
218 it = evas_object_box_iterator_new(pd->rp->object); 221 it = evas_object_box_iterator_new(pd->rp->object);
219 222
220 return _part_item_iterator_create(obj, it); 223 RETURN_VAL(_part_item_iterator_create(pd->rp->object, it));
221} 224}
222 225
223EOLIAN static int 226EOLIAN static int
224_efl_canvas_layout_internal_box_efl_container_content_count(Eo *obj EINA_UNUSED, Edje_Box_Data *pd) 227_efl_canvas_layout_internal_box_efl_container_content_count(Eo *obj, Edje_Box_Data *pd)
225{ 228{
226 return evas_obj_box_count(pd->rp->object); 229 RETURN_VAL(evas_obj_box_count(pd->rp->object));
227} 230}
228 231
229EOLIAN static Efl_Orient 232EOLIAN static Efl_Orient
230_efl_canvas_layout_internal_box_efl_pack_linear_pack_direction_get(Eo *obj EINA_UNUSED, Edje_Box_Data *pd) 233_efl_canvas_layout_internal_box_efl_pack_linear_pack_direction_get(Eo *obj, Edje_Box_Data *pd)
231{ 234{
232 const Edje_Part_Description_Box *desc = 235 const Edje_Part_Description_Box *desc =
233 (Edje_Part_Description_Box *) pd->rp->chosen_description; 236 (Edje_Part_Description_Box *) pd->rp->chosen_description;
234 237
235 if (!desc || !desc->box.layout) 238 if (!desc || !desc->box.layout)
236 return EFL_ORIENT_NONE; 239 RETURN_VAL(EFL_ORIENT_NONE);
237 240
238 if (!strncmp(desc->box.layout, "vertical", 8)) 241 if (!strncmp(desc->box.layout, "vertical", 8))
239 return EFL_ORIENT_VERTICAL; 242 RETURN_VAL(EFL_ORIENT_VERTICAL);
240 else if (!strncmp(desc->box.layout, "horizontal", 10)) 243 else if (!strncmp(desc->box.layout, "horizontal", 10))
241 return EFL_ORIENT_HORIZONTAL; 244 RETURN_VAL(EFL_ORIENT_HORIZONTAL);
242 245
243 WRN("unknown orientation '%s'", desc->box.layout); 246 WRN("unknown orientation '%s'", desc->box.layout);
244 return EFL_ORIENT_NONE; 247 RETURN_VAL(EFL_ORIENT_NONE);
245} 248}
246 249
247/* Table */ 250/* Table */
@@ -275,74 +278,75 @@ _efl_canvas_layout_internal_table_efl_container_content_iterate(Eo *obj, Edje_Ta
275{ 278{
276 Eina_Iterator *it; 279 Eina_Iterator *it;
277 280
278 if (!pd->rp->typedata.container) return NULL; 281 if (!pd->rp->typedata.container) RETURN_VAL(NULL);
279 it = evas_object_table_iterator_new(pd->rp->object); 282 it = evas_object_table_iterator_new(pd->rp->object);
280 283
281 return _part_item_iterator_create(obj, it); 284 RETURN_VAL(_part_item_iterator_create(pd->rp->object, it));
282} 285}
283 286
284EOLIAN static int 287EOLIAN static int
285_efl_canvas_layout_internal_table_efl_container_content_count(Eo *obj EINA_UNUSED, Edje_Table_Data *pd) 288_efl_canvas_layout_internal_table_efl_container_content_count(Eo *obj, Edje_Table_Data *pd)
286{ 289{
287 return evas_obj_table_count(pd->rp->object); 290 RETURN_VAL(evas_obj_table_count(pd->rp->object));
288} 291}
289 292
290EOLIAN static Eina_Bool 293EOLIAN static Eina_Bool
291_efl_canvas_layout_internal_table_efl_container_content_remove(Eo *obj, Edje_Table_Data *pd EINA_UNUSED, Efl_Gfx *content) 294_efl_canvas_layout_internal_table_efl_container_content_remove(Eo *obj, Edje_Table_Data *pd EINA_UNUSED, Efl_Gfx *content)
292{ 295{
293 return efl_pack_unpack(obj, content); 296 RETURN_VAL(efl_pack_unpack(obj, content));
294} 297}
295 298
296EOLIAN static Eina_Bool 299EOLIAN static Eina_Bool
297_efl_canvas_layout_internal_table_efl_pack_pack_clear(Eo *obj EINA_UNUSED, Edje_Table_Data *pd) 300_efl_canvas_layout_internal_table_efl_pack_pack_clear(Eo *obj, Edje_Table_Data *pd)
298{ 301{
299 return _edje_part_table_clear(pd->ed, pd->part, EINA_TRUE); 302 RETURN_VAL(_edje_part_table_clear(pd->ed, pd->part, EINA_TRUE));
300} 303}
301 304
302EOLIAN static Eina_Bool 305EOLIAN static Eina_Bool
303_efl_canvas_layout_internal_table_efl_pack_unpack_all(Eo *obj EINA_UNUSED, Edje_Table_Data *pd) 306_efl_canvas_layout_internal_table_efl_pack_unpack_all(Eo *obj, Edje_Table_Data *pd)
304{ 307{
305 return _edje_part_table_clear(pd->ed, pd->part, EINA_FALSE); 308 RETURN_VAL(_edje_part_table_clear(pd->ed, pd->part, EINA_FALSE));
306} 309}
307 310
308EOLIAN static Eina_Bool 311EOLIAN static Eina_Bool
309_efl_canvas_layout_internal_table_efl_pack_unpack(Eo *obj EINA_UNUSED EINA_UNUSED, Edje_Table_Data *pd, Efl_Gfx *subobj) 312_efl_canvas_layout_internal_table_efl_pack_unpack(Eo *obj EINA_UNUSED, Edje_Table_Data *pd, Efl_Gfx *subobj)
310{ 313{
311 return _edje_part_table_unpack(pd->ed, pd->part, subobj); 314 RETURN_VAL(_edje_part_table_unpack(pd->ed, pd->part, subobj));
312} 315}
313 316
314EOLIAN static Eina_Bool 317EOLIAN static Eina_Bool
315_efl_canvas_layout_internal_table_efl_pack_grid_pack_grid(Eo *obj EINA_UNUSED, Edje_Table_Data *pd, Efl_Gfx *subobj, int col, int row, int colspan, int rowspan) 318_efl_canvas_layout_internal_table_efl_pack_grid_pack_grid(Eo *obj, Edje_Table_Data *pd, Efl_Gfx *subobj, int col, int row, int colspan, int rowspan)
316{ 319{
317 return _edje_part_table_pack(pd->ed, pd->part, subobj, col, row, colspan, rowspan); 320 RETURN_VAL(_edje_part_table_pack(pd->ed, pd->part, subobj, col, row, colspan, rowspan));
318} 321}
319 322
320EOLIAN static Efl_Gfx * 323EOLIAN static Efl_Gfx *
321_efl_canvas_layout_internal_table_efl_pack_grid_grid_content_get(Eo *obj EINA_UNUSED, Edje_Table_Data *pd, int col, int row) 324_efl_canvas_layout_internal_table_efl_pack_grid_grid_content_get(Eo *obj, Edje_Table_Data *pd, int col, int row)
322{ 325{
323 return _edje_part_table_child_get(pd->ed, pd->part, col, row); 326 RETURN_VAL(_edje_part_table_child_get(pd->ed, pd->part, col, row));
324} 327}
325 328
326EOLIAN static void 329EOLIAN static void
327_efl_canvas_layout_internal_table_efl_pack_grid_grid_size_get(Eo *obj EINA_UNUSED, Edje_Table_Data *pd, int *cols, int *rows) 330_efl_canvas_layout_internal_table_efl_pack_grid_grid_size_get(Eo *obj, Edje_Table_Data *pd, int *cols, int *rows)
328{ 331{
329 _edje_part_table_col_row_size_get(pd->ed, pd->part, cols, rows); 332 _edje_part_table_col_row_size_get(pd->ed, pd->part, cols, rows);
333 RETURN_VOID;
330} 334}
331 335
332EOLIAN static int 336EOLIAN static int
333_efl_canvas_layout_internal_table_efl_pack_grid_grid_columns_get(Eo *obj EINA_UNUSED, Edje_Table_Data *pd) 337_efl_canvas_layout_internal_table_efl_pack_grid_grid_columns_get(Eo *obj, Edje_Table_Data *pd)
334{ 338{
335 int cols = 0, rows = 0; 339 int cols = 0, rows = 0;
336 _edje_part_table_col_row_size_get(pd->ed, pd->part, &cols, &rows); 340 _edje_part_table_col_row_size_get(pd->ed, pd->part, &cols, &rows);
337 return cols; 341 RETURN_VAL(cols);
338} 342}
339 343
340EOLIAN static int 344EOLIAN static int
341_efl_canvas_layout_internal_table_efl_pack_grid_grid_rows_get(Eo *obj EINA_UNUSED, Edje_Table_Data *pd) 345_efl_canvas_layout_internal_table_efl_pack_grid_grid_rows_get(Eo *obj, Edje_Table_Data *pd)
342{ 346{
343 int cols = 0, rows = 0; 347 int cols = 0, rows = 0;
344 _edje_part_table_col_row_size_get(pd->ed, pd->part, &cols, &rows); 348 _edje_part_table_col_row_size_get(pd->ed, pd->part, &cols, &rows);
345 return rows; 349 RETURN_VAL(rows);
346} 350}
347 351
348/* New table apis with eo */ 352/* New table apis with eo */
@@ -376,7 +380,7 @@ _table_item_iterator_free(Part_Item_Iterator *it)
376} 380}
377 381
378EOLIAN static Eina_Iterator * 382EOLIAN static Eina_Iterator *
379_efl_canvas_layout_internal_table_efl_pack_grid_grid_contents_get(Eo *obj EINA_UNUSED, Edje_Table_Data *pd, int col, int row, Eina_Bool below) 383_efl_canvas_layout_internal_table_efl_pack_grid_grid_contents_get(Eo *obj, Edje_Table_Data *pd, int col, int row, Eina_Bool below)
380{ 384{
381 Evas_Object *sobj; 385 Evas_Object *sobj;
382 Eina_Iterator *it; 386 Eina_Iterator *it;
@@ -402,7 +406,7 @@ _efl_canvas_layout_internal_table_efl_pack_grid_grid_contents_get(Eo *obj EINA_U
402 eina_iterator_free(it); 406 eina_iterator_free(it);
403 407
404 pit = calloc(1, sizeof(*pit)); 408 pit = calloc(1, sizeof(*pit));
405 if (!pit) return NULL; 409 if (!pit) RETURN_VAL(NULL);
406 410
407 EINA_MAGIC_SET(&pit->iterator, EINA_MAGIC_ITERATOR); 411 EINA_MAGIC_SET(&pit->iterator, EINA_MAGIC_ITERATOR);
408 412
@@ -414,11 +418,11 @@ _efl_canvas_layout_internal_table_efl_pack_grid_grid_contents_get(Eo *obj EINA_U
414 pit->iterator.free = FUNC_ITERATOR_FREE(_table_item_iterator_free); 418 pit->iterator.free = FUNC_ITERATOR_FREE(_table_item_iterator_free);
415 eo_wref_add(obj, &pit->object); 419 eo_wref_add(obj, &pit->object);
416 420
417 return &pit->iterator; 421 RETURN_VAL(&pit->iterator);
418} 422}
419 423
420EOLIAN static Eina_Bool 424EOLIAN static Eina_Bool
421_efl_canvas_layout_internal_table_efl_pack_grid_grid_position_get(Eo *obj EINA_UNUSED, Edje_Table_Data *pd, Efl_Gfx * subobj, int *col, int *row, int *colspan, int *rowspan) 425_efl_canvas_layout_internal_table_efl_pack_grid_grid_position_get(Eo *obj, Edje_Table_Data *pd, Efl_Gfx * subobj, int *col, int *row, int *colspan, int *rowspan)
422{ 426{
423 unsigned short c, r, cs, rs; 427 unsigned short c, r, cs, rs;
424 Eina_Bool ret; 428 Eina_Bool ret;
@@ -429,7 +433,7 @@ _efl_canvas_layout_internal_table_efl_pack_grid_grid_position_get(Eo *obj EINA_U
429 if (colspan) *colspan = cs; 433 if (colspan) *colspan = cs;
430 if (rowspan) *rowspan = rs; 434 if (rowspan) *rowspan = rs;
431 435
432 return ret; 436 RETURN_VAL(ret);
433} 437}
434 438
435/* Legacy API implementation */ 439/* Legacy API implementation */