diff --git a/samples/ffi/resource_management/arena_sample.dart b/samples/ffi/resource_management/arena_sample.dart index 94b1f6d8361..8dcdfda81dc 100644 --- a/samples/ffi/resource_management/arena_sample.dart +++ b/samples/ffi/resource_management/arena_sample.dart @@ -25,7 +25,7 @@ main() async { using((Arena arena) { final p = arena(2); p[0] = 24; - MemMove(p.elementAt(1).cast(), p.cast(), sizeOf()); + MemMove((p + 1).cast(), p.cast(), sizeOf()); print(p[1]); Expect.equals(24, p[1]); }); @@ -35,7 +35,7 @@ main() async { using((Arena arena) { final p = arena(2); p[0] = 25; - MemMove(p.elementAt(1).cast(), p.cast(), 8); + MemMove((p + 1).cast(), p.cast(), 8); print(p[1]); Expect.equals(25, p[1]); throw Exception("Some random exception"); diff --git a/samples/ffi/resource_management/arena_zoned_sample.dart b/samples/ffi/resource_management/arena_zoned_sample.dart index 39d15f19697..f3bdf44e645 100644 --- a/samples/ffi/resource_management/arena_zoned_sample.dart +++ b/samples/ffi/resource_management/arena_zoned_sample.dart @@ -24,7 +24,7 @@ main() async { withZoneArena(() { final p = zoneArena(2); p[0] = 24; - MemMove(p.elementAt(1).cast(), p.cast(), sizeOf()); + MemMove((p + 1).cast(), p.cast(), sizeOf()); print(p[1]); Expect.equals(24, p[1]); }); @@ -34,7 +34,7 @@ main() async { withZoneArena(() { final p = zoneArena(2); p[0] = 25; - MemMove(p.elementAt(1).cast(), p.cast(), 8); + MemMove((p + 1).cast(), p.cast(), 8); print(p[1]); Expect.equals(25, p[1]); throw Exception("Some random exception"); diff --git a/samples/ffi/resource_management/unmanaged_sample.dart b/samples/ffi/resource_management/unmanaged_sample.dart index 495564df2bb..ac38f3e1ca0 100644 --- a/samples/ffi/resource_management/unmanaged_sample.dart +++ b/samples/ffi/resource_management/unmanaged_sample.dart @@ -25,7 +25,7 @@ main() { // For automatic management use a Arena. final p = calloc(2); p[0] = 24; - memMove(p.elementAt(1).cast(), p.cast(), sizeOf()); + memMove((p + 1).cast(), p.cast(), sizeOf()); print(p[1]); Expect.equals(24, p[1]); calloc.free(p); diff --git a/samples/ffi/sample_ffi_data.dart b/samples/ffi/sample_ffi_data.dart index ef7ee074c47..858d53fb3ac 100644 --- a/samples/ffi/sample_ffi_data.dart +++ b/samples/ffi/sample_ffi_data.dart @@ -71,7 +71,7 @@ main() { Pointer p2 = p1.cast(); print('${p2.runtimeType} value: ${p2.value}'); // -1 - Pointer p3 = p2.elementAt(1); + Pointer p3 = p2 + 1; print('${p3.runtimeType} value: ${p3.value}'); // 2^31 - 1 calloc.free(p1); @@ -81,10 +81,10 @@ main() { // Data can be tightly packed in memory. Pointer p = calloc(8); for (var i in [0, 1, 2, 3, 4, 5, 6, 7]) { - p.elementAt(i).value = i * 3; + (p + i).value = i * 3; } for (var i in [0, 1, 2, 3, 4, 5, 6, 7]) { - print('p.elementAt($i) value: ${p.elementAt(i).value}'); + print('p.elementAt($i) value: ${(p + i).value}'); } calloc.free(p); } diff --git a/samples/ffi/sample_ffi_functions.dart b/samples/ffi/sample_ffi_functions.dart index 51376e18fbb..4630bf972fb 100644 --- a/samples/ffi/sample_ffi_functions.dart +++ b/samples/ffi/sample_ffi_functions.dart @@ -197,7 +197,7 @@ main() { Pointer p2 = calloc(2); p2.value = 42; p2[1] = 1000; - print(p2.elementAt(1).address.toRadixString(16)); + print((p2 + 1).address.toRadixString(16)); print(p2[1]); Pointer result = assign1337Index1(p2); print(p2[1]); diff --git a/samples/ffi/sample_ffi_functions_structs.dart b/samples/ffi/sample_ffi_functions_structs.dart index bf9c0ca4bae..9d12a137c7c 100644 --- a/samples/ffi/sample_ffi_functions_structs.dart +++ b/samples/ffi/sample_ffi_functions_structs.dart @@ -50,8 +50,8 @@ main() { NativeCoordinateOp f1 = p1.asFunction(); Pointer c1 = calloc(3); - Pointer c2 = c1.elementAt(1); - Pointer c3 = c1.elementAt(2); + Pointer c2 = c1 + 1; + Pointer c3 = c1 + 2; c1.ref.x = 10.0; c1.ref.y = 10.0; c1.ref.next = c3; diff --git a/samples/ffi/sample_ffi_structs.dart b/samples/ffi/sample_ffi_structs.dart index 5f02c1f11b0..5a0c8506fe2 100644 --- a/samples/ffi/sample_ffi_structs.dart +++ b/samples/ffi/sample_ffi_structs.dart @@ -40,8 +40,8 @@ main() { { // Allocates coordinates consecutively in c memory. Pointer c1 = calloc(3); - Pointer c2 = c1.elementAt(1); - Pointer c3 = c1.elementAt(2); + Pointer c2 = c1 + 1; + Pointer c3 = c1 + 2; c1.ref.x = 10.0; c1.ref.y = 10.0; c1.ref.next = c3;