Commit of the code which was suggested by Georg as a fix for:
[cake.git] / rom / oop / getmethodid.c
blobcfac0393664759dc437be07db0ed6d17e5805e31
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: OOP function OOP_GetMethodID
6 Lang: english
7 */
8 #include "intern.h"
9 /*****************************************************************************
11 NAME */
12 #include <proto/exec.h>
13 #include <proto/oop.h>
14 #include <exec/memory.h>
15 #include <aros/libcall.h>
17 #include <aros/debug.h>
18 #include "hash.h"
20 AROS_LH2(OOP_MethodID, OOP_GetMethodID,
22 /* SYNOPSIS */
23 AROS_LHA(STRPTR , interfaceID, A0),
24 AROS_LHA(ULONG , methodOffset, D0),
26 /* LOCATION */
27 struct Library *, OOPBase, 7, OOP)
29 /* FUNCTION
30 Maps a globally unique full method ID
31 (Interface ID + method offset) into
32 a numeric method ID.
34 INPUTS
35 interfaceID - globally unique interface identifier.
36 methodOffset - offset to the method in this interface.
39 RESULT
40 Numeric method identifier that is unique for this machine.
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 HISTORY
54 ******************************************************************************/
56 AROS_LIBFUNC_INIT
58 /* Look up ID */
59 ULONG mid = 0UL;
60 struct iid_bucket *idb;
61 struct HashTable *iidtable = GetOBase(OOPBase)->ob_IIDTable;
63 EnterFunc(bug("OOP_GetMethodID(interfaceID=%s, methodOffset=%ld)\n",
64 interfaceID, methodOffset));
66 /* #warning doesn't handle failures. (Should throw exception of some kind)
68 idb = (struct iid_bucket *)iidtable->Lookup(iidtable, (IPTR)interfaceID, GetOBase(OOPBase));
69 if (idb)
71 D(bug("Got mid %ld\n", mid));
72 /* Should throw eception here if metodbase == -1UL */
73 mid = idb->methodbase + methodOffset;
75 ReturnInt ("OOP_GetMethodID", ULONG, mid);
78 /* Should throw exception here */
80 /* The ID must be left-shifted to make place for method offsets */
81 ReturnInt ("OOP_GetMethodID", ULONG, -1);
83 AROS_LIBFUNC_EXIT
85 } /* OOP_GetMethodID */