blob: 60cda68e8acbc8d811a7170870e27ef225c2cd23 [file] [log] [blame] [edit]
// Copyright (c) 2024, 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/address_of_test_generator.dart.
//
// SharedObjects=ffi_test_functions
// VMOptions=
// VMOptions=--deterministic --optimization-counter-threshold=90
// VMOptions=--use-slow-path
// VMOptions=--use-slow-path --stacktrace-every=100
// ignore_for_file: unused_import
import 'dart:ffi';
import 'dart:typed_data';
import 'package:expect/expect.dart';
import 'address_of_generated_shared.dart';
import 'address_of_shared.dart';
import 'dylib_utils.dart';
final ffiTestFunctions = dlopenPlatformSpecific('ffi_test_functions');
void main() {
// Force dlopen so @Native lookups in DynamicLibrary.process() succeed.
dlopenGlobalPlatformSpecific('ffi_test_functions');
for (int i = 0; i < 100; ++i) {
testAddressOfInt8Array();
}
}
final class Int8ArrayStruct extends Struct {
@Array(20)
external Array<Int8> array;
}
Array<Int8> makeInt8Array(int length) {
assert(length == 20);
final typedData = makeInt8List(length);
final struct = Struct.create<Int8ArrayStruct>(typedData);
return struct.array;
}
void testAddressOfInt8Array() {
const length = 20;
final array = makeInt8Array(length);
final expectedResult = makeExpectedResultInt8(0, length);
final result = Foo.takeInt8Pointer(array.address, length);
Expect.equals(expectedResult, result);
}
class Foo {
@Native<Int8 Function(Pointer<Int8>, Size)>(
symbol: 'TakeInt8Pointer',
isLeaf: true,
)
external static int takeInt8Pointer(Pointer<Int8> pointer, int length);
}