home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / borhead.zip / GENERIC.H < prev    next >
C/C++ Source or Header  |  1994-11-09  |  2KB  |  55 lines

  1. /*  generic.h -- for faking generic class declarations
  2.  
  3.     When type templates are implemented in C++, this will probably go away.
  4. */
  5.  
  6. /*
  7.  *      C/C++ Run Time Library - Version 1.5
  8.  *
  9.  *      Copyright (c) 1990, 1994 by Borland International
  10.  *      All Rights Reserved.
  11.  *
  12.  */
  13.  
  14. #ifndef __cplusplus
  15. #error Must use C++ for classes
  16. #endif
  17.  
  18. #ifndef __GENERIC_H
  19. #define __GENERIC_H
  20.  
  21. #if !defined(___DEFS_H)
  22. #include <_defs.h>
  23. #endif
  24.  
  25. // token-pasting macros; ANSI requires an extra level of indirection
  26. #define _Paste2(z, y)       _Paste2_x(z, y)
  27. #define _Paste2_x(z, y)     z##y
  28. #define _Paste3(z, y, x)    _Paste3_x(z, y, x)
  29. #define _Paste3_x(z, y, x)  z##y##x
  30. #define _Paste4(z, y, x, w) _Paste4_x(z, y, x, w)
  31. #define _Paste4_x(z, y, x, w)   z##y##x##w
  32.  
  33. // macros for declaring and implementing classes
  34. #define name2 _Paste2
  35. #define declare(z, y) _Paste2(z, declare)(y)
  36. #define implement(z, y) _Paste2(z, implement)(y)
  37. #define declare2(z, y, x) _Paste2(z, declare2)(y, x)
  38. #define implement2(z, y, x) _Paste2(z, implement2)(y, x)
  39.  
  40. // macros for declaring error-handling functions
  41. extern _Cdecl genericerror(int, char _FAR *);    // not implemented ***
  42. typedef int _Cdecl (_FAR *GPT)(int, char _FAR *);
  43. #define set_handler(gen, tp, z) _Paste4(set_, tp, gen, _handler)(z)
  44. #define errorhandler(gen, tp) _Paste3(tp, gen, handler)
  45. #define callerror(gen, tp, z, y) (*errorhandler(gen, tp))(z, y)
  46.  
  47. /*
  48.  * function genericerror is not documented in the AT&T release, and
  49.  * is not supplied.  If you can document any expected behavior, we
  50.  * will try to adjust our implementation accordingly.
  51.  */
  52.  
  53. #endif  /* __GENERIC_H */
  54.  
  55.