somSupportsMethod
Appearance
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 */