Eo: Fix compilation for people using GCC.

Apparently you can't cast when initializing static consts, even if
the cast is to the same type. This commit splits the macro used
so we have an additional one that casts and thus works with
eo_override().
This commit is contained in:
Tom Hacohen 2016-05-20 16:16:14 +01:00
parent a52c7da714
commit 7b2b623180
2 changed files with 7 additions and 5 deletions

View File

@ -451,6 +451,8 @@ EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Cla
*/
EAPI Eina_Bool eo_override(Eo *obj, Eo_Ops ops);
#define EO_OVERRIDE_OPS(op_descs) ((Eo_Ops) { op_descs, EINA_C_ARRAY_LENGTH(op_descs) })
/**
* @brief Check if an object "is a" klass.
* @param obj The object to check
@ -491,8 +493,8 @@ EAPI Eina_Bool eo_init(void);
EAPI Eina_Bool eo_shutdown(void);
// Helpers macro to help populating #Eo_Class_Description.
#define EO_CLASS_DESCRIPTION_NOOPS() ((Eo_Ops) { NULL, 0})
#define EO_CLASS_DESCRIPTION_OPS(op_descs) ((Eo_Ops) { op_descs, EINA_C_ARRAY_LENGTH(op_descs) })
#define EO_CLASS_DESCRIPTION_NOOPS() { NULL, 0}
#define EO_CLASS_DESCRIPTION_OPS(op_descs) { op_descs, EINA_C_ARRAY_LENGTH(op_descs) }
// to fetch internal function and object data at once
typedef struct _Eo_Op_Call_Data

View File

@ -79,7 +79,7 @@ START_TEST(eo_override_tests)
* make sure we don't cache. */
ck_assert_int_eq(simple_a_get(obj), 0);
fail_if(!eo_override(obj, EO_CLASS_DESCRIPTION_OPS(override_descs)));
fail_if(!eo_override(obj, EO_OVERRIDE_OPS(override_descs)));
ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A);
@ -93,7 +93,7 @@ START_TEST(eo_override_tests)
EO_OP_FUNC_OVERRIDE(simple_a_set, _simple_obj_override_a_double_set),
};
fail_if(!eo_override(obj, EO_CLASS_DESCRIPTION_OPS(override_descs2)));
fail_if(!eo_override(obj, EO_OVERRIDE_OPS(override_descs2)));
simple_a_set(obj, OVERRIDE_A_SIMPLE);
ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A + (OVERRIDE_A_SIMPLE * 2));
@ -104,7 +104,7 @@ START_TEST(eo_override_tests)
EO_OP_FUNC(simple2_class_beef_get, _simple_obj_override_a_double_set),
};
fail_if(eo_override(obj, (Eo_Ops) EO_CLASS_DESCRIPTION_OPS(override_descs3)));
fail_if(eo_override(obj, EO_OVERRIDE_OPS(override_descs3)));
eo_unref(obj);