Revert "[ffi]: Remove pointer elementAt method."
This reverts commit f706ff4ee2.
Reason for revert: b/321667799 - package:win32 uses this method - https://github.com/dart-windows/win32/blob/a78ff108fbf54927b0334c1bab8f15526c24cbf8/lib/src/com/iapplicationactivationmanager.dart#L46
Original change's description:
> [ffi]: Remove pointer elementAt method.
>
> Closes #54250
>
> TEST=test/ffi
>
> R=dacoharkes@google.com
> Change-Id: I0e88adfcfe3caef0ad3bb6814ad8f27dce5dc7f4
> CoreLibraryReviewExempt: FFI only
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346380
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Auto-Submit: Shikhar <shikharish05@gmail.com>
Change-Id: I1b7a48d14e9b85676a27f76a926e21cac9c76c85
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347600
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
committed by
Commit Queue
parent
3a314331a7
commit
5a1ef6089c
@@ -25,7 +25,7 @@ main() async {
|
||||
using((Arena arena) {
|
||||
final p = arena<Int64>(2);
|
||||
p[0] = 24;
|
||||
MemMove((p + 1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
MemMove(p.elementAt(1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
print(p[1]);
|
||||
Expect.equals(24, p[1]);
|
||||
});
|
||||
@@ -35,7 +35,7 @@ main() async {
|
||||
using((Arena arena) {
|
||||
final p = arena<Int64>(2);
|
||||
p[0] = 25;
|
||||
MemMove((p + 1).cast<Void>(), p.cast<Void>(), 8);
|
||||
MemMove(p.elementAt(1).cast<Void>(), p.cast<Void>(), 8);
|
||||
print(p[1]);
|
||||
Expect.equals(25, p[1]);
|
||||
throw Exception("Some random exception");
|
||||
|
||||
@@ -24,7 +24,7 @@ main() async {
|
||||
withZoneArena(() {
|
||||
final p = zoneArena<Int64>(2);
|
||||
p[0] = 24;
|
||||
MemMove((p + 1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
MemMove(p.elementAt(1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
print(p[1]);
|
||||
Expect.equals(24, p[1]);
|
||||
});
|
||||
@@ -34,7 +34,7 @@ main() async {
|
||||
withZoneArena(() {
|
||||
final p = zoneArena<Int64>(2);
|
||||
p[0] = 25;
|
||||
MemMove((p + 1).cast<Void>(), p.cast<Void>(), 8);
|
||||
MemMove(p.elementAt(1).cast<Void>(), p.cast<Void>(), 8);
|
||||
print(p[1]);
|
||||
Expect.equals(25, p[1]);
|
||||
throw Exception("Some random exception");
|
||||
|
||||
@@ -25,7 +25,7 @@ main() {
|
||||
// For automatic management use a Arena.
|
||||
final p = calloc<Int64>(2);
|
||||
p[0] = 24;
|
||||
memMove((p + 1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
memMove(p.elementAt(1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
print(p[1]);
|
||||
Expect.equals(24, p[1]);
|
||||
calloc.free(p);
|
||||
|
||||
@@ -71,7 +71,7 @@ main() {
|
||||
Pointer<Int32> p2 = p1.cast();
|
||||
print('${p2.runtimeType} value: ${p2.value}'); // -1
|
||||
|
||||
Pointer<Int32> p3 = p2 + 1;
|
||||
Pointer<Int32> p3 = p2.elementAt(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<Int8> p = calloc(8);
|
||||
for (var i in [0, 1, 2, 3, 4, 5, 6, 7]) {
|
||||
(p + i).value = i * 3;
|
||||
p.elementAt(i).value = i * 3;
|
||||
}
|
||||
for (var i in [0, 1, 2, 3, 4, 5, 6, 7]) {
|
||||
print('(p + $i) value: ${(p + i).value}');
|
||||
print('p.elementAt($i) value: ${p.elementAt(i).value}');
|
||||
}
|
||||
calloc.free(p);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ main() {
|
||||
Pointer<Int64> p2 = calloc(2);
|
||||
p2.value = 42;
|
||||
p2[1] = 1000;
|
||||
print((p2 + 1).address.toRadixString(16));
|
||||
print(p2.elementAt(1).address.toRadixString(16));
|
||||
print(p2[1]);
|
||||
Pointer<Int64> result = assign1337Index1(p2);
|
||||
print(p2[1]);
|
||||
|
||||
@@ -50,8 +50,8 @@ main() {
|
||||
NativeCoordinateOp f1 = p1.asFunction();
|
||||
|
||||
Pointer<Coordinate> c1 = calloc<Coordinate>(3);
|
||||
Pointer<Coordinate> c2 = c1 + 1;
|
||||
Pointer<Coordinate> c3 = c1 + 2;
|
||||
Pointer<Coordinate> c2 = c1.elementAt(1);
|
||||
Pointer<Coordinate> c3 = c1.elementAt(2);
|
||||
c1.ref.x = 10.0;
|
||||
c1.ref.y = 10.0;
|
||||
c1.ref.next = c3;
|
||||
|
||||
@@ -40,8 +40,8 @@ main() {
|
||||
{
|
||||
// Allocates coordinates consecutively in c memory.
|
||||
Pointer<Coordinate> c1 = calloc<Coordinate>(3);
|
||||
Pointer<Coordinate> c2 = c1 + 1;
|
||||
Pointer<Coordinate> c3 = c1 + 2;
|
||||
Pointer<Coordinate> c2 = c1.elementAt(1);
|
||||
Pointer<Coordinate> c3 = c1.elementAt(2);
|
||||
c1.ref.x = 10.0;
|
||||
c1.ref.y = 10.0;
|
||||
c1.ref.next = c3;
|
||||
|
||||
Reference in New Issue
Block a user