Skip to content

Commit 546ddc6

Browse files
dcharkesCommit Queue
authored andcommitted
[ffi] Format tests with Dart 3.8
Change-Id: Iaa29e2df68875fbb363ab2ac5cd59cc99e65532b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422102 Auto-Submit: Daco Harkes <[email protected]> Commit-Queue: Bob Nystrom <[email protected]> Reviewed-by: Bob Nystrom <[email protected]> Commit-Queue: Daco Harkes <[email protected]>
1 parent 4d6adc5 commit 546ddc6

File tree

53 files changed

+3421
-3193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3421
-3193
lines changed

tests/ffi/callback_tests_utils.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,17 @@ class CallbackTest {
3131
}) {}
3232

3333
void run() {
34-
final NativeCallbackTestFn tester =
35-
isLeaf
36-
? ffiTestFunctions
37-
.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
38-
"Test$name",
39-
isLeaf: true,
40-
)
41-
: ffiTestFunctions
42-
.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
43-
"Test$name",
44-
isLeaf: false,
45-
);
34+
final NativeCallbackTestFn tester = isLeaf
35+
? ffiTestFunctions
36+
.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
37+
"Test$name",
38+
isLeaf: true,
39+
)
40+
: ffiTestFunctions
41+
.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
42+
"Test$name",
43+
isLeaf: false,
44+
);
4645

4746
final cb = callback;
4847
final int testCode = tester(

tests/ffi/data_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,11 @@ void testDynamicInvocation() {
440440
calloc.free(p);
441441
}
442442

443-
final nullableInt64ElementAt1 = ffiTestFunctions.lookupFunction<
444-
Pointer<Int64> Function(Pointer<Int64>),
445-
Pointer<Int64> Function(Pointer<Int64>)
446-
>("NullableInt64ElemAt1");
443+
final nullableInt64ElementAt1 = ffiTestFunctions
444+
.lookupFunction<
445+
Pointer<Int64> Function(Pointer<Int64>),
446+
Pointer<Int64> Function(Pointer<Int64>)
447+
>("NullableInt64ElemAt1");
447448

448449
void testNullptrCast() {
449450
Pointer<Int64> ptr = nullptr;

tests/ffi/deeply_immutable_c_api_finalizer_test.dart

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ final class MyFinalizable implements Finalizable {
4040
}
4141
}
4242

43-
final calloc =
44-
dlopenPlatformSpecific("ffi_test_functions")
45-
.lookup<NativeFunction<Pointer<Void> Function(Size, Size)>>('Calloc')
46-
.asFunction<Pointer<Void> Function(int, int)>();
43+
final calloc = dlopenPlatformSpecific("ffi_test_functions")
44+
.lookup<NativeFunction<Pointer<Void> Function(Size, Size)>>('Calloc')
45+
.asFunction<Pointer<Void> Function(int, int)>();
4746

4847
final freeFinalizer = dlopenPlatformSpecific(
4948
"ffi_test_functions",
@@ -55,19 +54,18 @@ final Dart_FinalizableHandle Function(
5554
int,
5655
Dart_HandleFinalizer,
5756
)
58-
newFinalizableHandle =
59-
_findDartApiFunction('Dart_NewFinalizableHandle')
60-
.cast<
61-
NativeFunction<
62-
Dart_FinalizableHandle Function(
63-
Handle,
64-
Pointer<Void>,
65-
IntPtr,
66-
Dart_HandleFinalizer,
67-
)
68-
>
69-
>()
70-
.asFunction();
57+
newFinalizableHandle = _findDartApiFunction('Dart_NewFinalizableHandle')
58+
.cast<
59+
NativeFunction<
60+
Dart_FinalizableHandle Function(
61+
Handle,
62+
Pointer<Void>,
63+
IntPtr,
64+
Dart_HandleFinalizer,
65+
)
66+
>
67+
>()
68+
.asFunction();
7169

7270
final void Function(Dart_FinalizableHandle, Object) deleteFinalizableHandle =
7371
_findDartApiFunction('Dart_DeleteFinalizableHandle')

tests/ffi/dl_api_exit_enter_isolate_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import 'dylib_utils.dart';
1111

1212
final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
1313

14-
final initializeApi = ffiTestFunctions.lookupFunction<
15-
IntPtr Function(Pointer<Void>),
16-
int Function(Pointer<Void>)
17-
>("InitDartApiDL");
14+
final initializeApi = ffiTestFunctions
15+
.lookupFunction<
16+
IntPtr Function(Pointer<Void>),
17+
int Function(Pointer<Void>)
18+
>("InitDartApiDL");
1819
final enterBarrier = ffiTestFunctions
1920
.lookupFunction<Void Function(IntPtr, Bool), void Function(int, bool)>(
2021
"WaitUntilNThreadsEnterBarrier",

tests/ffi/dylib_utils.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ const RTLD_GLOBAL_android_arm32 = 0x00002;
3838
/// On Linux and Android Arm64.
3939
const RTLD_GLOBAL_rest = 0x00100;
4040

41-
final RTLD_GLOBAL =
42-
Abi.current() == Abi.androidArm
43-
? RTLD_GLOBAL_android_arm32
44-
: RTLD_GLOBAL_rest;
41+
final RTLD_GLOBAL = Abi.current() == Abi.androidArm
42+
? RTLD_GLOBAL_android_arm32
43+
: RTLD_GLOBAL_rest;
4544

4645
@Native<Pointer<Void> Function(Pointer<Char>, Int)>()
4746
external Pointer<Void> dlopen(Pointer<Char> file, int mode);

tests/ffi/function_callbacks_leaf_test.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ void main(List<String> arguments) async {
4040
simpleAddition,
4141
);
4242
case "2":
43-
callbackPointer =
44-
NativeCallable<SimpleAdditionType>.isolateLocal(
45-
simpleAddition,
46-
).nativeFunction;
43+
callbackPointer = NativeCallable<SimpleAdditionType>.isolateLocal(
44+
simpleAddition,
45+
).nativeFunction;
4746
case "3":
48-
callbackPointer =
49-
NativeCallable<SimpleAdditionType>.listener(
50-
simpleAddition,
51-
).nativeFunction;
47+
callbackPointer = NativeCallable<SimpleAdditionType>.listener(
48+
simpleAddition,
49+
).nativeFunction;
5250
default:
5351
throw "Unknown";
5452
}

tests/ffi/function_callbacks_structs_by_value_generated_test.dart

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -951,26 +951,36 @@ typedef PassStruct1ByteIntx10Type =
951951
);
952952

953953
// Global variables to be able to test inputs after callback returned.
954-
Struct1ByteInt passStruct1ByteIntx10_a0 =
955-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
956-
Struct1ByteInt passStruct1ByteIntx10_a1 =
957-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
958-
Struct1ByteInt passStruct1ByteIntx10_a2 =
959-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
960-
Struct1ByteInt passStruct1ByteIntx10_a3 =
961-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
962-
Struct1ByteInt passStruct1ByteIntx10_a4 =
963-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
964-
Struct1ByteInt passStruct1ByteIntx10_a5 =
965-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
966-
Struct1ByteInt passStruct1ByteIntx10_a6 =
967-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
968-
Struct1ByteInt passStruct1ByteIntx10_a7 =
969-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
970-
Struct1ByteInt passStruct1ByteIntx10_a8 =
971-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
972-
Struct1ByteInt passStruct1ByteIntx10_a9 =
973-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
954+
Struct1ByteInt passStruct1ByteIntx10_a0 = Pointer<Struct1ByteInt>.fromAddress(
955+
0,
956+
).ref;
957+
Struct1ByteInt passStruct1ByteIntx10_a1 = Pointer<Struct1ByteInt>.fromAddress(
958+
0,
959+
).ref;
960+
Struct1ByteInt passStruct1ByteIntx10_a2 = Pointer<Struct1ByteInt>.fromAddress(
961+
0,
962+
).ref;
963+
Struct1ByteInt passStruct1ByteIntx10_a3 = Pointer<Struct1ByteInt>.fromAddress(
964+
0,
965+
).ref;
966+
Struct1ByteInt passStruct1ByteIntx10_a4 = Pointer<Struct1ByteInt>.fromAddress(
967+
0,
968+
).ref;
969+
Struct1ByteInt passStruct1ByteIntx10_a5 = Pointer<Struct1ByteInt>.fromAddress(
970+
0,
971+
).ref;
972+
Struct1ByteInt passStruct1ByteIntx10_a6 = Pointer<Struct1ByteInt>.fromAddress(
973+
0,
974+
).ref;
975+
Struct1ByteInt passStruct1ByteIntx10_a7 = Pointer<Struct1ByteInt>.fromAddress(
976+
0,
977+
).ref;
978+
Struct1ByteInt passStruct1ByteIntx10_a8 = Pointer<Struct1ByteInt>.fromAddress(
979+
0,
980+
).ref;
981+
Struct1ByteInt passStruct1ByteIntx10_a9 = Pointer<Struct1ByteInt>.fromAddress(
982+
0,
983+
).ref;
974984

975985
// Result variable also global, so we can delete it after the callback.
976986
int passStruct1ByteIntx10Result = 0;

tests/ffi/function_callbacks_structs_by_value_native_callable_generated_test.dart

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -999,26 +999,36 @@ typedef PassStruct1ByteIntx10Type =
999999
);
10001000

10011001
// Global variables to be able to test inputs after callback returned.
1002-
Struct1ByteInt passStruct1ByteIntx10_a0 =
1003-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1004-
Struct1ByteInt passStruct1ByteIntx10_a1 =
1005-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1006-
Struct1ByteInt passStruct1ByteIntx10_a2 =
1007-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1008-
Struct1ByteInt passStruct1ByteIntx10_a3 =
1009-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1010-
Struct1ByteInt passStruct1ByteIntx10_a4 =
1011-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1012-
Struct1ByteInt passStruct1ByteIntx10_a5 =
1013-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1014-
Struct1ByteInt passStruct1ByteIntx10_a6 =
1015-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1016-
Struct1ByteInt passStruct1ByteIntx10_a7 =
1017-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1018-
Struct1ByteInt passStruct1ByteIntx10_a8 =
1019-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1020-
Struct1ByteInt passStruct1ByteIntx10_a9 =
1021-
Pointer<Struct1ByteInt>.fromAddress(0).ref;
1002+
Struct1ByteInt passStruct1ByteIntx10_a0 = Pointer<Struct1ByteInt>.fromAddress(
1003+
0,
1004+
).ref;
1005+
Struct1ByteInt passStruct1ByteIntx10_a1 = Pointer<Struct1ByteInt>.fromAddress(
1006+
0,
1007+
).ref;
1008+
Struct1ByteInt passStruct1ByteIntx10_a2 = Pointer<Struct1ByteInt>.fromAddress(
1009+
0,
1010+
).ref;
1011+
Struct1ByteInt passStruct1ByteIntx10_a3 = Pointer<Struct1ByteInt>.fromAddress(
1012+
0,
1013+
).ref;
1014+
Struct1ByteInt passStruct1ByteIntx10_a4 = Pointer<Struct1ByteInt>.fromAddress(
1015+
0,
1016+
).ref;
1017+
Struct1ByteInt passStruct1ByteIntx10_a5 = Pointer<Struct1ByteInt>.fromAddress(
1018+
0,
1019+
).ref;
1020+
Struct1ByteInt passStruct1ByteIntx10_a6 = Pointer<Struct1ByteInt>.fromAddress(
1021+
0,
1022+
).ref;
1023+
Struct1ByteInt passStruct1ByteIntx10_a7 = Pointer<Struct1ByteInt>.fromAddress(
1024+
0,
1025+
).ref;
1026+
Struct1ByteInt passStruct1ByteIntx10_a8 = Pointer<Struct1ByteInt>.fromAddress(
1027+
0,
1028+
).ref;
1029+
Struct1ByteInt passStruct1ByteIntx10_a9 = Pointer<Struct1ByteInt>.fromAddress(
1030+
0,
1031+
).ref;
10221032

10231033
// Result variable also global, so we can delete it after the callback.
10241034
int passStruct1ByteIntx10Result = 0;

tests/ffi/function_callbacks_structs_by_value_test.dart

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,27 @@ Struct20BytesHomogeneousInt32 dartPassStructRecursive(
7171
return result;
7272
}
7373

74-
final functionPointer = Pointer.fromFunction<
75-
Struct20BytesHomogeneousInt32 Function(Int64, Struct20BytesHomogeneousInt32)
76-
>(dartPassStructRecursive);
77-
78-
final cPassStructRecursive = ffiTestFunctions.lookupFunction<
79-
Struct20BytesHomogeneousInt32 Function(
80-
Int64 recursionCounter,
81-
Struct20BytesHomogeneousInt32 struct,
82-
Pointer callbackAddress,
83-
),
84-
Struct20BytesHomogeneousInt32 Function(
85-
int recursionCounter,
86-
Struct20BytesHomogeneousInt32,
87-
Pointer,
88-
)
89-
>("PassStructRecursive");
74+
final functionPointer =
75+
Pointer.fromFunction<
76+
Struct20BytesHomogeneousInt32 Function(
77+
Int64,
78+
Struct20BytesHomogeneousInt32,
79+
)
80+
>(dartPassStructRecursive);
81+
82+
final cPassStructRecursive = ffiTestFunctions
83+
.lookupFunction<
84+
Struct20BytesHomogeneousInt32 Function(
85+
Int64 recursionCounter,
86+
Struct20BytesHomogeneousInt32 struct,
87+
Pointer callbackAddress,
88+
),
89+
Struct20BytesHomogeneousInt32 Function(
90+
int recursionCounter,
91+
Struct20BytesHomogeneousInt32,
92+
Pointer,
93+
)
94+
>("PassStructRecursive");
9095

9196
Struct8BytesNestedInt typedDataBackedStruct =
9297
Pointer<Struct8BytesNestedInt>.fromAddress(0).ref;
@@ -101,10 +106,15 @@ final _receiveStructByValuePointer =
101106
_receiveStructByValue,
102107
);
103108

104-
final _invokeReceiveStructByValue = ffiTestFunctions.lookupFunction<
105-
Void Function(Pointer<NativeFunction<Void Function(Struct8BytesNestedInt)>>),
106-
void Function(Pointer<NativeFunction<Void Function(Struct8BytesNestedInt)>>)
107-
>("CallbackWithStruct");
109+
final _invokeReceiveStructByValue = ffiTestFunctions
110+
.lookupFunction<
111+
Void Function(
112+
Pointer<NativeFunction<Void Function(Struct8BytesNestedInt)>>,
113+
),
114+
void Function(
115+
Pointer<NativeFunction<Void Function(Struct8BytesNestedInt)>>,
116+
)
117+
>("CallbackWithStruct");
108118

109119
void testCopyLogic() {
110120
_invokeReceiveStructByValue(_receiveStructByValuePointer);

tests/ffi/function_struct_by_value_out_of_bounds_test.dart

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,28 @@ Struct9Uint8 returnStruct9(Pointer<Struct9Uint8> s9) {
4949

5050
void main() {
5151
final ffiTestFunctions = dlopenPlatformSpecific('ffi_test_functions');
52-
final alloc = ffiTestFunctions.lookupFunction<
53-
Pointer<Struct9Uint8> Function(),
54-
Pointer<Struct9Uint8> Function()
55-
>('AllocStruct9Uint8');
52+
final alloc = ffiTestFunctions
53+
.lookupFunction<
54+
Pointer<Struct9Uint8> Function(),
55+
Pointer<Struct9Uint8> Function()
56+
>('AllocStruct9Uint8');
5657
final sum = ffiTestFunctions
5758
.lookupFunction<Int64 Function(Struct9Uint8), int Function(Struct9Uint8)>(
5859
'SumStruct9Uint8',
5960
);
60-
final sumReturnStruct9 = ffiTestFunctions.lookupFunction<
61-
Int64 Function(Pointer<NativeFunction<Callback>>, Pointer<Struct9Uint8>),
62-
int Function(Pointer<NativeFunction<Callback>>, Pointer<Struct9Uint8>)
63-
>('SumReturnStruct9Uint8');
64-
final free = ffiTestFunctions.lookupFunction<
65-
Void Function(Pointer<Struct9Uint8>),
66-
void Function(Pointer<Struct9Uint8>)
67-
>('FreeStruct9Uint8');
61+
final sumReturnStruct9 = ffiTestFunctions
62+
.lookupFunction<
63+
Int64 Function(
64+
Pointer<NativeFunction<Callback>>,
65+
Pointer<Struct9Uint8>,
66+
),
67+
int Function(Pointer<NativeFunction<Callback>>, Pointer<Struct9Uint8>)
68+
>('SumReturnStruct9Uint8');
69+
final free = ffiTestFunctions
70+
.lookupFunction<
71+
Void Function(Pointer<Struct9Uint8>),
72+
void Function(Pointer<Struct9Uint8>)
73+
>('FreeStruct9Uint8');
6874

6975
final array = alloc();
7076
Struct9Uint8 s9 = array[64 * 1024 - 1]; // At the end of a page.

0 commit comments

Comments
 (0)