home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / os-include / intuition / classes.h < prev    next >
C/C++ Source or Header  |  1993-10-15  |  2KB  |  84 lines

  1. #ifndef    INTUITION_CLASSES_H
  2. #define INTUITION_CLASSES_H    1
  3. /*
  4. **  $VER: classes.h 38.1 (11.11.91)
  5. **  Includes Release 40.15
  6. **
  7. **  Used only by class implementors
  8. **
  9. **  (C) Copyright 1989-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13. #ifndef UTILITY_HOOKS_H
  14. #include <utility/hooks.h>
  15. #endif
  16.  
  17. #ifndef    INTUITION_CLASSUSR_H
  18. #include <intuition/classusr.h>
  19. #endif
  20.  
  21. /*******************************************/
  22. /*** "White box" access to struct IClass ***/
  23. /*******************************************/
  24.  
  25. /* This structure is READ-ONLY, and allocated only by Intuition */
  26. typedef struct IClass {
  27.     struct Hook        cl_Dispatcher;
  28.     ULONG        cl_Reserved;    /* must be 0  */
  29.     struct IClass    *cl_Super;
  30.     ClassID        cl_ID;
  31.  
  32.     /* where within an object is the instance data for this class? */
  33.     UWORD        cl_InstOffset;
  34.     UWORD        cl_InstSize;
  35.  
  36.     ULONG        cl_UserData;    /* per-class data of your choice */
  37.     ULONG        cl_SubclassCount;
  38.                     /* how many direct subclasses?    */
  39.     ULONG        cl_ObjectCount;
  40.                 /* how many objects created of this class? */
  41.     ULONG        cl_Flags;
  42. #define    CLF_INLIST    0x00000001    /* class is in public class list */
  43. } Class;
  44.  
  45. /* add offset for instance data to an object handle */
  46. #define INST_DATA( cl, o )    ((VOID *) (((UBYTE *)o)+cl->cl_InstOffset))
  47.  
  48. /* sizeof the instance data for a given class */
  49. #define SIZEOF_INSTANCE( cl )    ((cl)->cl_InstOffset + (cl)->cl_InstSize \
  50.             + sizeof (struct _Object ))
  51.  
  52. /**************************************************/
  53. /*** "White box" access to struct _Object    ***/
  54. /**************************************************/
  55.  
  56. /*
  57.  * We have this, the instance data of the root class, PRECEDING
  58.  * the "object".  This is so that Gadget objects are Gadget pointers,
  59.  * and so on.  If this structure grows, it will always have o_Class
  60.  * at the end, so the macro OCLASS(o) will always have the same
  61.  * offset back from the pointer returned from NewObject().
  62.  *
  63.  * This data structure is subject to change.  Do not use the o_Node
  64.  * embedded structure.
  65.  */
  66. struct _Object {
  67.     struct MinNode    o_Node;
  68.     struct IClass    *o_Class;
  69. };
  70.  
  71. /* convenient typecast    */
  72. #define _OBJ( o )    ((struct _Object *)(o))
  73.  
  74. /* get "public" handle on baseclass instance from real beginning of obj data */
  75. #define BASEOBJECT( _obj )    ( (Object *) (_OBJ(_obj)+1) )
  76.  
  77. /* get back to object data struct from public handle */
  78. #define _OBJECT( o )        (_OBJ(o) - 1)
  79.  
  80. /* get class pointer from an object handle    */
  81. #define OCLASS( o )    ( (_OBJECT(o))->o_Class )
  82.  
  83. #endif
  84.