5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
13 # include <exec/lists.h>
16 #ifndef EXEC_LIBRARIES_H
17 # include <exec/libraries.h>
20 #ifndef EXEC_SEMAPHORES_H
21 # include <exec/semaphores.h>
25 # include <dos/bptr.h>
28 #ifndef UTILITY_TAGITEM_H
29 # include <utility/tagitem.h>
47 #define NUM_METHOD_BITS 10
48 #define METHOD_MASK ((1 << NUM_METHOD_BITS) - 1)
51 /* These are used to index an array in the library base
52 from which we get the IDs for the used interfaces.
67 /* Used by the internal GetIDs() functions, to get several
79 /* defines used to access the interface IDs stored in the library base */
81 #define __IRoot (GetOBase(OOPBase)->ob_InternIDs[IDX_IRoot])
82 #define __IMeta (GetOBase(OOPBase)->ob_InternIDs[IDX_IMeta])
83 #define __IMethod (GetOBase(OOPBase)->ob_InternIDs[IDX_IMethod])
84 #define __IServer (GetOBase(OOPBase)->ob_InternIDs[IDX_IServer])
85 #define __IProxy (GetOBase(OOPBase)->ob_InternIDs[IDX_IProxy])
86 #define __IInterface (GetOBase(OOPBase)->ob_InternIDs[IDX_IInterface])
88 #define GetOBase(lib) ((struct IntOOPBase *)(lib))
94 BOOL
GetIDs(struct IDDescr
*idDesr
, struct IntOOPBase
*OOPBase
);
98 BOOL
init_rootclass(struct IntOOPBase
*OOPBase
);
101 BOOL
init_basemeta(struct IntOOPBase
*OOPBase
);
102 BOOL
init_ifmetaclass(struct IntOOPBase
*OOPBase
);
105 OOP_Class
*init_methodclass(struct IntOOPBase
*OOPBase
);
108 OOP_Class
*init_serverclass(struct Library
*OOPBase
);
111 OOP_Class
*init_proxyclass(struct Library
*OOPBase
);
113 /* interfaceclass.c */
114 OOP_Class
*init_interfaceclass(struct Library
*OOPBase
);
117 OOP_Class
*init_hiddmetaclass(struct IntOOPBase
*OOPBase
);
120 BOOL
hasinterface(OOP_Class
*cl
, STRPTR interface_id
);
121 struct IFMethod
*findinterface(OOP_Class
*cl
, STRPTR interface_id
);
122 struct IFMethod
*findmethod(OOP_Class
*cl
, STRPTR interface_id
, ULONG method_offset
);
123 BOOL
init_methodbase(STRPTR interface_id
, ULONG methodbase
, ULONG
*methodbase_ptr
, struct IntOOPBase
*OOPBase
);
124 BOOL
init_mi_methodbase(STRPTR interface_id
, ULONG
*methodbase_ptr
, struct IntOOPBase
*OOPBase
);
125 VOID
release_idbucket(STRPTR interface_id
, struct IntOOPBase
*OOPBase
);
126 VOID
obtain_idbucket(STRPTR interface_id
, struct IntOOPBase
*OOPBase
);
131 /* Bucket for hashtable used to map string interface IDs to
132 ** numeric interface IDs and attrbases.
137 struct iid_bucket
*next
;
146 /* Definition of bucket for hashtable used to store
147 ** the interfaces (method tables)
152 struct IFBucket
*Next
;
154 STRPTR GlobalInterfaceID
;
155 struct IFMethod
*MethodTable
;
160 /* Definition of an entry in a method table.
161 ** Ie. the method tables are arrays of these.
162 ** One has to store the class for each method
163 ** because we skip unimplemented class calls, and
164 ** therefore a method can go directly to a parent
165 ** class of OCLASS(o)
170 IPTR (*MethodFunc
)();
175 /* Message struct used for sending object message structs across
180 struct Message pm_Message
;
183 OOP_Object
*pm_Object
;
186 /* Listnode that helps keeping track of servers. */
190 OOP_Object
*sn_Server
;
194 /* Instance data of base metaclass and rootclass */
198 OOP_Class
public; /* public part of class objects */
202 BOOL disptabs_inited
;
207 #define MD(x) ((struct metadata *)x)
209 #define NUM_BASEMETA_IFS 2
210 struct basemetaobject
/* Real instance data of the base meta class */
212 OOP_Class
*oclass
; /* The meta object's class */
215 struct metadata data
;
216 struct IFMethod
*iftable
[NUM_BASEMETA_IFS
]; /* has two interfaces: root and meta */
218 /* The interface tables */
219 struct IFMethod rootif
[num_Root_Methods
];
220 struct IFMethod metaif
[NUMTOTAL_M_Meta
];
224 struct rootclassobject
226 OOP_Class
*oclass
; /* The rootclass object's class */
229 struct metadata data
;
230 struct IFMethod rootif
[num_Root_Methods
];
240 /* The hashtable containing the interfaces (method tables) */
241 struct HashTable
*iftable
;
243 /* A direct pointer into the hashtable, for faster lookup */
244 struct IFBucket
**iftab_directptr
;
246 /* Used by the hash function. As the above field, it is put
251 /* Number of interfaces in the hashtable */
259 OOP_Class
*oclass
; /* The interface metaclass' class (itself) */
262 struct metadata base
;
263 struct ifmeta_data data
;
270 /*************************
271 ** Library Base struct **
272 *************************/
275 struct Library ob_LibNode
;
277 struct SignalSemaphore ob_ClassListLock
;
278 struct MinList ob_ClassList
;
280 struct SignalSemaphore ob_ServerListLock
;
281 struct MinList ob_ServerList
;
283 /* rootclass object */
284 struct rootclassobject ob_RootClassObject
;
286 /* base metaclass object */
287 struct basemetaobject ob_BaseMetaObject
;
289 /* interface metaclass object */
290 struct ifmetaobject ob_IFMetaObject
;
293 OOP_Class
*ob_HIDDMetaClass
;
295 /* Store pointers to some usefull classes here */
296 OOP_Class
*ob_MethodClass
;
297 OOP_Class
*ob_ServerClass
;
298 OOP_Class
*ob_ProxyClass
;
299 OOP_Class
*ob_InterfaceClass
;
301 /* Hashtable containing string interface ID => Numeric interface
302 ** ID mappings. Used by GetMethodID() and GetAttrBase()
304 struct HashTable
* ob_IIDTable
;
305 struct SignalSemaphore ob_IIDTableLock
;
307 /* The currently lowest available numeric interfaceID that
308 ** we can map a new interface string ID onto.
312 ULONG ob_CurrentMethodBase
;
313 ULONG ob_CurrentAttrBase
;
315 /* An array of the interface IDs used internally. */
316 ULONG ob_InternIDs
[NUM_Indexes
];
319 #define ROOTCLASSPTR (& (OOPBase)->ob_RootClassObject.inst.data.public)
320 #define BASEMETAPTR (& (OOPBase)->ob_BaseMetaObject.inst.data.public)
322 #endif /* INTERN_H */