PGSETJMP.H

Go to the documentation of this file.
00001 
00002 /*  $Id: PGSETJMP.H 415 2005-01-24 02:52:19Z terry_teague $    */
00003 
00004 /* Paige Exceptions Handler header.  Original source created by Tom Shaw, OITC.
00005 Modified by Gar for DataPak Software, Inc. to be more consistent with Paige
00006 syntax and parameter naming conventions.   Copyright 1993-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     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 
00032 /* Dec 22, 1994 Changed to fix some compiler optimization problems - TR Shaw, OITC */
00033  
00034 #ifndef PGSETJMP_H
00035 #define PGSETJMP_H
00036 
00037 #include "CPUDEFS.H"
00038 #include "PGERRORS.H"
00039 
00040 /* PG_VOLATILE - Any variable or parameter that is modified in a PG_TRY block and 
00041     used in the PG_CATCH block should be declared as volatile or it may have an incorrect 
00042     value in the PG_CATCH block. Since not all compilers support the 'volatile' keyword, 
00043     you can define PG_VOLATILE and have an alternate definition used which will confound
00044     the compiler's optimizer like volatile (eg PGVolatile).
00045 */
00046 
00047 //define PG_VOLATILE
00048 #define PGVolatile(x)   ((void) &x)
00049 
00050 #define BOOLEAN_EXCEPTION   0x1000
00051 
00052 /* Forward declaration of mem mgr globals required:  */
00053 
00054 typedef struct pgm_globals pgm_globals;
00055 typedef pgm_globals PG_FAR *pgm_globals_ptr;
00056 
00057 typedef struct pg_fail_info pg_fail_info;
00058 typedef pg_fail_info PG_FAR *pg_fail_info_ptr;
00059 
00060 /* Exception handler function */
00061 
00062 typedef PG_FN_PASCAL (void, pg_error_handler) (pgm_globals_ptr globals);
00063 
00064 #ifdef __cplusplus
00065 extern "C" {
00066 #endif
00067 
00068 extern PG_PASCAL (void) pgPushHandler (pgm_globals_ptr globals, pg_fail_info_ptr fail_info);
00069 extern PG_PASCAL (void) pgFailure (pgm_globals_ptr globals, pg_error error, long message);
00070 extern PG_PASCAL (void) pgSuccess (pgm_globals_ptr globals);
00071 extern PG_PASCAL (void) pgSetFailInfo( pgm_globals_ptr globals, pg_error new_error, long new_msg, void PG_FAR *new_ref);
00072 extern PG_PASCAL (pg_error) pgProcessError (pg_error error);
00073 extern PG_PASCAL (void) pgDebugProc (pg_error message, unsigned long what_ref);
00074 extern PG_PASCAL (void) pgFailNotError (pgm_globals_ptr globals, pg_error acceptable_error,
00075         pg_error actual_error);
00076 
00077 
00078 #ifdef NO_C_INLINE
00079 extern PG_PASCAL (pg_error) pgGetError( pgm_globals_ptr globals );
00080 extern PG_PASCAL (long) pgGetMessage( pgm_globals_ptr globals );
00081 extern PG_PASCAL (void PG_FAR *) pgGetReference( pgm_globals_ptr globals );
00082 extern PG_PASCAL (void) pgSetReference( pgm_globals_ptr globals, void PG_FAR * last_ref);
00083 extern PG_PASCAL (void) pgReRaise (pgm_globals_ptr globals);
00084 extern PG_PASCAL (void) pgFailNIL (pgm_globals_ptr globals, void PG_FAR *allocation);
00085 extern PG_PASCAL (void) pgFailZero (pgm_globals_ptr globals, generic_var value);
00086 extern PG_PASCAL (void) pgFailBoolean( pgm_globals_ptr pgm_globals_p, pg_boolean b);
00087 extern PG_PASCAL (void) pgFailError (pgm_globals_ptr globals, pg_error error);
00088 extern PG_PASCAL (void) pgSetFailureHandler( pgm_globals_ptr globals, pg_error_handler handler);
00089 #else
00090 #define pgGetError(globals) (globals->last_error)
00091 #define pgGetMessage(globals) (globals->last_message)
00092 #define pgGetReference(globals) (globals->last_ref)
00093 #define pgSetReference(globals,ref) (globals->last_ref = ref)
00094 #define pgReRaise(globals)                      \
00095         pgFailure(globals, pgGetError( globals ), pgGetMessage( globals ))
00096 #define pgFailNIL(globals,allocation)           \
00097         if (!(allocation)) pgFailure(globals, NO_MEMORY_ERR, 0)     
00098 #define pgFailZero(globals,allocation)          \
00099         if (!(allocation)) pgFailure(globals, NO_MEMORY_ERR, 0)     
00100 #define pgFailBoolean(globals,b)                \
00101         if ((b)) pgFailure( globals, BOOLEAN_EXCEPTION, 0)
00102 #define pgFailError(globals,error)          \
00103         if (error != NO_ERROR) pgFailure( globals, error, 0)
00104 #define pgSetFailureHandler(globals,handler)    \
00105         globals->last_handler = handler
00106 #endif
00107 
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111 
00112 #endif

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