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.
| 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. |
| 347 | Array *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, ¶m, 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 | // |
nothing calls this directly
no test coverage detected