home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / BOOPSI / GI1 / Include / intuition / classes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-27  |  3.5 KB  |  115 lines

  1. #ifndef    INTUITION_CLASSES_H
  2. #define INTUITION_CLASSES_H
  3. /*
  4. **  $Id: classes.h,v 40.0 94/02/15 17:46:35 davidj Exp Locker: davidj $
  5. **
  6. **  Used only by class implementors
  7. **
  8. **  (C) Copyright 1989-1999 Amiga, Inc.
  9. **        All Rights Reserved
  10. */
  11.  
  12. /*****************************************************************************/
  13.  
  14. #ifndef    EXEC_TYPES_H
  15. #include <exec/types.h>
  16. #endif
  17.  
  18. #ifndef    EXEC_LIBRARIES_H
  19. #include <exec/libraries.h>
  20. #endif
  21.  
  22. #ifndef UTILITY_HOOKS_H
  23. #include <utility/hooks.h>
  24. #endif
  25.  
  26. #ifndef    INTUITION_CLASSUSR_H
  27. #include <intuition/classusr.h>
  28. #endif
  29.  
  30. /*****************************************************************************/
  31. /***************** "White Box" access to struct IClass ***********************/
  32. /*****************************************************************************/
  33.  
  34. /* This structure is READ-ONLY, and allocated only by Intuition */
  35. typedef struct IClass
  36. {
  37.     struct Hook         cl_Dispatcher;        /* Class dispatcher */
  38.     ULONG         cl_Reserved;        /* Must be 0  */
  39.     struct IClass    *cl_Super;        /* Pointer to superclass */
  40.     ClassID         cl_ID;            /* Class ID */
  41.  
  42.     UWORD         cl_InstOffset;        /* Offset of instance data */
  43.     UWORD         cl_InstSize;        /* Size of instance data */
  44.  
  45.     ULONG         cl_UserData;        /* Class global data */
  46.     ULONG         cl_SubclassCount;    /* Number of subclasses */
  47.     ULONG         cl_ObjectCount;    /* Number of objects */
  48.     ULONG         cl_Flags;
  49.  
  50. } Class;
  51.  
  52. #define    CLF_INLIST    0x00000001
  53.     /* class is in public class list */
  54.  
  55. /*****************************************************************************/
  56.  
  57. /* add offset for instance data to an object handle */
  58. #define INST_DATA(cl,o)        ((void *)(((UBYTE *)o)+cl->cl_InstOffset))
  59.  
  60. /*****************************************************************************/
  61.  
  62. /* sizeof the instance data for a given class */
  63. #define SIZEOF_INSTANCE(cl)    ((cl)->cl_InstOffset + (cl)->cl_InstSize \
  64.             + sizeof (struct _Object))
  65.  
  66. /*****************************************************************************/
  67. /***************** "White box" access to struct _Object **********************/
  68. /*****************************************************************************/
  69.  
  70. /* We have this, the instance data of the root class, PRECEDING the "object".
  71.  * This is so that Gadget objects are Gadget pointers, and so on.  If this
  72.  * structure grows, it will always have o_Class at the end, so the macro
  73.  * OCLASS(o) will always have the same offset back from the pointer returned
  74.  * from NewObject().
  75.  *
  76.  * This data structure is subject to change.  Do not use the o_Node embedded
  77.  * structure. */
  78. struct _Object
  79. {
  80.     struct MinNode     o_Node;
  81.     struct IClass    *o_Class;
  82.  
  83. };
  84.  
  85. /*****************************************************************************/
  86.  
  87. /* convenient typecast    */
  88. #define _OBJ(o)            ((struct _Object *)(o))
  89.  
  90. /* get "public" handle on baseclass instance from real beginning of obj data */
  91. #define BASEOBJECT(_obj)    ((Object *)(_OBJ(_obj)+1))
  92.  
  93. /* get back to object data struct from public handle */
  94. #define _OBJECT(o)        (_OBJ(o) - 1)
  95.  
  96. /* get class pointer from an object handle    */
  97. #define OCLASS(o)        ((_OBJECT(o))->o_Class)
  98.  
  99. /*****************************************************************************/
  100.  
  101. /* BOOPSI class libraries should use this structure as the base for their
  102.  * library data.  This allows developers to obtain the class pointer for
  103.  * performing object-less inquiries. */
  104. struct ClassLibrary
  105. {
  106.     struct Library     cl_Lib;    /* Embedded library */
  107.     UWORD         cl_Pad;    /* Align the structure */
  108.     Class        *cl_Class;    /* Class pointer */
  109.  
  110. };
  111.  
  112. /*****************************************************************************/
  113.  
  114. #endif
  115.