OSSP CVS Repository

ossp - Difference in ossp-pkg/ex/ex.h versions 1.16 and 1.17
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/ex/ex.h 1.16 -> 1.17

--- ex.h 2002/02/25 10:33:02     1.16
+++ ex.h 2002/03/07 21:30:09     1.17
@@ -94,6 +94,9 @@
 /* declare the context type (private) */
 typedef struct {
     __ex_mctx_t  *ctx_mctx;     /* permanent machine context of enclosing try/catch */
+    int           ctx_deferred; /* permanent flag whether exception is deferred */
+    int           ctx_deferring;/* permanent counter of exception deferring level */
+    int           ctx_defer;    /* temporary flag for exception deferring macro */
     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 */
@@ -103,10 +106,13 @@
 
 /* the static and dynamic initializers for a context structure */
 #define EX_CTX_INITIALIZER \
-    { NULL, 0, 0, 0, 0, { NULL, NULL, NULL, NULL, 0, NULL } }
+    { NULL, 0, 0, 0, 0, 0, 0, 0, { NULL, NULL, NULL, NULL, 0, NULL } }
 #define EX_CTX_INITIALIZE(ctx) \
     do { \
         (ctx)->ctx_mctx         = NULL; \
+        (ctx)->ctx_deferred     = 0;    \
+        (ctx)->ctx_deferring    = 0;    \
+        (ctx)->ctx_defer        = 0;    \
         (ctx)->ctx_shielding    = 0;    \
         (ctx)->ctx_shield       = 0;    \
         (ctx)->ctx_caught       = 0;    \
@@ -178,20 +184,24 @@
 
 /* the throwing of a new exception */
 #define ex_throw(c,o,v) \
-    (__ex_ctx()->ctx_shielding > 0 ? 0 : \
+    ((   __ex_ctx()->ctx_shielding > 0 \
+      || (__ex_ctx()->ctx_deferring > 0 && __ex_ctx()->ctx_deferred == 1)) ? 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), \
       __ex_ctx()->ctx_ex.ex_file   = __FILE__, \
       __ex_ctx()->ctx_ex.ex_line   = __LINE__, \
       __ex_ctx()->ctx_ex.ex_func   = __EX_FUNC__, \
-      (  __ex_ctx()->ctx_mctx == NULL \
-       ? (__ex_terminate((ex_t *)&(__ex_ctx()->ctx_ex)), -1) \
-       : (__ex_mctx_restore(__ex_ctx()->ctx_mctx), 1) )))
+      __ex_ctx()->ctx_deferred     = 1, \
+      (__ex_ctx()->ctx_deferring > 0 ? 0 : \
+       (__ex_ctx()->ctx_mctx == NULL \
+        ? (__ex_terminate((ex_t *)&(__ex_ctx()->ctx_ex)), -1) \
+        : (__ex_mctx_restore(__ex_ctx()->ctx_mctx), 1) ))))
 
 /* the re-throwing of an already caught exception */
 #define ex_rethrow \
-    (__ex_ctx()->ctx_shielding > 0 ? 0 : \
+    ((   __ex_ctx()->ctx_shielding > 0 \
+      || __ex_ctx()->ctx_deferring > 0) ? 0 : \
       (  __ex_ctx()->ctx_mctx == NULL \
        ? (__ex_terminate((ex_t *)&(__ex_ctx()->ctx_ex)), -1) \
        : (__ex_mctx_restore(__ex_ctx()->ctx_mctx), 1) ))
@@ -204,11 +214,21 @@
          __ex_ctx()->ctx_shield =  0, \
          __ex_ctx()->ctx_shielding--)
 
+/* defer immediate exception handling */
+#define ex_defer \
+    for (((__ex_ctx()->ctx_deferring)++ == 0 ? __ex_ctx()->ctx_deferred = 0 : 0), \
+         __ex_ctx()->ctx_defer =  1;  \
+         __ex_ctx()->ctx_defer == 1;  \
+         __ex_ctx()->ctx_defer =  0,  \
+         ((--(__ex_ctx()->ctx_deferring) == 0 && __ex_ctx()->ctx_deferred == 1) ? ex_rethrow : 0))
+
 /* exception handling tests */
 #define ex_catching \
     (__ex_ctx()->ctx_mctx != NULL)
 #define ex_shielding \
     (__ex_ctx()->ctx_shielding > 0)
+#define ex_deferring \
+    (__ex_ctx()->ctx_deferring > 0)
 
 /* optional namespace mapping */
 #if defined(__EX_NS_UCCXX__)
@@ -218,6 +238,7 @@
 #define Throw    ex_throw
 #define Rethrow  ex_rethrow
 #define Shield   ex_shield
+#define Defer    ex_defer
 #elif defined(__EX_NS_CXX__) || (!defined(__cplusplus) && !defined(__EX_NS_CUSTOM__))
 #define try      ex_try
 #define cleanup  ex_cleanup
@@ -225,6 +246,7 @@
 #define throw    ex_throw
 #define rethrow  ex_rethrow
 #define shield   ex_shield
+#define defer    ex_defer
 #endif
 
 #endif /* __EX_H__ */

CVSTrac 2.0.1