summaryrefslogtreecommitdiff
path: root/legacy/eobj
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-06-13 11:38:56 +0000
committerTom Hacohen <tom@stosb.com>2012-06-13 11:38:56 +0000
commitd099b82f9acadf394e8f81feece0fc6ae5548d5f (patch)
tree7d176cbdc4a9ca347a5934151941b71c52eee996 /legacy/eobj
parentc513f84aa8f404c17e302a5c0b5d64430793d8de (diff)
Eo: Implement handling of eo_do errors and use it.
I'm now using it for constructor errors as well. SVN revision: 72081
Diffstat (limited to 'legacy/eobj')
-rw-r--r--legacy/eobj/src/lib/eo.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/legacy/eobj/src/lib/eo.c b/legacy/eobj/src/lib/eo.c
index 4f8d73863c..04ff8f88a0 100644
--- a/legacy/eobj/src/lib/eo.c
+++ b/legacy/eobj/src/lib/eo.c
@@ -17,8 +17,6 @@ static Eo_Class_Id _eo_classes_last_id;
17static Eina_Bool _eo_init_count = 0; 17static Eina_Bool _eo_init_count = 0;
18 18
19static void _eo_condtor_reset(Eo *obj); 19static void _eo_condtor_reset(Eo *obj);
20static inline Eina_Bool _eo_error_get(const Eo *obj);
21static inline void _eo_error_unset(Eo *obj);
22static inline void *_eo_data_get(const Eo *obj, const Eo_Class *klass); 20static inline void *_eo_data_get(const Eo *obj, const Eo_Class *klass);
23static inline Eo *_eo_ref(Eo *obj); 21static inline Eo *_eo_ref(Eo *obj);
24static inline void _eo_unref(Eo *obj); 22static inline void _eo_unref(Eo *obj);
@@ -44,7 +42,7 @@ struct _Eo {
44 42
45 Eo_Kls_Itr mro_itr; 43 Eo_Kls_Itr mro_itr;
46 44
47 Eina_Bool construct_error:1; 45 Eina_Bool do_error:1;
48 Eina_Bool condtor_done:1; 46 Eina_Bool condtor_done:1;
49 47
50 Eina_Bool composite:1; 48 Eina_Bool composite:1;
@@ -420,12 +418,14 @@ end:
420EAPI Eina_Bool 418EAPI Eina_Bool
421eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...) 419eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...)
422{ 420{
421 Eina_Bool prev_error;
423 Eina_Bool ret = EINA_TRUE; 422 Eina_Bool ret = EINA_TRUE;
424 Eo_Op op = EO_NOOP; 423 Eo_Op op = EO_NOOP;
425 va_list p_list; 424 va_list p_list;
426 425
427 EO_MAGIC_RETURN_VAL(obj, EO_EINA_MAGIC, EINA_FALSE); 426 EO_MAGIC_RETURN_VAL(obj, EO_EINA_MAGIC, EINA_FALSE);
428 427
428 prev_error = obj->do_error;
429 _eo_ref(obj); 429 _eo_ref(obj);
430 430
431 va_start(p_list, op_type); 431 va_start(p_list, op_type);
@@ -445,6 +445,12 @@ eo_do_internal(Eo *obj, Eo_Op_Type op_type, ...)
445 va_end(p_list); 445 va_end(p_list);
446 446
447 _eo_unref(obj); 447 _eo_unref(obj);
448
449 if (obj->do_error)
450 ret = EINA_FALSE;
451
452 obj->do_error = prev_error;
453
448 return ret; 454 return ret;
449} 455}
450 456
@@ -1097,6 +1103,7 @@ eo_parent_set(Eo *obj, const Eo *parent)
1097EAPI Eo * 1103EAPI Eo *
1098eo_add(const Eo_Class *klass, Eo *parent) 1104eo_add(const Eo_Class *klass, Eo *parent)
1099{ 1105{
1106 Eina_Bool do_err;
1100 EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, NULL); 1107 EO_MAGIC_RETURN_VAL(klass, EO_CLASS_EINA_MAGIC, NULL);
1101 1108
1102 if (parent) EO_MAGIC_RETURN_VAL(parent, EO_EINA_MAGIC, NULL); 1109 if (parent) EO_MAGIC_RETURN_VAL(parent, EO_EINA_MAGIC, NULL);
@@ -1119,13 +1126,12 @@ eo_add(const Eo_Class *klass, Eo *parent)
1119 Eo_Kls_Itr prev_state; 1126 Eo_Kls_Itr prev_state;
1120 1127
1121 _eo_kls_itr_init(klass, &obj->mro_itr, EO_NOOP, &prev_state); 1128 _eo_kls_itr_init(klass, &obj->mro_itr, EO_NOOP, &prev_state);
1122 _eo_error_unset(obj);
1123 _eo_condtor_reset(obj); 1129 _eo_condtor_reset(obj);
1124 1130
1125 _eo_ref(obj); 1131 _eo_ref(obj);
1126 eo_do(obj, eo_constructor()); 1132 do_err = !eo_do(obj, eo_constructor());
1127 1133
1128 if (EINA_UNLIKELY(_eo_error_get(obj))) 1134 if (EINA_UNLIKELY(do_err))
1129 { 1135 {
1130 ERR("Object of class '%s' - One of the object constructors have failed.", klass->desc->name); 1136 ERR("Object of class '%s' - One of the object constructors have failed.", klass->desc->name);
1131 goto fail; 1137 goto fail;
@@ -1228,6 +1234,7 @@ eo_ref(const Eo *_obj)
1228static inline void 1234static inline void
1229_eo_del_internal(Eo *obj) 1235_eo_del_internal(Eo *obj)
1230{ 1236{
1237 Eina_Bool do_err;
1231 /* We need that for the event callbacks that may ref/unref. */ 1238 /* We need that for the event callbacks that may ref/unref. */
1232 obj->refcount++; 1239 obj->refcount++;
1233 1240
@@ -1237,11 +1244,10 @@ _eo_del_internal(Eo *obj)
1237 Eo_Kls_Itr prev_state; 1244 Eo_Kls_Itr prev_state;
1238 1245
1239 _eo_kls_itr_init(klass, &obj->mro_itr, EO_NOOP, &prev_state); 1246 _eo_kls_itr_init(klass, &obj->mro_itr, EO_NOOP, &prev_state);
1240 _eo_error_unset(obj);
1241 _eo_condtor_reset(obj); 1247 _eo_condtor_reset(obj);
1242 1248
1243 eo_do(obj, eo_destructor()); 1249 do_err = eo_do(obj, eo_destructor());
1244 if (_eo_error_get(obj)) 1250 if (EINA_UNLIKELY(!do_err))
1245 { 1251 {
1246 ERR("Object of class '%s' - One of the object destructors have failed.", klass->desc->name); 1252 ERR("Object of class '%s' - One of the object destructors have failed.", klass->desc->name);
1247 } 1253 }
@@ -1349,13 +1355,7 @@ eo_error_set_internal(const Eo *obj, const char *file, int line)
1349 1355
1350 ERR("Error with obj '%p' at %s:%d", obj, file, line); 1356 ERR("Error with obj '%p' at %s:%d", obj, file, line);
1351 1357
1352 ((Eo *) obj)->construct_error = EINA_TRUE; 1358 ((Eo *) obj)->do_error = EINA_TRUE;
1353}
1354
1355static inline void
1356_eo_error_unset(Eo *obj)
1357{
1358 obj->construct_error = EINA_FALSE;
1359} 1359}
1360 1360
1361void 1361void
@@ -1376,18 +1376,6 @@ _eo_condtor_reset(Eo *obj)
1376 obj->condtor_done = EINA_FALSE; 1376 obj->condtor_done = EINA_FALSE;
1377} 1377}
1378 1378
1379/**
1380 * @internal
1381 * @brief Check if there was an error when constructing, destructing or calling a function of the object.
1382 * @param obj the object to work on.
1383 * @return @c EINA_TRUE if there was an error.
1384 */
1385static inline Eina_Bool
1386_eo_error_get(const Eo *obj)
1387{
1388 return obj->construct_error;
1389}
1390
1391static inline void * 1379static inline void *
1392_eo_data_get(const Eo *obj, const Eo_Class *klass) 1380_eo_data_get(const Eo *obj, const Eo_Class *klass)
1393{ 1381{