home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 7.ddi / MWHC.007 / I < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.7 KB  |  61 lines

  1. /*
  2.  *   generic.h
  3.  *
  4.  *   Macros to approximate generic class declarations.
  5.  *
  6.  *           Copyright (c) 1991, MetaWare Incorporated
  7.  */
  8.  
  9. /*   $Id: generic.h,v 1.3 1991/07/02 15:52:49 jeff Internal $  */
  10.  
  11. #ifndef __GENERIC_H
  12. #define __GENERIC_H 1
  13. #pragma push_align_members(64);
  14.  
  15. /*
  16.  *   Token-pasting macros.
  17.  *
  18.  *   Two levels of indirection are required to expand arguments that
  19.  *   are themselves macros.
  20.  */
  21.  
  22. #define name2(tok1,tok2)      _PASTE2(tok1,tok2)
  23. #define _PASTE2(tok1,tok2)      tok1##tok2
  24. #define name3(tok1,tok2,tok3)    _PASTE3(tok1,tok2,tok3)
  25. #define _PASTE3(tok1,tok2,tok3)    tok1##tok2##tok3
  26. #define name4(tok1,tok2,tok3,tok4)  _PASTE4(tok1,tok2,tok3,tok4)
  27. #define _PASTE4(tok1,tok2,tok3,tok4)  tok1##tok2##tok3##tok4
  28.  
  29.  
  30.  
  31. /*
  32.  *   Declaration and implementation macros.
  33.  */
  34.  
  35. #define declare(generic,type) name2(generic,declare)(type)
  36. #define implement(generic,type) name2(generic,implement)(type)
  37. #define declare2(generic,type1,type2) name2(generic,declare2)(type1,type2)
  38. #define implement2(generic,type1,type2) name2(generic,implement2)(type1,type2)
  39.  
  40.  
  41.  
  42. /*
  43.  *   Error-handling functions.
  44.  *
  45.  *   The function genericerror is not implemented because its 
  46.  *   functionality is unclear and documentation is insufficient.
  47.  *   The declaration is provided for AT&T compatibility only.
  48.  */
  49.  
  50. extern genericerror(int,char*);
  51. typedef int (*GPT)(int,char*);
  52. #define set_handler(generic,type,x) name4(set_,type,generic,_handler)(x)
  53. #define errorhandler(generic,type) name3(type,generic,handler)
  54. #define callerror(generic,type,a,b) (*errorhandler(generic,type))(a,b)
  55.  
  56. #pragma pop_align_members();
  57. #endif    // __GENERIC_H
  58.  
  59.  
  60. /**          Copyright (c) 1991, MetaWare Incorporated             **/
  61.