getView method

List<T> getView()

Returns an immutable view of the vector.

Implementation

List<T> getView() {
  final retValuePtr = calloc<COMObject>();

  try {
    final hr = ptr.ref.vtable
            .elementAt(8)
            .cast<
                Pointer<
                    NativeFunction<
                        HRESULT Function(Pointer, Pointer<COMObject>)>>>()
            .value
            .asFunction<int Function(Pointer, Pointer<COMObject>)>()(
        ptr.ref.lpVtbl, retValuePtr);

    if (FAILED(hr)) throw WindowsException(hr);

    return IVectorView.fromRawPointer(
      retValuePtr,
      creator: _creator,
      enumCreator: _enumCreator,
      iterableIid: _iterableIid,
      intType: _intType,
    ).toList();
  } finally {
    free(retValuePtr);
  }
}