- Set a default PCM volume so that something can be heard when driver is
[AROS.git] / test / oop / method.c
blob7230c5813bd3ad93bdc26ac4d0740c68e430e545
1 /*
2 Copyright © 1997-98, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Demo of new OOP system
6 Lang: english
7 */
9 #include "types.h"
10 #include "oop.h"
11 #include "intern.h"
14 #define CallMethod(cl, o, msg) \
15 { \
16 register struct Bucket *b; \
17 register ULONG mid = msg->MethodID; \
19 for (b = cl->HashTable[CalcHash(mid, cl->HashTableSize)]; \
20 b; b = b->Next) \
21 { \
22 if (b->MethodID == mid) \
23 { \
24 IPTR (*method)(Class *, Object *, Msg); \
25 method = b->MethodFunc; \
26 return (method(b->mClass, o, msg)); \
27 } \
28 } \
29 return (NULL); \
32 IPTR CoerceMethodA(Class *cl, Object *o, Msg msg)
34 CallMethod(cl, o, msg);
37 IPTR DoMethodA(Object *o, Msg msg)
39 register Class *cl = OCLASS(o);
40 CallMethod(cl, o, msg);
43 IPTR DoSuperMethodA(Class *cl, Object *o, Msg msg)
45 Class *super = cl->SuperClass;
46 CallMethod(super, o, msg)
49 BOOL GetMethod(Object *o, ULONG methodID, APTR *methodPtrPtr, Class **classPtrPtr)
51 ULONG idx;
52 struct Bucket *b;
53 Class *cl = OCLASS(o);
54 idx = CalcHash(methodID, cl->HashTableSize);
55 b = cl->HashTable[idx];
56 while (b)
58 if (b->MethodID == methodID)
60 *methodPtrPtr = b->MethodFunc;
61 *classPtrPtr = b->mClass;
62 return (TRUE);
64 b = b->Next;
66 return (FALSE);