summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-10-21 12:37:00 +0100
committerTom Hacohen <tom@stosb.com>2014-10-21 12:37:00 +0100
commit01a487d881b7153753f2cc5d1fd85a3580b38fbf (patch)
treec585cc8d01e87c3c4712c3fe72f7bcf253c2b5c2
parent2ac6c4accfe6acdcc75b458d7b0eb29949714f73 (diff)
downloadefl-01a487d881b7153753f2cc5d1fd85a3580b38fbf.tar.gz
Eo composite: Fix composite object functions to be eo functions.
For some reason, they were normal functions instead of eo functions, which makes them harder to bind, less safe, and just wrong. This commit fixes that.
-rw-r--r--src/examples/eo/evas/evas_elw_boxedbutton.c2
-rw-r--r--src/lib/eo/Eo.h47
-rw-r--r--src/lib/eo/eo.c51
-rw-r--r--src/lib/eo/eo_base.eo42
-rw-r--r--src/lib/eo/eo_base_class.c55
-rw-r--r--src/lib/eo/eo_private.h2
-rw-r--r--src/tests/eo/composite_objects/composite_objects_comp.c6
-rw-r--r--src/tests/eo/composite_objects/composite_objects_main.c18
-rw-r--r--src/tests/eo/suite/eo_test_general.c12
9 files changed, 114 insertions, 121 deletions
diff --git a/src/examples/eo/evas/evas_elw_boxedbutton.c b/src/examples/eo/evas/evas_elw_boxedbutton.c
index 43fe6f9a6b..44fc2605c8 100644
--- a/src/examples/eo/evas/evas_elw_boxedbutton.c
+++ b/src/examples/eo/evas/evas_elw_boxedbutton.c
@@ -23,7 +23,7 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
eo_do_super(obj, MY_CLASS, eo_constructor());
Eo *bt = eo_add(ELW_BUTTON_CLASS, obj);
- eo_composite_attach(bt, obj);
+ eo_do(obj, eo_composite_attach(bt));
eo_do(bt, eo_event_callback_forwarder_add(EV_CLICKED, obj));
eo_do(bt, exevas_obj_visibility_set(EINA_TRUE));
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 8c26d6e1c9..21999c6d78 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -873,53 +873,6 @@ EAPI Eina_Bool eo_manual_free(Eo *obj);
EAPI Eina_Bool eo_destructed_is(const Eo *obj);
/**
- * @addtogroup Eo_Composite_Objects Composite Objects.
- * @{
- */
-
-/**
- * @brief Make an object a composite object of another.
- * @param comp_obj the object that will be used to composite parent.
- * @param parent the "parent" object.
- * @return EINA_TRUE if successfull. EINA_FALSE otherwise.
- *
- * The class of comp_obj must be part of the extensions of the class of the parent.
- * It is not possible to attach more then 1 composite of the same class.
- * This functions also sets the parent of comp_obj to parent.
- *
- * @see eo_composite_detach()
- * @see eo_composite_is()
- */
-EAPI Eina_Bool eo_composite_attach(Eo *comp_obj, Eo *parent);
-
-/**
- * @brief Detach a composite object from another object.
- * @param comp_obj the object attached to parent.
- * @param parent the "parent" object.
- * @return EINA_TRUE if successfull. EINA_FALSE otherwise.
- *
- * This functions also sets the parent of comp_obj to @c NULL.
- *
- * @see eo_composite_attach()
- * @see eo_composite_is()
- */
-EAPI Eina_Bool eo_composite_detach(Eo *comp_obj, Eo *parent);
-
-/**
- * @brief Check if an object is a composite object.
- * @param comp_obj the object to be checked.
- * @return @c EINA_TRUE if it is, @c EINA_FALSE otherwise.
- *
- * @see eo_composite_attach()
- * @see eo_composite_detach()
- */
-EAPI Eina_Bool eo_composite_is(const Eo *comp_obj);
-
-/**
- * @}
- */
-
-/**
* @addtogroup Eo_Class_Class Eo's Class class.
* @{
*/
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 6e3ed7381c..a8fc42ec69 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1856,57 +1856,6 @@ eo_shutdown(void)
}
EAPI Eina_Bool
-eo_composite_attach(Eo *comp_obj_id, Eo *parent_id)
-{
- EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
- EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, EINA_FALSE);
-
- if (!eo_isa(parent_id, _eo_class_id_get(comp_obj->klass))) return EINA_FALSE;
-
- {
- Eina_List *itr;
- Eo *emb_obj_id;
- EINA_LIST_FOREACH(parent->composite_objects, itr, emb_obj_id)
- {
- EO_OBJ_POINTER_RETURN_VAL(emb_obj_id, emb_obj, EINA_FALSE);
- if(emb_obj->klass == comp_obj->klass)
- return EINA_FALSE;
- }
- }
-
- comp_obj->composite = EINA_TRUE;
- parent->composite_objects = eina_list_prepend(parent->composite_objects, comp_obj_id);
-
- eo_do(comp_obj_id, eo_parent_set(parent_id));
-
- return EINA_TRUE;
-}
-
-EAPI Eina_Bool
-eo_composite_detach(Eo *comp_obj_id, Eo *parent_id)
-{
- EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
- EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, EINA_FALSE);
-
- if (!comp_obj->composite)
- return EINA_FALSE;
-
- comp_obj->composite = EINA_FALSE;
- parent->composite_objects = eina_list_remove(parent->composite_objects, comp_obj_id);
- eo_do(comp_obj_id, eo_parent_set(NULL));
-
- return EINA_TRUE;
-}
-
-EAPI Eina_Bool
-eo_composite_is(const Eo *comp_obj_id)
-{
- EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
-
- return comp_obj->composite;
-}
-
-EAPI Eina_Bool
eo_destructed_is(const Eo *obj_id)
{
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo
index dc05c3e2a9..abec82e9fb 100644
--- a/src/lib/eo/eo_base.eo
+++ b/src/lib/eo/eo_base.eo
@@ -173,6 +173,48 @@ callbacks of the same priority are called in reverse order of creation. */
/*@ Get an iterator on all childrens */
return: free(own(iterator<Eo *> *), eina_iterator_free) @warn_unused;
}
+ composite_attach {
+ /**
+ * @brief Make an object a composite object of another.
+ *
+ * The class of comp_obj must be part of the extensions of the class of the parent.
+ * It is not possible to attach more then 1 composite of the same class.
+ * This functions also sets the parent of comp_obj to parent.
+ *
+ * @see eo_composite_detach()
+ * @see eo_composite_part_is()
+ * @ingroup Eo_Composite_Objects
+ */
+ params {
+ @in Eo *comp_obj; /*@ the object that will be used to composite the parent. */
+ }
+ return: bool; /*@ EINA_TRUE if successfull. EINA_FALSE otherwise. */
+ }
+ composite_detach {
+ /**
+ * @brief Detach a composite object from another object.
+ *
+ * This functions also sets the parent of comp_obj to @c NULL.
+ *
+ * @see eo_composite_attach()
+ * @see eo_composite_part_is()
+ * @ingroup Eo_Composite_Objects
+ */
+ params {
+ @in Eo *comp_obj; /*@ the object that will be removed from the parent. */
+ }
+ return: bool; /*@ EINA_TRUE if successfull. EINA_FALSE otherwise. */
+ }
+ composite_part_is {
+ /**
+ * @brief Check if an object is part of a composite object.
+ *
+ * @see eo_composite_attach()
+ * @see eo_composite_part_is()
+ * @ingroup Eo_Composite_Objects
+ */
+ return: bool; /*@ EINA_TRUE if it is. EINA_FALSE otherwise. */
+ }
}
implements {
class.constructor;
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 344e221055..8b7f1d01f4 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -104,9 +104,9 @@ _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo *parent_id)
if (pd->parent == parent_id)
return;
- if (eo_composite_is(obj) && pd->parent)
+ if (eo_do(obj, eo_composite_part_is()) && pd->parent)
{
- eo_composite_detach(obj, pd->parent);
+ eo_do(pd->parent, eo_composite_detach(obj));
}
if (pd->parent)
@@ -813,6 +813,57 @@ _eo_base_event_global_freeze_count_get(Eo *klass EINA_UNUSED, void *pd EINA_UNUS
return event_freeze_count;
}
+EOLIAN static Eina_Bool
+_eo_base_composite_attach(Eo *parent_id, Eo_Base_Data *pd EINA_UNUSED, Eo *comp_obj_id)
+{
+ EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
+ EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, EINA_FALSE);
+
+ if (!eo_isa(parent_id, _eo_class_id_get(comp_obj->klass))) return EINA_FALSE;
+
+ {
+ Eina_List *itr;
+ Eo *emb_obj_id;
+ EINA_LIST_FOREACH(parent->composite_objects, itr, emb_obj_id)
+ {
+ EO_OBJ_POINTER_RETURN_VAL(emb_obj_id, emb_obj, EINA_FALSE);
+ if(emb_obj->klass == comp_obj->klass)
+ return EINA_FALSE;
+ }
+ }
+
+ comp_obj->composite = EINA_TRUE;
+ parent->composite_objects = eina_list_prepend(parent->composite_objects, comp_obj_id);
+
+ eo_do(comp_obj_id, eo_parent_set(parent_id));
+
+ return EINA_TRUE;
+}
+
+EOLIAN static Eina_Bool
+_eo_base_composite_detach(Eo *parent_id, Eo_Base_Data *pd EINA_UNUSED, Eo *comp_obj_id)
+{
+ EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
+ EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, EINA_FALSE);
+
+ if (!comp_obj->composite)
+ return EINA_FALSE;
+
+ comp_obj->composite = EINA_FALSE;
+ parent->composite_objects = eina_list_remove(parent->composite_objects, comp_obj_id);
+ eo_do(comp_obj_id, eo_parent_set(NULL));
+
+ return EINA_TRUE;
+}
+
+EOLIAN static Eina_Bool
+_eo_base_composite_part_is(Eo *comp_obj_id, Eo_Base_Data *pd EINA_UNUSED)
+{
+ EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
+
+ return comp_obj->composite;
+}
+
/* Eo_Dbg */
EAPI void
eo_dbg_info_free(Eo_Dbg_Info *info)
diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
index be0a03a09d..c652271dd6 100644
--- a/src/lib/eo/eo_private.h
+++ b/src/lib/eo/eo_private.h
@@ -231,7 +231,7 @@ _eo_del_internal(const char *file, int line, _Eo_Object *obj)
Eo *emb_obj;
EINA_LIST_FOREACH_SAFE(obj->composite_objects, itr, itr_n, emb_obj)
{
- eo_composite_detach(emb_obj, _eo_id_get(obj));
+ eo_do(_eo_id_get(obj), eo_composite_detach(emb_obj));
}
}
diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c
index 17cd95cff2..d08d492b8f 100644
--- a/src/tests/eo/composite_objects/composite_objects_comp.c
+++ b/src/tests/eo/composite_objects/composite_objects_comp.c
@@ -25,11 +25,11 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
eo_do_super(obj, MY_CLASS, eo_constructor());
Eo *simple = eo_add(SIMPLE_CLASS, obj);
- eo_composite_attach(simple, obj);
+ eo_do(obj, eo_composite_attach(simple));
eo_do(simple, eo_event_callback_forwarder_add(EV_A_CHANGED, obj));
- fail_if(eo_composite_is(obj));
- fail_if(!eo_composite_is(simple));
+ fail_if(eo_do(obj, eo_composite_part_is()));
+ fail_if(!eo_do(simple, eo_composite_part_is()));
eo_do(obj, eo_key_data_set("simple-obj", simple, NULL));
}
diff --git a/src/tests/eo/composite_objects/composite_objects_main.c b/src/tests/eo/composite_objects/composite_objects_main.c
index 9c3d95c426..00c74c70d2 100644
--- a/src/tests/eo/composite_objects/composite_objects_main.c
+++ b/src/tests/eo/composite_objects/composite_objects_main.c
@@ -53,15 +53,15 @@ main(int argc, char *argv[])
eo_do(obj, simple_a_set(2));
fail_if(cb_called);
- fail_if(!eo_composite_is(simple));
- fail_if(!eo_composite_detach(simple, obj));
- fail_if(eo_composite_detach(simple, obj));
- fail_if(eo_composite_is(simple));
- fail_if(!eo_composite_attach(simple, obj));
- fail_if(!eo_composite_is(simple));
- fail_if(eo_composite_attach(simple, obj));
-
- fail_if(eo_composite_attach(obj, simple));
+ fail_if(!eo_do(simple, eo_composite_part_is()));
+ fail_if(!eo_do(obj, eo_composite_detach(simple)));
+ fail_if(eo_do(obj, eo_composite_detach(simple)));
+ fail_if(eo_do(simple, eo_composite_part_is()));
+ fail_if(!eo_do(obj, eo_composite_attach(simple)));
+ fail_if(!eo_do(simple, eo_composite_part_is()));
+ fail_if(eo_do(obj, eo_composite_attach(simple)));
+
+ fail_if(eo_do(simple, eo_composite_attach(obj)));
eo_unref(simple);
eo_unref(obj);
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 77fca9cc61..18b1a00df0 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -275,9 +275,9 @@ START_TEST(eo_composite_tests)
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
fail_if(!obj2);
- eo_composite_attach(obj2, obj);
+ eo_do(obj, eo_composite_attach(obj2));
eo_do(obj2, eo_parent_set(NULL));
- fail_if(eo_composite_is(obj2));
+ fail_if(eo_do(obj2, eo_composite_part_is()));
eo_unref(obj2);
eo_unref(obj);
@@ -681,11 +681,9 @@ START_TEST(eo_magic_checks)
fail_if(eo_data_scope_get((Eo *) buf, SIMPLE_CLASS));
- eo_composite_attach((Eo *) buf, obj);
- eo_composite_attach(obj, (Eo *) buf);
- eo_composite_detach((Eo *) buf, obj);
- eo_composite_detach(obj, (Eo *) buf);
- eo_composite_is((Eo *) buf);
+ eo_do(obj, eo_composite_attach((Eo *) buf));
+ eo_do(obj, eo_composite_detach((Eo *) buf));
+ eo_do((Eo *) buf, eo_composite_part_is());
eo_do(obj, eo_event_callback_forwarder_add(NULL, (Eo *) buf));
eo_do(obj, eo_event_callback_forwarder_del(NULL, (Eo *) buf));