--- ex.h 2002/01/31 19:54:05 1.14
+++ ex.h 2002/02/25 10:30:15 1.15
@@ -94,7 +94,8 @@
/* declare the context type (private) */
typedef struct {
__ex_mctx_t *ctx_mctx; /* permanent machine context of enclosing try/catch */
- int ctx_disabled; /* permanent flag whether exception handling is disabled */
+ int ctx_shielding;/* permanent counter of exception shielding level */
+ int ctx_shield; /* temporary flag for exception shielding macro */
int ctx_caught; /* temporary flag whether exception was caught */
int ctx_cleanup; /* temporary flag whether cleanup block was present */
volatile ex_t ctx_ex; /* temporary exception storage */
@@ -102,11 +103,12 @@
/* the static and dynamic initializers for a context structure */
#define EX_CTX_INITIALIZER \
- { NULL, 0, 0, 0, { NULL, NULL, NULL, NULL, 0, NULL } }
+ { NULL, 0, 0, 0, 0, { NULL, NULL, NULL, NULL, 0, NULL } }
#define EX_CTX_INITIALIZE(ctx) \
do { \
(ctx)->ctx_mctx = NULL; \
- (ctx)->ctx_disabled = 0; \
+ (ctx)->ctx_shielding = 0; \
+ (ctx)->ctx_shield = 0; \
(ctx)->ctx_caught = 0; \
(ctx)->ctx_cleanup = 0; \
(ctx)->ctx_ex.ex_class = NULL; \
@@ -176,7 +178,7 @@
/* the throwing of a new exception */
#define ex_throw(c,o,v) \
- (__ex_ctx()->ctx_disabled ? 0 : \
+ (__ex_ctx()->ctx_shielding > 0 ? 0 : \
(__ex_ctx()->ctx_ex.ex_class = (void *)(c), \
__ex_ctx()->ctx_ex.ex_object = (void *)(o), \
__ex_ctx()->ctx_ex.ex_value = (void *)(v), \
@@ -189,22 +191,24 @@
/* the re-throwing of an already caught exception */
#define ex_rethrow \
- (__ex_ctx()->ctx_disabled ? 0 : \
+ (__ex_ctx()->ctx_shielding > 0 ? 0 : \
( __ex_ctx()->ctx_mctx == NULL \
? (__ex_terminate((ex_t *)&(__ex_ctx()->ctx_ex)), -1) \
: (__ex_mctx_restore(__ex_ctx()->ctx_mctx), 1) ))
/* shield an operation from exception handling */
#define ex_shield \
- for (__ex_ctx()->ctx_disabled = 1; \
- __ex_ctx()->ctx_disabled == 1; \
- __ex_ctx()->ctx_disabled = 0)
+ for (__ex_ctx()->ctx_shielding++, \
+ __ex_ctx()->ctx_shield = 1; \
+ __ex_ctx()->ctx_shield == 1; \
+ __ex_ctx()->ctx_shield = 0, \
+ __ex_ctx()->ctx_shielding--)
/* exception handling tests */
#define ex_catching \
(__ex_ctx()->ctx_mctx != NULL)
#define ex_shielding \
- (__ex_ctx()->ctx_disabled)
+ (__ex_ctx()->ctx_shielding > 0)
/* optional namespace mapping */
#if defined(__EX_NS_UCCXX__)
|