SomClassResolve: Difference between revisions
mNo edit summary |
|||
Line 1: | Line 1: | ||
This function obtains a pointer to the procedure that implements a static method for instances of a particular SOM class. | {{DISPLAYTITLE:somClassResolve}} | ||
This function obtains a pointer to the procedure that implements a static method for instances of a particular SOM class. | |||
==Syntax== | ==Syntax== | ||
SOMClass cls; | |||
SOMClass cls; | somMToken mToken; | ||
somMToken mToken; | somMethodPtr rc; | ||
somMethodPtr rc; | |||
rc = somClassResolve(cls, mToken); | |||
rc = somClassResolve(cls, mToken); | |||
==Parameters== | ==Parameters== | ||
;cls (SOMClass) : A pointer to the class object whose instance method procedure is required. | ;cls (SOMClass): A pointer to the class object whose instance method procedure is required. | ||
;mToken (somMToken) : The method token for the method to be resolved. The SOM API requires that if the class "XYZ" introduces the static method "foo", then the method token for "foo" is found in the class data structure for "XYZ" (called XYZClassData) in the structure member named "foo" (i.e., at XYZClassData.foo). Method tokens can also be obtained using the somGetMethodToken method. A pointer to the class object whose instance method procedure is required. | ;mToken (somMToken) : The method token for the method to be resolved. The SOM API requires that if the class "XYZ" introduces the static method "foo", then the method token for "foo" is found in the class data structure for "XYZ" (called XYZClassData) in the structure member named "foo" (i.e., at XYZClassData.foo). Method tokens can also be obtained using the somGetMethodToken method. A pointer to the class object whose instance method procedure is required. | ||
Line 70: | Line 69: | ||
==Related== | ==Related== | ||
;Data Structures | |||
*somMethodPtr (sombtype.h) | *somMethodPtr (sombtype.h) | ||
* [[SOMClass]] (somcls.idl) | *[[SOMClass]] (somcls.idl) | ||
*somMToken (somapi.h) | *somMToken (somapi.h) | ||
;Functions | |||
*[[somResolveByName]] | |||
* [[somResolveByName]] | *[[somParentResolve]] | ||
* [[somParentResolve]] | *[[somParentNumResolve]] | ||
* [[somParentNumResolve]] | *[[somResolve]] | ||
* [[somResolve]] | ;Methods | ||
*somDispatch | *somDispatch | ||
*somClassDispatch | *somClassDispatch | ||
Line 87: | Line 84: | ||
*somFindMethodOk | *somFindMethodOk | ||
*somGetMethodToken | *somGetMethodToken | ||
;Macros | |||
*[[SOM_Resolve]] | |||
*[[SOM_ResolveNoCheck]] | |||
[[Category:SOM function]] | |||
[[Category:SOM |
Latest revision as of 04:22, 6 May 2020
This function obtains a pointer to the procedure that implements a static method for instances of a particular SOM class.
Syntax
SOMClass cls; somMToken mToken; somMethodPtr rc; rc = somClassResolve(cls, mToken);
Parameters
- cls (SOMClass)
- A pointer to the class object whose instance method procedure is required.
- mToken (somMToken)
- The method token for the method to be resolved. The SOM API requires that if the class "XYZ" introduces the static method "foo", then the method token for "foo" is found in the class data structure for "XYZ" (called XYZClassData) in the structure member named "foo" (i.e., at XYZClassData.foo). Method tokens can also be obtained using the somGetMethodToken method. A pointer to the class object whose instance method procedure is required.
Return Code
- rc (somMethodPtr)
- A pointer to the somMethodProc (procedure) that implements the specified method for the specified class of SOM object.
Remarks
This function is used to obtain a pointer to the procedure that implements the specified method for instances of the specified SOM class. The returned procedure pointer can then be used to invoke the method. The somClassResolve function is used to support "casted" method calls, in which a method is resolved with respect to a specified class rather than the class of which an object is a direct instance. The somClassResolve function can only be used to obtain a method procedure for a static method (a method declared in an IDL specification for a class); dynamic methods do not have method tokens.
The SOM language usage bindings for C and C++ do not support casted method calls, so this function must be used directly to achieve this functionality. Whenever using SOM method procedure pointers, it is necessary to indicate the use of system linkage to the compiler. 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 this purpose. The name of the typedef is based on the name of the class that introduces the method, as illustrated in the example below.
Example Code
// SOM IDL for class A and class B #include <somobj.idl> module scrExample { interface A : SOMObject { void foo(); implementation { callstyle=oidl;};}; interface B : A { implementation { foo: override;};}; }; // Example C++ program to implement and test module scrExample #define SOM_Module_screxample_Source #include <scrExample.xih> #include <stdio.h> SOM_Scope void SOMLINK scrExample_Afoo(scrExample_A *somSelf); { printf("1\n");} SOM_Scope void SOMLINK scrExample_Bfoo(scrExample_B *somSelf); { printf("2\n");} main() { scrExample_B *objPtr = new scrExample_B; // This prints 2 objPtr->foo(); // This prints 1 ((somTD_scrExample_A_foo) /* A necessary method procedure cast */ somClassResolve( ,_scrExample_A, // the A class object scrExample_AClassData.foo) // the foo method token ) /* end of method procedure expression */ (objPtr); /* method arguments */ // This prints 2 ((somTD_scrExample_A_foo) /* A necessary method procedure cast */ somClassResolve( ,_scrExample_B, // the B class object scrExample_AClassData.foo) // the foo method token ) /* end of method procedure expression */ (objPtr); /* method arguments */ }
Related
- Data Structures
- somMethodPtr (sombtype.h)
- SOMClass (somcls.idl)
- somMToken (somapi.h)
- Functions
- Methods
- somDispatch
- somClassDispatch
- somFindMethod
- somFindMethodOk
- somGetMethodToken
- Macros