gtpc2mgo | C/C++ Language Support User's Guide |
This function causes TPF collection support (TPFCS) to locate the specific method definition in storage and return its entry point address to the caller.
Format
#include <c$to2.h> long TO2_convertMethodName (TO2_ENV_PTR env_ptr, long *class_namelength, char class_name[TO2_MAX_CLASS_NAME], long *method_namelength, char method_name[64]);
Normal Return
TPFCS returns a positive address value as the return value, which is the entry point address of the method in memory.
Error Return
An error return is indicated by a zero. When zero is returned, use the TO2_getErrorCode function to determine the specific error code. For more information, see Error Handling.
The following error codes are common for this function:
TO2_ERROR_CLASS_NOTFOUND
TO2_ERROR_ENV
TO2_ERROR_METHOD_NOTFOUND
TO2_ERROR_NOT_INIT
Programming Considerations
None.
Examples
The following example locates the method address for class methodName new.
#include <c$to2.h> /* Needed for TO2 API Functions */ #include <stdio.h> /* APIs for standard I/O functions */ TO2_ENV_PTR env_ptr; /* Pointer to TO2 environment */ char className[]="OBJECT"; /* class name */ long classNameLength=(sizeof "OBJECT")-1; /* length of */ /* class name */ char methodName[]="new"; /* method name */ long methodNameLength=(sizeof "new")-1; /* length of */ /* method name */ TO2_ERR_CODE to2_rc=1; /* return code receiver */ TO2_ERR_TEXT_PTR err_textPtr; /* TO2 error code text pointer */
·
·
·
{ if ((to2_rc = TO2_convertMethodName(env_ptr, &classNameLength, className, &methodNameLength, methodName)) == TO2_ERROR) { to2_rc = TO2_getErrorCode(env_ptr); err_textPtr = TO2_getErrorText(env_ptr, to2_rc); printf ("TO2_convertMethodName failed, error code - %d\n ", to2_rc); printf ("TO2 Error Text is %s\n ", err_textPtr); } else printf("TO2_convertMethodName successful\n"); }
Related Information