Skip to content

Commit

Permalink
Revert "[vm/ffi] Remove deprecated Struct.addressOf getter"
Browse files Browse the repository at this point in the history
This reverts commit 65fab23.

Reason for revert: These can't be remove until the next dev roll of Flutter. See flutter/flutter#76129.

Original change's description:
> [vm/ffi] Remove deprecated `Struct.addressOf` getter
>
> This got deprecated in Dart 2.12 stable. Removing for the next release.
>
> Closes: #40667
>
> Change-Id: Ifdbcf76178be6fca8603d478d629b6b6655b7123
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184463
> Reviewed-by: Clement Skau <cskau@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

Change-Id: I94c22a206f3668ddb72d284afdc3b048d8b11aaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185500
Commit-Queue: Zach Anderson <zra@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
  • Loading branch information
zanderso authored and commit-bot@chromium.org committed Feb 17, 2021
1 parent b6dc4da commit 1d1f68f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdk/lib/ffi/struct.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ abstract class Struct extends NativeType {

Struct._fromPointer(this._addressOf);
}

/// Extension on [Struct] specialized for its subtypes.
extension StructAddressOf<T extends Struct> on T {
/// Returns the address backing the reference.
@Deprecated('Hold on to the pointer backing a struct instead.')
Pointer<T> get addressOf => _addressOf as Pointer<T>;
}
2 changes: 2 additions & 0 deletions tests/ffi/structs_nnbd_workaround_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ void testTypeTest() {
final pointer = calloc<Coordinate>();
Coordinate c = pointer.ref;
Expect.isTrue(c is Struct);
// TODO(https://dartbug.com/40667): Remove support for this.
Expect.isTrue(c.addressOf is Pointer<Coordinate>);
calloc.free(pointer);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/ffi/structs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void testTypeTest() {
final pointer = calloc<Coordinate>();
Coordinate c = pointer.ref;
Expect.isTrue(c is Struct);
// TODO(https://dartbug.com/40667): Remove support for this.
Expect.isTrue(c.addressOf is Pointer<Coordinate>);
calloc.free(pointer);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/ffi_2/structs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void testTypeTest() {
final pointer = calloc<Coordinate>();
Coordinate c = pointer.ref;
Expect.isTrue(c is Struct);
// TODO(https://dartbug.com/40667): Remove support for this.
Expect.isTrue(c.addressOf is Pointer<Coordinate>);
calloc.free(pointer);
}

Expand Down

0 comments on commit 1d1f68f

Please sign in to comment.