5 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
10 # include <exec/types.h>
14 # include <exec/nodes.h>
17 #ifndef EXEC_LIBRARIES_H
18 # include <exec/libraries.h>
21 #ifndef UTILITY_TAGITEM_H
22 # include <utility/tagitem.h>
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) \
49 ooperr_ParseAttrs_TooManyAttrs
= 1
52 typedef OOP_MethodID
* OOP_Msg
;
58 OOP_AttrBase
*attrBase
;
61 typedef struct OOP_IClass OOP_Class
;
65 /* Array of pointers to methodtables for this class */
66 struct Node ClassNode
;
67 struct Library
*OOPBasePtr
;
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
);
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
;
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
;
125 /* Some basic interfaces and classes */
127 /*********************
129 *********************/
131 #define IID_Root "Root"
132 #define CLID_Root "rootclass"
149 struct TagItem
*attrList
;
155 struct TagItem
*attrList
;
165 /**************************
166 ** meta interface defs **
167 **************************/
169 #define IID_Meta "Meta"
171 #define MetaAttrBase (__IMeta)
181 aoMeta_InterfaceDescr
,
187 aoMeta_DoSuperMethod
,
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) )
216 aoMethod_TargetObject
= 0,
223 #define aMethod_TargetObject (MethodAttrBase + aoMethod_TargetObject)
224 #define aMethod_Message (MethodAttrBase + aoMethod_Message)
225 #define aMethod_MethodID (MethodAttrBase + aoMethod_MethodID)
229 OOP_Object
*targetObject
;
231 OOP_Class
*methodClass
;
232 OOP_MethodFunc methodFunc
;
236 /**************************
237 ** interfaceclass defs **
238 **************************/
240 extern ULONG __IInterface
;
242 #define IID_Interface "Interface"
244 #define CLID_Interface "interfaceclass"
246 #define InterfaceAttrBase (__IInterface)
250 aoInterface_TargetObject
= 0,
251 aoInterface_InterfaceID
,
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
;
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 */