Jump to content

SomGetMethodToken: Difference between revisions

From EDM2
Created page with "{{DISPLAYTITLE:somGetMethodToken}} This method returns a method access token for static method. Not generally overridden. For backward compatibility, this method does not tak..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 4: Line 4:
For backward compatibility, this method does not take an Environment parameter.
For backward compatibility, this method does not take an Environment parameter.


; Original Class : [[SOMClass]]
;Original Class : [[SOMClass]]


==Syntax==
==Syntax==
  somMToken somGetMethodToken (SOMClass receiver, somId methodId)
  somMToken somGetMethodToken (SOMClass receiver, somId methodId)
==Parameters==
==Parameters==
; receiver (SOMClass) : A pointer to a SOMClass object.  
;receiver (SOMClass) : A pointer to a SOMClass object.
 
;methodId (somId) : A somId identifying a method.
; methodId (somId) : A somId identifying a method.


==Return Code==
==Return Code==
; rc (somMToken) : Returns a somMToken method access token.
;rc (somMToken) : Returns a somMToken method access token.


==Remarks==
==Remarks==
Line 41: Line 41:


==Related==
==Related==
===Functions===
;Functions
* [[somResolve]]
* [[somResolve]]
* [[somClassResolve]]
* [[somClassResolve]]
* [[somParentNumResolve]]
* [[somParentNumResolve]]
 
;Methods
===Methods===
* [[somGetNthMethodInfo]]
* [[somGetNthMethodInfo]]
* [[somGetMethodData]]
* [[somGetMethodData]]


[[Category:SOMClass]]
[[Category:SOMClass]]

Latest revision as of 18:33, 12 October 2022

This method returns a method access token for static method. Not generally overridden.

For backward compatibility, this method does not take an Environment parameter.

Original Class
SOMClass

Syntax

somMToken somGetMethodToken (SOMClass receiver, somId methodId)

Parameters

receiver (SOMClass)
A pointer to a SOMClass object.
methodId (somId)
A somId identifying a method.

Return Code

rc (somMToken)
Returns a somMToken method access token.

Remarks

This 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.

The example below assumes that the class Animal introduces the method setSound.

Example Code

#include < >
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);
}

Related

Functions
Methods