fix use of deprecated members in ffi samples
Change-Id: Ia0b38bfbdc3c2fe9747d024d05364c8aed4b1909 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349580 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Alexander Aprelev <aam@google.com> Auto-Submit: Jake Macdonald <jakemac@google.com>
This commit is contained in:
committed by
Commit Queue
parent
ba958ff255
commit
5052ab6f34
@@ -25,7 +25,7 @@ main() async {
|
||||
using((Arena arena) {
|
||||
final p = arena<Int64>(2);
|
||||
p[0] = 24;
|
||||
MemMove(p.elementAt(1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
MemMove((p + 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.elementAt(1).cast<Void>(), p.cast<Void>(), 8);
|
||||
MemMove((p + 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.elementAt(1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
MemMove((p + 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.elementAt(1).cast<Void>(), p.cast<Void>(), 8);
|
||||
MemMove((p + 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.elementAt(1).cast<Void>(), p.cast<Void>(), sizeOf<Int64>());
|
||||
memMove((p + 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.elementAt(1);
|
||||
Pointer<Int32> 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<Int8> 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);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ main() {
|
||||
Pointer<Int64> 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<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.elementAt(1);
|
||||
Pointer<Coordinate> c3 = c1.elementAt(2);
|
||||
Pointer<Coordinate> c2 = c1 + 1;
|
||||
Pointer<Coordinate> c3 = c1 + 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.elementAt(1);
|
||||
Pointer<Coordinate> c3 = c1.elementAt(2);
|
||||
Pointer<Coordinate> c2 = c1 + 1;
|
||||
Pointer<Coordinate> c3 = c1 + 2;
|
||||
c1.ref.x = 10.0;
|
||||
c1.ref.y = 10.0;
|
||||
c1.ref.next = c3;
|
||||
|
||||
Reference in New Issue
Block a user