home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / INCLUDE.ZIP / GENERIC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  1.6 KB  |  56 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. #ifdef __DLL__
  17. #define _FAR far
  18. #else
  19. #define _FAR
  20. #endif
  21.  
  22. #if __STDC__
  23. #define _Cdecl
  24. #else
  25. #define _Cdecl  cdecl
  26. #endif
  27.  
  28. // token-pasting macros; ANSI requires an extra level of indirection
  29. #define _Paste2(z, y)       _Paste2_x(z, y)
  30. #define _Paste2_x(z, y)     z##y
  31. #define _Paste3(z, y, x)    _Paste3_x(z, y, x)
  32. #define _Paste3_x(z, y, x)  z##y##x
  33. #define _Paste4(z, y, x, w) _Paste4_x(z, y, x, w)
  34. #define _Paste4_x(z, y, x, w)   z##y##x##w
  35.  
  36. // macros for declaring and implementing classes
  37. #define declare(z, y) _Paste2(z, declare)(y)
  38. #define implement(z, y) _Paste2(z, implement)(y)
  39. #define declare2(z, y, x) _Paste2(z, declare2)(y, x)
  40. #define implement2(z, y, x) _Paste2(z, implement2)(y, x)
  41.  
  42. // macros for declaring error-handling functions
  43. extern _Cdecl genericerror(int, char _FAR *);    // not implemented ***
  44. typedef int _Cdecl (*GPT)(int, char _FAR *);
  45. #define set_handler(gen, tp, z) _Paste4(set_, tp, gen, _handler)(z)
  46. #define errorhandler(gen, tp) _Paste3(tp, gen, handler)
  47. #define callerror(gen, tp, z, y) (*errorhandler(gen, tp))(z, y)
  48.  
  49. /*
  50.  * function genericerror is not documented in the AT&T release, and
  51.  * is not supplied.  If you can document any expected behavior, we
  52.  * will try to adjust our implementation accordingly.
  53.  */
  54.  
  55. #endif
  56.