fix ffi sample diagnostics

Change-Id: I70cac821de46311e3c8d91f5853c5de09d3a7b6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292041
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Jake Macdonald 2023-03-30 19:19:21 +00:00 committed by Commit Queue
parent 103a098d64
commit 836e56b774
2 changed files with 6 additions and 7 deletions

View file

@ -27,7 +27,7 @@ main() {
c1.ref.next = c3;
Coordinate currentCoordinate = c1.ref;
for (var i in [0, 1, 2, 3, 4]) {
for (var _ in [0, 1, 2, 3, 4]) {
currentCoordinate = currentCoordinate.next.ref;
print("${currentCoordinate.x}; ${currentCoordinate.y}");
}
@ -53,7 +53,7 @@ main() {
c3.ref.next = c2;
Coordinate currentCoordinate = c1.ref;
for (var i in [0, 1, 2, 3, 4]) {
for (var _ in [0, 1, 2, 3, 4]) {
currentCoordinate = currentCoordinate.next.ref;
print("${currentCoordinate.x}; ${currentCoordinate.y}");
}
@ -64,9 +64,9 @@ main() {
{
// Allocating in native memory returns a pointer.
final c = calloc<Coordinate>();
print(c is Pointer<Coordinate>);
print(c is Pointer<Coordinate>); // ignore: unnecessary_type_check
// `.ref` returns a reference which gives access to the fields.
print(c.ref is Coordinate);
print(c.ref is Coordinate); // ignore: unnecessary_type_check
calloc.free(c);
}

View file

@ -2,7 +2,6 @@
// 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.
import "dart:ffi";
import "dart:io";
import "package:ffi/ffi.dart";
@ -44,7 +43,7 @@ void main() {
int id = r.readColumnAsInt("id");
expect(true, 1 <= id && id <= 3);
String name = r.readColumnByIndex(1);
expect(true, name is String);
expect(name, isA<String>());
final alternativeName = r.readColumn("alternative_name") as String?;
dynamic multiTypedValue = r.readColumn("multi_typed_column");
expect(
@ -70,7 +69,7 @@ void main() {
int id = r.readColumnAsInt("id");
expect(true, 1 <= id && id <= 3);
String name = r.readColumnByIndex(1);
expect(true, name is String);
expect(name, isA<String>());
final alternativeName = r.readColumn("alternative_name") as String?;
dynamic multiTypedValue = r.readColumn("multi_typed_column");
expect(