eo2: eo2_do() uses __attribute__ cleanup

to protect us against bad use of break, goto, return ... in eo2_do,
we use __attribute__((cleanup(eo2_do_end))) to ensure that eo2_do_end()
is called whatever.
This commit is contained in:
Jérémy Zurcher 2013-12-25 16:22:42 +01:00 committed by Tom Hacohen
parent adc1ac0c23
commit b6991985ed
2 changed files with 8 additions and 8 deletions

View File

@ -678,28 +678,28 @@ EAPI Eina_Bool eo2_call_resolve_internal(const Eo_Class *klass, Eo_Op op, Eo2_Op
EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super); EAPI Eina_Bool eo2_do_start(Eo *obj_id, Eina_Bool do_super);
// end of the eo2_do barrier, unref the obj, move the stack pointer // end of the eo2_do barrier, unref the obj, move the stack pointer
EAPI void eo2_do_end(); EAPI void eo2_do_end(Eo **ojb);
EAPI int eo2_call_stack_depth(); EAPI int eo2_call_stack_depth();
#define EO2_DO_CLEANUP __attribute__((cleanup(eo2_do_end)))
// eo object method calls batch, // eo object method calls batch,
// DO NOT use return statement in it, use break if necessary // DO NOT use return statement in it, use break if necessary
#define eo2_do(objid, ...) \ #define eo2_do(objid, ...) \
do \ do \
{ \ { \
Eo *_objid_ = objid; \ Eo *_objid_ EO2_DO_CLEANUP = objid; \
if (!eo2_do_start(_objid_, EINA_FALSE)) break; \ if (!eo2_do_start(_objid_, EINA_FALSE)) break; \
do { __VA_ARGS__ ; } while (0); \ __VA_ARGS__; \
eo2_do_end(); \
} while (0) } while (0)
#define eo2_do_super(objid, ...) \ #define eo2_do_super(objid, ...) \
do \ do \
{ \ { \
Eo *_objid_ = objid; \ Eo *_objid_ EO2_DO_CLEANUP = objid; \
if (!eo2_do_start(_objid_, EINA_TRUE)) break; \ if (!eo2_do_start(_objid_, EINA_TRUE)) break; \
do { __VA_ARGS__ ; } while (0); \ __VA_ARGS__; \
eo2_do_end(); \
} while (0) } while (0)
// FIXME // FIXME

View File

@ -354,7 +354,7 @@ eo2_do_start(Eo *obj_id, Eina_Bool do_super)
} }
EAPI void EAPI void
eo2_do_end() eo2_do_end(Eo **objid EINA_UNUSED)
{ {
Eo2_Stack_Frame *fptr; Eo2_Stack_Frame *fptr;