home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c063 / 1.ddi / INCLUDE.ZIP / GENERIC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  1.5 KB  |  49 lines

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