[vm/ffi] Add Since annotations to dart:ffi
Closes: https://github.com/dart-lang/sdk/issues/48711 Change-Id: Iac0bcecdf81b02bcb2feb746aa94a1bef6caf600 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240045 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
@@ -40,7 +40,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -40,7 +40,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -74,7 +74,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -34,7 +34,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -65,7 +65,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -34,7 +34,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -34,7 +34,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -65,7 +65,7 @@ constants {
|
||||
|
||||
Constructor coverage from constants:
|
||||
org-dartlang-testcase:///ffi_sample.dart:
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:114:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:34:9)
|
||||
- Double. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:115:9)
|
||||
- _NativeDouble. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:35:9)
|
||||
- NativeType. (from org-dartlang-sdk:///sdk/lib/ffi/native_type.dart:12:9)
|
||||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
|
||||
|
||||
@@ -24,12 +24,13 @@ const configuration = [
|
||||
Config("Uint16", "int", "Uint16List", 2),
|
||||
Config("Uint32", "int", "Uint32List", 4),
|
||||
Config("Uint64", "int", "Uint64List", 8),
|
||||
Config("IntPtr", "int", kDoNotEmit, kIntPtrElementSize),
|
||||
Config("Float", "double", "Float32List", 4),
|
||||
Config("Double", "double", "Float64List", 8),
|
||||
Config("Bool", "bool", kDoNotEmit, 1),
|
||||
Config("Bool", "bool", kDoNotEmit, 1, since: Version(2, 15)),
|
||||
];
|
||||
|
||||
const arrayVersion = Version(2, 13);
|
||||
|
||||
//
|
||||
// Generator.
|
||||
//
|
||||
@@ -81,8 +82,6 @@ void generatePublicExtension(
|
||||
final elementSize = config.elementSize;
|
||||
|
||||
final bits = sizeOfBits(elementSize);
|
||||
// final sizeInBytes =
|
||||
// "${sizeOf(elementSize)} byte${elementSize != 1 ? "s" : ""}";
|
||||
|
||||
String property;
|
||||
if (_isInt(nativeType)) {
|
||||
@@ -178,9 +177,10 @@ $alignment external $typedListType asTypedList(int length);
|
||||
""";
|
||||
|
||||
if (container == "Pointer") {
|
||||
final since = config.since?.sinceAnnotation ?? '';
|
||||
buffer.write("""
|
||||
/// Extension on [Pointer] specialized for the type argument [$nativeType].
|
||||
extension ${nativeType}Pointer on Pointer<$nativeType> {
|
||||
$since extension ${nativeType}Pointer on Pointer<$nativeType> {
|
||||
/// The $property at [address].
|
||||
$platform$truncate$alignment external $dartType get value;
|
||||
|
||||
@@ -197,9 +197,11 @@ $asTypedList
|
||||
|
||||
""");
|
||||
} else {
|
||||
final since =
|
||||
Version.latest(config.since, arrayVersion)?.sinceAnnotation ?? '';
|
||||
buffer.write("""
|
||||
/// Bounds checking indexing methods on [Array]s of [$nativeType].
|
||||
extension ${nativeType}Array on Array<$nativeType> {
|
||||
$since extension ${nativeType}Array on Array<$nativeType> {
|
||||
external $dartType operator [](int index);
|
||||
|
||||
external void operator []=(int index, $dartType value);
|
||||
@@ -288,32 +290,11 @@ void generateFooter(StringBuffer buffer) {
|
||||
bool _isInt(String type) => type.startsWith("Int") || type.startsWith("Uint");
|
||||
bool _isSigned(String type) => type.startsWith("Int");
|
||||
|
||||
String sizeOf(int size) {
|
||||
switch (size) {
|
||||
case kIntPtrElementSize:
|
||||
return "4 or 8";
|
||||
default:
|
||||
return "$size";
|
||||
}
|
||||
}
|
||||
String sizeOf(int size) => "$size";
|
||||
|
||||
String sizeOfBits(int size) {
|
||||
switch (size) {
|
||||
case kIntPtrElementSize:
|
||||
return "32 or 64";
|
||||
default:
|
||||
return "${size * 8}";
|
||||
}
|
||||
}
|
||||
String sizeOfBits(int size) => "${size * 8}";
|
||||
|
||||
String sizeOfIntPtrSize(int size) {
|
||||
switch (size) {
|
||||
case kIntPtrElementSize:
|
||||
return "_intPtrSize";
|
||||
default:
|
||||
return "$size";
|
||||
}
|
||||
}
|
||||
String sizeOfIntPtrSize(int size) => "$size";
|
||||
|
||||
String bracketOr(String input) {
|
||||
if (input.contains("or")) {
|
||||
@@ -348,9 +329,32 @@ class Config {
|
||||
final String dartType;
|
||||
final String typedListType;
|
||||
final int elementSize;
|
||||
final Version? since;
|
||||
const Config(
|
||||
this.nativeType, this.dartType, this.typedListType, this.elementSize);
|
||||
this.nativeType, this.dartType, this.typedListType, this.elementSize,
|
||||
{Version? since})
|
||||
: since = since;
|
||||
}
|
||||
|
||||
const String kDoNotEmit = "donotemit";
|
||||
const int kIntPtrElementSize = -1;
|
||||
|
||||
class Version {
|
||||
final int major;
|
||||
final int minor;
|
||||
|
||||
const Version(this.major, this.minor);
|
||||
|
||||
@override
|
||||
String toString() => '$major.$minor';
|
||||
|
||||
static Version? latest(Version? a, Version? b) {
|
||||
if (a == null) return b;
|
||||
if (b == null) return a;
|
||||
if (a.major > b.major) return a;
|
||||
if (b.major > a.major) return b;
|
||||
if (a.minor > b.minor) return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
String get sinceAnnotation => "@Since('$this')";
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ part of dart.ffi;
|
||||
/// The Dart VM can run on a variety of operating systems and architectures.
|
||||
/// Supported ABIs are represented by `Abi` objects.
|
||||
/// See [values] for all the supported ABIs.
|
||||
@Since('2.16')
|
||||
class Abi {
|
||||
/// The application binary interface for Android on the Arm architecture.
|
||||
static const androidArm = _androidArm;
|
||||
|
||||
@@ -43,6 +43,7 @@ part of dart.ffi;
|
||||
/// const UintPtr();
|
||||
/// }
|
||||
/// ```
|
||||
@Since('2.16')
|
||||
class AbiSpecificInteger extends NativeType {
|
||||
const AbiSpecificInteger();
|
||||
}
|
||||
@@ -50,6 +51,7 @@ class AbiSpecificInteger extends NativeType {
|
||||
/// Mapping for a subtype of [AbiSpecificInteger].
|
||||
///
|
||||
/// See documentation on [AbiSpecificInteger].
|
||||
@Since('2.16')
|
||||
class AbiSpecificIntegerMapping {
|
||||
final Map<Abi, NativeType> mapping;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
part of dart.ffi;
|
||||
|
||||
/// Manages memory on the native heap.
|
||||
@Since('2.12')
|
||||
abstract class Allocator {
|
||||
/// This interface is meant to be implemented, not extended or mixed in.
|
||||
Allocator._() {
|
||||
@@ -28,6 +29,7 @@ abstract class Allocator {
|
||||
}
|
||||
|
||||
/// Extension on [Allocator] to provide allocation with [NativeType].
|
||||
@Since('2.12')
|
||||
extension AllocatorAlloc on Allocator {
|
||||
/// Allocates `sizeOf<T>() * count` bytes of memory using
|
||||
/// `allocator.allocate`.
|
||||
|
||||
@@ -21,6 +21,7 @@ part of dart.ffi;
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint8(),
|
||||
Abi.androidArm64: Uint8(),
|
||||
@@ -57,6 +58,7 @@ class Char extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Int8(),
|
||||
Abi.androidArm64: Int8(),
|
||||
@@ -93,6 +95,7 @@ class SignedChar extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint8(),
|
||||
Abi.androidArm64: Uint8(),
|
||||
@@ -129,6 +132,7 @@ class UnsignedChar extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Int16(),
|
||||
Abi.androidArm64: Int16(),
|
||||
@@ -165,6 +169,7 @@ class Short extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint16(),
|
||||
Abi.androidArm64: Uint16(),
|
||||
@@ -201,6 +206,7 @@ class UnsignedShort extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Int32(),
|
||||
Abi.androidArm64: Int32(),
|
||||
@@ -237,6 +243,7 @@ class Int extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint32(),
|
||||
Abi.androidArm64: Uint32(),
|
||||
@@ -274,6 +281,7 @@ class UnsignedInt extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Int32(),
|
||||
Abi.androidArm64: Int64(),
|
||||
@@ -311,6 +319,7 @@ class Long extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint32(),
|
||||
Abi.androidArm64: Uint64(),
|
||||
@@ -347,6 +356,7 @@ class UnsignedLong extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Int64(),
|
||||
Abi.androidArm64: Int64(),
|
||||
@@ -383,6 +393,7 @@ class LongLong extends AbiSpecificInteger {
|
||||
/// in Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint64(),
|
||||
Abi.androidArm64: Uint64(),
|
||||
@@ -447,6 +458,7 @@ class IntPtr extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint32(),
|
||||
Abi.androidArm64: Uint64(),
|
||||
@@ -479,6 +491,7 @@ class UintPtr extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint32(),
|
||||
Abi.androidArm64: Uint64(),
|
||||
@@ -514,6 +527,7 @@ class Size extends AbiSpecificInteger {
|
||||
/// Dart code.
|
||||
/// It occurs only in native type signatures and as annotation on [Struct] and
|
||||
/// [Union] fields.
|
||||
@Since('2.17')
|
||||
@AbiSpecificIntegerMapping({
|
||||
Abi.androidArm: Uint32(),
|
||||
Abi.androidArm64: Uint32(),
|
||||
|
||||
+39
-8
@@ -2,13 +2,12 @@
|
||||
// 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
|
||||
|
||||
/**
|
||||
* Foreign Function Interface for interoperability with the C programming language.
|
||||
*
|
||||
* For further details, please see: https://dart.dev/server/c-interop
|
||||
*
|
||||
* {@category VM}
|
||||
*/
|
||||
/// Foreign Function Interface for interoperability with the C programming language.
|
||||
///
|
||||
/// For further details, please see: https://dart.dev/server/c-interop.
|
||||
///
|
||||
/// {@category VM}
|
||||
@Since('2.6')
|
||||
library dart.ffi;
|
||||
|
||||
import 'dart:_internal' show Since;
|
||||
@@ -93,6 +92,7 @@ class Pointer<T extends NativeType> extends NativeType {
|
||||
}
|
||||
|
||||
/// A fixed-sized array of [T]s.
|
||||
@Since('2.13')
|
||||
class Array<T extends NativeType> extends NativeType {
|
||||
/// Const constructor to specify [Array] dimensions in [Struct]s.
|
||||
///
|
||||
@@ -523,6 +523,7 @@ extension DoublePointer on Pointer<Double> {
|
||||
}
|
||||
|
||||
/// Extension on [Pointer] specialized for the type argument [Bool].
|
||||
@Since('2.15')
|
||||
extension BoolPointer on Pointer<Bool> {
|
||||
/// The bool at [address].
|
||||
external bool get value;
|
||||
@@ -537,6 +538,7 @@ extension BoolPointer on Pointer<Bool> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Int8].
|
||||
@Since('2.13')
|
||||
extension Int8Array on Array<Int8> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -544,6 +546,7 @@ extension Int8Array on Array<Int8> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Int16].
|
||||
@Since('2.13')
|
||||
extension Int16Array on Array<Int16> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -551,6 +554,7 @@ extension Int16Array on Array<Int16> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Int32].
|
||||
@Since('2.13')
|
||||
extension Int32Array on Array<Int32> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -558,6 +562,7 @@ extension Int32Array on Array<Int32> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Int64].
|
||||
@Since('2.13')
|
||||
extension Int64Array on Array<Int64> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -565,6 +570,7 @@ extension Int64Array on Array<Int64> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Uint8].
|
||||
@Since('2.13')
|
||||
extension Uint8Array on Array<Uint8> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -572,6 +578,7 @@ extension Uint8Array on Array<Uint8> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Uint16].
|
||||
@Since('2.13')
|
||||
extension Uint16Array on Array<Uint16> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -579,6 +586,7 @@ extension Uint16Array on Array<Uint16> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Uint32].
|
||||
@Since('2.13')
|
||||
extension Uint32Array on Array<Uint32> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -586,6 +594,7 @@ extension Uint32Array on Array<Uint32> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Uint64].
|
||||
@Since('2.13')
|
||||
extension Uint64Array on Array<Uint64> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -593,6 +602,7 @@ extension Uint64Array on Array<Uint64> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Float].
|
||||
@Since('2.13')
|
||||
extension FloatArray on Array<Float> {
|
||||
external double operator [](int index);
|
||||
|
||||
@@ -600,6 +610,7 @@ extension FloatArray on Array<Float> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Double].
|
||||
@Since('2.13')
|
||||
extension DoubleArray on Array<Double> {
|
||||
external double operator [](int index);
|
||||
|
||||
@@ -607,6 +618,7 @@ extension DoubleArray on Array<Double> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Bool].
|
||||
@Since('2.15')
|
||||
extension BoolArray on Array<Bool> {
|
||||
external bool operator [](int index);
|
||||
|
||||
@@ -642,7 +654,7 @@ extension PointerPointer<T extends NativeType> on Pointer<Pointer<T>> {
|
||||
/// Store a Dart value into this location offset by [index].
|
||||
///
|
||||
/// A [Pointer] is unboxed before being stored (as if by `.address`), and the
|
||||
/// pointer is boxed (as if by `Pointer.fromAddress`) when loaded.
|
||||
/// pointer is boxed (as if by [Pointer.fromAddress]) when loaded.
|
||||
///
|
||||
/// On 32-bit platforms the [address] must be 4-byte aligned, and on 64-bit
|
||||
/// platforms the [address] must be 8-byte aligned.
|
||||
@@ -650,6 +662,7 @@ extension PointerPointer<T extends NativeType> on Pointer<Pointer<T>> {
|
||||
}
|
||||
|
||||
/// Extension on [Pointer] specialized for the type argument [Struct].
|
||||
@Since('2.12')
|
||||
extension StructPointer<T extends Struct> on Pointer<T> {
|
||||
/// A Dart view of the struct referenced by this pointer.
|
||||
///
|
||||
@@ -685,6 +698,7 @@ extension StructPointer<T extends Struct> on Pointer<T> {
|
||||
}
|
||||
|
||||
/// Extension on [Pointer] specialized for the type argument [Union].
|
||||
@Since('2.14')
|
||||
extension UnionPointer<T extends Union> on Pointer<T> {
|
||||
/// A Dart view of the union referenced by this pointer.
|
||||
///
|
||||
@@ -721,6 +735,7 @@ extension UnionPointer<T extends Union> on Pointer<T> {
|
||||
|
||||
/// Extension on [Pointer] specialized for the type argument
|
||||
/// [AbiSpecificInteger].
|
||||
@Since('2.16')
|
||||
extension AbiSpecificIntegerPointer<T extends AbiSpecificInteger>
|
||||
on Pointer<T> {
|
||||
/// The integer at [address].
|
||||
@@ -736,6 +751,7 @@ extension AbiSpecificIntegerPointer<T extends AbiSpecificInteger>
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Pointer].
|
||||
@Since('2.13')
|
||||
extension PointerArray<T extends NativeType> on Array<Pointer<T>> {
|
||||
external Pointer<T> operator [](int index);
|
||||
|
||||
@@ -743,6 +759,7 @@ extension PointerArray<T extends NativeType> on Array<Pointer<T>> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Struct].
|
||||
@Since('2.13')
|
||||
extension StructArray<T extends Struct> on Array<T> {
|
||||
/// This extension method must be invoked on a receiver of type `Pointer<T>`
|
||||
/// where `T` is a compile-time constant type.
|
||||
@@ -750,6 +767,7 @@ extension StructArray<T extends Struct> on Array<T> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Union].
|
||||
@Since('2.14')
|
||||
extension UnionArray<T extends Union> on Array<T> {
|
||||
/// This extension method must be invoked on a receiver of type `Pointer<T>`
|
||||
/// where `T` is a compile-time constant type.
|
||||
@@ -757,6 +775,7 @@ extension UnionArray<T extends Union> on Array<T> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [Array].
|
||||
@Since('2.13')
|
||||
extension ArrayArray<T extends NativeType> on Array<Array<T>> {
|
||||
external Array<T> operator [](int index);
|
||||
|
||||
@@ -764,6 +783,7 @@ extension ArrayArray<T extends NativeType> on Array<Array<T>> {
|
||||
}
|
||||
|
||||
/// Bounds checking indexing methods on [Array]s of [AbiSpecificInteger].
|
||||
@Since('2.16')
|
||||
extension AbiSpecificIntegerArray on Array<AbiSpecificInteger> {
|
||||
external int operator [](int index);
|
||||
|
||||
@@ -771,31 +791,40 @@ extension AbiSpecificIntegerArray on Array<AbiSpecificInteger> {
|
||||
}
|
||||
|
||||
/// Extension to retrieve the native `Dart_Port` from a [SendPort].
|
||||
@Since('2.7')
|
||||
extension NativePort on SendPort {
|
||||
/// The native port of this [SendPort].
|
||||
///
|
||||
/// The returned native port can for example be used by C code to post
|
||||
/// messages to the connected [ReceivePort] via `Dart_PostCObject()` - see
|
||||
/// `dart_native_api.h`.
|
||||
///
|
||||
/// Only the send ports from the platform classes [ReceivePort] and
|
||||
/// [RawReceivePort] are supported. User-defined implementations of
|
||||
/// [SendPort] are not supported.
|
||||
external int get nativePort;
|
||||
}
|
||||
|
||||
/// Opaque, not exposing it's members.
|
||||
@Since('2.8')
|
||||
class Dart_CObject extends Opaque {}
|
||||
|
||||
typedef Dart_NativeMessageHandler = Void Function(Int64, Pointer<Dart_CObject>);
|
||||
|
||||
/// Utilities for accessing the Dart VM API from Dart code or
|
||||
/// from C code via `dart_api_dl.h`.
|
||||
@Since('2.8')
|
||||
abstract class NativeApi {
|
||||
/// On breaking changes the major version is increased.
|
||||
///
|
||||
/// The versioning covers the API surface in `dart_api_dl.h`.
|
||||
@Since('2.9')
|
||||
external static int get majorVersion;
|
||||
|
||||
/// On backwards compatible changes the minor version is increased.
|
||||
///
|
||||
/// The versioning covers the API surface in `dart_api_dl.h`.
|
||||
@Since('2.9')
|
||||
external static int get minorVersion;
|
||||
|
||||
/// A function pointer to
|
||||
@@ -827,6 +856,7 @@ abstract class NativeApi {
|
||||
|
||||
/// Pass this to `Dart_InitializeApiDL` in your native code to enable using the
|
||||
/// symbols in `dart_api_dl.h`.
|
||||
@Since('2.9')
|
||||
external static Pointer<Void> get initializeApiDLData;
|
||||
}
|
||||
|
||||
@@ -843,6 +873,7 @@ abstract class NativeApi {
|
||||
/// See `Dart_SetFfiNativeResolver` in `dart_api.h`
|
||||
///
|
||||
/// NOTE: This is an experimental feature and may change in the future.
|
||||
@Since('2.14')
|
||||
class FfiNative<T> {
|
||||
final String nativeName;
|
||||
final bool isLeaf;
|
||||
|
||||
@@ -218,6 +218,7 @@ part of dart.ffi;
|
||||
/// ```
|
||||
// TODO(http://dartbug.com/44395): Add implicit await to Dart implementation.
|
||||
// This will fix `useAsync2` above.
|
||||
@Since('2.17')
|
||||
abstract class Finalizable {
|
||||
factory Finalizable._() => throw UnsupportedError("");
|
||||
}
|
||||
@@ -246,6 +247,7 @@ typedef NativeFinalizerFunction
|
||||
/// attached finalizers are definitely called at least once before the program
|
||||
/// ends, and the callbacks are called as soon as possible after an object
|
||||
/// is recognized as inaccessible.
|
||||
@Since('2.17')
|
||||
abstract class NativeFinalizer {
|
||||
/// Creates a finalizer with the given finalization callback.
|
||||
///
|
||||
|
||||
@@ -16,6 +16,7 @@ abstract class NativeType {
|
||||
///
|
||||
/// [Opaque]'s subtypes are not constructible in the Dart code and serve purely
|
||||
/// as markers in type signatures.
|
||||
@Since('2.12')
|
||||
abstract class Opaque extends NativeType {}
|
||||
|
||||
/// [_NativeInteger]'s subtypes represent a native integer in C.
|
||||
@@ -118,6 +119,7 @@ class Double extends _NativeDouble {
|
||||
///
|
||||
/// [Bool] is not constructible in the Dart code and serves purely as marker
|
||||
/// in type signatures.
|
||||
@Since('2.15')
|
||||
class Bool extends NativeType {
|
||||
const Bool();
|
||||
}
|
||||
@@ -133,6 +135,7 @@ abstract class Void extends NativeType {}
|
||||
///
|
||||
/// [Handle] is not constructible in the Dart code and serves purely as marker in
|
||||
/// type signatures.
|
||||
@Since('2.9')
|
||||
abstract class Handle extends NativeType {}
|
||||
|
||||
/// Represents a function type in C.
|
||||
|
||||
@@ -61,6 +61,7 @@ abstract class _Compound extends NativeType {
|
||||
/// by native memory or typed data. They may allocated via allocation or loaded
|
||||
/// from a [Pointer] or created by ffi calls or callbacks. They cannot be
|
||||
/// created by a generative constructor.
|
||||
@Since('2.12')
|
||||
abstract class Struct extends _Compound {
|
||||
/// Construct a reference to the [nullptr].
|
||||
///
|
||||
@@ -76,6 +77,7 @@ abstract class Struct extends _Compound {
|
||||
/// need to be packed.
|
||||
///
|
||||
/// Valid values for [memberAlignment] are 1, 2, 4, 8, and 16.
|
||||
@Since('2.13')
|
||||
class Packed {
|
||||
final int memberAlignment;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ part of dart.ffi;
|
||||
/// Instances of a subclass of [Union] have reference semantics and are backed
|
||||
/// by native memory. The may allocated via allocation or loaded from a
|
||||
/// [Pointer], but cannot be created by a generative constructor.
|
||||
@Since('2.14')
|
||||
abstract class Union extends _Compound {
|
||||
/// Construct a reference to the [nullptr].
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user