home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tlx501.zip / GENMACRO.H < prev    next >
C/C++ Source or Header  |  1996-01-05  |  2KB  |  57 lines

  1. /****************************************************************************
  2.     $Id: genmacro.h 501.0 1995/03/07 12:26:42 RON Exp $
  3.  
  4.     Copyright (c) 1991-95 Tarma Software Research. All rights reserved.
  5.  
  6.     Project:    Tarma Library for C++ V5.0
  7.     Author:    Ron van der Wal
  8.  
  9.     Preprocessor macros to imitate or enhance C++ templates. They are used
  10.     in situations where the C++ template mechanism cannot be used, e.g.
  11.     function templates with template arguments not appearing in the function
  12.     header.
  13.  
  14.     $Log: genmacro.h $
  15.     Revision 501.0  1995/03/07 12:26:42  RON
  16.     Updated for TLX 5.01
  17.     Revision 1.2  1995/01/31 16:29:20  RON
  18.     Update for release 012
  19.     Added partial support for SunPro C++ compiler
  20.     Revision 1.1  1994/08/16  18:06:47  ron
  21.     Initial revision
  22.  
  23. ****************************************************************************/
  24.  
  25. #ifndef _TLX_GENMACRO_H
  26. #define _TLX_GENMACRO_H
  27.  
  28. /*---------------------------------------------------------------------------
  29.     Token pasting macros use an extra level to allow macros to appear as
  30.     arguments in other macros if an ANSI-C compatible preprocessor is
  31.     used. Usage:
  32.  
  33.     NAME2()        - concatenates 2 names (with argument expansion)
  34.     NAME3()        - concatenates 3 names (with argument expansion)
  35.     NAME4()        - concatenates 4 names (with argument expansion)
  36.  
  37.     DECLARE(X,Y)    - produces 'Xdeclare(Y)' (with argument expansion)
  38.     DECLARE2(X,Y,Z)    - produces 'Xdeclare(Y,Z)' (with argument expansion)
  39.     IMPLEMENT(X,Y)    - produces 'Ximplement(Y)' (with argument expansion)
  40.     IMPLEMENT2(X,Y,Z)    - produces 'Ximplement(Y,Z)' (with argument expansion)
  41. ---------------------------------------------------------------------------*/
  42.  
  43. #define NAME2(a,b)        _P2(a,b)
  44. #define NAME3(a,b,c)        _P3(a,b,c)
  45. #define NAME4(a,b,c,d)        _P4(a,b,c,d)
  46.  
  47. #define _P2(a,b)        a ## b
  48. #define _P3(a,b,c)        a ## b ## c
  49. #define _P4(a,b,c,d)        a ## b ## c ## d
  50.  
  51. #define DECLARE(x,y)        NAME2(x,declare)(y)
  52. #define DECLARE2(x,y,z)        NAME2(x,declare)(y,z)
  53. #define IMPLEMENT(x,y)        NAME2(x,implement)(y)
  54. #define IMPLEMENT2(x,y,z)    NAME2(x,implement)(y,z)
  55.  
  56. #endif    // _TLX_GENMACRO_H
  57.