MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / CallMethod

Function CallMethod

source/script_object.cpp:19–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17//
18
19ResultType 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//

Callers 6

ExecuteInNewThreadMethod · 0.85
CallMethod · 0.85
SortUDFFunction · 0.85
RegExCalloutFunction · 0.85
RegisterCallbackCStubFunction · 0.85
MsgMonitorFunction · 0.85

Calls 7

ResultTokenClass · 0.85
TokenIsEmptyStringFunction · 0.85
TokenToInt64Function · 0.85
InitResultMethod · 0.80
UnknownMemberErrorMethod · 0.80
InvokeMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected