| 1391 | |
| 1392 | |
| 1393 | ResultType ComObject::SafeArrayItem(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount) |
| 1394 | { |
| 1395 | SAFEARRAY *psa = (SAFEARRAY*)mVal64; |
| 1396 | VARTYPE item_type = (mVarType & VT_TYPEMASK); |
| 1397 | |
| 1398 | UINT dims = SafeArrayGetDim(psa); |
| 1399 | LONG index[8]; |
| 1400 | // Verify correct number of parameters/dimensions (maximum 8). |
| 1401 | if (dims > _countof(index) || dims != (IS_INVOKE_SET ? aParamCount - 1 : aParamCount)) |
| 1402 | _o_throw(ERR_PARAM_COUNT_INVALID); |
| 1403 | // Adjust aParam for assignment rvalue. |
| 1404 | ExprTokenType *rvalue = IS_INVOKE_SET ? *aParam++ : nullptr; |
| 1405 | // Build array of indices from parameters. |
| 1406 | for (UINT i = 0; i < dims; ++i) |
| 1407 | { |
| 1408 | if (!TokenIsNumeric(*aParam[i])) |
| 1409 | _o_throw_param(i, _T("Number")); |
| 1410 | index[i] = (LONG)TokenToInt64(*aParam[i]); |
| 1411 | } |
| 1412 | |
| 1413 | void *item; |
| 1414 | |
| 1415 | SafeArrayLock(psa); |
| 1416 | |
| 1417 | auto hr = SafeArrayPtrOfIndex(psa, index, &item); |
| 1418 | if (SUCCEEDED(hr)) |
| 1419 | { |
| 1420 | if (rvalue) |
| 1421 | hr = TokenToVarType(*rvalue, item_type, item); |
| 1422 | else |
| 1423 | VarTypeToToken(item_type, item, aResultToken); |
| 1424 | } |
| 1425 | |
| 1426 | SafeArrayUnlock(psa); |
| 1427 | |
| 1428 | if (FAILED(hr)) |
| 1429 | ComError(hr, aResultToken); |
| 1430 | return aResultToken.Result(); |
| 1431 | } |
| 1432 | |
| 1433 | |
| 1434 | LPTSTR ComObject::Type() |
nothing calls this directly
no test coverage detected