Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Windows.Foundation.Collections #259

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions lib/src/com/IIterable`1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// IIterable.dart

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: unused_import

import 'dart:ffi';

import 'package:ffi/ffi.dart';

import '../combase.dart';
import '../constants.dart';
import '../exceptions.dart';
import '../macros.dart';
import '../ole32.dart';
import '../structs.dart';
import '../structs.g.dart';
import '../utils.dart';

import '../winrt/winrt_constants.dart';

import 'IInspectable.dart';
/// @nodoc
const IID_IIterable = '{FAA585EA-6214-4217-AFDA-7F46DE5869B3}';

typedef _First_Native = Int32 Function(
Pointer obj,
Pointer<Pointer> result
);
typedef _First_Dart = int Function(
Pointer obj,
Pointer<Pointer> result
);

/// {@category Interface}
/// {@category winrt}
class IIterable<T> extends IInspectable {
// vtable begins at 6, ends at 6

IIterable(Pointer<COMObject> ptr) : super(ptr);

int First(Pointer<Pointer> result) => ptr.ref.lpVtbl.value .elementAt(6)
.cast<Pointer<NativeFunction<_First_Native>>>()
.value
.asFunction<_First_Dart>()(ptr.ref.lpVtbl, result);

}


91 changes: 91 additions & 0 deletions lib/src/com/IVectorView`1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// IVectorView.dart

// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY.

// ignore_for_file: unused_import

import 'dart:ffi';

import 'package:ffi/ffi.dart';

import '../combase.dart';
import '../constants.dart';
import '../exceptions.dart';
import '../macros.dart';
import '../ole32.dart';
import '../structs.dart';
import '../structs.g.dart';
import '../utils.dart';

import '../winrt/winrt_constants.dart';

/// @nodoc
const IID_IVectorView = '{BBE1FA4C-B0E3-4583-BAEF-1F1B2E483E56}';

typedef _GetAt_Native = Int32 Function(
Pointer obj, Uint32 index, Pointer<Pointer> result);
typedef _GetAt_Dart = int Function(
Pointer obj, int index, Pointer<Pointer> result);

typedef _get_Size_Native = Int32 Function(Pointer obj, Pointer<Uint32> value);
typedef _get_Size_Dart = int Function(Pointer obj, Pointer<Uint32> value);

typedef _IndexOf_Native = Int32 Function(Pointer obj, Pointer value, Pointer<Uint32> index,
Pointer< /* Boolean */ Uint8> result);
typedef _IndexOf_Dart = int Function(Pointer obj, Pointer value, Pointer<Uint32> index,
Pointer< /* Boolean */ Uint8> result);

typedef _GetMany_Native = Int32 Function(
Pointer obj, Uint32 startIndex, Pointer<Pointer> items, Pointer<Uint32> result);
typedef _GetMany_Dart = int Function(
Pointer obj, int startIndex, Pointer<Pointer> items, Pointer<Uint32> result);

/// {@category Interface}
/// {@category winrt}
class IVectorView<T> {
// vtable begins at 6, ends at 9

Pointer<COMObject> ptr;

IVectorView(this.ptr);

int GetAt(int index, Pointer<Pointer> result) => ptr.ref.lpVtbl.value
.elementAt(6)
.cast<Pointer<NativeFunction<_GetAt_Native>>>()
.value
.asFunction<_GetAt_Dart>()(ptr.ref.lpVtbl, index, result);

int get Size {
final retValuePtr = calloc<Uint32>();

try {
final hr = ptr.ref.lpVtbl.value
.elementAt(7)
.cast<Pointer<NativeFunction<_get_Size_Native>>>()
.value
.asFunction<_get_Size_Dart>()(ptr.ref.lpVtbl, retValuePtr);

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

final retValue = retValuePtr.value;
return retValue;
} finally {
free(retValuePtr);
}
}

int IndexOf(
Pointer value, Pointer<Uint32> index, Pointer< /* Boolean */ Uint8> result) =>
ptr.ref.lpVtbl.value
.elementAt(8)
.cast<Pointer<NativeFunction<_IndexOf_Native>>>()
.value
.asFunction<_IndexOf_Dart>()(ptr.ref.lpVtbl, value, index, result);

int GetMany(int startIndex, Pointer<Pointer> items, Pointer<Uint32> result) => ptr
.ref.lpVtbl.value
.elementAt(9)
.cast<Pointer<NativeFunction<_GetMany_Native>>>()
.value
.asFunction<_GetMany_Dart>()(ptr.ref.lpVtbl, startIndex, items, result);
}
2 changes: 2 additions & 0 deletions lib/win32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export 'src/com/IFileOpenDialog.dart';
export 'src/com/IFileOpenPicker.dart';
export 'src/com/IFileSaveDialog.dart';
export 'src/com/IInspectable.dart';
export 'src/com/IIterable`1.dart';
export 'src/com/IKnownFolder.dart';
export 'src/com/IKnownFolderManager.dart';
export 'src/com/IModalWindow.dart';
Expand Down Expand Up @@ -222,6 +223,7 @@ export 'src/com/IUnknown.dart';
export 'src/com/IUri.dart';
export 'src/com/IUserDataPathsStatics.dart';
export 'src/com/IVirtualDesktopManager.dart';
export 'src/com/IVectorView`1.dart';
export 'src/com/IWbemClassObject.dart';
export 'src/com/IWbemContext.dart';
export 'src/com/IWbemLocator.dart';
Expand Down
2 changes: 2 additions & 0 deletions tool/metadata/generate_winrt_apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import 'projection/classprojector.dart';
import 'projection/typeprinter.dart';

final typesToGenerate = [
'Windows.Foundation.Collections.IIterable`1',
'Windows.Foundation.Collections.IVectorView`1',
'Windows.Foundation.IPropertyValue',
'Windows.Foundation.IAsyncAction',
'Windows.Foundation.IAsyncInfo',
Expand Down