Indentation fix, cleanup.
[AROS.git] / rom / oop / getmethod.c
blob8e394a54ef16880f356d06f5141cadbc1ac0546a
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Get a pointer to a method for an object
6 Lang: english
7 */
8 #include <exec/lists.h>
9 #include <proto/exec.h>
10 #include <oop/oop.h>
11 #include <aros/debug.h>
12 #include "intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/oop.h>
19 AROS_LH3(OOP_MethodFunc, OOP_GetMethod,
21 /* SYNOPSIS */
22 AROS_LHA(OOP_Object *, obj, A0),
23 AROS_LHA(OOP_MethodID, mid, D0),
24 AROS_LHA(OOP_Class **, classPtr, A1),
26 /* LOCATION */
27 struct Library *, OOPBase, 21, OOP)
29 /* FUNCTION
30 Get a specific method function for a specific object and
31 a specific interface. This a direct pointer to the method
32 implementation. The pointer should ONLY be used on the object you
33 acquired.
35 INPUTS
36 obj - pointer to object to get method for.
37 mid - method id for method to get. This may be obtained with GetMethodID()
38 classPtr - A pointer to a location where implementation class pointer will be stored.
39 The obtained method must be called with this class pointer. This pointer
40 is mandatory!
42 RESULT
43 The method asked for, or NULL if the method does not exist in
44 the object's class.
46 NOTES
47 !!! Use with EXTREME CAUTION. Very few programs need the extra speed gained
48 by calling a method directly
49 !!!
51 EXAMPLE
53 BUGS
55 SEE ALSO
56 OOP_GetMethodID()
58 INTERNALS
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 struct IFMethod *ifm;
66 /* First get mid */
67 /* Get the method from the object's class */
68 ifm = meta_findmethod((OOP_Object *)OOP_OCLASS(obj), mid, (struct Library *)OOPBase);
69 if (NULL == ifm)
70 return NULL;
72 /* Set class pointer */
73 *classPtr = ifm->mClass;
75 /* Paranoia */
76 D(if (NULL == ifm->MethodFunc) bug("!!! OOP/GetMethod(): IFMethod instance had no methodfunc. This should NEVER happen !!!\n");)
78 return ifm->MethodFunc;
80 AROS_LIBFUNC_EXIT
81 } /* OOP_GetMethod */