1 #ifndef INTUITION_CLASSES_H
    2 #define INTUITION_CLASSES_H
    3 
    4 /*
    5 	intuition class definitions
    6 
    7 	Copyright © 2002-2008 The MorphOS Development Team, All Rights Reserved.
    8 */
    9 
   10 #ifndef EXEC_TYPES_H
   11 # include <exec/types.h>
   12 #endif
   13 
   14 #ifndef EXEC_LIBRARIES_H
   15 # include <exec/libraries.h>
   16 #endif
   17 
   18 #ifndef UTILITY_HOOKS_H
   19 # include <utility/hooks.h>
   20 #endif
   21 
   22 #ifndef INTUITION_CLASSUSR_H
   23 # include <intuition/classusr.h>
   24 #endif
   25 
   26 #pragma pack(2)
   27 
   28 
   29 typedef
   30 struct IClass
   31 {
   32 	struct Hook    cl_Dispatcher;    /* pointer to the class' Dispatcher */
   33 	ULONG          cl_Reserved;      /* must be 0 */
   34 	struct IClass *cl_Super;         /* pointer to the class's Super class, that is the class it inherits from */
   35 	ClassID        cl_ID;
   36 
   37 	UWORD          cl_InstOffset;    /* offset and size of the instance data for this class */ 
   38 	UWORD          cl_InstSize;
   39 
   40 	ULONG          cl_UserData;      /* class' private data of choice */
   41 	ULONG          cl_SubclassCount; /* number of direct subclasses */
   42 	ULONG          cl_ObjectCount;   /* number of instances */
   43 	ULONG          cl_Flags;
   44 } Boopsiclass;
   45 
   46 #if !defined(__OBJC__) 
   47 typedef Boopsiclass Class;
   48 #endif
   49 
   50 
   51 #define CLF_INLIST  0x00000001L      /* set if the class is in the public class list */
   52 
   53 /* returns the instance data for the given class and object */
   54 #define INST_DATA(cl,o)      ((void *)(((UBYTE *)o)+cl->cl_InstOffset))
   55 
   56 /* returns the size of instance data */
   57 #define SIZEOF_INSTANCE(cl)  ((cl)->cl_InstOffset+(cl)->cl_InstSize+sizeof(struct _Object))
   58 
   59 /* Instance data of the root class, preceeding the object. Might grow from
   60 ** the beginning, so the o_Class offset will always stay the same relatively to
   61 ** the pointer returned by NewObject() */
   62 struct _Object
   63 {
   64 	struct MinNode  o_Node;        /* do NOT use */
   65 	struct IClass  *o_Class;
   66 };
   67 
   68 #define _OBJ(o)           ((struct _Object *)(o))
   69 
   70 #define BASEOBJECT(_obj)  ((Boopsiobject *)(_OBJ(_obj)+1))
   71 
   72 #define _OBJECT(o)        (_OBJ(o)-1)
   73 
   74 #define OCLASS(o)         ((_OBJECT(o))->o_Class)
   75 
   76 
   77 struct ClassLibrary
   78 {
   79 	struct Library  cl_Lib;
   80 	UWORD           cl_Pad;
   81 	Boopsiclass    *cl_Class;
   82 };
   83 
   84 
   85 #pragma pack()
   86 
   87 #endif /* INTUITION_CLASSES_H */