mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:13:19 +00:00
40f7a11d89
This enables adding the `external` keyword to struct fields, which enables use in nnbd (weak mode). Closes: https://github.com/dart-lang/sdk/issues/40247 External fields are not implemented in the analyzer yet: https://github.com/dart-lang/sdk/issues/41940 Change-Id: I9d88acbdabf73ca63a6ad3d549930aa3c97cb53f Cq-Include-Trybots: luci.dart.try: analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148242 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
27 lines
637 B
Dart
27 lines
637 B
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
|
|
library FfiTest;
|
|
|
|
import 'dart:ffi';
|
|
import "package:ffi/ffi.dart";
|
|
|
|
/// Sample struct for dart:ffi library.
|
|
class Coordinate extends Struct {
|
|
@Double()
|
|
external double x;
|
|
|
|
@Double()
|
|
external double y;
|
|
|
|
external Pointer<Coordinate> next;
|
|
|
|
factory Coordinate.allocate(double x, double y, Pointer<Coordinate> next) {
|
|
return allocate<Coordinate>().ref
|
|
..x = x
|
|
..y = y
|
|
..next = next;
|
|
}
|
|
}
|