SOM Kernel Reference 1-91
somGetMethodToken Method
Purpose
Returns a method access token for a static method. Not generally overridden.
IDL Syntax
somMToken somGetMethodToken (in somId methodId);
Note: For backward compatibility, this method does not take an Environment parameter.
Description
The somGetMethodToken method returns a method access token for a static method with
the specified ID that was introduced by the receiver class or an ancestor of the receiver
class. This method token can be passed to the somResolve function (or one of the other
offset-based method resolution functions) to select a method procedure pointer from a
method table of an object whose class is the same as, or is derived from the class that
introduced the method.
Parameters
receiver A pointer to a SOMClass object.
methodId A somId identifying a method.
Return Value
The somGetMethodToken method returns a somMToken method-access token.
C Example
Assuming that the class Animal introduces the method setSound,
#include <animal.h>
main() {
somMToken tok;
Animal myAnimal;
somTD_Animal_setSound methodPtr; /* use typedef from animal.h
*/
Environment *ev = somGetGlobalEnvironment();
myAnimal = AnimalNew();
/*next 3 lines equivalent to _setSound(myAnimal, ev,
”Roar!!!”);*/
tok = _somGetMethodToken(_Animal, somIdFromString(“setSound”));
methodPtr = (somTD_Animal_setSound)somResolve(myAnimal, tok);
methodPtr(myAnimal, ev, ”Roar!!!”);
_display(myAnimal, ev);
_somFree(myAnimal);
}
Original Class
SOMClass
Related Information
Methods: somGetNthMethodInfo, somGetMethodData
Functions: somResolve, somClassResolve, somParentNumResolve
Komentáře k této Příručce