SomSupportsMethod: Difference between revisions
Appearance
Created page with "{{DISPLAYTITLE:somSupportsMethod}} This method returns a boolean indicating whether instances of a class respond to a given (static or dynamic) method. For backward compatibi..." |
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== | ||
Line 10: | Line 10: | ||
==Parameters== | ==Parameters== | ||
; | ;receiver (SOMClass) : A pointer to the class object to be tested. | ||
;methodId (somId) : An ID that represents the name of the method. | |||
; methodId (somId) : An ID that represents the name of the method. | |||
==Return Code== | ==Return Code== | ||
; | ;rc (boolean) : Returns 1 (true) if instances of the specified class support the specified method, and 0 (false) otherwise. | ||
==Remarks== | ==Remarks== | ||
Line 49: | Line 48: | ||
==Related== | ==Related== | ||
;Methods | |||
* [[somRespondsTo]] | * [[somRespondsTo]] | ||
[[Category:SOMClassMgr]] | [[Category:SOMClassMgr]] |
Latest revision as of 18:28, 12 October 2022
This method returns a boolean indicating whether instances of a class respond to a given (static or dynamic) method.
For backward compatibility, this method does not take an Environment parameter.
- Original Class
- SOMClass
Syntax
boolean somSupportsMethod (SOMClass receiver, somId methodId)
Parameters
- receiver (SOMClass)
- A pointer to the class object to be tested.
- methodId (somId)
- An ID that represents the name of the method.
Return Code
- rc (boolean)
- Returns 1 (true) if instances of the specified class support the specified method, and 0 (false) otherwise.
Remarks
The somSupportsMethod method determines if instances of the specified class respond to the specified (static or dynamic) method.
Example Code
/* ------------------------------------------------ Note: animal supports a setSound method; animal does not support a doTrick method. ------------------------------------------------ */ #include <animal.h> main() { SOMClass animalClass; char *methodName1 = "setSound"; char *methodName2 = "doTrick"; animalClass = AnimalNewClass(Animal_MajorVersion, Animal_MinorVersion); if (_somSupportsMethod(animalClass, somIdFromString(methodName1))) somPrintf("Animals respond to %s\n", methodName1); if (_somSupportsMethod(animalClass, somIdFromString(methodName2))) somPrintf("Animals respond to %s\n", methodName2); } /* Output from this program: Animals respond to setSound */
Related
- Methods