summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-05-20 16:16:14 +0100
committerTom Hacohen <tom@stosb.com>2016-05-20 16:16:17 +0100
commit7b2b62318041ceffc1d629402c4603b7b76d5b01 (patch)
treedf5e10192392ba410b1e5b0717d7eac718b59807
parenta52c7da7140a04017916e3a130d3dcb7af385cf4 (diff)
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().
-rw-r--r--src/lib/eo/Eo.h6
-rw-r--r--src/tests/eo/suite/eo_test_general.c6
2 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index a241d4fe70..61af39bc1b 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -451,6 +451,8 @@ EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Cla
451 */ 451 */
452EAPI Eina_Bool eo_override(Eo *obj, Eo_Ops ops); 452EAPI Eina_Bool eo_override(Eo *obj, Eo_Ops ops);
453 453
454#define EO_OVERRIDE_OPS(op_descs) ((Eo_Ops) { op_descs, EINA_C_ARRAY_LENGTH(op_descs) })
455
454/** 456/**
455 * @brief Check if an object "is a" klass. 457 * @brief Check if an object "is a" klass.
456 * @param obj The object to check 458 * @param obj The object to check
@@ -491,8 +493,8 @@ EAPI Eina_Bool eo_init(void);
491EAPI Eina_Bool eo_shutdown(void); 493EAPI Eina_Bool eo_shutdown(void);
492 494
493// Helpers macro to help populating #Eo_Class_Description. 495// Helpers macro to help populating #Eo_Class_Description.
494#define EO_CLASS_DESCRIPTION_NOOPS() ((Eo_Ops) { NULL, 0}) 496#define EO_CLASS_DESCRIPTION_NOOPS() { NULL, 0}
495#define EO_CLASS_DESCRIPTION_OPS(op_descs) ((Eo_Ops) { op_descs, EINA_C_ARRAY_LENGTH(op_descs) }) 497#define EO_CLASS_DESCRIPTION_OPS(op_descs) { op_descs, EINA_C_ARRAY_LENGTH(op_descs) }
496 498
497// to fetch internal function and object data at once 499// to fetch internal function and object data at once
498typedef struct _Eo_Op_Call_Data 500typedef struct _Eo_Op_Call_Data
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 1fffc3521e..055bd3c12a 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -79,7 +79,7 @@ START_TEST(eo_override_tests)
79 * make sure we don't cache. */ 79 * make sure we don't cache. */
80 ck_assert_int_eq(simple_a_get(obj), 0); 80 ck_assert_int_eq(simple_a_get(obj), 0);
81 81
82 fail_if(!eo_override(obj, EO_CLASS_DESCRIPTION_OPS(override_descs))); 82 fail_if(!eo_override(obj, EO_OVERRIDE_OPS(override_descs)));
83 83
84 ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A); 84 ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A);
85 85
@@ -93,7 +93,7 @@ START_TEST(eo_override_tests)
93 EO_OP_FUNC_OVERRIDE(simple_a_set, _simple_obj_override_a_double_set), 93 EO_OP_FUNC_OVERRIDE(simple_a_set, _simple_obj_override_a_double_set),
94 }; 94 };
95 95
96 fail_if(!eo_override(obj, EO_CLASS_DESCRIPTION_OPS(override_descs2))); 96 fail_if(!eo_override(obj, EO_OVERRIDE_OPS(override_descs2)));
97 97
98 simple_a_set(obj, OVERRIDE_A_SIMPLE); 98 simple_a_set(obj, OVERRIDE_A_SIMPLE);
99 ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A + (OVERRIDE_A_SIMPLE * 2)); 99 ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A + (OVERRIDE_A_SIMPLE * 2));
@@ -104,7 +104,7 @@ START_TEST(eo_override_tests)
104 EO_OP_FUNC(simple2_class_beef_get, _simple_obj_override_a_double_set), 104 EO_OP_FUNC(simple2_class_beef_get, _simple_obj_override_a_double_set),
105 }; 105 };
106 106
107 fail_if(eo_override(obj, (Eo_Ops) EO_CLASS_DESCRIPTION_OPS(override_descs3))); 107 fail_if(eo_override(obj, EO_OVERRIDE_OPS(override_descs3)));
108 108
109 eo_unref(obj); 109 eo_unref(obj);
110 110