SomFindMethod

This method finds the method procedure for a method and indicates whether it represents a static method or a dynamic method. Not generally overridden.

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


 * Original Class : SOMClass

Syntax
boolean somFindMethod (SOMClass receiver, somId methodId, somMethodPtr m)

Parameters

 * receiver (SOMClass) : A pointer to the class object whose method is desired.


 * methodId (somId) : An ID that represents the name of the desired method. The somIdFromString function can used to obtain an ID from the method's name.


 * m (somMethodPtr) : A pointer to the location in memory where a pointer to the specified method's procedure should be stored. The method stores a NULL pointer in this location (if the method does not exist) or a value that can be called.

Return Code

 * rc (boolean)
 * TRUE  Returns TRUE when the method procedure can be called directly and FALSE when the method procedure is a dispatch function.
 * FALSE Returns FALSE when the method procedure is a dispatch function.

Remarks
This method performs name-lookup method resolution, determines the method procedure appropriate for performing the indicated method on instances of the receiving class, and loads m with the method procedure address. For static methods, method procedure resolution is done using the instance method table of the receiving class.

Name-lookup resolution must be used to invoke dynamic methods. Also, name-lookup can be useful when different classes introduce methods of the same name, signature, and desired semantics, but it is not known until runtime which of these classes should be used as a type for the objects on which the method is to be invoked. If the signature of a method is a not known, then method procedures cannot be used directly, and the somDispatch method can be used after dynamically discovering the signature to allow the correct arguments can be placed on a va_list.

As with any method that returns procedure pointers, this method allows repeated invocations of the same method procedure to be programmed. If this is done, it up to the programmer to prevent runtime errors by assuring that each invocation is performed either on an instance of the class used to resolve the method procedure or of some class derived from it. Whenever using SOM method procedure pointers, it is necessary to indicate the arguments to be passed and the use of system linkage to the compiler, so it can generate a correct procedure call. The way this is done depends on the compiler and the system being used. However, C and C++ usage bindings provide an appropriate typedef for static methods. The name of the typedef is based on the name of the class that introduces the method, as illustrated in the example below.

If the class does not support the specified method, then *m is set to NULL and the return value is meaningless. Otherwise, the returned result is true if the indicated method was a static method.

Example Code
Assuming that the Animal class introduces the method setSound, the type name for the setSound method procedure type will be somTD_Animal_setSound, as illustrated in the Example.  void main {  Animal myAnimal; somId somId_setSound; somTD_Animal_setSound methodPtr; Environment *ev = somGetGlobalEnvironment;
 * 1) include 

myAnimal = AnimalNew; /* ---  Note: Next three lines are equivalent to       _setSound(myAnimal, ev, "Roar!!!"); --- */  somId_setSound = somIdFromString("setSound"); _somFindMethod (_somGetClass(myAnimal),                   somId_setSound, &methodPtr); methodPtr(myAnimal, ev, "Roar!!!"); /* --- */  _display(myAnimal, ev); _somFree(myAnimal); } /* Program Output: This Animal says Roar!!! 

Methods

 * somFindSMethod
 * somFindSMethodOK
 * somSupportsMethod
 * somDispatch
 * somClassDispatch

Functions

 * somApply
 * somResolve
 * somClassResolve
 * somResolveByName
 * somParentNumResolve

Macros

 * SOM_Resolve
 * SOM_ResolveNoCheck
 * SOM_ParentNumResolve