Skip to content

Commit 6abfa93

Browse files
authored
Merge pull request github#18 from guitargeek/cppyylegacy
Make `CppyyLegacy` namespace in CPyCppyy optional
2 parents 344335a + ca7a686 commit 6abfa93

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/SignalTryCatch.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,28 @@
1818
#define NEED_SIGJMP 1
1919
#endif
2020

21+
// By default, the ExceptionContext_t class is expected in the namespace
22+
// CppyyLegacy, If it is expected in no namespace, one can explicitly define
23+
// NO_CPPYY_LEGACY_NAMESPACE at build time (e.g. if one wants to use ROOT).
24+
25+
#ifndef NO_CPPYY_LEGACY_NAMESPACE
2126
namespace CppyyLegacy {
27+
#endif
2228
struct ExceptionContext_t {
2329
#ifdef NEED_SIGJMP
2430
sigjmp_buf fBuf;
2531
#else
2632
jmp_buf fBuf;
2733
#endif
2834
};
35+
#ifndef NO_CPPYY_LEGACY_NAMESPACE
2936
}
3037

38+
using CppyyExceptionContext_t = CppyyLegacy::ExceptionContext_t;
39+
#else
40+
using CppyyExceptionContext_t = ExceptionContext_t;
41+
#endif
42+
3143
#ifdef NEED_SIGJMP
3244
# define CLING_EXCEPTION_SETJMP(buf) sigsetjmp(buf,1)
3345
#else
@@ -36,14 +48,14 @@ struct ExceptionContext_t {
3648

3749
#define CLING_EXCEPTION_RETRY \
3850
{ \
39-
static CppyyLegacy::ExceptionContext_t R__curr, *R__old = gException; \
51+
static CppyyExceptionContext_t R__curr, *R__old = gException; \
4052
int R__code; \
4153
gException = &R__curr; \
4254
R__code = CLING_EXCEPTION_SETJMP(gException->fBuf); if (R__code) { }; {
4355

4456
#define CLING_EXCEPTION_TRY \
4557
{ \
46-
static CppyyLegacy::ExceptionContext_t R__curr, *R__old = gException; \
58+
static CppyyExceptionContext_t R__curr, *R__old = gException; \
4759
int R__code; \
4860
gException = &R__curr; \
4961
if ((R__code = CLING_EXCEPTION_SETJMP(gException->fBuf)) == 0) {
@@ -59,6 +71,6 @@ struct ExceptionContext_t {
5971
gException = R__old; \
6072
}
6173

62-
CPYCPPYY_IMPORT CppyyLegacy::ExceptionContext_t *gException;
74+
CPYCPPYY_IMPORT CppyyExceptionContext_t *gException;
6375

6476
#endif

0 commit comments

Comments
 (0)