home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ctdemo.zip / classes / @CLSLIB1.ZIP / cls / runtime / xh.cpp < prev   
C/C++ Source or Header  |  1995-03-28  |  6KB  |  309 lines

  1. #ifndef INC_XH
  2. #define INC_XH
  3.  
  4. #ifndef __FIRST__
  5. #define __FIRST__
  6. #define __IMPL__XH
  7. #endif
  8.  
  9. /////V XH PCM f:\cls_ibm\cls\runtime 1  PM 28.03.95 14:22:29
  10. /*
  11. /////H
  12. 20.10.94 19:37 PM 1 copied from: XH TOS f:\cls_ibm\cls\runtime 1  PM 19.10.94 01:06:53
  13. 30.03.95 10:34 PM 1 archived: XH PCM f:\cls_ibm\cls\runtime 1  PM 28.03.95 14:22:29
  14. /////
  15. */
  16.  
  17. /////1
  18. #undef inline
  19.  
  20. #include <bsa.h>
  21.  
  22. /////I setjmp.h @ @ @ @ pre 
  23. #include <setjmp.h>
  24.  
  25. /////I stddef.h @ @ @ @ pre 
  26. #include <stddef.h>
  27.  
  28. /////I os2.h @ @ INCL_DOS @ @ pre 
  29. #define INCL_DOS
  30. #include <os2.h>
  31. #undef INCL_DOS
  32.  
  33. /////T Pre pre 
  34. #define MAX_THREADS        10
  35. #define MAX_JUMPS        10
  36.  
  37. #define DA_ABORT    100
  38. #define DA_RETRY    101
  39. #define DA_IGNORE    102
  40.  
  41. #define SET_SAVEPOINT(a)  SavePoint a; a.setRetVal( setjmp(a.JmpBuffer))
  42.  
  43. // ********* remove that stuff after deleting refs ***************
  44. #define ABORT    DA_ABORT
  45. #define RETRY    DA_RETRY
  46. #define IGNORE  DA_IGNORE
  47. #define RAISE(a,b,c)    XH::raise( a,c)
  48. #define DOS(a)             XH::dosApi((int)a)
  49. #define PM(a)             XH::pmApi((int)a)
  50. //*****************************************************************
  51.  
  52.  
  53. #define XRAISE(a)        XH::XRepRec.ExceptionNum=XCPT_SIGNAL; XH::XRepRec.cParameters=1; XH::XRepRec.ExceptionInfo[0]=a; DosRaiseException(&XH::XRepRec)        
  54. #define REGISTER_XCPT    EXCEPTIONREGISTRATIONRECORD xRec={0,&exceptionHandler};DosSetExceptionHandler (&xRec)
  55. #define UNREGISTER_XCPT    DosUnsetExceptionHandler (&xRec)
  56.  
  57. #define REG_XHANDLER(a,b,c,d,e)     union {ulong(*p1)(void*,void*) ; ulong(a::*p2)(void*); } caster_##b; caster_##b.p2 = &a::b; XH::addXProcessor( (void*)c, (void*)d, e, caster_##b.p1) 
  58. #define CHANGE_XHANDLER(a,b,c,d)     union {ulong(*p1)(void*,void*) ; ulong(a::*p2)(void*); } caster_##b; caster_##b.p2 = &a::b; XH::changeXProcessor( caster_##b.p1, (void*) c, d) 
  59. typedef ulong (*XFunc) (void*, void*);
  60.  
  61. class SavePoint;
  62. /////
  63.  
  64.  
  65. #ifndef __INLINE__
  66. #define inline
  67. #endif
  68.  
  69. /////C XH @ @ define:_PM_ 
  70. class XH
  71.  
  72. {
  73.  
  74. public:
  75. /////D SPTable @  @ class public 
  76.     static SavePoint*  SPTable [MAX_THREADS][MAX_JUMPS];
  77.  
  78. /////D SPTop @  @ class public 
  79.     static int  SPTop [MAX_THREADS];
  80.  
  81. /////D XRepRec @  @ class public 
  82.     static EXCEPTIONREPORTRECORD  XRepRec;
  83.  
  84.  
  85. public:
  86.     static int  addXProcessor (void*,void*,ulong,XFunc);
  87.     static int  changeXGPage (void*,void*,ulong);
  88.     static int  changeXProcessor (XFunc,void*,ulong);
  89.     static void   dosApi (int);
  90.     static void   pmApi (int);
  91.     static void   raise (int);
  92.     static void   raise (char*,int);
  93.     static int  removeXProcessor (XFunc);
  94. public:
  95.     XH& operator   << (char*);
  96.     XH& operator   << (ulong);
  97.     XH& operator   << (char);
  98.     XH& operator   << (const char*);
  99.     XH& operator   << (int);
  100.     int  printf (const char*,...);
  101. };
  102.  
  103.     ulong _System  exceptionHandler (PEXCEPTIONREPORTRECORD,PEXCEPTIONREGISTRATIONRECORD,PCONTEXTRECORD,PVOID);
  104.  
  105. /////2
  106. #undef inline
  107.  
  108. /////T Post post 
  109. class SavePoint
  110. {
  111. public:
  112.     jmp_buf    JmpBuffer;
  113.     int        SetRet;
  114.  
  115.     SavePoint:: SavePoint () {
  116.         XH::SPTop[ *_threadid] ++;
  117.         XH::SPTable[ *_threadid][XH::SPTop [ *_threadid] ] = this;
  118.     }
  119.  
  120.     SavePoint:: ~SavePoint () {
  121.         XH::SPTop[ *_threadid] --;
  122.     }
  123.  
  124.     void SavePoint:: setRetVal( int ret) {
  125.         SetRet = ret;
  126.     }
  127. };
  128. /////
  129.  
  130. //< EXTERNAL DATA >
  131. extern XH  XStream;
  132.  
  133. #if (defined __INLINE__) || (defined __IMPL__XH)
  134.  
  135. #ifndef __INLINE__
  136. #define inline
  137. #endif
  138.  
  139. /////
  140. #endif
  141.  
  142. /////3
  143. #undef inline
  144.  
  145. #ifdef __IMPL__XH
  146. //< GLOBAL DATA >
  147. /////D XStream @  @ global 
  148. XH  XStream;
  149.  
  150. /////
  151. SavePoint*  XH::SPTable [MAX_THREADS][MAX_JUMPS];
  152. EXCEPTIONREPORTRECORD  XH::XRepRec;
  153. int  XH::SPTop [MAX_THREADS];
  154.  
  155. /////
  156. #ifdef NEVER
  157. /////F << @ @ hideDef public instance 
  158. XH& XH:: operator << ( int num )
  159. {
  160.     // implementation not visible
  161. }
  162. /////
  163. #endif
  164.  
  165. /////
  166. #ifdef NEVER
  167. /////F << @ @ hideDef public instance 
  168. XH& XH:: operator << ( const char* s )
  169. {
  170.     // implementation not visible
  171. }
  172. /////
  173. #endif
  174.  
  175. /////
  176. #ifdef NEVER
  177. /////F << @ @ hideDef public instance 
  178. XH& XH:: operator << ( char c )
  179. {
  180.     // implementation not visible
  181. }
  182. /////
  183. #endif
  184.  
  185. /////
  186. #ifdef NEVER
  187. /////F << @ @ hideDef public instance 
  188. XH& XH:: operator << ( ulong num )
  189. {
  190.     // implementation not visible
  191. }
  192. /////
  193. #endif
  194.  
  195. /////
  196. #ifdef NEVER
  197. /////F << @ @ hideDef public instance 
  198. XH& XH:: operator << ( char* s )
  199. {
  200.     // implementation not visible
  201. }
  202. /////
  203. #endif
  204.  
  205. /////
  206. #ifdef NEVER
  207. /////F addXProcessor @ @ hideDef public class 
  208. int XH:: addXProcessor ( void* procObj, void* memBeg, ulong memSize, XFunc procFunc )
  209. {
  210.     // implementation not visible
  211. }
  212. /////
  213. #endif
  214.  
  215. /////
  216. #ifdef NEVER
  217. /////F changeXGPage @ @ hideDef public class 
  218. int XH:: changeXGPage ( void* oldAdr, void* newAdr, ulong newSize )
  219. {
  220.     // implementation not visible
  221. }
  222. /////
  223. #endif
  224.  
  225. /////
  226. #ifdef NEVER
  227. /////F changeXProcessor @ @ hideDef public class 
  228. int XH:: changeXProcessor ( XFunc procFunc, void* memBeg, ulong memSize )
  229. {
  230.     // implementation not visible
  231. }
  232. /////
  233. #endif
  234.  
  235. /////
  236. #ifdef NEVER
  237. /////F dosApi @ @ hideDef public class 
  238. void XH:: dosApi ( int ret )
  239. {
  240.     // implementation not visible
  241. }
  242. /////
  243. #endif
  244.  
  245. /////
  246. #ifdef NEVER
  247. /////F exceptionHandler @ @ global hideDef 
  248. ulong _System exceptionHandler ( PEXCEPTIONREPORTRECORD pXrepR, PEXCEPTIONREGISTRATIONRECORD pXregR, PCONTEXTRECORD pconR, PVOID p )
  249. {
  250.     // implementation not visible
  251. }
  252. /////
  253. #endif
  254.  
  255. /////
  256. #ifdef NEVER
  257. /////F pmApi @ @ hideDef public class 
  258. void XH:: pmApi ( int ret )
  259. {
  260.     // implementation not visible
  261. }
  262. /////
  263. #endif
  264.  
  265. /////
  266. #ifdef NEVER
  267. /////F printf @ @ hideDef public instance 
  268. int XH:: printf ( const char* fmt, ...  )
  269. {
  270.     // implementation not visible
  271. }
  272. /////
  273. #endif
  274.  
  275. /////
  276. #ifdef NEVER
  277. /////F raise @ @ hideDef public class 
  278. void XH:: raise ( char* text, int defAct )
  279. {
  280.     // implementation not visible
  281. }
  282. /////
  283. #endif
  284.  
  285. /////
  286. #ifdef NEVER
  287. /////F raise @ @ hideDef public class 
  288. void XH:: raise ( int act )
  289. {
  290.     // implementation not visible
  291. }
  292. /////
  293. #endif
  294.  
  295. /////
  296. #ifdef NEVER
  297. /////F removeXProcessor @ @ hideDef public class 
  298. int XH:: removeXProcessor ( XFunc procFunc )
  299. {
  300.     // implementation not visible
  301. }
  302. /////
  303. #endif
  304.  
  305. /////
  306. #endif
  307.  
  308. #endif
  309.