Skip to content

Commit

Permalink
refactor: refactor the projection of PassArray style array paramete…
Browse files Browse the repository at this point in the history
…rs (#326)
  • Loading branch information
halildurmus committed Jul 25, 2023
1 parent c4ddb4a commit ca45f92
Show file tree
Hide file tree
Showing 151 changed files with 2,117 additions and 1,417 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ILearningModelBinding extends IInspectable {
.asFunction<
int Function(
VTablePointer lpVtbl, int name, VTablePointer value)>()(
ptr.ref.lpVtbl, name.toHString(), value?.intoBox().lpVtbl ?? nullptr);
ptr.ref.lpVtbl, name.toHString(), value?.boxValue().lpVtbl ?? nullptr);

if (FAILED(hr)) throwWindowsException(hr);
}
Expand All @@ -56,7 +56,7 @@ class ILearningModelBinding extends IInspectable {
.asFunction<
int Function(VTablePointer lpVtbl, int name,
VTablePointer value, VTablePointer props)>()(ptr.ref.lpVtbl,
name.toHString(), value?.intoBox().lpVtbl ?? nullptr, props.lpVtbl);
name.toHString(), value?.boxValue().lpVtbl ?? nullptr, props.lpVtbl);

if (FAILED(hr)) throwWindowsException(hr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorBooleanStatics extends IInspectable {

TensorBoolean? createFromArray(IIterable<int>? shape, List<bool> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Bool>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorBooleanStatics2 extends IInspectable {
TensorBoolean? createFromShapeArrayAndDataArray(
List<int> shape, List<bool> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Bool>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorBooleanStatics2 extends IInspectable {

TensorBoolean? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorDoubleStatics extends IInspectable {

TensorDouble? createFromArray(IIterable<int>? shape, List<double> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Double>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Double>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorDoubleStatics2 extends IInspectable {
TensorDouble? createFromShapeArrayAndDataArray(
List<int> shape, List<double> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Double>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Double>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorDoubleStatics2 extends IInspectable {

TensorDouble? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorFloat16BitStatics extends IInspectable {

TensorFloat16Bit? createFromArray(IIterable<int>? shape, List<double> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Float>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Float>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorFloat16BitStatics2 extends IInspectable {
TensorFloat16Bit? createFromShapeArrayAndDataArray(
List<int> shape, List<double> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Float>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Float>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorFloat16BitStatics2 extends IInspectable {

TensorFloat16Bit? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorFloatStatics extends IInspectable {

TensorFloat? createFromArray(IIterable<int>? shape, List<double> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Float>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Float>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorFloatStatics2 extends IInspectable {
TensorFloat? createFromShapeArrayAndDataArray(
List<int> shape, List<double> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Float>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Float>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorFloatStatics2 extends IInspectable {

TensorFloat? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorInt16BitStatics extends IInspectable {

TensorInt16Bit? createFromArray(IIterable<int>? shape, List<int> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Int16>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Int16>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorInt16BitStatics2 extends IInspectable {
TensorInt16Bit? createFromShapeArrayAndDataArray(
List<int> shape, List<int> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Int16>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Int16>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorInt16BitStatics2 extends IInspectable {

TensorInt16Bit? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorInt32BitStatics extends IInspectable {

TensorInt32Bit? createFromArray(IIterable<int>? shape, List<int> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Int32>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Int32>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorInt32BitStatics2 extends IInspectable {
TensorInt32Bit? createFromShapeArrayAndDataArray(
List<int> shape, List<int> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Int32>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Int32>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorInt32BitStatics2 extends IInspectable {

TensorInt32Bit? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorInt64BitStatics extends IInspectable {

TensorInt64Bit? createFromArray(IIterable<int>? shape, List<int> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Int64>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorInt64BitStatics2 extends IInspectable {
TensorInt64Bit? createFromShapeArrayAndDataArray(
List<int> shape, List<int> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Int64>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorInt64BitStatics2 extends IInspectable {

TensorInt64Bit? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorInt8BitStatics extends IInspectable {

TensorInt8Bit? createFromArray(IIterable<int>? shape, List<int> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Uint8>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Uint8>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ class ITensorInt8BitStatics2 extends IInspectable {
TensorInt8Bit? createFromShapeArrayAndDataArray(
List<int> shape, List<int> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<Uint8>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray<Uint8>();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down Expand Up @@ -83,10 +77,7 @@ class ITensorInt8BitStatics2 extends IInspectable {

TensorInt8Bit? createFromBuffer(List<int> shape, IBuffer? buffer) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final shapeArray = shape.toArray<Int64>();

final hr = ptr.ref.vtable
.elementAt(7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorStringStatics extends IInspectable {

TensorString? createFromArray(IIterable<int>? shape, List<String> data) {
final result = calloc<COMObject>();
final dataArray = calloc<IntPtr>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i].toHString();
}
final dataArray = data.toArray();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ class ITensorStringStatics2 extends IInspectable {
TensorString? createFromShapeArrayAndDataArray(
List<int> shape, List<String> data) {
final result = calloc<COMObject>();
final shapeArray = calloc<Int64>(shape.length);
for (var i = 0; i < shape.length; i++) {
shapeArray[i] = shape[i];
}
final dataArray = calloc<IntPtr>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i].toHString();
}
final shapeArray = shape.toArray<Int64>();
final dataArray = data.toArray();

final hr = ptr.ref.vtable
.elementAt(6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ class ITensorUInt16BitStatics extends IInspectable {

TensorUInt16Bit? createFromArray(IIterable<int>? shape, List<int> data) {
final result = calloc<COMObject>();
final dataArray = calloc<Uint16>(data.length);
for (var i = 0; i < data.length; i++) {
dataArray[i] = data[i];
}
final dataArray = data.toArray<Uint16>();

final hr = ptr.ref.vtable
.elementAt(8)
Expand Down
Loading

0 comments on commit ca45f92

Please sign in to comment.