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

Method FromEnumerable

source/script_object.cpp:347–375  ·  view source on GitHub ↗

Calls an Enumerator repeatedly and returns an Array of all first-arg values. This is used in conjunction with Array::ToParams to support other objects.

Source from the content-addressed store, hash-verified

345// Calls an Enumerator repeatedly and returns an Array of all first-arg values.
346// This is used in conjunction with Array::ToParams to support other objects.
347Array *Array::FromEnumerable(ExprTokenType &aEnumerable)
348{
349 IObject *enumerator;
350 auto result = GetEnumerator(enumerator, aEnumerable, 1, true);
351 if (result == FAIL || result == EARLY_EXIT)
352 return nullptr;
353
354 auto varref = new VarRef();
355 ExprTokenType tvar { varref }, *param = &tvar;
356 Array *vargs = Array::Create();
357 for (;;)
358 {
359 auto result = CallEnumerator(enumerator, &param, 1, true);
360 if (result == FAIL)
361 {
362 vargs->Release();
363 vargs = nullptr;
364 break;
365 }
366 if (result != CONDITION_TRUE)
367 break;
368 ExprTokenType value;
369 varref->ToTokenSkipAddRef(value);
370 vargs->Append(value);
371 }
372 varref->Release();
373 enumerator->Release();
374 return vargs;
375}
376
377
378//

Callers

nothing calls this directly

Calls 5

GetEnumeratorFunction · 0.85
CallEnumeratorFunction · 0.85
ToTokenSkipAddRefMethod · 0.80
ReleaseMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected