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

Function GetEnumerator

source/script_object.cpp:301–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301ResultType GetEnumerator(IObject *&aEnumerator, ExprTokenType &aEnumerable, int aVarCount, bool aDisplayError)
302{
303 FuncResult result_token;
304 ExprTokenType t_count(aVarCount), *param[] = { &t_count };
305 IObject *invokee = TokenToObject(aEnumerable);
306 if (!invokee)
307 invokee = Object::ValueBase(aEnumerable);
308 // enum := object.__Enum(number of vars)
309 // IF_NEWENUM causes ComObjects to invoke a _NewEnum method or property.
310 // IF_BYPASS_METAFUNC causes Objects to skip the __Call meta-function if __Enum is not found.
311 auto result = invokee->Invoke(result_token, IT_CALL | IF_NEWENUM | IF_BYPASS_METAFUNC, _T("__Enum"), aEnumerable, param, 1);
312 if (result == FAIL || result == EARLY_EXIT)
313 return result;
314 if (result == INVOKE_NOT_HANDLED)
315 {
316 aEnumerator = invokee;
317 aEnumerator->AddRef();
318 return OK;
319 }
320 aEnumerator = TokenToObject(result_token);
321 if (aEnumerator)
322 return OK;
323 result_token.Free();
324 if (aDisplayError)
325 g_script.RuntimeError(ERR_TYPE_MISMATCH, _T("__Enum"), FAIL, nullptr, ErrorPrototype::Type);
326 return FAIL;
327}
328
329ResultType CallEnumerator(IObject *aEnumerator, ExprTokenType *aParam[], int aParamCount, bool aDisplayError)
330{

Callers 3

FromEnumerableMethod · 0.85
PerformLoopForMethod · 0.85
WriteEnumItemsMethod · 0.85

Calls 5

TokenToObjectFunction · 0.85
RuntimeErrorMethod · 0.80
InvokeMethod · 0.45
AddRefMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected