| 17 | // |
| 18 | |
| 19 | ResultType CallMethod(IObject *aInvokee, IObject *aThis, LPTSTR aMethodName |
| 20 | , ExprTokenType *aParamValue, int aParamCount, __int64 *aRetVal // For event handlers. |
| 21 | , int aExtraFlags) // For Object.__Delete(). |
| 22 | { |
| 23 | ResultToken result_token; |
| 24 | TCHAR result_buf[MAX_NUMBER_SIZE]; |
| 25 | result_token.InitResult(result_buf); |
| 26 | |
| 27 | ExprTokenType this_token(aThis); |
| 28 | |
| 29 | ExprTokenType **param = (ExprTokenType **)_alloca(aParamCount * sizeof(ExprTokenType *)); |
| 30 | for (int i = 0; i < aParamCount; ++i) |
| 31 | param[i] = aParamValue + i; |
| 32 | |
| 33 | ResultType result = aInvokee->Invoke(result_token, IT_CALL | aExtraFlags, aMethodName, this_token, param, aParamCount); |
| 34 | |
| 35 | // Exceptions are thrown by Invoke for too few/many parameters, but not for non-existent method. |
| 36 | // Check for that here, with the exception that objects are permitted to lack a __Delete method. |
| 37 | if (result == INVOKE_NOT_HANDLED && !(aExtraFlags & IF_BYPASS_METAFUNC)) |
| 38 | result = ResultToken().UnknownMemberError(this_token, IT_CALL, aMethodName); |
| 39 | |
| 40 | if (result != EARLY_EXIT && result != FAIL) |
| 41 | { |
| 42 | // Indicate to caller whether an integer value was returned (for MsgMonitor()). |
| 43 | result = TokenIsEmptyString(result_token) ? OK : EARLY_RETURN; |
| 44 | } |
| 45 | |
| 46 | if (aRetVal) // Always set this as some callers don't initialize it: |
| 47 | *aRetVal = result == EARLY_RETURN ? TokenToInt64(result_token) : 0; |
| 48 | |
| 49 | result_token.Free(); |
| 50 | return result; |
| 51 | } |
| 52 | |
| 53 | |
| 54 | // |
no test coverage detected