PGEXCEPS.H

Go to the documentation of this file.
00001 
00002 /*  $Id: PGEXCEPS.H 422 2005-01-24 03:43:41Z terry_teague $    */
00003 
00004 /* This PAIGE file is separate to maintain compatibility with MS Foundation Class
00005 development for Windows (when users use pure MFC their compiler complains about
00006 <setjmp> code and it is not supported!  Copyright 1994    */
00007 
00008 /* July 19, 1994 Changed to add support calls to aid in interfacing Paige and Paige's
00009     failure mechanisms with C++ and other languages failure mechanisms by Tom Shaw, OITC 
00010     Also, restructured for inlines. */
00011 
00012 /*
00013     TRS/OITC Change summary:
00014         last_ref            A void* to pgm_globals to hold object's reference (actually can be used 
00015                             for anything). This was added as Paige uses last_message to pass various 
00016                             messages to support debug
00017         pgGetReference      Macro or procedure (depending on compilation option) to access the last_ref
00018         PG_GET_REFERENCE    Macro to access the last_ref in a PG_TRY-PG_CATCH-PG_ENDTRY sequence
00019         pgSetReference      Macro or procedure (depending on compilation option) to set the last_ref
00020         PG_SET_REFERENCE    Macro to set the last_ref in a PG_TRY-PG_CATCH-PG_ENDTRY sequence
00021     Added for ease of use:
00022         pgReRaise           Function to pass a failure up the failure chain
00023         PG_RERAISE          Macro to pass a failure up the chain in a PG_TRY-PG_CATCH-PG_ENDTRY sequence
00024     Changed:
00025         pgSetFailInfo       To optionally set last_ref
00026         pg_error_handler    Cut down on parameter passing as all info is in pgm_globals
00027         pgGetError          Made a macro or procedure depending on compilation option for linkages
00028         pgGetMessage        Made a macro or procedure depending on compilation option for linkages
00029 */
00030 
00031 #ifndef PGEXCEPS_H
00032 #define PGEXCEPS_H
00033 
00034 #include "CPUDEFS.H"
00035 #include "PGSETJMP.H"
00036 
00037 #include <setjmp.h>
00038 #ifdef _INC_SETJMP
00039 #ifdef WIN16_COMPILE
00040 #ifdef __cplusplus
00041 #include "win16jmp.h"
00042 #endif
00043 #endif
00044 #endif
00045 
00046 struct pg_fail_info
00047 {
00048     pg_fail_info_ptr    next;           /* Pointer to next handler  */
00049     pg_error_handler    handler;        /* Optional error handler proc */
00050     jmp_buf             regs;           /* This is machine and environment specific but C takes care of it */
00051 };
00052 
00053 
00054 #define PG_TRY(pg_globals_p)                                \
00055         { pg_fail_info __fi;                                \
00056           pgm_globals_ptr __pg_globals_p = pg_globals_p;    \
00057           pgPushHandler( __pg_globals_p, &__fi);            \
00058           if (!setjmp( __fi.regs)) {
00059 
00060 #define PG_CATCH                                            \
00061             pgSuccess(__pg_globals_p); }                    \
00062         else {
00063         
00064 #define PG_ENDTRY                                           \
00065         }   }
00066 
00067 
00068 /* Some useful macros */
00069 
00070 /* These following macros can only be used within a TRY-CATCH-ENDTRY sequence */
00071         
00072 #define PG_GET_ERROR()                                      \
00073         pgGetError( __pg_globals_p)
00074         
00075 #define PG_GET_MESSAGE()                                    \
00076         pgGetMessage( __pg_globals_p)
00077 
00078 #define PG_GET_REFERENCE()                                  \
00079         pgGetReference( __pg_globals_p)
00080 
00081 #define PG_SET_REFERENCE(ref)                               \
00082         pgSetReference( __pg_globals_p, ref)
00083 
00084 #define PG_FAIL_NIL(p)                                      \
00085         pgFailNIL( __pg_globals_p, (void PG_FAR *)(p))
00086         
00087 #define PG_FAIL_BOOLEAN(b)                                  \
00088         pgFailBoolean( __pg_globals_p, (pg_boolean)(b))
00089         
00090 #define PG_FAIL_ERROR(err)                                  \
00091         pgFailError( __pg_globals_p, (pg_error)(err))
00092         
00093 #define PG_FAIL_NOT_ERROR(acceptable_error,actual_error)    \
00094         pgFailNotError( __pg_globals_p, (pg_error)(acceptable_error), (pg_error)(actual_error))
00095         
00096 #define PG_FAILURE(err,message)                             \
00097         pgFailure( __pg_globals_p, (pg_error)(err), (long)(message))
00098         
00099 #define PG_SUCCESS()                                        \
00100         pgSuccess( __pg_globals_p)
00101         
00102 #define PG_SET_FAIL_INFO(err,message,ref)                   \
00103         pgSetFailInfo( __pg_globals_p, (pg_error)(err), (long)(message), (void *)(ref))
00104         
00105 #define PG_GET_MEM_GLOBALS()                                \
00106         (__pg_globals_p)
00107 
00108 #define PG_RERAISE()                                        \
00109         pgReRaise(__pg_globals_p)
00110 
00111 
00112 #endif

Generated on Wed May 31 18:19:59 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6