home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / GENERIC.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  2KB  |  71 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 6.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. #if !defined(RC_INVOKED)
  26.  
  27. #if defined(__STDC__)
  28. #pragma warn -nak
  29. #endif
  30.  
  31. #endif
  32.  
  33. // token-pasting macros; ANSI requires an extra level of indirection
  34. #define _Paste2(z, y)       _Paste2_x(z, y)
  35. #define _Paste2_x(z, y)     z##y
  36. #define _Paste3(z, y, x)    _Paste3_x(z, y, x)
  37. #define _Paste3_x(z, y, x)  z##y##x
  38. #define _Paste4(z, y, x, w) _Paste4_x(z, y, x, w)
  39. #define _Paste4_x(z, y, x, w)   z##y##x##w
  40.  
  41. // macros for declaring and implementing classes
  42. #define name2 _Paste2
  43. #define declare(z, y) _Paste2(z, declare)(y)
  44. #define implement(z, y) _Paste2(z, implement)(y)
  45. #define declare2(z, y, x) _Paste2(z, declare2)(y, x)
  46. #define implement2(z, y, x) _Paste2(z, implement2)(y, x)
  47.  
  48. // macros for declaring error-handling functions
  49. extern _RTLENTRY genericerror(int, char _FAR *);    // not implemented ***
  50. typedef int _RTLENTRY (_FAR *GPT)(int, char _FAR *);
  51. #define set_handler(gen, tp, z) _Paste4(set_, tp, gen, _handler)(z)
  52. #define errorhandler(gen, tp) _Paste3(tp, gen, handler)
  53. #define callerror(gen, tp, z, y) (*errorhandler(gen, tp))(z, y)
  54.  
  55. /*
  56.  * function genericerror is not documented in the AT&T release, and
  57.  * is not supplied.  If you can document any expected behavior, we
  58.  * will try to adjust our implementation accordingly.
  59.  */
  60.  
  61. #if !defined(RC_INVOKED)
  62.  
  63. #if defined(__STDC__)
  64. #pragma warn .nak
  65. #endif
  66.  
  67. #endif
  68.  
  69. #endif  /* __GENERIC_H */
  70.  
  71.