Index: ossp-pkg/ex/ex.h RCS File: /v/ossp/cvs/ossp-pkg/ex/ex.h,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/ex/ex.h,v' 2>/dev/null --- ex.h 2002/01/26 22:35:02 1.6 +++ ex.h 2002/01/26 22:42:46 1.7 @@ -190,8 +190,12 @@ for (__ex_ctx->ctx_disabled = 1; \ __ex_ctx->ctx_disabled == 1; \ __ex_ctx->ctx_disabled = 0) -#define ex_shielded \ - (__ex_ctx->ctx_disabled) + +/* exception handling tests */ +#define ex_catching \ + (__ex_ctx->ctx_mctx != NULL) +#define ex_shielding \ + (__ex_ctx->ctx_disabled) /* optional namespace mapping */ #if defined(__EX_NS_USE_UCCXX__) @@ -200,14 +204,12 @@ #define Throw ex_throw #define Rethrow ex_rethrow #define Shield ex_shield -#define Shielded ex_shielded #elif defined(__EX_NS_USE_CXX__) || (!defined(__cplusplus) && !defined(__EX_NS_USE_CUSTOM__)) #define try ex_try #define catch ex_catch #define throw ex_throw #define rethrow ex_rethrow #define shield ex_shield -#define shielded ex_shielded #endif #endif /* __EX_H__ */ Index: ossp-pkg/ex/ex.pod RCS File: /v/ossp/cvs/ossp-pkg/ex/ex.pod,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/ex/ex.pod,v' 2>/dev/null --- ex.pod 2002/01/26 22:35:02 1.5 +++ ex.pod 2002/01/26 22:42:46 1.6 @@ -44,7 +44,9 @@ B { ... }; -if (B) ... +if (B) ... + +if (B) ... =head1 DESCRIPTION @@ -186,10 +188,16 @@ of exceptions, i.e., in the dynamic scope of B any B operation is ignored. -=item B +=item B + +This is a flag which can be tested inside a block to test whether the +current scope is exception catching (by B somewhere in the +dynamic scope) or not. + +=item B This is a flag which can be tested inside a block to test whether the -current scope is exception shielded (by B somewhere in the +current scope is exception shielding (by B somewhere in the dynamic scope) or not. =back @@ -293,18 +301,17 @@ B implementation consistently uses the B, B<__ex_> and B<__EX_> prefixes for namespace protection. But at least the B prefix for the API macros B, B, B, -B, B and B sometimes have a -unpleasant optical appearance. Especially because B is modeled -after the exception facility in ISO C++ where there is no such prefix on -the directives. +B and B sometimes have a unpleasant optical +appearance. Especially because B is modeled after the exception +facility in ISO C++ where there is no such prefix on the directives. For this B optionally provides the ability to provide additional namespace mappings for those API macros. By default (define C<__EX_NS_USE_CXX__> o or as long as C<__EX_CTX_USE_CUSTOM__> and -C<__cplusplus> is not defined) you can additional C++ style macros -named B, B, B, B and B. As an -alternative you can define C<__EX_NS_USE_UCCXX__> to get the same but -with an (more namespace safe) upper case first letter. +C<__cplusplus> is not defined) you can additional C++ style macros named +B, B, B and B. As an alternative you +can define C<__EX_NS_USE_UCCXX__> to get the same but with an (more +namespace safe) upper case first letter. =head1 MULTITHREADING ENVIRONMENTS @@ -539,7 +546,7 @@ #ifdef WITH_EX #define FOO_ERR(ctx,err) \ - (( ex_shielded \ + (( ex_shielding \ || !foo_ex_use \ || ((ctx) != NULL && !(ctx)->ex_use)) ? FOO_ERR_##err \ Index: ossp-pkg/ex/ex_test.c RCS File: /v/ossp/cvs/ossp-pkg/ex/ex_test.c,v rcsdiff -q -kk '-r1.4' '-r1.5' -u '/v/ossp/cvs/ossp-pkg/ex/ex_test.c,v' 2>/dev/null --- ex_test.c 2002/01/26 22:35:02 1.4 +++ ex_test.c 2002/01/26 22:42:46 1.5 @@ -116,16 +116,16 @@ ex_t ex; ts_test_check(TS_CTX, "exception shielding"); - if (ex_shielded) - ts_test_fail(TS_CTX, "unexpected shielded scope"); + if (ex_shielding) + ts_test_fail(TS_CTX, "unexpected shielding scope"); ex_try { ex_shield { - if (!ex_shielded) - ts_test_fail(TS_CTX, "unexpected non-shielded scope"); + if (!ex_shielding) + ts_test_fail(TS_CTX, "unexpected non-shielding scope"); ex_throw(0, 0, 0); } - if (ex_shielded) - ts_test_fail(TS_CTX, "unexpected shielded scope"); + if (ex_shielding) + ts_test_fail(TS_CTX, "unexpected shielding scope"); } ex_catch (ex) { ts_test_fail(TS_CTX, "unexpected exception catched");