Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
style: use lpVtbl and vtable extension getters
Browse files Browse the repository at this point in the history
  • Loading branch information
halildurmus committed Oct 12, 2023
1 parent e21ed9b commit 7a847c3
Show file tree
Hide file tree
Showing 736 changed files with 16,675 additions and 17,330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class IImageFeatureDescriptor extends IInspectable {
final value = calloc<Int32>();

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

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -55,17 +55,17 @@ class IImageFeatureDescriptor extends IInspectable {
final value = calloc<Int32>();

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

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -79,7 +79,7 @@ class IImageFeatureDescriptor extends IInspectable {
final value = calloc<Uint32>();

try {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(8)
.cast<
Pointer<
Expand All @@ -89,7 +89,7 @@ class IImageFeatureDescriptor extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<Uint32> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -103,7 +103,7 @@ class IImageFeatureDescriptor extends IInspectable {
final value = calloc<Uint32>();

try {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(9)
.cast<
Pointer<
Expand All @@ -113,7 +113,7 @@ class IImageFeatureDescriptor extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<Uint32> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) throwWindowsException(hr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ class IImageFeatureDescriptor2 extends IInspectable {
final value = calloc<Int32>();

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

if (FAILED(hr)) throwWindowsException(hr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class IImageFeatureValue extends IInspectable {
VideoFrame? get videoFrame {
final value = calloc<COMObject>();

final hr = ptr.ref.vtable
final hr = vtable
.elementAt(6)
.cast<
Pointer<
Expand All @@ -40,7 +40,7 @@ class IImageFeatureValue extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<COMObject> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) {
free(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IImageFeatureValueStatics extends IInspectable {
ImageFeatureValue? createFromVideoFrame(VideoFrame? image) {
final result = calloc<COMObject>();

final hr = ptr.ref.vtable
final hr = vtable
.elementAt(6)
.cast<
Pointer<
Expand All @@ -41,11 +41,8 @@ class IImageFeatureValueStatics extends IInspectable {
Pointer<COMObject> result)>>>()
.value
.asFunction<
int Function(
VTablePointer lpVtbl,
VTablePointer image,
Pointer<COMObject>
result)>()(ptr.ref.lpVtbl, image.lpVtbl, result);
int Function(VTablePointer lpVtbl, VTablePointer image,
Pointer<COMObject> result)>()(lpVtbl, image.lpVtbl, result);

if (FAILED(hr)) {
free(result);
Expand Down
50 changes: 25 additions & 25 deletions packages/windows_ai/lib/src/machinelearning/ilearningmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ILearningModel extends IInspectable {
final value = calloc<IntPtr>();

try {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(6)
.cast<
Pointer<
Expand All @@ -42,7 +42,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<IntPtr> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -56,7 +56,7 @@ class ILearningModel extends IInspectable {
final value = calloc<IntPtr>();

try {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(7)
.cast<
Pointer<
Expand All @@ -66,7 +66,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<IntPtr> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -80,7 +80,7 @@ class ILearningModel extends IInspectable {
final value = calloc<IntPtr>();

try {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(8)
.cast<
Pointer<
Expand All @@ -90,7 +90,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<IntPtr> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -104,7 +104,7 @@ class ILearningModel extends IInspectable {
final value = calloc<IntPtr>();

try {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(9)
.cast<
Pointer<
Expand All @@ -114,7 +114,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<IntPtr> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -128,17 +128,17 @@ class ILearningModel extends IInspectable {
final value = calloc<Int64>();

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

if (FAILED(hr)) throwWindowsException(hr);

Expand All @@ -151,7 +151,7 @@ class ILearningModel extends IInspectable {
Map<String, String>? get metadata {
final value = calloc<COMObject>();

final hr = ptr.ref.vtable
final hr = vtable
.elementAt(11)
.cast<
Pointer<
Expand All @@ -161,7 +161,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<COMObject> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) {
free(value);
Expand All @@ -181,7 +181,7 @@ class ILearningModel extends IInspectable {
List<ILearningModelFeatureDescriptor?>? get inputFeatures {
final value = calloc<COMObject>();

final hr = ptr.ref.vtable
final hr = vtable
.elementAt(12)
.cast<
Pointer<
Expand All @@ -191,7 +191,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<COMObject> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) {
free(value);
Expand All @@ -212,7 +212,7 @@ class ILearningModel extends IInspectable {
List<ILearningModelFeatureDescriptor?>? get outputFeatures {
final value = calloc<COMObject>();

final hr = ptr.ref.vtable
final hr = vtable
.elementAt(13)
.cast<
Pointer<
Expand All @@ -222,7 +222,7 @@ class ILearningModel extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, Pointer<COMObject> value)>()(
ptr.ref.lpVtbl, value);
lpVtbl, value);

if (FAILED(hr)) {
free(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ILearningModelBinding extends IInspectable {
interface.cast(ILearningModelBinding.fromPtr, IID_ILearningModelBinding);

void bind(String name, Object? value) {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(6)
.cast<
Pointer<
Expand All @@ -38,13 +38,13 @@ class ILearningModelBinding extends IInspectable {
.asFunction<
int Function(
VTablePointer lpVtbl, int name, VTablePointer value)>()(
ptr.ref.lpVtbl, name.toHString(), value?.boxValue().lpVtbl ?? nullptr);
lpVtbl, name.toHString(), value?.boxValue().lpVtbl ?? nullptr);

if (FAILED(hr)) throwWindowsException(hr);
}

void bindWithProperties(String name, Object? value, IPropertySet? props) {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(7)
.cast<
Pointer<
Expand All @@ -54,18 +54,18 @@ class ILearningModelBinding extends IInspectable {
.value
.asFunction<
int Function(VTablePointer lpVtbl, int name,
VTablePointer value, VTablePointer props)>()(ptr.ref.lpVtbl,
VTablePointer value, VTablePointer props)>()(lpVtbl,
name.toHString(), value?.boxValue().lpVtbl ?? nullptr, props.lpVtbl);

if (FAILED(hr)) throwWindowsException(hr);
}

void clear() {
final hr = ptr.ref.vtable
final hr = vtable
.elementAt(8)
.cast<Pointer<NativeFunction<HRESULT Function(VTablePointer lpVtbl)>>>()
.value
.asFunction<int Function(VTablePointer lpVtbl)>()(ptr.ref.lpVtbl);
.asFunction<int Function(VTablePointer lpVtbl)>()(lpVtbl);

if (FAILED(hr)) throwWindowsException(hr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ class ILearningModelBindingFactory extends IInspectable {
LearningModelBinding createFromSession(LearningModelSession? session) {
final value = calloc<COMObject>();

final hr =
ptr.ref.vtable
.elementAt(6)
.cast<
Pointer<
NativeFunction<
HRESULT Function(
VTablePointer lpVtbl,
VTablePointer session,
Pointer<COMObject> value)>>>()
.value
.asFunction<
int Function(VTablePointer lpVtbl, VTablePointer session,
Pointer<COMObject> value)>()(
ptr.ref.lpVtbl, session.lpVtbl, value);
final hr = vtable
.elementAt(6)
.cast<
Pointer<
NativeFunction<
HRESULT Function(VTablePointer lpVtbl,
VTablePointer session, Pointer<COMObject> value)>>>()
.value
.asFunction<
int Function(VTablePointer lpVtbl, VTablePointer session,
Pointer<COMObject> value)>()(lpVtbl, session.lpVtbl, value);

if (FAILED(hr)) {
free(value);
Expand Down
Loading

0 comments on commit 7a847c3

Please sign in to comment.