SOM Kernel Reference 1-61
SOM_Resolve Macro
Purpose
Obtains a pointer to a static method procedure.
Syntax
somMethodPtr SOM_Resolve (
SOMObject objPtr,
<token> className,
<token> methodName);
Description
The SOM_Resolve macro invokes the somResolve function to obtain a pointer to the static
method procedure that implements the specified method for the specified object. This
pointer can be used for efficient repeated casted method invocations on instances of the
class of the object on which the resolution is done, or instances of subclasses of this class.
The name of the class that introduces the method and the name of the method must be
known to use this macro. Otherwise, use the somResolveByName, somFindMethod or
somFindMethodOk method.
The SOM_Resolve macro can only be used to obtain a method procedure for a static
method (one defined in the IDL specification for a class); not a dynamic method. Unlike the
SOM_ResolveNoCheck macro, the SOM_Resolve macro performs several consistency
checks on the object pointed to by objPtr.
Parameters
objPtr A pointer to the object to which the resolved method procedure will be
applied.
className The name of the class that introduces methodName. This name should be
given as a simple token, rather than a quoted string (for example, Animal
rather than “Animal”).
methodName The name of the method to be resolved. This name should be given as a
simple token, rather than a quoted string (for example, setSound rather
than “setSound”).
Expansion
The SOM_Resolve macro uses the className and methodName to construct the method
token for the specified method, then invokes the somResolve function. Thus, the macro
expands to an expression that represents the entry-point address of the method procedure.
This value can be stored in a variable and used for subsequent invocations of the method.
Example
Animal myObj = AnimalNew();
somMethodProc *procPtr;
procPtr = SOM_Resolve(myObj, Animal, setSound);
/* note that procPtr will need to be typecast when it is used */
Related Information
Macros: SOM_ResolveNoCheck
Functions: somResolve, somClassResolve, somResolveByName
Methods: somFindMethod, somFindMethodOk, somDispatch, somClassDispatch
Kommentare zu diesen Handbüchern