| // Copyright (c) 2023, 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. |
| // Generated by tests/ffi/generator/structs_by_value_tests_generator.dart. |
| // |
| // SharedObjects=ffi_test_functions |
| // VMOptions= |
| // VMOptions=--deterministic --optimization-counter-threshold=20 |
| // VMOptions=--use-slow-path |
| // VMOptions=--use-slow-path --stacktrace-every=100 |
| |
| import 'dart:ffi'; |
| |
| import 'package:expect/expect.dart'; |
| // ignore: unused_import |
| import 'package:ffi/ffi.dart'; |
| |
| import 'callback_tests_utils.dart'; |
| |
| import 'dylib_utils.dart'; |
| |
| // Reuse the compound classes. |
| import 'function_structs_by_value_generated_compounds.dart'; |
| |
| final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions"); |
| |
| void main() { |
| testCases.forEach((t) { |
| print("==== Running " + t.name); |
| t.run(); |
| }); |
| } |
| |
| final testCases = [ |
| CallbackTest.withCheck( |
| "VariadicAt1Int64x2", |
| NativeCallable<VariadicAt1Int64x2Type>.isolateLocal(variadicAt1Int64x2, |
| exceptionalReturn: 0), |
| variadicAt1Int64x2AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Doublex2", |
| NativeCallable<VariadicAt1Doublex2Type>.isolateLocal(variadicAt1Doublex2, |
| exceptionalReturn: 0.0), |
| variadicAt1Doublex2AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Int64x5", |
| NativeCallable<VariadicAt1Int64x5Type>.isolateLocal(variadicAt1Int64x5, |
| exceptionalReturn: 0), |
| variadicAt1Int64x5AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Doublex5", |
| NativeCallable<VariadicAt1Doublex5Type>.isolateLocal(variadicAt1Doublex5, |
| exceptionalReturn: 0.0), |
| variadicAt1Doublex5AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Int64x20", |
| NativeCallable<VariadicAt1Int64x20Type>.isolateLocal(variadicAt1Int64x20, |
| exceptionalReturn: 0), |
| variadicAt1Int64x20AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Doublex20", |
| NativeCallable<VariadicAt1Doublex20Type>.isolateLocal( |
| variadicAt1Doublex20, |
| exceptionalReturn: 0.0), |
| variadicAt1Doublex20AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Int64x2Struct8BytesIntInt64", |
| NativeCallable<VariadicAt1Int64x2Struct8BytesIntInt64Type>.isolateLocal( |
| variadicAt1Int64x2Struct8BytesIntInt64, |
| exceptionalReturn: 0), |
| variadicAt1Int64x2Struct8BytesIntInt64AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Doublex2Struct32BytesHomogeneousDoubleD", |
| NativeCallable< |
| VariadicAt1Doublex2Struct32BytesHomogeneousDoubleDType>.isolateLocal( |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleD, |
| exceptionalReturn: 0.0), |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleDAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1DoubleStruct12BytesHomogeneousFloatDoub", |
| NativeCallable< |
| VariadicAt1DoubleStruct12BytesHomogeneousFloatDoubType>.isolateLocal( |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoub, |
| exceptionalReturn: 0.0), |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoubAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Int32Struct20BytesHomogeneousInt32Int32", |
| NativeCallable< |
| VariadicAt1Int32Struct20BytesHomogeneousInt32Int32Type>.isolateLocal( |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32, |
| exceptionalReturn: 0), |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1DoubleStruct20BytesHomogeneousFloatDoub", |
| NativeCallable< |
| VariadicAt1DoubleStruct20BytesHomogeneousFloatDoubType>.isolateLocal( |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoub, |
| exceptionalReturn: 0.0), |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoubAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt2Int32Int64IntPtr", |
| NativeCallable<VariadicAt2Int32Int64IntPtrType>.isolateLocal( |
| variadicAt2Int32Int64IntPtr, |
| exceptionalReturn: 0), |
| variadicAt2Int32Int64IntPtrAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1DoubleInt64Int32DoubleInt64Int32", |
| NativeCallable< |
| VariadicAt1DoubleInt64Int32DoubleInt64Int32Type>.isolateLocal( |
| variadicAt1DoubleInt64Int32DoubleInt64Int32, |
| exceptionalReturn: 0.0), |
| variadicAt1DoubleInt64Int32DoubleInt64Int32AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Int64Int32Struct12BytesHomogeneousFloat", |
| NativeCallable< |
| VariadicAt1Int64Int32Struct12BytesHomogeneousFloatType>.isolateLocal( |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloat, |
| exceptionalReturn: 0.0), |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloatAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt11Doublex8FloatStruct12BytesHomogeneousF", |
| NativeCallable< |
| VariadicAt11Doublex8FloatStruct12BytesHomogeneousFType>.isolateLocal( |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF, |
| exceptionalReturn: 0.0), |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousFAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1DoubleInt64Int32Struct20BytesHomogeneou", |
| NativeCallable< |
| VariadicAt1DoubleInt64Int32Struct20BytesHomogeneouType>.isolateLocal( |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou, |
| exceptionalReturn: 0.0), |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneouAfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt5Doublex5", |
| NativeCallable<VariadicAt5Doublex5Type>.isolateLocal(variadicAt5Doublex5, |
| exceptionalReturn: 0.0), |
| variadicAt5Doublex5AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Int64x7Struct12BytesHomogeneousInt32", |
| NativeCallable< |
| VariadicAt1Int64x7Struct12BytesHomogeneousInt32Type>.isolateLocal( |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32, |
| exceptionalReturn: 0), |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32AfterCallback), |
| CallbackTest.withCheck( |
| "VariadicAt1Struct12BytesHomogeneousInt32Int32x4", |
| NativeCallable< |
| VariadicAt1Struct12BytesHomogeneousInt32Int32x4Type>.isolateLocal( |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4, |
| exceptionalReturn: 0), |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4AfterCallback), |
| ]; |
| typedef VariadicAt1Int64x2Type = Int64 Function(Int64, VarArgs<(Int64,)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int64x2_a0 = 0; |
| int variadicAt1Int64x2_a1 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Int64x2Result = 0; |
| |
| int variadicAt1Int64x2CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Int64x2_a0; |
| result += variadicAt1Int64x2_a1; |
| |
| variadicAt1Int64x2Result = result; |
| |
| return result; |
| } |
| |
| /// Single variadic argument. |
| int variadicAt1Int64x2(int a0, int a1) { |
| print("variadicAt1Int64x2(${a0}, ${a1})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt1Int64x2 throwing on purpose!"); |
| } |
| |
| variadicAt1Int64x2_a0 = a0; |
| variadicAt1Int64x2_a1 = a1; |
| |
| final result = variadicAt1Int64x2CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int64x2AfterCallback() { |
| final result = variadicAt1Int64x2CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(1, result); |
| } |
| |
| typedef VariadicAt1Doublex2Type = Double Function(Double, VarArgs<(Double,)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1Doublex2_a0 = 0.0; |
| double variadicAt1Doublex2_a1 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1Doublex2Result = 0.0; |
| |
| double variadicAt1Doublex2CalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1Doublex2_a0; |
| result += variadicAt1Doublex2_a1; |
| |
| variadicAt1Doublex2Result = result; |
| |
| return result; |
| } |
| |
| /// Single variadic argument. |
| double variadicAt1Doublex2(double a0, double a1) { |
| print("variadicAt1Doublex2(${a0}, ${a1})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt1Doublex2 throwing on purpose!"); |
| } |
| |
| variadicAt1Doublex2_a0 = a0; |
| variadicAt1Doublex2_a1 = a1; |
| |
| final result = variadicAt1Doublex2CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Doublex2AfterCallback() { |
| final result = variadicAt1Doublex2CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(1.0, result); |
| } |
| |
| typedef VariadicAt1Int64x5Type = Int64 Function( |
| Int64, VarArgs<(Int64, Int64, Int64, Int64)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int64x5_a0 = 0; |
| int variadicAt1Int64x5_a1 = 0; |
| int variadicAt1Int64x5_a2 = 0; |
| int variadicAt1Int64x5_a3 = 0; |
| int variadicAt1Int64x5_a4 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Int64x5Result = 0; |
| |
| int variadicAt1Int64x5CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Int64x5_a0; |
| result += variadicAt1Int64x5_a1; |
| result += variadicAt1Int64x5_a2; |
| result += variadicAt1Int64x5_a3; |
| result += variadicAt1Int64x5_a4; |
| |
| variadicAt1Int64x5Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments. |
| int variadicAt1Int64x5(int a0, int a1, int a2, int a3, int a4) { |
| print("variadicAt1Int64x5(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt1Int64x5 throwing on purpose!"); |
| } |
| |
| variadicAt1Int64x5_a0 = a0; |
| variadicAt1Int64x5_a1 = a1; |
| variadicAt1Int64x5_a2 = a2; |
| variadicAt1Int64x5_a3 = a3; |
| variadicAt1Int64x5_a4 = a4; |
| |
| final result = variadicAt1Int64x5CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int64x5AfterCallback() { |
| final result = variadicAt1Int64x5CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(-3, result); |
| } |
| |
| typedef VariadicAt1Doublex5Type = Double Function( |
| Double, VarArgs<(Double, Double, Double, Double)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1Doublex5_a0 = 0.0; |
| double variadicAt1Doublex5_a1 = 0.0; |
| double variadicAt1Doublex5_a2 = 0.0; |
| double variadicAt1Doublex5_a3 = 0.0; |
| double variadicAt1Doublex5_a4 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1Doublex5Result = 0.0; |
| |
| double variadicAt1Doublex5CalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1Doublex5_a0; |
| result += variadicAt1Doublex5_a1; |
| result += variadicAt1Doublex5_a2; |
| result += variadicAt1Doublex5_a3; |
| result += variadicAt1Doublex5_a4; |
| |
| variadicAt1Doublex5Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments. |
| double variadicAt1Doublex5( |
| double a0, double a1, double a2, double a3, double a4) { |
| print("variadicAt1Doublex5(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt1Doublex5 throwing on purpose!"); |
| } |
| |
| variadicAt1Doublex5_a0 = a0; |
| variadicAt1Doublex5_a1 = a1; |
| variadicAt1Doublex5_a2 = a2; |
| variadicAt1Doublex5_a3 = a3; |
| variadicAt1Doublex5_a4 = a4; |
| |
| final result = variadicAt1Doublex5CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Doublex5AfterCallback() { |
| final result = variadicAt1Doublex5CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-3.0, result); |
| } |
| |
| typedef VariadicAt1Int64x20Type = Int64 Function( |
| Int64, |
| VarArgs< |
| ( |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64 |
| )>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int64x20_a0 = 0; |
| int variadicAt1Int64x20_a1 = 0; |
| int variadicAt1Int64x20_a2 = 0; |
| int variadicAt1Int64x20_a3 = 0; |
| int variadicAt1Int64x20_a4 = 0; |
| int variadicAt1Int64x20_a5 = 0; |
| int variadicAt1Int64x20_a6 = 0; |
| int variadicAt1Int64x20_a7 = 0; |
| int variadicAt1Int64x20_a8 = 0; |
| int variadicAt1Int64x20_a9 = 0; |
| int variadicAt1Int64x20_a10 = 0; |
| int variadicAt1Int64x20_a11 = 0; |
| int variadicAt1Int64x20_a12 = 0; |
| int variadicAt1Int64x20_a13 = 0; |
| int variadicAt1Int64x20_a14 = 0; |
| int variadicAt1Int64x20_a15 = 0; |
| int variadicAt1Int64x20_a16 = 0; |
| int variadicAt1Int64x20_a17 = 0; |
| int variadicAt1Int64x20_a18 = 0; |
| int variadicAt1Int64x20_a19 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Int64x20Result = 0; |
| |
| int variadicAt1Int64x20CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Int64x20_a0; |
| result += variadicAt1Int64x20_a1; |
| result += variadicAt1Int64x20_a2; |
| result += variadicAt1Int64x20_a3; |
| result += variadicAt1Int64x20_a4; |
| result += variadicAt1Int64x20_a5; |
| result += variadicAt1Int64x20_a6; |
| result += variadicAt1Int64x20_a7; |
| result += variadicAt1Int64x20_a8; |
| result += variadicAt1Int64x20_a9; |
| result += variadicAt1Int64x20_a10; |
| result += variadicAt1Int64x20_a11; |
| result += variadicAt1Int64x20_a12; |
| result += variadicAt1Int64x20_a13; |
| result += variadicAt1Int64x20_a14; |
| result += variadicAt1Int64x20_a15; |
| result += variadicAt1Int64x20_a16; |
| result += variadicAt1Int64x20_a17; |
| result += variadicAt1Int64x20_a18; |
| result += variadicAt1Int64x20_a19; |
| |
| variadicAt1Int64x20Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments exhaust registers. |
| int variadicAt1Int64x20( |
| int a0, |
| int a1, |
| int a2, |
| int a3, |
| int a4, |
| int a5, |
| int a6, |
| int a7, |
| int a8, |
| int a9, |
| int a10, |
| int a11, |
| int a12, |
| int a13, |
| int a14, |
| int a15, |
| int a16, |
| int a17, |
| int a18, |
| int a19) { |
| print( |
| "variadicAt1Int64x20(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8}, ${a9}, ${a10}, ${a11}, ${a12}, ${a13}, ${a14}, ${a15}, ${a16}, ${a17}, ${a18}, ${a19})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt1Int64x20 throwing on purpose!"); |
| } |
| |
| variadicAt1Int64x20_a0 = a0; |
| variadicAt1Int64x20_a1 = a1; |
| variadicAt1Int64x20_a2 = a2; |
| variadicAt1Int64x20_a3 = a3; |
| variadicAt1Int64x20_a4 = a4; |
| variadicAt1Int64x20_a5 = a5; |
| variadicAt1Int64x20_a6 = a6; |
| variadicAt1Int64x20_a7 = a7; |
| variadicAt1Int64x20_a8 = a8; |
| variadicAt1Int64x20_a9 = a9; |
| variadicAt1Int64x20_a10 = a10; |
| variadicAt1Int64x20_a11 = a11; |
| variadicAt1Int64x20_a12 = a12; |
| variadicAt1Int64x20_a13 = a13; |
| variadicAt1Int64x20_a14 = a14; |
| variadicAt1Int64x20_a15 = a15; |
| variadicAt1Int64x20_a16 = a16; |
| variadicAt1Int64x20_a17 = a17; |
| variadicAt1Int64x20_a18 = a18; |
| variadicAt1Int64x20_a19 = a19; |
| |
| final result = variadicAt1Int64x20CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int64x20AfterCallback() { |
| final result = variadicAt1Int64x20CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(10, result); |
| } |
| |
| typedef VariadicAt1Doublex20Type = Double Function( |
| Double, |
| VarArgs< |
| ( |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double |
| )>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1Doublex20_a0 = 0.0; |
| double variadicAt1Doublex20_a1 = 0.0; |
| double variadicAt1Doublex20_a2 = 0.0; |
| double variadicAt1Doublex20_a3 = 0.0; |
| double variadicAt1Doublex20_a4 = 0.0; |
| double variadicAt1Doublex20_a5 = 0.0; |
| double variadicAt1Doublex20_a6 = 0.0; |
| double variadicAt1Doublex20_a7 = 0.0; |
| double variadicAt1Doublex20_a8 = 0.0; |
| double variadicAt1Doublex20_a9 = 0.0; |
| double variadicAt1Doublex20_a10 = 0.0; |
| double variadicAt1Doublex20_a11 = 0.0; |
| double variadicAt1Doublex20_a12 = 0.0; |
| double variadicAt1Doublex20_a13 = 0.0; |
| double variadicAt1Doublex20_a14 = 0.0; |
| double variadicAt1Doublex20_a15 = 0.0; |
| double variadicAt1Doublex20_a16 = 0.0; |
| double variadicAt1Doublex20_a17 = 0.0; |
| double variadicAt1Doublex20_a18 = 0.0; |
| double variadicAt1Doublex20_a19 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1Doublex20Result = 0.0; |
| |
| double variadicAt1Doublex20CalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1Doublex20_a0; |
| result += variadicAt1Doublex20_a1; |
| result += variadicAt1Doublex20_a2; |
| result += variadicAt1Doublex20_a3; |
| result += variadicAt1Doublex20_a4; |
| result += variadicAt1Doublex20_a5; |
| result += variadicAt1Doublex20_a6; |
| result += variadicAt1Doublex20_a7; |
| result += variadicAt1Doublex20_a8; |
| result += variadicAt1Doublex20_a9; |
| result += variadicAt1Doublex20_a10; |
| result += variadicAt1Doublex20_a11; |
| result += variadicAt1Doublex20_a12; |
| result += variadicAt1Doublex20_a13; |
| result += variadicAt1Doublex20_a14; |
| result += variadicAt1Doublex20_a15; |
| result += variadicAt1Doublex20_a16; |
| result += variadicAt1Doublex20_a17; |
| result += variadicAt1Doublex20_a18; |
| result += variadicAt1Doublex20_a19; |
| |
| variadicAt1Doublex20Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments exhaust registers. |
| double variadicAt1Doublex20( |
| double a0, |
| double a1, |
| double a2, |
| double a3, |
| double a4, |
| double a5, |
| double a6, |
| double a7, |
| double a8, |
| double a9, |
| double a10, |
| double a11, |
| double a12, |
| double a13, |
| double a14, |
| double a15, |
| double a16, |
| double a17, |
| double a18, |
| double a19) { |
| print( |
| "variadicAt1Doublex20(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8}, ${a9}, ${a10}, ${a11}, ${a12}, ${a13}, ${a14}, ${a15}, ${a16}, ${a17}, ${a18}, ${a19})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt1Doublex20 throwing on purpose!"); |
| } |
| |
| variadicAt1Doublex20_a0 = a0; |
| variadicAt1Doublex20_a1 = a1; |
| variadicAt1Doublex20_a2 = a2; |
| variadicAt1Doublex20_a3 = a3; |
| variadicAt1Doublex20_a4 = a4; |
| variadicAt1Doublex20_a5 = a5; |
| variadicAt1Doublex20_a6 = a6; |
| variadicAt1Doublex20_a7 = a7; |
| variadicAt1Doublex20_a8 = a8; |
| variadicAt1Doublex20_a9 = a9; |
| variadicAt1Doublex20_a10 = a10; |
| variadicAt1Doublex20_a11 = a11; |
| variadicAt1Doublex20_a12 = a12; |
| variadicAt1Doublex20_a13 = a13; |
| variadicAt1Doublex20_a14 = a14; |
| variadicAt1Doublex20_a15 = a15; |
| variadicAt1Doublex20_a16 = a16; |
| variadicAt1Doublex20_a17 = a17; |
| variadicAt1Doublex20_a18 = a18; |
| variadicAt1Doublex20_a19 = a19; |
| |
| final result = variadicAt1Doublex20CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Doublex20AfterCallback() { |
| final result = variadicAt1Doublex20CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(10.0, result); |
| } |
| |
| typedef VariadicAt1Int64x2Struct8BytesIntInt64Type = Int64 Function( |
| Int64, VarArgs<(Int64, Struct8BytesInt, Int64)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int64x2Struct8BytesIntInt64_a0 = 0; |
| int variadicAt1Int64x2Struct8BytesIntInt64_a1 = 0; |
| Struct8BytesInt variadicAt1Int64x2Struct8BytesIntInt64_a2 = |
| Pointer<Struct8BytesInt>.fromAddress(0).ref; |
| int variadicAt1Int64x2Struct8BytesIntInt64_a3 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Int64x2Struct8BytesIntInt64Result = 0; |
| |
| int variadicAt1Int64x2Struct8BytesIntInt64CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Int64x2Struct8BytesIntInt64_a0; |
| result += variadicAt1Int64x2Struct8BytesIntInt64_a1; |
| result += variadicAt1Int64x2Struct8BytesIntInt64_a2.a0; |
| result += variadicAt1Int64x2Struct8BytesIntInt64_a2.a1; |
| result += variadicAt1Int64x2Struct8BytesIntInt64_a2.a2; |
| result += variadicAt1Int64x2Struct8BytesIntInt64_a3; |
| |
| variadicAt1Int64x2Struct8BytesIntInt64Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments including struct. |
| int variadicAt1Int64x2Struct8BytesIntInt64( |
| int a0, int a1, Struct8BytesInt a2, int a3) { |
| print("variadicAt1Int64x2Struct8BytesIntInt64(${a0}, ${a1}, ${a2}, ${a3})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1Int64x2Struct8BytesIntInt64 throwing on purpose!"); |
| } |
| |
| variadicAt1Int64x2Struct8BytesIntInt64_a0 = a0; |
| variadicAt1Int64x2Struct8BytesIntInt64_a1 = a1; |
| variadicAt1Int64x2Struct8BytesIntInt64_a2 = a2; |
| variadicAt1Int64x2Struct8BytesIntInt64_a3 = a3; |
| |
| final result = variadicAt1Int64x2Struct8BytesIntInt64CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int64x2Struct8BytesIntInt64AfterCallback() { |
| final result = variadicAt1Int64x2Struct8BytesIntInt64CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(3, result); |
| } |
| |
| typedef VariadicAt1Doublex2Struct32BytesHomogeneousDoubleDType = Double |
| Function(Double, VarArgs<(Double, Struct32BytesHomogeneousDouble, Double)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a0 = 0.0; |
| double variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a1 = 0.0; |
| Struct32BytesHomogeneousDouble |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a2 = |
| Pointer<Struct32BytesHomogeneousDouble>.fromAddress(0).ref; |
| double variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a3 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1Doublex2Struct32BytesHomogeneousDoubleDResult = 0.0; |
| |
| double variadicAt1Doublex2Struct32BytesHomogeneousDoubleDCalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a0; |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a1; |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a2.a0; |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a2.a1; |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a2.a2; |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a2.a3; |
| result += variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a3; |
| |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleDResult = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments including struct. |
| double variadicAt1Doublex2Struct32BytesHomogeneousDoubleD( |
| double a0, double a1, Struct32BytesHomogeneousDouble a2, double a3) { |
| print( |
| "variadicAt1Doublex2Struct32BytesHomogeneousDoubleD(${a0}, ${a1}, ${a2}, ${a3})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1Doublex2Struct32BytesHomogeneousDoubleD throwing on purpose!"); |
| } |
| |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a0 = a0; |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a1 = a1; |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a2 = a2; |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleD_a3 = a3; |
| |
| final result = |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleDCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Doublex2Struct32BytesHomogeneousDoubleDAfterCallback() { |
| final result = |
| variadicAt1Doublex2Struct32BytesHomogeneousDoubleDCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-4.0, result); |
| } |
| |
| typedef VariadicAt1DoubleStruct12BytesHomogeneousFloatDoubType = Double |
| Function(Double, VarArgs<(Struct12BytesHomogeneousFloat, Double)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a0 = 0.0; |
| Struct12BytesHomogeneousFloat |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a1 = |
| Pointer<Struct12BytesHomogeneousFloat>.fromAddress(0).ref; |
| double variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a2 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1DoubleStruct12BytesHomogeneousFloatDoubResult = 0.0; |
| |
| double variadicAt1DoubleStruct12BytesHomogeneousFloatDoubCalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a0; |
| result += variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a1.a0; |
| result += variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a1.a1; |
| result += variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a1.a2; |
| result += variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a2; |
| |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoubResult = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments including struct. |
| double variadicAt1DoubleStruct12BytesHomogeneousFloatDoub( |
| double a0, Struct12BytesHomogeneousFloat a1, double a2) { |
| print( |
| "variadicAt1DoubleStruct12BytesHomogeneousFloatDoub(${a0}, ${a1}, ${a2})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1DoubleStruct12BytesHomogeneousFloatDoub throwing on purpose!"); |
| } |
| |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a0 = a0; |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a1 = a1; |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoub_a2 = a2; |
| |
| final result = |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoubCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1DoubleStruct12BytesHomogeneousFloatDoubAfterCallback() { |
| final result = |
| variadicAt1DoubleStruct12BytesHomogeneousFloatDoubCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-3.0, result); |
| } |
| |
| typedef VariadicAt1Int32Struct20BytesHomogeneousInt32Int32Type = Int32 Function( |
| Int32, VarArgs<(Struct20BytesHomogeneousInt32, Int32)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a0 = 0; |
| Struct20BytesHomogeneousInt32 |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1 = |
| Pointer<Struct20BytesHomogeneousInt32>.fromAddress(0).ref; |
| int variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a2 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Int32Struct20BytesHomogeneousInt32Int32Result = 0; |
| |
| int variadicAt1Int32Struct20BytesHomogeneousInt32Int32CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a0; |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1.a0; |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1.a1; |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1.a2; |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1.a3; |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1.a4; |
| result += variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a2; |
| |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments including struct. |
| int variadicAt1Int32Struct20BytesHomogeneousInt32Int32( |
| int a0, Struct20BytesHomogeneousInt32 a1, int a2) { |
| print( |
| "variadicAt1Int32Struct20BytesHomogeneousInt32Int32(${a0}, ${a1}, ${a2})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1Int32Struct20BytesHomogeneousInt32Int32 throwing on purpose!"); |
| } |
| |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a0 = a0; |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a1 = a1; |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32_a2 = a2; |
| |
| final result = |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int32Struct20BytesHomogeneousInt32Int32AfterCallback() { |
| final result = |
| variadicAt1Int32Struct20BytesHomogeneousInt32Int32CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(-4, result); |
| } |
| |
| typedef VariadicAt1DoubleStruct20BytesHomogeneousFloatDoubType = Double |
| Function(Double, VarArgs<(Struct20BytesHomogeneousFloat, Double)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a0 = 0.0; |
| Struct20BytesHomogeneousFloat |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1 = |
| Pointer<Struct20BytesHomogeneousFloat>.fromAddress(0).ref; |
| double variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a2 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1DoubleStruct20BytesHomogeneousFloatDoubResult = 0.0; |
| |
| double variadicAt1DoubleStruct20BytesHomogeneousFloatDoubCalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a0; |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1.a0; |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1.a1; |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1.a2; |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1.a3; |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1.a4; |
| result += variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a2; |
| |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoubResult = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments including struct. |
| double variadicAt1DoubleStruct20BytesHomogeneousFloatDoub( |
| double a0, Struct20BytesHomogeneousFloat a1, double a2) { |
| print( |
| "variadicAt1DoubleStruct20BytesHomogeneousFloatDoub(${a0}, ${a1}, ${a2})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1DoubleStruct20BytesHomogeneousFloatDoub throwing on purpose!"); |
| } |
| |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a0 = a0; |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a1 = a1; |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoub_a2 = a2; |
| |
| final result = |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoubCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1DoubleStruct20BytesHomogeneousFloatDoubAfterCallback() { |
| final result = |
| variadicAt1DoubleStruct20BytesHomogeneousFloatDoubCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-4.0, result); |
| } |
| |
| typedef VariadicAt2Int32Int64IntPtrType = Int32 Function( |
| Int32, Int64, VarArgs<(IntPtr,)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt2Int32Int64IntPtr_a0 = 0; |
| int variadicAt2Int32Int64IntPtr_a1 = 0; |
| int variadicAt2Int32Int64IntPtr_a2 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt2Int32Int64IntPtrResult = 0; |
| |
| int variadicAt2Int32Int64IntPtrCalculateResult() { |
| int result = 0; |
| |
| result += variadicAt2Int32Int64IntPtr_a0; |
| result += variadicAt2Int32Int64IntPtr_a1; |
| result += variadicAt2Int32Int64IntPtr_a2; |
| |
| variadicAt2Int32Int64IntPtrResult = result; |
| |
| return result; |
| } |
| |
| /// Regression test for variadic arguments. |
| /// https://github.com/dart-lang/sdk/issues/49460 |
| int variadicAt2Int32Int64IntPtr(int a0, int a1, int a2) { |
| print("variadicAt2Int32Int64IntPtr(${a0}, ${a1}, ${a2})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt2Int32Int64IntPtr throwing on purpose!"); |
| } |
| |
| variadicAt2Int32Int64IntPtr_a0 = a0; |
| variadicAt2Int32Int64IntPtr_a1 = a1; |
| variadicAt2Int32Int64IntPtr_a2 = a2; |
| |
| final result = variadicAt2Int32Int64IntPtrCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt2Int32Int64IntPtrAfterCallback() { |
| final result = variadicAt2Int32Int64IntPtrCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(-2, result); |
| } |
| |
| typedef VariadicAt1DoubleInt64Int32DoubleInt64Int32Type = Double Function( |
| Double, VarArgs<(Int64, Int32, Double, Int64, Int32)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1DoubleInt64Int32DoubleInt64Int32_a0 = 0.0; |
| int variadicAt1DoubleInt64Int32DoubleInt64Int32_a1 = 0; |
| int variadicAt1DoubleInt64Int32DoubleInt64Int32_a2 = 0; |
| double variadicAt1DoubleInt64Int32DoubleInt64Int32_a3 = 0.0; |
| int variadicAt1DoubleInt64Int32DoubleInt64Int32_a4 = 0; |
| int variadicAt1DoubleInt64Int32DoubleInt64Int32_a5 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1DoubleInt64Int32DoubleInt64Int32Result = 0.0; |
| |
| double variadicAt1DoubleInt64Int32DoubleInt64Int32CalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1DoubleInt64Int32DoubleInt64Int32_a0; |
| result += variadicAt1DoubleInt64Int32DoubleInt64Int32_a1; |
| result += variadicAt1DoubleInt64Int32DoubleInt64Int32_a2; |
| result += variadicAt1DoubleInt64Int32DoubleInt64Int32_a3; |
| result += variadicAt1DoubleInt64Int32DoubleInt64Int32_a4; |
| result += variadicAt1DoubleInt64Int32DoubleInt64Int32_a5; |
| |
| variadicAt1DoubleInt64Int32DoubleInt64Int32Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments mixed. |
| double variadicAt1DoubleInt64Int32DoubleInt64Int32( |
| double a0, int a1, int a2, double a3, int a4, int a5) { |
| print( |
| "variadicAt1DoubleInt64Int32DoubleInt64Int32(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1DoubleInt64Int32DoubleInt64Int32 throwing on purpose!"); |
| } |
| |
| variadicAt1DoubleInt64Int32DoubleInt64Int32_a0 = a0; |
| variadicAt1DoubleInt64Int32DoubleInt64Int32_a1 = a1; |
| variadicAt1DoubleInt64Int32DoubleInt64Int32_a2 = a2; |
| variadicAt1DoubleInt64Int32DoubleInt64Int32_a3 = a3; |
| variadicAt1DoubleInt64Int32DoubleInt64Int32_a4 = a4; |
| variadicAt1DoubleInt64Int32DoubleInt64Int32_a5 = a5; |
| |
| final result = variadicAt1DoubleInt64Int32DoubleInt64Int32CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1DoubleInt64Int32DoubleInt64Int32AfterCallback() { |
| final result = variadicAt1DoubleInt64Int32DoubleInt64Int32CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(3.0, result); |
| } |
| |
| typedef VariadicAt1Int64Int32Struct12BytesHomogeneousFloatType = Double |
| Function(Int64, VarArgs<(Int32, Struct12BytesHomogeneousFloat)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a0 = 0; |
| int variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a1 = 0; |
| Struct12BytesHomogeneousFloat |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a2 = |
| Pointer<Struct12BytesHomogeneousFloat>.fromAddress(0).ref; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1Int64Int32Struct12BytesHomogeneousFloatResult = 0.0; |
| |
| double variadicAt1Int64Int32Struct12BytesHomogeneousFloatCalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a0; |
| result += variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a1; |
| result += variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a2.a0; |
| result += variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a2.a1; |
| result += variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a2.a2; |
| |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloatResult = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments homogenous struct stack alignment on macos_arm64. |
| double variadicAt1Int64Int32Struct12BytesHomogeneousFloat( |
| int a0, int a1, Struct12BytesHomogeneousFloat a2) { |
| print( |
| "variadicAt1Int64Int32Struct12BytesHomogeneousFloat(${a0}, ${a1}, ${a2})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1Int64Int32Struct12BytesHomogeneousFloat throwing on purpose!"); |
| } |
| |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a0 = a0; |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a1 = a1; |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloat_a2 = a2; |
| |
| final result = |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloatCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int64Int32Struct12BytesHomogeneousFloatAfterCallback() { |
| final result = |
| variadicAt1Int64Int32Struct12BytesHomogeneousFloatCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-3.0, result); |
| } |
| |
| typedef VariadicAt11Doublex8FloatStruct12BytesHomogeneousFType |
| = Double Function( |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Double, |
| Float, |
| Struct12BytesHomogeneousFloat, |
| Int64, |
| VarArgs<(Int32, Struct12BytesHomogeneousFloat)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a0 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a1 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a2 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a3 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a4 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a5 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a6 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a7 = 0.0; |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a8 = 0.0; |
| Struct12BytesHomogeneousFloat |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a9 = |
| Pointer<Struct12BytesHomogeneousFloat>.fromAddress(0).ref; |
| int variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a10 = 0; |
| int variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a11 = 0; |
| Struct12BytesHomogeneousFloat |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a12 = |
| Pointer<Struct12BytesHomogeneousFloat>.fromAddress(0).ref; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousFResult = 0.0; |
| |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousFCalculateResult() { |
| double result = 0; |
| |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a0; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a1; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a2; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a3; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a4; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a5; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a6; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a7; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a8; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a9.a0; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a9.a1; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a9.a2; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a10; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a11; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a12.a0; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a12.a1; |
| result += variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a12.a2; |
| |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousFResult = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments homogenous struct stack alignment on macos_arm64. |
| double variadicAt11Doublex8FloatStruct12BytesHomogeneousF( |
| double a0, |
| double a1, |
| double a2, |
| double a3, |
| double a4, |
| double a5, |
| double a6, |
| double a7, |
| double a8, |
| Struct12BytesHomogeneousFloat a9, |
| int a10, |
| int a11, |
| Struct12BytesHomogeneousFloat a12) { |
| print( |
| "variadicAt11Doublex8FloatStruct12BytesHomogeneousF(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8}, ${a9}, ${a10}, ${a11}, ${a12})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt11Doublex8FloatStruct12BytesHomogeneousF throwing on purpose!"); |
| } |
| |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a0 = a0; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a1 = a1; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a2 = a2; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a3 = a3; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a4 = a4; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a5 = a5; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a6 = a6; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a7 = a7; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a8 = a8; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a9 = a9; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a10 = a10; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a11 = a11; |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousF_a12 = a12; |
| |
| final result = |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousFCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt11Doublex8FloatStruct12BytesHomogeneousFAfterCallback() { |
| final result = |
| variadicAt11Doublex8FloatStruct12BytesHomogeneousFCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-9.0, result); |
| } |
| |
| typedef VariadicAt1DoubleInt64Int32Struct20BytesHomogeneouType |
| = Double Function( |
| Double, |
| VarArgs< |
| ( |
| Int64, |
| Int32, |
| Struct20BytesHomogeneousInt32, |
| Double, |
| Int64, |
| Int32, |
| Struct12BytesHomogeneousFloat, |
| Int64 |
| )>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a0 = 0.0; |
| int variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a1 = 0; |
| int variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a2 = 0; |
| Struct20BytesHomogeneousInt32 |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3 = |
| Pointer<Struct20BytesHomogeneousInt32>.fromAddress(0).ref; |
| double variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a4 = 0.0; |
| int variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a5 = 0; |
| int variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a6 = 0; |
| Struct12BytesHomogeneousFloat |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a7 = |
| Pointer<Struct12BytesHomogeneousFloat>.fromAddress(0).ref; |
| int variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a8 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt1DoubleInt64Int32Struct20BytesHomogeneouResult = 0.0; |
| |
| double variadicAt1DoubleInt64Int32Struct20BytesHomogeneouCalculateResult() { |
| double result = 0; |
| |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a0; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a1; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a2; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3.a0; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3.a1; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3.a2; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3.a3; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3.a4; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a4; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a5; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a6; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a7.a0; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a7.a1; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a7.a2; |
| result += variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a8; |
| |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneouResult = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments mixed. |
| double variadicAt1DoubleInt64Int32Struct20BytesHomogeneou( |
| double a0, |
| int a1, |
| int a2, |
| Struct20BytesHomogeneousInt32 a3, |
| double a4, |
| int a5, |
| int a6, |
| Struct12BytesHomogeneousFloat a7, |
| int a8) { |
| print( |
| "variadicAt1DoubleInt64Int32Struct20BytesHomogeneou(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7}, ${a8})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1DoubleInt64Int32Struct20BytesHomogeneou throwing on purpose!"); |
| } |
| |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a0 = a0; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a1 = a1; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a2 = a2; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a3 = a3; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a4 = a4; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a5 = a5; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a6 = a6; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a7 = a7; |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneou_a8 = a8; |
| |
| final result = |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneouCalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1DoubleInt64Int32Struct20BytesHomogeneouAfterCallback() { |
| final result = |
| variadicAt1DoubleInt64Int32Struct20BytesHomogeneouCalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-8.0, result); |
| } |
| |
| typedef VariadicAt5Doublex5Type = Double Function( |
| Double, Double, Double, Double, Double, VarArgs<()>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| double variadicAt5Doublex5_a0 = 0.0; |
| double variadicAt5Doublex5_a1 = 0.0; |
| double variadicAt5Doublex5_a2 = 0.0; |
| double variadicAt5Doublex5_a3 = 0.0; |
| double variadicAt5Doublex5_a4 = 0.0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| double variadicAt5Doublex5Result = 0.0; |
| |
| double variadicAt5Doublex5CalculateResult() { |
| double result = 0; |
| |
| result += variadicAt5Doublex5_a0; |
| result += variadicAt5Doublex5_a1; |
| result += variadicAt5Doublex5_a2; |
| result += variadicAt5Doublex5_a3; |
| result += variadicAt5Doublex5_a4; |
| |
| variadicAt5Doublex5Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments function definition, but not passing any. |
| double variadicAt5Doublex5( |
| double a0, double a1, double a2, double a3, double a4) { |
| print("variadicAt5Doublex5(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception("VariadicAt5Doublex5 throwing on purpose!"); |
| } |
| |
| variadicAt5Doublex5_a0 = a0; |
| variadicAt5Doublex5_a1 = a1; |
| variadicAt5Doublex5_a2 = a2; |
| variadicAt5Doublex5_a3 = a3; |
| variadicAt5Doublex5_a4 = a4; |
| |
| final result = variadicAt5Doublex5CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt5Doublex5AfterCallback() { |
| final result = variadicAt5Doublex5CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.approxEquals(-3.0, result); |
| } |
| |
| typedef VariadicAt1Int64x7Struct12BytesHomogeneousInt32Type = Int64 Function( |
| Int64, |
| VarArgs< |
| ( |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Int64, |
| Struct12BytesHomogeneousInt32 |
| )>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a0 = 0; |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a1 = 0; |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a2 = 0; |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a3 = 0; |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a4 = 0; |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a5 = 0; |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32_a6 = 0; |
| Struct12BytesHomogeneousInt32 |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a7 = |
| Pointer<Struct12BytesHomogeneousInt32>.fromAddress(0).ref; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32Result = 0; |
| |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a0; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a1; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a2; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a3; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a4; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a5; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a6; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a7.a0; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a7.a1; |
| result += variadicAt1Int64x7Struct12BytesHomogeneousInt32_a7.a2; |
| |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32Result = result; |
| |
| return result; |
| } |
| |
| /// Struct stradles last argument register, variadic |
| int variadicAt1Int64x7Struct12BytesHomogeneousInt32(int a0, int a1, int a2, |
| int a3, int a4, int a5, int a6, Struct12BytesHomogeneousInt32 a7) { |
| print( |
| "variadicAt1Int64x7Struct12BytesHomogeneousInt32(${a0}, ${a1}, ${a2}, ${a3}, ${a4}, ${a5}, ${a6}, ${a7})"); |
| |
| // Possibly throw. |
| if (a0 == 42 || a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1Int64x7Struct12BytesHomogeneousInt32 throwing on purpose!"); |
| } |
| |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a0 = a0; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a1 = a1; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a2 = a2; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a3 = a3; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a4 = a4; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a5 = a5; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a6 = a6; |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32_a7 = a7; |
| |
| final result = |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Int64x7Struct12BytesHomogeneousInt32AfterCallback() { |
| final result = |
| variadicAt1Int64x7Struct12BytesHomogeneousInt32CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(5, result); |
| } |
| |
| typedef VariadicAt1Struct12BytesHomogeneousInt32Int32x4Type = Int32 Function( |
| Struct12BytesHomogeneousInt32, VarArgs<(Int32, Int32, Int32, Int32)>); |
| |
| // Global variables to be able to test inputs after callback returned. |
| Struct12BytesHomogeneousInt32 |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4_a0 = |
| Pointer<Struct12BytesHomogeneousInt32>.fromAddress(0).ref; |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4_a1 = 0; |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4_a2 = 0; |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4_a3 = 0; |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4_a4 = 0; |
| |
| // Result variable also global, so we can delete it after the callback. |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4Result = 0; |
| |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4CalculateResult() { |
| int result = 0; |
| |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a0.a0; |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a0.a1; |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a0.a2; |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a1; |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a2; |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a3; |
| result += variadicAt1Struct12BytesHomogeneousInt32Int32x4_a4; |
| |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4Result = result; |
| |
| return result; |
| } |
| |
| /// Variadic arguments test on macos_arm64. |
| int variadicAt1Struct12BytesHomogeneousInt32Int32x4( |
| Struct12BytesHomogeneousInt32 a0, int a1, int a2, int a3, int a4) { |
| print( |
| "variadicAt1Struct12BytesHomogeneousInt32Int32x4(${a0}, ${a1}, ${a2}, ${a3}, ${a4})"); |
| |
| // Possibly throw. |
| if (a0.a0 == 42 || a0.a0 == 84) { |
| print("throwing!"); |
| throw Exception( |
| "VariadicAt1Struct12BytesHomogeneousInt32Int32x4 throwing on purpose!"); |
| } |
| |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4_a0 = a0; |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4_a1 = a1; |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4_a2 = a2; |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4_a3 = a3; |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4_a4 = a4; |
| |
| final result = |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4CalculateResult(); |
| |
| print("result = $result"); |
| |
| return result; |
| } |
| |
| void variadicAt1Struct12BytesHomogeneousInt32Int32x4AfterCallback() { |
| final result = |
| variadicAt1Struct12BytesHomogeneousInt32Int32x4CalculateResult(); |
| |
| print("after callback result = $result"); |
| |
| Expect.equals(-4, result); |
| } |