| 299 | } |
| 300 | |
| 301 | ResultType 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 | |
| 329 | ResultType CallEnumerator(IObject *aEnumerator, ExprTokenType *aParam[], int aParamCount, bool aDisplayError) |
| 330 | { |
no test coverage detected