OSSP CVS Repository

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

ossp-pkg/ex/ex.h 1.9 -> 1.10

--- ex.h 2002/01/27 19:38:49     1.9
+++ ex.h 2002/01/29 11:05:21     1.10
@@ -93,10 +93,10 @@
 
 /* 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_caught;    /* temporary flag whether exception was caught */
-    volatile ex_t ctx_ex;        /* temporary exception storage */
+    __ex_mctx_t  *ctx_mctx;     /* permanent machine context of enclosing try/catch */
+    int           ctx_disabled; /* permanent flag whether exception handling is disabled */
+    int           ctx_caught;   /* temporary flag whether exception was caught */
+    volatile ex_t ctx_ex;       /* temporary exception storage */
 } ex_ctx_t;
 
 /* the static and dynamic initializers for a context structure */
@@ -116,33 +116,17 @@
     } while (0)
 
 /* the exception context */
-#if defined(__EX_CTX_USE_STATIC__)
-static ex_ctx_t __ex_ctx_global;
-#define __ex_ctx (&__ex_ctx_global)
-#elif defined(__EX_CTX_USE_GLOBAL__) || !defined(__EX_CTX_USE_CUSTOM__)
-#define EX_CTX_GLOBAL ex_ctx_t __ex_ctx_global;
-extern ex_ctx_t __ex_ctx_global;
-#define __ex_ctx (&__ex_ctx_global)
-#endif
+typedef ex_ctx_t *(*ex_ctx_cb_t)(void);
+extern ex_ctx_cb_t __ex_ctx;
 
 /* the termination handler */
-#if defined(__EX_TERMINATE_USE_NOOP__)
-#define __ex_terminate(e) \
-    /* noop */
-#elif defined(__EX_TERMINATE_USE_ABORT__) || !defined(__EX_CTX_USE_CUSTOM__)
-#define __ex_terminate(e) \
-    ( fprintf(stderr, \
-              "**EX: UNCAUGHT EXCEPTION: " \
-              "class=0x%lx object=0x%lx value=0x%lx [%s:%d@%s]\n", \
-              (long)((e)->ex_class), (long)((e)->ex_object), (long)((e)->ex_value), \
-              (e)->ex_file, (e)->ex_line, (e)->ex_func), \
-     abort() )
-#endif
+typedef void (*ex_term_cb_t)(ex_t *);
+extern ex_term_cb_t __ex_terminate; 
 
 /* the block for trying execution */
 #define ex_try \
     { \
-        ex_ctx_t *__ex_ctx_ptr = __ex_ctx; \
+        ex_ctx_t *__ex_ctx_ptr = __ex_ctx(); \
         __ex_mctx_t *__ex_mctx_en; \
         __ex_mctx_t __ex_mctx_me; \
         __ex_mctx_en = __ex_ctx_ptr->ctx_mctx; \
@@ -162,41 +146,42 @@
         } \
         __ex_ctx_ptr->ctx_mctx = __ex_mctx_en; \
     } \
-    if (   !(__ex_ctx->ctx_caught) \
-        || ((e) = __ex_ctx->ctx_ex, 0)) { \
+    if (   !(__ex_ctx()->ctx_caught) \
+        || ((e) = __ex_ctx()->ctx_ex, 0)) { \
     } \
     else
 
 /* the throwing of a new exception */
 #define ex_throw(c,o,v) \
-    (__ex_ctx->ctx_disabled ? 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_ctx->ctx_ex)), -1) \
-       : (__ex_mctx_restore(__ex_ctx->ctx_mctx), 1) )))
+    (__ex_ctx()->ctx_disabled ? 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) )))
 
 /* the re-throwing of an already caught exception */
 #define ex_rethrow \
-    (__ex_ctx->ctx_disabled ? 0 : \
-      (__ex_ctx->ctx_mctx == NULL ? (__ex_terminate(&(__ex_ctx->ctx_ex)), -1) : \
-        (__ex_mctx_restore(__ex_ctx->ctx_mctx), 1) ))
+    (__ex_ctx()->ctx_disabled ? 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_disabled = 1; \
+         __ex_ctx()->ctx_disabled == 1; \
+         __ex_ctx()->ctx_disabled = 0)
 
 /* exception handling tests */
 #define ex_catching \
-    (__ex_ctx->ctx_mctx != NULL)
+    (__ex_ctx()->ctx_mctx != NULL)
 #define ex_shielding \
-    (__ex_ctx->ctx_disabled)
+    (__ex_ctx()->ctx_disabled)
 
 /* optional namespace mapping */
 #if defined(__EX_NS_USE_UCCXX__)

CVSTrac 2.0.1