TException.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TException.h 22535 2008-03-08 11:30:22Z rdm $
00002 // Author: Fons Rademakers   21/09/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TException
00013 #define ROOT_TException
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // Exception Handling                                                   //
00019 //                                                                      //
00020 // Provide some macro's to simulate the coming C++ try, catch and throw //
00021 // exception handling functionality.                                    //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef __CINT__
00026 #include <setjmp.h>
00027 #else
00028 struct sigjmp_buf;
00029 struct jmp_buf;
00030 #endif
00031 
00032 #ifndef ROOT_RConfig
00033 #include "RConfig.h"
00034 #endif
00035 #ifndef ROOT_DllImport
00036 #include "DllImport.h"
00037 #endif
00038 
00039 struct ExceptionContext_t {
00040 #ifdef NEED_SIGJMP
00041    sigjmp_buf fBuf;
00042 #else
00043    jmp_buf fBuf;
00044 #endif
00045 };
00046 
00047 #ifdef NEED_SIGJMP
00048 #define SETJMP(buf) sigsetjmp(buf,1)
00049 #else
00050 #define SETJMP(buf) setjmp(buf)
00051 #endif
00052 
00053 #define RETRY \
00054    { \
00055       static ExceptionContext_t R__curr, *R__old = gException; \
00056       int R__code; \
00057       gException = &R__curr; \
00058       R__code = SETJMP(gException->fBuf); if (R__code) { }; {
00059 
00060 #define TRY \
00061    { \
00062       static ExceptionContext_t R__curr, *R__old = gException; \
00063       int R__code; \
00064       gException = &R__curr; \
00065       if ((R__code = SETJMP(gException->fBuf)) == 0) {
00066 
00067 #define CATCH(n) \
00068          gException = R__old; \
00069       } else { \
00070          int n = R__code; \
00071          gException = R__old;
00072 
00073 #define ENDTRY \
00074       } \
00075       gException = R__old; \
00076    }
00077 
00078 R__EXTERN ExceptionContext_t *gException;
00079 
00080 extern void Throw(int code);
00081 
00082 #endif

Generated on Tue Jul 5 14:10:26 2011 for ROOT_528-00b_version by  doxygen 1.5.1