| // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| // |
| // This file has been automatically generated. Please do not edit it manually. |
| // |
| // SharedObjects=ffi_test_functions |
| // VMOptions= |
| // VMOptions=--deterministic --optimization-counter-threshold=5 |
| // VMOptions=--use-slow-path |
| // VMOptions=--use-slow-path --stacktrace-every=100 |
| |
| // @dart = 2.9 |
| |
| import 'dart:ffi'; |
| |
| import "package:expect/expect.dart"; |
| import "package:ffi/ffi.dart"; |
| |
| import 'dylib_utils.dart'; |
| |
| final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions"); |
| void main() { |
| for (int i = 0; i < 10; ++i) { |
| testPassStruct1ByteIntx10(); |
| testPassStruct3BytesHomogeneousUint8x10(); |
| testPassStruct3BytesInt2ByteAlignedx10(); |
| testPassStruct4BytesHomogeneousInt16x10(); |
| testPassStruct7BytesHomogeneousUint8x10(); |
| testPassStruct7BytesInt4ByteAlignedx10(); |
| testPassStruct8BytesIntx10(); |
| testPassStruct8BytesHomogeneousFloatx10(); |
| testPassStruct8BytesMixedx10(); |
| testPassStruct9BytesHomogeneousUint8x10(); |
| testPassStruct9BytesInt4Or8ByteAlignedx10(); |
| testPassStruct12BytesHomogeneousFloatx6(); |
| testPassStruct16BytesHomogeneousFloatx5(); |
| testPassStruct16BytesMixedx10(); |
| testPassStruct16BytesMixed2x10(); |
| testPassStruct17BytesIntx10(); |
| testPassStruct19BytesHomogeneousUint8x10(); |
| testPassStruct20BytesHomogeneousInt32x10(); |
| testPassStruct20BytesHomogeneousFloat(); |
| testPassStruct32BytesHomogeneousDoublex5(); |
| testPassStruct40BytesHomogeneousDouble(); |
| testPassStruct1024BytesHomogeneousUint64(); |
| testPassFloatStruct16BytesHomogeneousFloatFloatStruct1(); |
| testPassFloatStruct32BytesHomogeneousDoubleFloatStruct(); |
| testPassInt8Struct16BytesMixedInt8Struct16BytesMixedIn(); |
| testPassDoublex6Struct16BytesMixedx4Int32(); |
| testPassInt32x4Struct16BytesMixedx4Double(); |
| testPassStruct40BytesHomogeneousDoubleStruct4BytesHomo(); |
| testPassInt32x8Doublex8Int64Int8Struct1ByteIntInt64Int(); |
| testPassStructAlignmentInt16(); |
| testPassStructAlignmentInt32(); |
| testPassStructAlignmentInt64(); |
| testPassStruct8BytesNestedIntx10(); |
| testPassStruct8BytesNestedFloatx10(); |
| testPassStruct8BytesNestedFloat2x10(); |
| testPassStruct8BytesNestedMixedx10(); |
| testPassStruct16BytesNestedIntx2(); |
| testPassStruct32BytesNestedIntx2(); |
| testPassStructNestedIntStructAlignmentInt16(); |
| testPassStructNestedIntStructAlignmentInt32(); |
| testPassStructNestedIntStructAlignmentInt64(); |
| testPassStructNestedIrregularEvenBiggerx4(); |
| testPassStruct8BytesInlineArrayIntx4(); |
| testPassStructInlineArrayIrregularx4(); |
| testPassStructInlineArray100Bytes(); |
| testPassStructStruct16BytesHomogeneousFloat2x5(); |
| testPassStructStruct32BytesHomogeneousDouble2x5(); |
| testPassStructStruct16BytesMixed3x10(); |
| testPassUint8Struct32BytesInlineArrayMultiDimensionalI(); |
| testPassUint8Struct4BytesInlineArrayMultiDimensionalIn(); |
| testPassStruct3BytesPackedIntx10(); |
| testPassStruct8BytesPackedIntx10(); |
| testPassStruct9BytesPackedMixedx10DoubleInt32x2(); |
| testPassStruct5BytesPackedMixed(); |
| testPassStructNestedAlignmentStruct5BytesPackedMixed(); |
| testPassStruct6BytesInlineArrayInt(); |
| testPassStruct15BytesInlineArrayMixed(); |
| testPassUnion4BytesMixedx10(); |
| testPassUnion8BytesNestedFloatx10(); |
| testPassUnion9BytesNestedIntx10(); |
| testPassUnion16BytesNestedInlineArrayFloatx10(); |
| testPassUnion16BytesNestedFloatx10(); |
| testReturnStruct1ByteInt(); |
| testReturnStruct3BytesHomogeneousUint8(); |
| testReturnStruct3BytesInt2ByteAligned(); |
| testReturnStruct4BytesHomogeneousInt16(); |
| testReturnStruct7BytesHomogeneousUint8(); |
| testReturnStruct7BytesInt4ByteAligned(); |
| testReturnStruct8BytesInt(); |
| testReturnStruct8BytesHomogeneousFloat(); |
| testReturnStruct8BytesMixed(); |
| testReturnStruct9BytesHomogeneousUint8(); |
| testReturnStruct9BytesInt4Or8ByteAligned(); |
| testReturnStruct12BytesHomogeneousFloat(); |
| testReturnStruct16BytesHomogeneousFloat(); |
| testReturnStruct16BytesMixed(); |
| testReturnStruct16BytesMixed2(); |
| testReturnStruct17BytesInt(); |
| testReturnStruct19BytesHomogeneousUint8(); |
| testReturnStruct20BytesHomogeneousInt32(); |
| testReturnStruct20BytesHomogeneousFloat(); |
| testReturnStruct32BytesHomogeneousDouble(); |
| testReturnStruct40BytesHomogeneousDouble(); |
| testReturnStruct1024BytesHomogeneousUint64(); |
| testReturnStruct3BytesPackedInt(); |
| testReturnStruct8BytesPackedInt(); |
| testReturnStruct9BytesPackedMixed(); |
| testReturnUnion4BytesMixed(); |
| testReturnUnion8BytesNestedFloat(); |
| testReturnUnion9BytesNestedInt(); |
| testReturnUnion16BytesNestedFloat(); |
| testReturnStructArgumentStruct1ByteInt(); |
| testReturnStructArgumentInt32x8Struct1ByteInt(); |
| testReturnStructArgumentStruct8BytesHomogeneousFloat(); |
| testReturnStructArgumentStruct20BytesHomogeneousInt32(); |
| testReturnStructArgumentInt32x8Struct20BytesHomogeneou(); |
| testReturnStructArgumentStruct8BytesInlineArrayInt(); |
| testReturnStructArgumentStructStruct16BytesHomogeneous(); |
| testReturnStructArgumentStructStruct32BytesHomogeneous(); |
| testReturnStructArgumentStructStruct16BytesMixed3(); |
| testReturnStructAlignmentInt16(); |
| testReturnStructAlignmentInt32(); |
| testReturnStructAlignmentInt64(); |
| testReturnStruct8BytesNestedInt(); |
| testReturnStruct8BytesNestedFloat(); |
| testReturnStruct8BytesNestedFloat2(); |
| testReturnStruct8BytesNestedMixed(); |
| testReturnStruct16BytesNestedInt(); |
| testReturnStruct32BytesNestedInt(); |
| testReturnStructNestedIntStructAlignmentInt16(); |
| testReturnStructNestedIntStructAlignmentInt32(); |
| testReturnStructNestedIntStructAlignmentInt64(); |
| testReturnStructNestedIrregularEvenBigger(); |
| testPassStruct1ByteIntx10Leaf(); |
| testPassStruct3BytesHomogeneousUint8x10Leaf(); |
| testPassStruct3BytesInt2ByteAlignedx10Leaf(); |
| testPassStruct4BytesHomogeneousInt16x10Leaf(); |
| testPassStruct7BytesHomogeneousUint8x10Leaf(); |
| testPassStruct7BytesInt4ByteAlignedx10Leaf(); |
| testPassStruct8BytesIntx10Leaf(); |
| testPassStruct8BytesHomogeneousFloatx10Leaf(); |
| testPassStruct8BytesMixedx10Leaf(); |
| testPassStruct9BytesHomogeneousUint8x10Leaf(); |
| testPassStruct9BytesInt4Or8ByteAlignedx10Leaf(); |
| testPassStruct12BytesHomogeneousFloatx6Leaf(); |
| testPassStruct16BytesHomogeneousFloatx5Leaf(); |
| testPassStruct16BytesMixedx10Leaf(); |
| testPassStruct16BytesMixed2x10Leaf(); |
| testPassStruct17BytesIntx10Leaf(); |
| testPassStruct19BytesHomogeneousUint8x10Leaf(); |
| testPassStruct20BytesHomogeneousInt32x10Leaf(); |
| testPassStruct20BytesHomogeneousFloatLeaf(); |
| testPassStruct32BytesHomogeneousDoublex5Leaf(); |
| testPassStruct40BytesHomogeneousDoubleLeaf(); |
| testPassStruct1024BytesHomogeneousUint64Leaf(); |
| testPassFloatStruct16BytesHomogeneousFloatFloatStruct1Leaf(); |
| testPassFloatStruct32BytesHomogeneousDoubleFloatStructLeaf(); |
| testPassInt8Struct16BytesMixedInt8Struct16BytesMixedInLeaf(); |
| testPassDoublex6Struct16BytesMixedx4Int32Leaf(); |
| testPassInt32x4Struct16BytesMixedx4DoubleLeaf(); |
| testPassStruct40BytesHomogeneousDoubleStruct4BytesHomoLeaf(); |
| testPassInt32x8Doublex8Int64Int8Struct1ByteIntInt64IntLeaf(); |
| testPassStructAlignmentInt16Leaf(); |
| testPassStructAlignmentInt32Leaf(); |
| testPassStructAlignmentInt64Leaf(); |
| testPassStruct8BytesNestedIntx10Leaf(); |
| testPassStruct8BytesNestedFloatx10Leaf(); |
| testPassStruct8BytesNestedFloat2x10Leaf(); |
| testPassStruct8BytesNestedMixedx10Leaf(); |
| testPassStruct16BytesNestedIntx2Leaf(); |
| testPassStruct32BytesNestedIntx2Leaf(); |
| testPassStructNestedIntStructAlignmentInt16Leaf(); |
| testPassStructNestedIntStructAlignmentInt32Leaf(); |
| testPassStructNestedIntStructAlignmentInt64Leaf(); |
| testPassStructNestedIrregularEvenBiggerx4Leaf(); |
| testPassStruct8BytesInlineArrayIntx4Leaf(); |
| testPassStructInlineArrayIrregularx4Leaf(); |
| testPassStructInlineArray100BytesLeaf(); |
| testPassStructStruct16BytesHomogeneousFloat2x5Leaf(); |
| testPassStructStruct32BytesHomogeneousDouble2x5Leaf(); |
| testPassStructStruct16BytesMixed3x10Leaf(); |
| testPassUint8Struct32BytesInlineArrayMultiDimensionalILeaf(); |
| testPassUint8Struct4BytesInlineArrayMultiDimensionalInLeaf(); |
| testPassStruct3BytesPackedIntx10Leaf(); |
| testPassStruct8BytesPackedIntx10Leaf(); |
| testPassStruct9BytesPackedMixedx10DoubleInt32x2Leaf(); |
| testPassStruct5BytesPackedMixedLeaf(); |
| testPassStructNestedAlignmentStruct5BytesPackedMixedLeaf(); |
| testPassStruct6BytesInlineArrayIntLeaf(); |
| testPassStruct15BytesInlineArrayMixedLeaf(); |
| testPassUnion4BytesMixedx10Leaf(); |
| testPassUnion8BytesNestedFloatx10Leaf(); |
| testPassUnion9BytesNestedIntx10Leaf(); |
| testPassUnion16BytesNestedInlineArrayFloatx10Leaf(); |
| testPassUnion16BytesNestedFloatx10Leaf(); |
| testReturnStruct1ByteIntLeaf(); |
| testReturnStruct3BytesHomogeneousUint8Leaf(); |
| testReturnStruct3BytesInt2ByteAlignedLeaf(); |
| testReturnStruct4BytesHomogeneousInt16Leaf(); |
| testReturnStruct7BytesHomogeneousUint8Leaf(); |
| testReturnStruct7BytesInt4ByteAlignedLeaf(); |
| testReturnStruct8BytesIntLeaf(); |
| testReturnStruct8BytesHomogeneousFloatLeaf(); |
| testReturnStruct8BytesMixedLeaf(); |
| testReturnStruct9BytesHomogeneousUint8Leaf(); |
| testReturnStruct9BytesInt4Or8ByteAlignedLeaf(); |
| testReturnStruct12BytesHomogeneousFloatLeaf(); |
| testReturnStruct16BytesHomogeneousFloatLeaf(); |
| testReturnStruct16BytesMixedLeaf(); |
| testReturnStruct16BytesMixed2Leaf(); |
| testReturnStruct17BytesIntLeaf(); |
| testReturnStruct19BytesHomogeneousUint8Leaf(); |
| testReturnStruct20BytesHomogeneousInt32Leaf(); |
| testReturnStruct20BytesHomogeneousFloatLeaf(); |
| testReturnStruct32BytesHomogeneousDoubleLeaf(); |
| testReturnStruct40BytesHomogeneousDoubleLeaf(); |
| testReturnStruct1024BytesHomogeneousUint64Leaf(); |
| testReturnStruct3BytesPackedIntLeaf(); |
| testReturnStruct8BytesPackedIntLeaf(); |
| testReturnStruct9BytesPackedMixedLeaf(); |
| testReturnUnion4BytesMixedLeaf(); |
| testReturnUnion8BytesNestedFloatLeaf(); |
| testReturnUnion9BytesNestedIntLeaf(); |
| testReturnUnion16BytesNestedFloatLeaf(); |
| testReturnStructArgumentStruct1ByteIntLeaf(); |
| testReturnStructArgumentInt32x8Struct1ByteIntLeaf(); |
| testReturnStructArgumentStruct8BytesHomogeneousFloatLeaf(); |
| testReturnStructArgumentStruct20BytesHomogeneousInt32Leaf(); |
| testReturnStructArgumentInt32x8Struct20BytesHomogeneouLeaf(); |
| testReturnStructArgumentStruct8BytesInlineArrayIntLeaf(); |
| testReturnStructArgumentStructStruct16BytesHomogeneousLeaf(); |
| testReturnStructArgumentStructStruct32BytesHomogeneousLeaf(); |
| testReturnStructArgumentStructStruct16BytesMixed3Leaf(); |
| testReturnStructAlignmentInt16Leaf(); |
| testReturnStructAlignmentInt32Leaf(); |
| testReturnStructAlignmentInt64Leaf(); |
| testReturnStruct8BytesNestedIntLeaf(); |
| testReturnStruct8BytesNestedFloatLeaf(); |
| testReturnStruct8BytesNestedFloat2Leaf(); |
| testReturnStruct8BytesNestedMixedLeaf(); |
| testReturnStruct16BytesNestedIntLeaf(); |
| testReturnStruct32BytesNestedIntLeaf(); |
| testReturnStructNestedIntStructAlignmentInt16Leaf(); |
| testReturnStructNestedIntStructAlignmentInt32Leaf(); |
| testReturnStructNestedIntStructAlignmentInt64Leaf(); |
| testReturnStructNestedIrregularEvenBiggerLeaf(); |
| } |
| } |
| |
| class Struct1ByteInt extends Struct { |
| @Int8() |
| int a0; |
| |
| String toString() => "(${a0})"; |
| } |
| |
| class Struct3BytesHomogeneousUint8 extends Struct { |
| @Uint8() |
| int a0; |
| |
| @Uint8() |
| int a1; |
| |
| @Uint8() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct3BytesInt2ByteAligned extends Struct { |
| @Int16() |
| int a0; |
| |
| @Int8() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct4BytesHomogeneousInt16 extends Struct { |
| @Int16() |
| int a0; |
| |
| @Int16() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct4BytesFloat extends Struct { |
| @Float() |
| double a0; |
| |
| String toString() => "(${a0})"; |
| } |
| |
| class Struct7BytesHomogeneousUint8 extends Struct { |
| @Uint8() |
| int a0; |
| |
| @Uint8() |
| int a1; |
| |
| @Uint8() |
| int a2; |
| |
| @Uint8() |
| int a3; |
| |
| @Uint8() |
| int a4; |
| |
| @Uint8() |
| int a5; |
| |
| @Uint8() |
| int a6; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6})"; |
| } |
| |
| class Struct7BytesInt4ByteAligned extends Struct { |
| @Int32() |
| int a0; |
| |
| @Int16() |
| int a1; |
| |
| @Int8() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct8BytesInt extends Struct { |
| @Int16() |
| int a0; |
| |
| @Int16() |
| int a1; |
| |
| @Int32() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct8BytesHomogeneousFloat extends Struct { |
| @Float() |
| double a0; |
| |
| @Float() |
| double a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct8BytesFloat extends Struct { |
| @Double() |
| double a0; |
| |
| String toString() => "(${a0})"; |
| } |
| |
| class Struct8BytesMixed extends Struct { |
| @Float() |
| double a0; |
| |
| @Int16() |
| int a1; |
| |
| @Int16() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct9BytesHomogeneousUint8 extends Struct { |
| @Uint8() |
| int a0; |
| |
| @Uint8() |
| int a1; |
| |
| @Uint8() |
| int a2; |
| |
| @Uint8() |
| int a3; |
| |
| @Uint8() |
| int a4; |
| |
| @Uint8() |
| int a5; |
| |
| @Uint8() |
| int a6; |
| |
| @Uint8() |
| int a7; |
| |
| @Uint8() |
| int a8; |
| |
| String toString() => |
| "(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8})"; |
| } |
| |
| class Struct9BytesInt4Or8ByteAligned extends Struct { |
| @Int64() |
| int a0; |
| |
| @Int8() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct12BytesHomogeneousFloat extends Struct { |
| @Float() |
| double a0; |
| |
| @Float() |
| double a1; |
| |
| @Float() |
| double a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct16BytesHomogeneousFloat extends Struct { |
| @Float() |
| double a0; |
| |
| @Float() |
| double a1; |
| |
| @Float() |
| double a2; |
| |
| @Float() |
| double a3; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3})"; |
| } |
| |
| class Struct16BytesMixed extends Struct { |
| @Double() |
| double a0; |
| |
| @Int64() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct16BytesMixed2 extends Struct { |
| @Float() |
| double a0; |
| |
| @Float() |
| double a1; |
| |
| @Float() |
| double a2; |
| |
| @Int32() |
| int a3; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3})"; |
| } |
| |
| class Struct17BytesInt extends Struct { |
| @Int64() |
| int a0; |
| |
| @Int64() |
| int a1; |
| |
| @Int8() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct19BytesHomogeneousUint8 extends Struct { |
| @Uint8() |
| int a0; |
| |
| @Uint8() |
| int a1; |
| |
| @Uint8() |
| int a2; |
| |
| @Uint8() |
| int a3; |
| |
| @Uint8() |
| int a4; |
| |
| @Uint8() |
| int a5; |
| |
| @Uint8() |
| int a6; |
| |
| @Uint8() |
| int a7; |
| |
| @Uint8() |
| int a8; |
| |
| @Uint8() |
| int a9; |
| |
| @Uint8() |
| int a10; |
| |
| @Uint8() |
| int a11; |
| |
| @Uint8() |
| int a12; |
| |
| @Uint8() |
| int a13; |
| |
| @Uint8() |
| int a14; |
| |
| @Uint8() |
| int a15; |
| |
| @Uint8() |
| int a16; |
| |
| @Uint8() |
| int a17; |
| |
| @Uint8() |
| int a18; |
| |
| String toString() => |
| "(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8}, ${a9}, ${a10}, ${a11}, ${a12}, ${a13}, ${a14}, ${a15}, ${a16}, ${a17}, ${a18})"; |
| } |
| |
| class Struct20BytesHomogeneousInt32 extends Struct { |
| @Int32() |
| int a0; |
| |
| @Int32() |
| int a1; |
| |
| @Int32() |
| int a2; |
| |
| @Int32() |
| int a3; |
| |
| @Int32() |
| int a4; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"; |
| } |
| |
| class Struct20BytesHomogeneousFloat extends Struct { |
| @Float() |
| double a0; |
| |
| @Float() |
| double a1; |
| |
| @Float() |
| double a2; |
| |
| @Float() |
| double a3; |
| |
| @Float() |
| double a4; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"; |
| } |
| |
| class Struct32BytesHomogeneousDouble extends Struct { |
| @Double() |
| double a0; |
| |
| @Double() |
| double a1; |
| |
| @Double() |
| double a2; |
| |
| @Double() |
| double a3; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3})"; |
| } |
| |
| class Struct40BytesHomogeneousDouble extends Struct { |
| @Double() |
| double a0; |
| |
| @Double() |
| double a1; |
| |
| @Double() |
| double a2; |
| |
| @Double() |
| double a3; |
| |
| @Double() |
| double a4; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"; |
| } |
| |
| class Struct1024BytesHomogeneousUint64 extends Struct { |
| @Uint64() |
| int a0; |
| |
| @Uint64() |
| int a1; |
| |
| @Uint64() |
| int a2; |
| |
| @Uint64() |
| int a3; |
| |
| @Uint64() |
| int a4; |
| |
| @Uint64() |
| int a5; |
| |
| @Uint64() |
| int a6; |
| |
| @Uint64() |
| int a7; |
| |
| @Uint64() |
| int a8; |
| |
| @Uint64() |
| int a9; |
| |
| @Uint64() |
| int a10; |
| |
| @Uint64() |
| int a11; |
| |
| @Uint64() |
| int a12; |
| |
| @Uint64() |
| int a13; |
| |
| @Uint64() |
| int a14; |
| |
| @Uint64() |
| int a15; |
| |
| @Uint64() |
| int a16; |
| |
| @Uint64() |
| int a17; |
| |
| @Uint64() |
| int a18; |
| |
| @Uint64() |
| int a19; |
| |
| @Uint64() |
| int a20; |
| |
| @Uint64() |
| int a21; |
| |
| @Uint64() |
| int a22; |
| |
| @Uint64() |
| int a23; |
| |
| @Uint64() |
| int a24; |
| |
| @Uint64() |
| int a25; |
| |
| @Uint64() |
| int a26; |
| |
| @Uint64() |
| int a27; |
| |
| @Uint64() |
| int a28; |
| |
| @Uint64() |
| int a29; |
| |
| @Uint64() |
| int a30; |
| |
| @Uint64() |
| int a31; |
| |
| @Uint64() |
| int a32; |
| |
| @Uint64() |
| int a33; |
| |
| @Uint64() |
| int a34; |
| |
| @Uint64() |
| int a35; |
| |
| @Uint64() |
| int a36; |
| |
| @Uint64() |
| int a37; |
| |
| @Uint64() |
| int a38; |
| |
| @Uint64() |
| int a39; |
| |
| @Uint64() |
| int a40; |
| |
| @Uint64() |
| int a41; |
| |
| @Uint64() |
| int a42; |
| |
| @Uint64() |
| int a43; |
| |
| @Uint64() |
| int a44; |
| |
| @Uint64() |
| int a45; |
| |
| @Uint64() |
| int a46; |
| |
| @Uint64() |
| int a47; |
| |
| @Uint64() |
| int a48; |
| |
| @Uint64() |
| int a49; |
| |
| @Uint64() |
| int a50; |
| |
| @Uint64() |
| int a51; |
| |
| @Uint64() |
| int a52; |
| |
| @Uint64() |
| int a53; |
| |
| @Uint64() |
| int a54; |
| |
| @Uint64() |
| int a55; |
| |
| @Uint64() |
| int a56; |
| |
| @Uint64() |
| int a57; |
| |
| @Uint64() |
| int a58; |
| |
| @Uint64() |
| int a59; |
| |
| @Uint64() |
| int a60; |
| |
| @Uint64() |
| int a61; |
| |
| @Uint64() |
| int a62; |
| |
| @Uint64() |
| int a63; |
| |
| @Uint64() |
| int a64; |
| |
| @Uint64() |
| int a65; |
| |
| @Uint64() |
| int a66; |
| |
| @Uint64() |
| int a67; |
| |
| @Uint64() |
| int a68; |
| |
| @Uint64() |
| int a69; |
| |
| @Uint64() |
| int a70; |
| |
| @Uint64() |
| int a71; |
| |
| @Uint64() |
| int a72; |
| |
| @Uint64() |
| int a73; |
| |
| @Uint64() |
| int a74; |
| |
| @Uint64() |
| int a75; |
| |
| @Uint64() |
| int a76; |
| |
| @Uint64() |
| int a77; |
| |
| @Uint64() |
| int a78; |
| |
| @Uint64() |
| int a79; |
| |
| @Uint64() |
| int a80; |
| |
| @Uint64() |
| int a81; |
| |
| @Uint64() |
| int a82; |
| |
| @Uint64() |
| int a83; |
| |
| @Uint64() |
| int a84; |
| |
| @Uint64() |
| int a85; |
| |
| @Uint64() |
| int a86; |
| |
| @Uint64() |
| int a87; |
| |
| @Uint64() |
| int a88; |
| |
| @Uint64() |
| int a89; |
| |
| @Uint64() |
| int a90; |
| |
| @Uint64() |
| int a91; |
| |
| @Uint64() |
| int a92; |
| |
| @Uint64() |
| int a93; |
| |
| @Uint64() |
| int a94; |
| |
| @Uint64() |
| int a95; |
| |
| @Uint64() |
| int a96; |
| |
| @Uint64() |
| int a97; |
| |
| @Uint64() |
| int a98; |
| |
| @Uint64() |
| int a99; |
| |
| @Uint64() |
| int a100; |
| |
| @Uint64() |
| int a101; |
| |
| @Uint64() |
| int a102; |
| |
| @Uint64() |
| int a103; |
| |
| @Uint64() |
| int a104; |
| |
| @Uint64() |
| int a105; |
| |
| @Uint64() |
| int a106; |
| |
| @Uint64() |
| int a107; |
| |
| @Uint64() |
| int a108; |
| |
| @Uint64() |
| int a109; |
| |
| @Uint64() |
| int a110; |
| |
| @Uint64() |
| int a111; |
| |
| @Uint64() |
| int a112; |
| |
| @Uint64() |
| int a113; |
| |
| @Uint64() |
| int a114; |
| |
| @Uint64() |
| int a115; |
| |
| @Uint64() |
| int a116; |
| |
| @Uint64() |
| int a117; |
| |
| @Uint64() |
| int a118; |
| |
| @Uint64() |
| int a119; |
| |
| @Uint64() |
| int a120; |
| |
| @Uint64() |
| int a121; |
| |
| @Uint64() |
| int a122; |
| |
| @Uint64() |
| int a123; |
| |
| @Uint64() |
| int a124; |
| |
| @Uint64() |
| int a125; |
| |
| @Uint64() |
| int a126; |
| |
| @Uint64() |
| int a127; |
| |
| String toString() => |
| "(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8}, ${a9}, ${a10}, ${a11}, ${a12}, ${a13}, ${a14}, ${a15}, ${a16}, ${a17}, ${a18}, ${a19}, ${a20}, ${a21}, ${a22}, ${a23}, ${a24}, ${a25}, ${a26}, ${a27}, ${a28}, ${a29}, ${a30}, ${a31}, ${a32}, ${a33}, ${a34}, ${a35}, ${a36}, ${a37}, ${a38}, ${a39}, ${a40}, ${a41}, ${a42}, ${a43}, ${a44}, ${a45}, ${a46}, ${a47}, ${a48}, ${a49}, ${a50}, ${a51}, ${a52}, ${a53}, ${a54}, ${a55}, ${a56}, ${a57}, ${a58}, ${a59}, ${a60}, ${a61}, ${a62}, ${a63}, ${a64}, ${a65}, ${a66}, ${a67}, ${a68}, ${a69}, ${a70}, ${a71}, ${a72}, ${a73}, ${a74}, ${a75}, ${a76}, ${a77}, ${a78}, ${a79}, ${a80}, ${a81}, ${a82}, ${a83}, ${a84}, ${a85}, ${a86}, ${a87}, ${a88}, ${a89}, ${a90}, ${a91}, ${a92}, ${a93}, ${a94}, ${a95}, ${a96}, ${a97}, ${a98}, ${a99}, ${a100}, ${a101}, ${a102}, ${a103}, ${a104}, ${a105}, ${a106}, ${a107}, ${a108}, ${a109}, ${a110}, ${a111}, ${a112}, ${a113}, ${a114}, ${a115}, ${a116}, ${a117}, ${a118}, ${a119}, ${a120}, ${a121}, ${a122}, ${a123}, ${a124}, ${a125}, ${a126}, ${a127})"; |
| } |
| |
| class StructAlignmentInt16 extends Struct { |
| @Int8() |
| int a0; |
| |
| @Int16() |
| int a1; |
| |
| @Int8() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class StructAlignmentInt32 extends Struct { |
| @Int8() |
| int a0; |
| |
| @Int32() |
| int a1; |
| |
| @Int8() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class StructAlignmentInt64 extends Struct { |
| @Int8() |
| int a0; |
| |
| @Int64() |
| int a1; |
| |
| @Int8() |
| int a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| class Struct8BytesNestedInt extends Struct { |
| Struct4BytesHomogeneousInt16 a0; |
| |
| Struct4BytesHomogeneousInt16 a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct8BytesNestedFloat extends Struct { |
| Struct4BytesFloat a0; |
| |
| Struct4BytesFloat a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct8BytesNestedFloat2 extends Struct { |
| Struct4BytesFloat a0; |
| |
| @Float() |
| double a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct8BytesNestedMixed extends Struct { |
| Struct4BytesHomogeneousInt16 a0; |
| |
| Struct4BytesFloat a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct16BytesNestedInt extends Struct { |
| Struct8BytesNestedInt a0; |
| |
| Struct8BytesNestedInt a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct32BytesNestedInt extends Struct { |
| Struct16BytesNestedInt a0; |
| |
| Struct16BytesNestedInt a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class StructNestedIntStructAlignmentInt16 extends Struct { |
| StructAlignmentInt16 a0; |
| |
| StructAlignmentInt16 a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class StructNestedIntStructAlignmentInt32 extends Struct { |
| StructAlignmentInt32 a0; |
| |
| StructAlignmentInt32 a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class StructNestedIntStructAlignmentInt64 extends Struct { |
| StructAlignmentInt64 a0; |
| |
| StructAlignmentInt64 a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class StructNestedIrregularBig extends Struct { |
| @Uint16() |
| int a0; |
| |
| Struct8BytesNestedMixed a1; |
| |
| @Uint16() |
| int a2; |
| |
| Struct8BytesNestedFloat2 a3; |
| |
| @Uint16() |
| int a4; |
| |
| Struct8BytesNestedFloat a5; |
| |
| @Uint16() |
| int a6; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6})"; |
| } |
| |
| class StructNestedIrregularBigger extends Struct { |
| StructNestedIrregularBig a0; |
| |
| Struct8BytesNestedMixed a1; |
| |
| @Float() |
| double a2; |
| |
| @Double() |
| double a3; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3})"; |
| } |
| |
| class StructNestedIrregularEvenBigger extends Struct { |
| @Uint64() |
| int a0; |
| |
| StructNestedIrregularBigger a1; |
| |
| StructNestedIrregularBigger a2; |
| |
| @Double() |
| double a3; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3})"; |
| } |
| |
| class Struct8BytesInlineArrayInt extends Struct { |
| @Array(8) |
| Array<Uint8> a0; |
| |
| String toString() => "(${[for (var i0 = 0; i0 < 8; i0 += 1) a0[i0]]})"; |
| } |
| |
| class StructInlineArrayIrregular extends Struct { |
| @Array(2) |
| Array<Struct3BytesInt2ByteAligned> a0; |
| |
| @Uint8() |
| int a1; |
| |
| String toString() => "(${[for (var i0 = 0; i0 < 2; i0 += 1) a0[i0]]}, ${a1})"; |
| } |
| |
| class StructInlineArray100Bytes extends Struct { |
| @Array(100) |
| Array<Uint8> a0; |
| |
| String toString() => "(${[for (var i0 = 0; i0 < 100; i0 += 1) a0[i0]]})"; |
| } |
| |
| class StructInlineArrayBig extends Struct { |
| @Uint32() |
| int a0; |
| |
| @Uint32() |
| int a1; |
| |
| @Array(4000) |
| Array<Uint8> a2; |
| |
| String toString() => |
| "(${a0}, ${a1}, ${[for (var i0 = 0; i0 < 4000; i0 += 1) a2[i0]]})"; |
| } |
| |
| class StructStruct16BytesHomogeneousFloat2 extends Struct { |
| Struct4BytesFloat a0; |
| |
| @Array(2) |
| Array<Struct4BytesFloat> a1; |
| |
| @Float() |
| double a2; |
| |
| String toString() => |
| "(${a0}, ${[for (var i0 = 0; i0 < 2; i0 += 1) a1[i0]]}, ${a2})"; |
| } |
| |
| class StructStruct32BytesHomogeneousDouble2 extends Struct { |
| Struct8BytesFloat a0; |
| |
| @Array(2) |
| Array<Struct8BytesFloat> a1; |
| |
| @Double() |
| double a2; |
| |
| String toString() => |
| "(${a0}, ${[for (var i0 = 0; i0 < 2; i0 += 1) a1[i0]]}, ${a2})"; |
| } |
| |
| class StructStruct16BytesMixed3 extends Struct { |
| Struct4BytesFloat a0; |
| |
| @Array(1) |
| Array<Struct8BytesMixed> a1; |
| |
| @Array(2) |
| Array<Int16> a2; |
| |
| String toString() => "(${a0}, ${[ |
| for (var i0 = 0; i0 < 1; i0 += 1) a1[i0] |
| ]}, ${[for (var i0 = 0; i0 < 2; i0 += 1) a2[i0]]})"; |
| } |
| |
| class Struct8BytesInlineArrayMultiDimensionalInt extends Struct { |
| @Array(2, 2, 2) |
| Array<Array<Array<Uint8>>> a0; |
| |
| String toString() => "(${[ |
| for (var i0 = 0; i0 < 2; i0 += 1) |
| [ |
| for (var i1 = 0; i1 < 2; i1 += 1) |
| [for (var i2 = 0; i2 < 2; i2 += 1) a0[i0][i1][i2]] |
| ] |
| ]})"; |
| } |
| |
| class Struct32BytesInlineArrayMultiDimensionalInt extends Struct { |
| @Array(2, 2, 2, 2, 2) |
| Array<Array<Array<Array<Array<Uint8>>>>> a0; |
| |
| String toString() => "(${[ |
| for (var i0 = 0; i0 < 2; i0 += 1) |
| [ |
| for (var i1 = 0; i1 < 2; i1 += 1) |
| [ |
| for (var i2 = 0; i2 < 2; i2 += 1) |
| [ |
| for (var i3 = 0; i3 < 2; i3 += 1) |
| [for (var i4 = 0; i4 < 2; i4 += 1) a0[i0][i1][i2][i3][i4]] |
| ] |
| ] |
| ] |
| ]})"; |
| } |
| |
| class Struct64BytesInlineArrayMultiDimensionalInt extends Struct { |
| @Array.multi([2, 2, 2, 2, 2, 2]) |
| Array<Array<Array<Array<Array<Array<Uint8>>>>>> a0; |
| |
| String toString() => "(${[ |
| for (var i0 = 0; i0 < 2; i0 += 1) |
| [ |
| for (var i1 = 0; i1 < 2; i1 += 1) |
| [ |
| for (var i2 = 0; i2 < 2; i2 += 1) |
| [ |
| for (var i3 = 0; i3 < 2; i3 += 1) |
| [ |
| for (var i4 = 0; i4 < 2; i4 += 1) |
| [ |
| for (var i5 = 0; i5 < 2; i5 += 1) |
| a0[i0][i1][i2][i3][i4][i5] |
| ] |
| ] |
| ] |
| ] |
| ] |
| ]})"; |
| } |
| |
| class Struct4BytesInlineArrayMultiDimensionalInt extends Struct { |
| @Array(2, 2) |
| Array<Array<Struct1ByteInt>> a0; |
| |
| String toString() => "(${[ |
| for (var i0 = 0; i0 < 2; i0 += 1) |
| [for (var i1 = 0; i1 < 2; i1 += 1) a0[i0][i1]] |
| ]})"; |
| } |
| |
| @Packed(1) |
| class Struct3BytesPackedInt extends Struct { |
| @Int8() |
| int a0; |
| |
| @Int16() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| @Packed(1) |
| class Struct3BytesPackedIntMembersAligned extends Struct { |
| @Int8() |
| int a0; |
| |
| @Int16() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| @Packed(1) |
| class Struct5BytesPackedMixed extends Struct { |
| @Float() |
| double a0; |
| |
| @Uint8() |
| int a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class StructNestedAlignmentStruct5BytesPackedMixed extends Struct { |
| @Uint8() |
| int a0; |
| |
| Struct5BytesPackedMixed a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct6BytesInlineArrayInt extends Struct { |
| @Array(2) |
| Array<Struct3BytesPackedIntMembersAligned> a0; |
| |
| String toString() => "(${[for (var i0 = 0; i0 < 2; i0 += 1) a0[i0]]})"; |
| } |
| |
| @Packed(1) |
| class Struct8BytesPackedInt extends Struct { |
| @Uint8() |
| int a0; |
| |
| @Uint32() |
| int a1; |
| |
| @Uint8() |
| int a2; |
| |
| @Uint8() |
| int a3; |
| |
| @Uint8() |
| int a4; |
| |
| String toString() => "(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"; |
| } |
| |
| @Packed(1) |
| class Struct9BytesPackedMixed extends Struct { |
| @Uint8() |
| int a0; |
| |
| @Double() |
| double a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Struct15BytesInlineArrayMixed extends Struct { |
| @Array(3) |
| Array<Struct5BytesPackedMixed> a0; |
| |
| String toString() => "(${[for (var i0 = 0; i0 < 3; i0 += 1) a0[i0]]})"; |
| } |
| |
| class Union4BytesMixed extends Union { |
| @Uint32() |
| int a0; |
| |
| @Float() |
| double a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Union8BytesNestedFloat extends Union { |
| @Double() |
| double a0; |
| |
| Struct8BytesHomogeneousFloat a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Union9BytesNestedInt extends Union { |
| Struct8BytesInt a0; |
| |
| Struct9BytesHomogeneousUint8 a1; |
| |
| String toString() => "(${a0}, ${a1})"; |
| } |
| |
| class Union16BytesNestedInlineArrayFloat extends Union { |
| @Array(4) |
| Array<Float> a0; |
| |
| Struct16BytesHomogeneousFloat a1; |
| |
| String toString() => "(${[for (var i0 = 0; i0 < 4; i0 += 1) a0[i0]]}, ${a1})"; |
| } |
| |
| class Union16BytesNestedFloat extends Union { |
| Struct8BytesHomogeneousFloat a0; |
| |
| Struct12BytesHomogeneousFloat a1; |
| |
| Struct16BytesHomogeneousFloat a2; |
| |
| String toString() => "(${a0}, ${a1}, ${a2})"; |
| } |
| |
| final passStruct1ByteIntx10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt), |
| int Function( |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt, |
| Struct1ByteInt)>("PassStruct1ByteIntx10"); |
| |
| /// Smallest struct with data. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct1ByteIntx10() { |
| final a0Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct1ByteInt>(); |
| final Struct1ByteInt a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a1.a0 = 2; |
| a2.a0 = -3; |
| a3.a0 = 4; |
| a4.a0 = -5; |
| a5.a0 = 6; |
| a6.a0 = -7; |
| a7.a0 = 8; |
| a8.a0 = -9; |
| a9.a0 = 10; |
| |
| final result = passStruct1ByteIntx10(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(5, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct3BytesHomogeneousUint8x10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8), |
| int Function( |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8, |
| Struct3BytesHomogeneousUint8)>("PassStruct3BytesHomogeneousUint8x10"); |
| |
| /// Not a multiple of word size, not a power of two. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct3BytesHomogeneousUint8x10() { |
| final a0Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct3BytesHomogeneousUint8>(); |
| final Struct3BytesHomogeneousUint8 a9 = a9Pointer.ref; |
| |
| a0.a0 = 1; |
| a0.a1 = 2; |
| a0.a2 = 3; |
| a1.a0 = 4; |
| a1.a1 = 5; |
| a1.a2 = 6; |
| a2.a0 = 7; |
| a2.a1 = 8; |
| a2.a2 = 9; |
| a3.a0 = 10; |
| a3.a1 = 11; |
| a3.a2 = 12; |
| a4.a0 = 13; |
| a4.a1 = 14; |
| a4.a2 = 15; |
| a5.a0 = 16; |
| a5.a1 = 17; |
| a5.a2 = 18; |
| a6.a0 = 19; |
| a6.a1 = 20; |
| a6.a2 = 21; |
| a7.a0 = 22; |
| a7.a1 = 23; |
| a7.a2 = 24; |
| a8.a0 = 25; |
| a8.a1 = 26; |
| a8.a2 = 27; |
| a9.a0 = 28; |
| a9.a1 = 29; |
| a9.a2 = 30; |
| |
| final result = passStruct3BytesHomogeneousUint8x10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(465, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct3BytesInt2ByteAlignedx10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned), |
| int Function( |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned, |
| Struct3BytesInt2ByteAligned)>("PassStruct3BytesInt2ByteAlignedx10"); |
| |
| /// Not a multiple of word size, not a power of two. |
| /// With alignment rules taken into account size is 4 bytes. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct3BytesInt2ByteAlignedx10() { |
| final a0Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct3BytesInt2ByteAligned>(); |
| final Struct3BytesInt2ByteAligned a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a0.a1 = 2; |
| a1.a0 = -3; |
| a1.a1 = 4; |
| a2.a0 = -5; |
| a2.a1 = 6; |
| a3.a0 = -7; |
| a3.a1 = 8; |
| a4.a0 = -9; |
| a4.a1 = 10; |
| a5.a0 = -11; |
| a5.a1 = 12; |
| a6.a0 = -13; |
| a6.a1 = 14; |
| a7.a0 = -15; |
| a7.a1 = 16; |
| a8.a0 = -17; |
| a8.a1 = 18; |
| a9.a0 = -19; |
| a9.a1 = 20; |
| |
| final result = passStruct3BytesInt2ByteAlignedx10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(10, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct4BytesHomogeneousInt16x10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16), |
| int Function( |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16, |
| Struct4BytesHomogeneousInt16)>("PassStruct4BytesHomogeneousInt16x10"); |
| |
| /// Exactly word size on 32-bit architectures. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct4BytesHomogeneousInt16x10() { |
| final a0Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct4BytesHomogeneousInt16>(); |
| final Struct4BytesHomogeneousInt16 a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a0.a1 = 2; |
| a1.a0 = -3; |
| a1.a1 = 4; |
| a2.a0 = -5; |
| a2.a1 = 6; |
| a3.a0 = -7; |
| a3.a1 = 8; |
| a4.a0 = -9; |
| a4.a1 = 10; |
| a5.a0 = -11; |
| a5.a1 = 12; |
| a6.a0 = -13; |
| a6.a1 = 14; |
| a7.a0 = -15; |
| a7.a1 = 16; |
| a8.a0 = -17; |
| a8.a1 = 18; |
| a9.a0 = -19; |
| a9.a1 = 20; |
| |
| final result = passStruct4BytesHomogeneousInt16x10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(10, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct7BytesHomogeneousUint8x10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8), |
| int Function( |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8, |
| Struct7BytesHomogeneousUint8)>("PassStruct7BytesHomogeneousUint8x10"); |
| |
| /// Sub word size on 64 bit architectures. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct7BytesHomogeneousUint8x10() { |
| final a0Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct7BytesHomogeneousUint8>(); |
| final Struct7BytesHomogeneousUint8 a9 = a9Pointer.ref; |
| |
| a0.a0 = 1; |
| a0.a1 = 2; |
| a0.a2 = 3; |
| a0.a3 = 4; |
| a0.a4 = 5; |
| a0.a5 = 6; |
| a0.a6 = 7; |
| a1.a0 = 8; |
| a1.a1 = 9; |
| a1.a2 = 10; |
| a1.a3 = 11; |
| a1.a4 = 12; |
| a1.a5 = 13; |
| a1.a6 = 14; |
| a2.a0 = 15; |
| a2.a1 = 16; |
| a2.a2 = 17; |
| a2.a3 = 18; |
| a2.a4 = 19; |
| a2.a5 = 20; |
| a2.a6 = 21; |
| a3.a0 = 22; |
| a3.a1 = 23; |
| a3.a2 = 24; |
| a3.a3 = 25; |
| a3.a4 = 26; |
| a3.a5 = 27; |
| a3.a6 = 28; |
| a4.a0 = 29; |
| a4.a1 = 30; |
| a4.a2 = 31; |
| a4.a3 = 32; |
| a4.a4 = 33; |
| a4.a5 = 34; |
| a4.a6 = 35; |
| a5.a0 = 36; |
| a5.a1 = 37; |
| a5.a2 = 38; |
| a5.a3 = 39; |
| a5.a4 = 40; |
| a5.a5 = 41; |
| a5.a6 = 42; |
| a6.a0 = 43; |
| a6.a1 = 44; |
| a6.a2 = 45; |
| a6.a3 = 46; |
| a6.a4 = 47; |
| a6.a5 = 48; |
| a6.a6 = 49; |
| a7.a0 = 50; |
| a7.a1 = 51; |
| a7.a2 = 52; |
| a7.a3 = 53; |
| a7.a4 = 54; |
| a7.a5 = 55; |
| a7.a6 = 56; |
| a8.a0 = 57; |
| a8.a1 = 58; |
| a8.a2 = 59; |
| a8.a3 = 60; |
| a8.a4 = 61; |
| a8.a5 = 62; |
| a8.a6 = 63; |
| a9.a0 = 64; |
| a9.a1 = 65; |
| a9.a2 = 66; |
| a9.a3 = 67; |
| a9.a4 = 68; |
| a9.a5 = 69; |
| a9.a6 = 70; |
| |
| final result = passStruct7BytesHomogeneousUint8x10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(2485, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct7BytesInt4ByteAlignedx10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned), |
| int Function( |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned, |
| Struct7BytesInt4ByteAligned)>("PassStruct7BytesInt4ByteAlignedx10"); |
| |
| /// Sub word size on 64 bit architectures. |
| /// With alignment rules taken into account size is 8 bytes. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct7BytesInt4ByteAlignedx10() { |
| final a0Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct7BytesInt4ByteAligned>(); |
| final Struct7BytesInt4ByteAligned a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a0.a1 = 2; |
| a0.a2 = -3; |
| a1.a0 = 4; |
| a1.a1 = -5; |
| a1.a2 = 6; |
| a2.a0 = -7; |
| a2.a1 = 8; |
| a2.a2 = -9; |
| a3.a0 = 10; |
| a3.a1 = -11; |
| a3.a2 = 12; |
| a4.a0 = -13; |
| a4.a1 = 14; |
| a4.a2 = -15; |
| a5.a0 = 16; |
| a5.a1 = -17; |
| a5.a2 = 18; |
| a6.a0 = -19; |
| a6.a1 = 20; |
| a6.a2 = -21; |
| a7.a0 = 22; |
| a7.a1 = -23; |
| a7.a2 = 24; |
| a8.a0 = -25; |
| a8.a1 = 26; |
| a8.a2 = -27; |
| a9.a0 = 28; |
| a9.a1 = -29; |
| a9.a2 = 30; |
| |
| final result = passStruct7BytesInt4ByteAlignedx10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(15, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct8BytesIntx10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt), |
| int Function( |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt, |
| Struct8BytesInt)>("PassStruct8BytesIntx10"); |
| |
| /// Exactly word size struct on 64bit architectures. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct8BytesIntx10() { |
| final a0Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct8BytesInt>(); |
| final Struct8BytesInt a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a0.a1 = 2; |
| a0.a2 = -3; |
| a1.a0 = 4; |
| a1.a1 = -5; |
| a1.a2 = 6; |
| a2.a0 = -7; |
| a2.a1 = 8; |
| a2.a2 = -9; |
| a3.a0 = 10; |
| a3.a1 = -11; |
| a3.a2 = 12; |
| a4.a0 = -13; |
| a4.a1 = 14; |
| a4.a2 = -15; |
| a5.a0 = 16; |
| a5.a1 = -17; |
| a5.a2 = 18; |
| a6.a0 = -19; |
| a6.a1 = 20; |
| a6.a2 = -21; |
| a7.a0 = 22; |
| a7.a1 = -23; |
| a7.a2 = 24; |
| a8.a0 = -25; |
| a8.a1 = 26; |
| a8.a2 = -27; |
| a9.a0 = 28; |
| a9.a1 = -29; |
| a9.a2 = 30; |
| |
| final result = passStruct8BytesIntx10(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(15, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct8BytesHomogeneousFloatx10 = ffiTestFunctions.lookupFunction< |
| Float Function( |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat), |
| double Function( |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat, |
| Struct8BytesHomogeneousFloat)>("PassStruct8BytesHomogeneousFloatx10"); |
| |
| /// Arguments passed in FP registers as long as they fit. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct8BytesHomogeneousFloatx10() { |
| final a0Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct8BytesHomogeneousFloat>(); |
| final Struct8BytesHomogeneousFloat a9 = a9Pointer.ref; |
| |
| a0.a0 = -1.0; |
| a0.a1 = 2.0; |
| a1.a0 = -3.0; |
| a1.a1 = 4.0; |
| a2.a0 = -5.0; |
| a2.a1 = 6.0; |
| a3.a0 = -7.0; |
| a3.a1 = 8.0; |
| a4.a0 = -9.0; |
| a4.a1 = 10.0; |
| a5.a0 = -11.0; |
| a5.a1 = 12.0; |
| a6.a0 = -13.0; |
| a6.a1 = 14.0; |
| a7.a0 = -15.0; |
| a7.a1 = 16.0; |
| a8.a0 = -17.0; |
| a8.a1 = 18.0; |
| a9.a0 = -19.0; |
| a9.a1 = 20.0; |
| |
| final result = passStruct8BytesHomogeneousFloatx10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.approxEquals(10.0, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct8BytesMixedx10 = ffiTestFunctions.lookupFunction< |
| Float Function( |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed), |
| double Function( |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed, |
| Struct8BytesMixed)>("PassStruct8BytesMixedx10"); |
| |
| /// On x64, arguments go in int registers because it is not only float. |
| /// 10 struct arguments will exhaust available registers. |
| void testPassStruct8BytesMixedx10() { |
| final a0Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct8BytesMixed>(); |
| final Struct8BytesMixed a9 = a9Pointer.ref; |
| |
| a0.a0 = -1.0; |
| a0.a1 = 2; |
| a0.a2 = -3; |
| a1.a0 = 4.0; |
| a1.a1 = -5; |
| a1.a2 = 6; |
| a2.a0 = -7.0; |
| a2.a1 = 8; |
| a2.a2 = -9; |
| a3.a0 = 10.0; |
| a3.a1 = -11; |
| a3.a2 = 12; |
| a4.a0 = -13.0; |
| a4.a1 = 14; |
| a4.a2 = -15; |
| a5.a0 = 16.0; |
| a5.a1 = -17; |
| a5.a2 = 18; |
| a6.a0 = -19.0; |
| a6.a1 = 20; |
| a6.a2 = -21; |
| a7.a0 = 22.0; |
| a7.a1 = -23; |
| a7.a2 = 24; |
| a8.a0 = -25.0; |
| a8.a1 = 26; |
| a8.a2 = -27; |
| a9.a0 = 28.0; |
| a9.a1 = -29; |
| a9.a2 = 30; |
| |
| final result = |
| passStruct8BytesMixedx10(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.approxEquals(15.0, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct9BytesHomogeneousUint8x10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8), |
| int Function( |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8, |
| Struct9BytesHomogeneousUint8)>("PassStruct9BytesHomogeneousUint8x10"); |
| |
| /// Argument is a single byte over a multiple of word size. |
| /// 10 struct arguments will exhaust available registers. |
| /// Struct only has 1-byte aligned fields to test struct alignment itself. |
| /// Tests upper bytes in the integer registers that are partly filled. |
| /// Tests stack alignment of non word size stack arguments. |
| void testPassStruct9BytesHomogeneousUint8x10() { |
| final a0Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct9BytesHomogeneousUint8>(); |
| final Struct9BytesHomogeneousUint8 a9 = a9Pointer.ref; |
| |
| a0.a0 = 1; |
| a0.a1 = 2; |
| a0.a2 = 3; |
| a0.a3 = 4; |
| a0.a4 = 5; |
| a0.a5 = 6; |
| a0.a6 = 7; |
| a0.a7 = 8; |
| a0.a8 = 9; |
| a1.a0 = 10; |
| a1.a1 = 11; |
| a1.a2 = 12; |
| a1.a3 = 13; |
| a1.a4 = 14; |
| a1.a5 = 15; |
| a1.a6 = 16; |
| a1.a7 = 17; |
| a1.a8 = 18; |
| a2.a0 = 19; |
| a2.a1 = 20; |
| a2.a2 = 21; |
| a2.a3 = 22; |
| a2.a4 = 23; |
| a2.a5 = 24; |
| a2.a6 = 25; |
| a2.a7 = 26; |
| a2.a8 = 27; |
| a3.a0 = 28; |
| a3.a1 = 29; |
| a3.a2 = 30; |
| a3.a3 = 31; |
| a3.a4 = 32; |
| a3.a5 = 33; |
| a3.a6 = 34; |
| a3.a7 = 35; |
| a3.a8 = 36; |
| a4.a0 = 37; |
| a4.a1 = 38; |
| a4.a2 = 39; |
| a4.a3 = 40; |
| a4.a4 = 41; |
| a4.a5 = 42; |
| a4.a6 = 43; |
| a4.a7 = 44; |
| a4.a8 = 45; |
| a5.a0 = 46; |
| a5.a1 = 47; |
| a5.a2 = 48; |
| a5.a3 = 49; |
| a5.a4 = 50; |
| a5.a5 = 51; |
| a5.a6 = 52; |
| a5.a7 = 53; |
| a5.a8 = 54; |
| a6.a0 = 55; |
| a6.a1 = 56; |
| a6.a2 = 57; |
| a6.a3 = 58; |
| a6.a4 = 59; |
| a6.a5 = 60; |
| a6.a6 = 61; |
| a6.a7 = 62; |
| a6.a8 = 63; |
| a7.a0 = 64; |
| a7.a1 = 65; |
| a7.a2 = 66; |
| a7.a3 = 67; |
| a7.a4 = 68; |
| a7.a5 = 69; |
| a7.a6 = 70; |
| a7.a7 = 71; |
| a7.a8 = 72; |
| a8.a0 = 73; |
| a8.a1 = 74; |
| a8.a2 = 75; |
| a8.a3 = 76; |
| a8.a4 = 77; |
| a8.a5 = 78; |
| a8.a6 = 79; |
| a8.a7 = 80; |
| a8.a8 = 81; |
| a9.a0 = 82; |
| a9.a1 = 83; |
| a9.a2 = 84; |
| a9.a3 = 85; |
| a9.a4 = 86; |
| a9.a5 = 87; |
| a9.a6 = 88; |
| a9.a7 = 89; |
| a9.a8 = 90; |
| |
| final result = passStruct9BytesHomogeneousUint8x10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(4095, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct9BytesInt4Or8ByteAlignedx10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned), |
| int Function( |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned, |
| Struct9BytesInt4Or8ByteAligned)>( |
| "PassStruct9BytesInt4Or8ByteAlignedx10"); |
| |
| /// Argument is a single byte over a multiple of word size. |
| /// With alignment rules taken into account size is 12 or 16 bytes. |
| /// 10 struct arguments will exhaust available registers. |
| /// |
| void testPassStruct9BytesInt4Or8ByteAlignedx10() { |
| final a0Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct9BytesInt4Or8ByteAligned>(); |
| final Struct9BytesInt4Or8ByteAligned a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a0.a1 = 2; |
| a1.a0 = -3; |
| a1.a1 = 4; |
| a2.a0 = -5; |
| a2.a1 = 6; |
| a3.a0 = -7; |
| a3.a1 = 8; |
| a4.a0 = -9; |
| a4.a1 = 10; |
| a5.a0 = -11; |
| a5.a1 = 12; |
| a6.a0 = -13; |
| a6.a1 = 14; |
| a7.a0 = -15; |
| a7.a1 = 16; |
| a8.a0 = -17; |
| a8.a1 = 18; |
| a9.a0 = -19; |
| a9.a1 = 20; |
| |
| final result = passStruct9BytesInt4Or8ByteAlignedx10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(10, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct12BytesHomogeneousFloatx6 = ffiTestFunctions.lookupFunction< |
| Float Function( |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat), |
| double Function( |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat, |
| Struct12BytesHomogeneousFloat)>("PassStruct12BytesHomogeneousFloatx6"); |
| |
| /// Arguments in FPU registers on arm hardfp and arm64. |
| /// Struct arguments will exhaust available registers, and leave some empty. |
| /// The last argument is to test whether arguments are backfilled. |
| void testPassStruct12BytesHomogeneousFloatx6() { |
| final a0Pointer = calloc<Struct12BytesHomogeneousFloat>(); |
| final Struct12BytesHomogeneousFloat a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct12BytesHomogeneousFloat>(); |
| final Struct12BytesHomogeneousFloat a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct12BytesHomogeneousFloat>(); |
| final Struct12BytesHomogeneousFloat a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct12BytesHomogeneousFloat>(); |
| final Struct12BytesHomogeneousFloat a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct12BytesHomogeneousFloat>(); |
| final Struct12BytesHomogeneousFloat a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct12BytesHomogeneousFloat>(); |
| final Struct12BytesHomogeneousFloat a5 = a5Pointer.ref; |
| |
| a0.a0 = -1.0; |
| a0.a1 = 2.0; |
| a0.a2 = -3.0; |
| a1.a0 = 4.0; |
| a1.a1 = -5.0; |
| a1.a2 = 6.0; |
| a2.a0 = -7.0; |
| a2.a1 = 8.0; |
| a2.a2 = -9.0; |
| a3.a0 = 10.0; |
| a3.a1 = -11.0; |
| a3.a2 = 12.0; |
| a4.a0 = -13.0; |
| a4.a1 = 14.0; |
| a4.a2 = -15.0; |
| a5.a0 = 16.0; |
| a5.a1 = -17.0; |
| a5.a2 = 18.0; |
| |
| final result = passStruct12BytesHomogeneousFloatx6(a0, a1, a2, a3, a4, a5); |
| |
| print("result = $result"); |
| |
| Expect.approxEquals(9.0, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| } |
| |
| final passStruct16BytesHomogeneousFloatx5 = ffiTestFunctions.lookupFunction< |
| Float Function( |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat), |
| double Function( |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat, |
| Struct16BytesHomogeneousFloat)>("PassStruct16BytesHomogeneousFloatx5"); |
| |
| /// On Linux x64 argument is transferred on stack because it is over 16 bytes. |
| /// Arguments in FPU registers on arm hardfp and arm64. |
| /// 5 struct arguments will exhaust available registers. |
| void testPassStruct16BytesHomogeneousFloatx5() { |
| final a0Pointer = calloc<Struct16BytesHomogeneousFloat>(); |
| final Struct16BytesHomogeneousFloat a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct16BytesHomogeneousFloat>(); |
| final Struct16BytesHomogeneousFloat a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct16BytesHomogeneousFloat>(); |
| final Struct16BytesHomogeneousFloat a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct16BytesHomogeneousFloat>(); |
| final Struct16BytesHomogeneousFloat a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct16BytesHomogeneousFloat>(); |
| final Struct16BytesHomogeneousFloat a4 = a4Pointer.ref; |
| |
| a0.a0 = -1.0; |
| a0.a1 = 2.0; |
| a0.a2 = -3.0; |
| a0.a3 = 4.0; |
| a1.a0 = -5.0; |
| a1.a1 = 6.0; |
| a1.a2 = -7.0; |
| a1.a3 = 8.0; |
| a2.a0 = -9.0; |
| a2.a1 = 10.0; |
| a2.a2 = -11.0; |
| a2.a3 = 12.0; |
| a3.a0 = -13.0; |
| a3.a1 = 14.0; |
| a3.a2 = -15.0; |
| a3.a3 = 16.0; |
| a4.a0 = -17.0; |
| a4.a1 = 18.0; |
| a4.a2 = -19.0; |
| a4.a3 = 20.0; |
| |
| final result = passStruct16BytesHomogeneousFloatx5(a0, a1, a2, a3, a4); |
| |
| print("result = $result"); |
| |
| Expect.approxEquals(10.0, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| } |
| |
| final passStruct16BytesMixedx10 = ffiTestFunctions.lookupFunction< |
| Double Function( |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed), |
| double Function( |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed, |
| Struct16BytesMixed)>("PassStruct16BytesMixedx10"); |
| |
| /// On x64, arguments are split over FP and int registers. |
| /// On x64, it will exhaust the integer registers with the 6th argument. |
| /// The rest goes on the stack. |
| /// On arm, arguments are 8 byte aligned. |
| void testPassStruct16BytesMixedx10() { |
| final a0Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct16BytesMixed>(); |
| final Struct16BytesMixed a9 = a9Pointer.ref; |
| |
| a0.a0 = -1.0; |
| a0.a1 = 2; |
| a1.a0 = -3.0; |
| a1.a1 = 4; |
| a2.a0 = -5.0; |
| a2.a1 = 6; |
| a3.a0 = -7.0; |
| a3.a1 = 8; |
| a4.a0 = -9.0; |
| a4.a1 = 10; |
| a5.a0 = -11.0; |
| a5.a1 = 12; |
| a6.a0 = -13.0; |
| a6.a1 = 14; |
| a7.a0 = -15.0; |
| a7.a1 = 16; |
| a8.a0 = -17.0; |
| a8.a1 = 18; |
| a9.a0 = -19.0; |
| a9.a1 = 20; |
| |
| final result = |
| passStruct16BytesMixedx10(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.approxEquals(10.0, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct16BytesMixed2x10 = ffiTestFunctions.lookupFunction< |
| Float Function( |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2), |
| double Function( |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2, |
| Struct16BytesMixed2)>("PassStruct16BytesMixed2x10"); |
| |
| /// On x64, arguments are split over FP and int registers. |
| /// On x64, it will exhaust the integer registers with the 6th argument. |
| /// The rest goes on the stack. |
| /// On arm, arguments are 4 byte aligned. |
| void testPassStruct16BytesMixed2x10() { |
| final a0Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct16BytesMixed2>(); |
| final Struct16BytesMixed2 a9 = a9Pointer.ref; |
| |
| a0.a0 = -1.0; |
| a0.a1 = 2.0; |
| a0.a2 = -3.0; |
| a0.a3 = 4; |
| a1.a0 = -5.0; |
| a1.a1 = 6.0; |
| a1.a2 = -7.0; |
| a1.a3 = 8; |
| a2.a0 = -9.0; |
| a2.a1 = 10.0; |
| a2.a2 = -11.0; |
| a2.a3 = 12; |
| a3.a0 = -13.0; |
| a3.a1 = 14.0; |
| a3.a2 = -15.0; |
| a3.a3 = 16; |
| a4.a0 = -17.0; |
| a4.a1 = 18.0; |
| a4.a2 = -19.0; |
| a4.a3 = 20; |
| a5.a0 = -21.0; |
| a5.a1 = 22.0; |
| a5.a2 = -23.0; |
| a5.a3 = 24; |
| a6.a0 = -25.0; |
| a6.a1 = 26.0; |
| a6.a2 = -27.0; |
| a6.a3 = 28; |
| a7.a0 = -29.0; |
| a7.a1 = 30.0; |
| a7.a2 = -31.0; |
| a7.a3 = 32; |
| a8.a0 = -33.0; |
| a8.a1 = 34.0; |
| a8.a2 = -35.0; |
| a8.a3 = 36; |
| a9.a0 = -37.0; |
| a9.a1 = 38.0; |
| a9.a2 = -39.0; |
| a9.a3 = 40; |
| |
| final result = |
| passStruct16BytesMixed2x10(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.approxEquals(20.0, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct17BytesIntx10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt), |
| int Function( |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt, |
| Struct17BytesInt)>("PassStruct17BytesIntx10"); |
| |
| /// Arguments are passed as pointer to copy on arm64. |
| /// Tests that the memory allocated for copies are rounded up to word size. |
| void testPassStruct17BytesIntx10() { |
| final a0Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct17BytesInt>(); |
| final Struct17BytesInt a9 = a9Pointer.ref; |
| |
| a0.a0 = -1; |
| a0.a1 = 2; |
| a0.a2 = -3; |
| a1.a0 = 4; |
| a1.a1 = -5; |
| a1.a2 = 6; |
| a2.a0 = -7; |
| a2.a1 = 8; |
| a2.a2 = -9; |
| a3.a0 = 10; |
| a3.a1 = -11; |
| a3.a2 = 12; |
| a4.a0 = -13; |
| a4.a1 = 14; |
| a4.a2 = -15; |
| a5.a0 = 16; |
| a5.a1 = -17; |
| a5.a2 = 18; |
| a6.a0 = -19; |
| a6.a1 = 20; |
| a6.a2 = -21; |
| a7.a0 = 22; |
| a7.a1 = -23; |
| a7.a2 = 24; |
| a8.a0 = -25; |
| a8.a1 = 26; |
| a8.a2 = -27; |
| a9.a0 = 28; |
| a9.a1 = -29; |
| a9.a2 = 30; |
| |
| final result = |
| passStruct17BytesIntx10(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(15, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct19BytesHomogeneousUint8x10 = ffiTestFunctions.lookupFunction< |
| Int64 Function( |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8), |
| int Function( |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8, |
| Struct19BytesHomogeneousUint8)>("PassStruct19BytesHomogeneousUint8x10"); |
| |
| /// The minimum alignment of this struct is only 1 byte based on its fields. |
| /// Test that the memory backing these structs is extended to the right size. |
| /// |
| void testPassStruct19BytesHomogeneousUint8x10() { |
| final a0Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a0 = a0Pointer.ref; |
| final a1Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a1 = a1Pointer.ref; |
| final a2Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a2 = a2Pointer.ref; |
| final a3Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a3 = a3Pointer.ref; |
| final a4Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a4 = a4Pointer.ref; |
| final a5Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a5 = a5Pointer.ref; |
| final a6Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a6 = a6Pointer.ref; |
| final a7Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a7 = a7Pointer.ref; |
| final a8Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a8 = a8Pointer.ref; |
| final a9Pointer = calloc<Struct19BytesHomogeneousUint8>(); |
| final Struct19BytesHomogeneousUint8 a9 = a9Pointer.ref; |
| |
| a0.a0 = 1; |
| a0.a1 = 2; |
| a0.a2 = 3; |
| a0.a3 = 4; |
| a0.a4 = 5; |
| a0.a5 = 6; |
| a0.a6 = 7; |
| a0.a7 = 8; |
| a0.a8 = 9; |
| a0.a9 = 10; |
| a0.a10 = 11; |
| a0.a11 = 12; |
| a0.a12 = 13; |
| a0.a13 = 14; |
| a0.a14 = 15; |
| a0.a15 = 16; |
| a0.a16 = 17; |
| a0.a17 = 18; |
| a0.a18 = 19; |
| a1.a0 = 20; |
| a1.a1 = 21; |
| a1.a2 = 22; |
| a1.a3 = 23; |
| a1.a4 = 24; |
| a1.a5 = 25; |
| a1.a6 = 26; |
| a1.a7 = 27; |
| a1.a8 = 28; |
| a1.a9 = 29; |
| a1.a10 = 30; |
| a1.a11 = 31; |
| a1.a12 = 32; |
| a1.a13 = 33; |
| a1.a14 = 34; |
| a1.a15 = 35; |
| a1.a16 = 36; |
| a1.a17 = 37; |
| a1.a18 = 38; |
| a2.a0 = 39; |
| a2.a1 = 40; |
| a2.a2 = 41; |
| a2.a3 = 42; |
| a2.a4 = 43; |
| a2.a5 = 44; |
| a2.a6 = 45; |
| a2.a7 = 46; |
| a2.a8 = 47; |
| a2.a9 = 48; |
| a2.a10 = 49; |
| a2.a11 = 50; |
| a2.a12 = 51; |
| a2.a13 = 52; |
| a2.a14 = 53; |
| a2.a15 = 54; |
| a2.a16 = 55; |
| a2.a17 = 56; |
| a2.a18 = 57; |
| a3.a0 = 58; |
| a3.a1 = 59; |
| a3.a2 = 60; |
| a3.a3 = 61; |
| a3.a4 = 62; |
| a3.a5 = 63; |
| a3.a6 = 64; |
| a3.a7 = 65; |
| a3.a8 = 66; |
| a3.a9 = 67; |
| a3.a10 = 68; |
| a3.a11 = 69; |
| a3.a12 = 70; |
| a3.a13 = 71; |
| a3.a14 = 72; |
| a3.a15 = 73; |
| a3.a16 = 74; |
| a3.a17 = 75; |
| a3.a18 = 76; |
| a4.a0 = 77; |
| a4.a1 = 78; |
| a4.a2 = 79; |
| a4.a3 = 80; |
| a4.a4 = 81; |
| a4.a5 = 82; |
| a4.a6 = 83; |
| a4.a7 = 84; |
| a4.a8 = 85; |
| a4.a9 = 86; |
| a4.a10 = 87; |
| a4.a11 = 88; |
| a4.a12 = 89; |
| a4.a13 = 90; |
| a4.a14 = 91; |
| a4.a15 = 92; |
| a4.a16 = 93; |
| a4.a17 = 94; |
| a4.a18 = 95; |
| a5.a0 = 96; |
| a5.a1 = 97; |
| a5.a2 = 98; |
| a5.a3 = 99; |
| a5.a4 = 100; |
| a5.a5 = 101; |
| a5.a6 = 102; |
| a5.a7 = 103; |
| a5.a8 = 104; |
| a5.a9 = 105; |
| a5.a10 = 106; |
| a5.a11 = 107; |
| a5.a12 = 108; |
| a5.a13 = 109; |
| a5.a14 = 110; |
| a5.a15 = 111; |
| a5.a16 = 112; |
| a5.a17 = 113; |
| a5.a18 = 114; |
| a6.a0 = 115; |
| a6.a1 = 116; |
| a6.a2 = 117; |
| a6.a3 = 118; |
| a6.a4 = 119; |
| a6.a5 = 120; |
| a6.a6 = 121; |
| a6.a7 = 122; |
| a6.a8 = 123; |
| a6.a9 = 124; |
| a6.a10 = 125; |
| a6.a11 = 126; |
| a6.a12 = 127; |
| a6.a13 = 128; |
| a6.a14 = 129; |
| a6.a15 = 130; |
| a6.a16 = 131; |
| a6.a17 = 132; |
| a6.a18 = 133; |
| a7.a0 = 134; |
| a7.a1 = 135; |
| a7.a2 = 136; |
| a7.a3 = 137; |
| a7.a4 = 138; |
| a7.a5 = 139; |
| a7.a6 = 140; |
| a7.a7 = 141; |
| a7.a8 = 142; |
| a7.a9 = 143; |
| a7.a10 = 144; |
| a7.a11 = 145; |
| a7.a12 = 146; |
| a7.a13 = 147; |
| a7.a14 = 148; |
| a7.a15 = 149; |
| a7.a16 = 150; |
| a7.a17 = 151; |
| a7.a18 = 152; |
| a8.a0 = 153; |
| a8.a1 = 154; |
| a8.a2 = 155; |
| a8.a3 = 156; |
| a8.a4 = 157; |
| a8.a5 = 158; |
| a8.a6 = 159; |
| a8.a7 = 160; |
| a8.a8 = 161; |
| a8.a9 = 162; |
| a8.a10 = 163; |
| a8.a11 = 164; |
| a8.a12 = 165; |
| a8.a13 = 166; |
| a8.a14 = 167; |
| a8.a15 = 168; |
| a8.a16 = 169; |
| a8.a17 = 170; |
| a8.a18 = 171; |
| a9.a0 = 172; |
| a9.a1 = 173; |
| a9.a2 = 174; |
| a9.a3 = 175; |
| a9.a4 = 176; |
| a9.a5 = 177; |
| a9.a6 = 178; |
| a9.a7 = 179; |
| a9.a8 = 180; |
| a9.a9 = 181; |
| a9.a10 = 182; |
| a9.a11 = 183; |
| a9.a12 = 184; |
| a9.a13 = 185; |
| a9.a14 = 186; |
| a9.a15 = 187; |
| a9.a16 = 188; |
| a9.a17 = 189; |
| a9.a18 = 190; |
| |
| final result = passStruct19BytesHomogeneousUint8x10( |
| a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| |
| print("result = $result"); |
| |
| Expect.equals(18145, result); |
| |
| calloc.free(a0Pointer); |
| calloc.free(a1Pointer); |
| calloc.free(a2Pointer); |
| calloc.free(a3Pointer); |
| calloc.free(a4Pointer); |
| calloc.free(a5Pointer); |
| calloc.free(a6Pointer); |
| calloc.free(a7Pointer); |
| calloc.free(a8Pointer); |
| calloc.free(a9Pointer); |
| } |
| |
| final passStruct20BytesHomogeneousInt32x10 = ffiTestFunctions.lookupFunction< |
| Int32 Function( |
| Struct20BytesHomogeneousInt32, |
| Struct20BytesHomogeneousInt32, |
| Struct20BytesHomogeneousInt32, |
|