home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / tcopuls_.sit / class.h next >
Encoding:
C/C++ Source or Header  |  1989-10-03  |  2.4 KB  |  89 lines  |  [TEXT/EDIT]

  1. /* -*-Emacs Mode: C++ -*- */
  2.  
  3. /*    class.h - Macros for Portable C++/THINK C4.0 Object programs
  4.  
  5.     Copyright (C) 1989, Integrity Software
  6.     Author: Isaac J. Salzman (salzman@rand.org)
  7.  
  8.     This software may be freely used/modified/distributed
  9.     as desired so long as this copyright notice remains
  10.     in tact.
  11. */
  12.  
  13. /*
  14.  *------------------------------------------------------------------
  15.  * $Header: /tmp_mnt/amnt/lh/salzman/src/class/RCS/class.h,v 1.2 89/10/03 00:33:15 salzman Exp Locker: salzman $
  16.  *------------------------------------------------------------------
  17.  * $Log:    class.h,v $
  18.  * Revision 1.2  89/10/03  00:33:15  salzman
  19.  * all C++ destructors are virtual for compatability with TCO
  20.  * (see README)
  21.  * 
  22.  * Revision 1.1  89/09/17  15:01:38  salzman
  23.  * Initial revision
  24.  * 
  25.  */
  26.  
  27. /*
  28.     Some pre-processor macros for writing *portable* C++ and THINK C
  29.     Object programs.
  30. */
  31.  
  32. #ifndef _H_class
  33. #define _H_class
  34.  
  35. #ifdef THINK_C
  36. # include <oops.h>  /* a must for THINK C */
  37.  
  38.   /* things needed for declaring classes */
  39. # define class struct
  40. # define virtual
  41. # define ROOT : indirect
  42. # define PROTECTED
  43. # define PRIVATE
  44. # define PUBLIC
  45. # define PREDEC_CLASS(Class)
  46. # define INHERIT_PUBLIC
  47.  
  48.   /* things needed for initialization */
  49. # define DECL_INIT(Class) Class *Init##Class
  50. # define DEF_INIT(Class) Class *Class::Init##Class
  51. # define MakeObject(Class) ((Class *)new (Class))->Init##Class
  52. # define INIT_SUPER(Class,args) Class::Init##Class args
  53. # define SUPER_INIT_ARGS(args)
  54. # define RETURN_THIS return this
  55.  
  56.   /* things needed for destroying objects */
  57. # define DECL_DEST(Class) void Destroy
  58. # define DEF_DEST(Class)  void Class::Destroy
  59. # define DestroyObject(Object) { Object->Destroy();delete(Object); }
  60. # define DESTROY_SUPER inherited::Destroy()
  61.  
  62. #else /* C++ */
  63.   /* things needed for declaring classes */
  64.   /* class and virtual are keywords */
  65. # define ROOT
  66. # define PROTECTED protected:
  67. # define PRIVATE private:
  68. # define PUBLIC public:
  69. # define PREDEC_CLASS(Class) class Class 
  70. # define INHERIT_PUBLIC public
  71.  
  72.   /* things needed for initialization */
  73. # define DECL_INIT(Class) Class
  74. # define DEF_INIT(Class) Class::Class
  75. # define MakeObject(Class) new Class
  76. # define INIT_SUPER(Class,args)
  77. # define SUPER_INIT_ARGS(args) : args
  78. # define RETURN_THIS
  79.  
  80.   /* things needed for destroying objects */
  81. # define DECL_DEST(Class) virtual ~Class
  82. # define DEF_DEST(Class) Class::~Class
  83. # define DestroyObject(Object) delete Object
  84. # define DESTROY_SUPER
  85.  
  86. #endif
  87.  
  88. #endif /* _H_class */
  89.