Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / oop / include / oop.h
blobb7f47c8418c6a665865b7d5cd546782cd0517f67
1 #ifndef OOP_OOP_H
2 #define OOP_OOP_H
4 /*
5 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
6 $Id$
7 */
9 #ifndef EXEC_TYPES_H
10 # include <exec/types.h>
11 #endif
13 #ifndef EXEC_NODES_H
14 # include <exec/nodes.h>
15 #endif
17 #ifndef EXEC_LIBRARIES_H
18 # include <exec/libraries.h>
19 #endif
21 #ifndef UTILITY_TAGITEM_H
22 # include <utility/tagitem.h>
23 #endif
25 #define AROSOOP_NAME "oop.library"
27 typedef ULONG OOP_Object;
29 typedef ULONG OOP_MethodID;
30 typedef ULONG OOP_AttrID;
32 typedef ULONG OOP_AttrBase;
34 typedef ULONG OOP_AttrCheck;
36 #define GOT_ATTR(code, pre_tag, pre_ac) \
37 ((pre_ac ## _attrcheck & (1L << pre_tag ## _ ## code)) == (1L << pre_tag ## _ ## code))
39 #define FOUND_ATTR(code, pre_tag, pre_ac) \
40 pre_ac ## _attrcheck |= (1L << pre_tag ## _ ## code)
42 #define DECLARE_ATTRCHECK(pre_tag) \
43 OOP_AttrCheck pre_tag ## _attrcheck = 0UL
45 #define ATTRCHECK(pre_tag) \
46 pre_tag ## _attrcheck
48 enum {
49 ooperr_ParseAttrs_TooManyAttrs = 1
52 typedef OOP_MethodID * OOP_Msg;
55 struct OOP_ABDescr
57 STRPTR interfaceID;
58 OOP_AttrBase *attrBase;
61 typedef struct OOP_IClass OOP_Class;
63 struct OOP_IClass
65 /* Array of pointers to methodtables for this class */
66 struct Node ClassNode;
67 struct Library *OOPBasePtr;
68 ULONG InstOffset;
69 APTR UserData;
70 IPTR (*cl_DoMethod)(OOP_Object *, OOP_Msg);
71 IPTR (*cl_CoerceMethod)(OOP_Class *, OOP_Object *, OOP_Msg);
72 IPTR (*cl_DoSuperMethod)(OOP_Class *, OOP_Object *, OOP_Msg);
77 struct _OOP_Object
79 OOP_Class *o_Class;
84 /* Macros */
87 #define OOP_BASEOBJECT(obj) ((OOP_Object *)(_OOP_OBJ(obj) + 1))
88 #define _OOP_OBJECT(obj) (_OOP_OBJ(obj) - 1)
89 #define _OOP_OBJ(obj) ((struct _OOP_Object *)(obj))
91 #define OOP_INST_DATA(cl, obj) \
92 ((APTR)(((UBYTE *)obj) + (cl)->InstOffset))
94 #define OOP_OCLASS(obj) \
95 (_OOP_OBJECT(obj)->o_Class)
97 #define OOP_OOPBASE(obj) \
98 (OOP_OCLASS(obj)->OOPBasePtr)
100 #define OOP_DoMethod(o, msg) ( (OOP_OCLASS(o))->cl_DoMethod((o), (msg)) )
101 #define OOP_DoSuperMethod(cl, o, msg) ((cl)->cl_DoSuperMethod(cl, o, msg))
102 #define OOP_CoerceMethod(cl, o, msg) ((cl)->cl_CoerceMethod(cl, o, msg))
104 #define OOP_METHODDEF(x) (IPTR (*)())x
107 #define IS_IF_ATTR(attr, idx, attrbase, numifattrs) ( ((idx) = (attr) - (attrbase)) < (numifattrs) )
109 struct OOP_InterfaceDescr
111 struct OOP_MethodDescr *MethodTable;
112 STRPTR InterfaceID;
113 ULONG NumMethods; /* Number of methods in the methodtable */
116 typedef IPTR (*OOP_MethodFunc)(OOP_Class *cl, OOP_Object *o, OOP_Msg msg);
118 struct OOP_MethodDescr
120 OOP_MethodFunc MethodFunc;
121 ULONG MethodIdx;
125 /* Some basic interfaces and classes */
127 /*********************
128 ** rootclass defs **
129 *********************/
131 #define IID_Root "Root"
132 #define CLID_Root "rootclass"
135 enum
137 moRoot_New = 0,
138 moRoot_Dispose,
139 moRoot_Set,
140 moRoot_Get,
142 num_Root_Methods
146 struct pRoot_New
148 OOP_MethodID mID;
149 struct TagItem *attrList;
152 struct pRoot_Set
154 OOP_MethodID mID;
155 struct TagItem *attrList;
158 struct pRoot_Get
160 OOP_MethodID mID;
161 ULONG attrID;
162 IPTR *storage;
165 /**************************
166 ** meta interface defs **
167 **************************/
169 #define IID_Meta "Meta"
171 #define MetaAttrBase (__IMeta)
174 enum
176 num_Meta_Methods
179 enum {
180 aoMeta_SuperID = 0,
181 aoMeta_InterfaceDescr,
182 aoMeta_ID,
183 aoMeta_SuperPtr,
184 aoMeta_InstSize,
185 aoMeta_DoMethod,
186 aoMeta_CoerceMethod,
187 aoMeta_DoSuperMethod,
189 num_Meta_Attrs
192 #define aMeta_SuperID (MetaAttrBase + aoMeta_SuperID)
193 #define aMeta_InterfaceDescr (MetaAttrBase + aoMeta_InterfaceDescr)
194 #define aMeta_ID (MetaAttrBase + aoMeta_ID)
195 #define aMeta_SuperPtr (MetaAttrBase + aoMeta_SuperPtr)
196 #define aMeta_InstSize (MetaAttrBase + aoMeta_InstSize)
197 #define aMeta_DoMethod (MetaAttrBase + aoMeta_DoMethod)
198 #define aMeta_CoerceMethod (MetaAttrBase + aoMeta_CoerceMethod)
199 #define aMeta_DoSuperMethod (MetaAttrBase + aoMeta_DoSuperMethod)
201 /***********************
202 ** methodclass defs **
203 ***********************/
205 extern ULONG __IMethod;
207 #define IID_Method "Method"
209 #define CLID_Method "methodclass"
211 #define MethodAttrBase (__IMethod)
213 #define OOP_CallMethod(m) ( (m)->methodFunc((m)->methodClass, (m)->targetObject, (m)->message) )
215 enum {
216 aoMethod_TargetObject= 0,
217 aoMethod_Message,
218 aoMethod_MethodID,
220 num_Method_Attrs
223 #define aMethod_TargetObject (MethodAttrBase + aoMethod_TargetObject)
224 #define aMethod_Message (MethodAttrBase + aoMethod_Message)
225 #define aMethod_MethodID (MethodAttrBase + aoMethod_MethodID)
227 typedef struct
229 OOP_Object *targetObject;
230 OOP_Msg message;
231 OOP_Class *methodClass;
232 OOP_MethodFunc methodFunc;
233 } OOP_Method;
236 /**************************
237 ** interfaceclass defs **
238 **************************/
240 extern ULONG __IInterface;
242 #define IID_Interface "Interface"
244 #define CLID_Interface "interfaceclass"
246 #define InterfaceAttrBase (__IInterface)
249 enum {
250 aoInterface_TargetObject= 0,
251 aoInterface_InterfaceID,
253 NUM_A_Interface
256 #define aInterface_TargetObject (InterfaceAttrBase + aoInterface_TargetObject)
257 #define aInterface_InterfaceID (InterfaceAttrBase + aoInterface_InterfaceID)
260 typedef struct OOP_InterfaceStruct
262 IPTR (*callMethod)(struct OOP_InterfaceStruct *, OOP_Msg);
263 OOP_Object *targetObject;
265 } OOP_Interface;
268 /***********************
269 ** Some metaclasses **
270 ***********************/
272 #define CLID_MIMeta "mimetaclass" /* Supports multiple interfaces */
273 #define CLID_SIMeta "simetaclass" /* Supports only single intefaces */
277 #endif /* OOP_OOP_H */