mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 21:25:02 +00:00
7d46d4b5cb
Prototype for `dart:ffi` on Linux/MacOS x64 in JIT mode. `dart:ffi` is experimental and its API is likely to change in the future. Progress and design decisions are tracked in https://github.com/dart-lang/sdk/projects/13 issue: https://github.com/dart-lang/sdk/issues/34452 Change-Id: Ifa4566388e42c8757f154741d11e303465ef305d Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try, vm-kernel-mac-debug-x64-try, vm-kernel-asan-linux-release-x64 Reviewed-on: https://dart-review.googlesource.com/c/80124 Reviewed-by: Samir Jindel <sjindel@google.com> Auto-Submit: Daco Harkes <dacoharkes@google.com>
51 lines
1.8 KiB
Dart
51 lines
1.8 KiB
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.
|
|
|
|
part of dart.ffi;
|
|
|
|
class Struct {
|
|
const Struct();
|
|
}
|
|
|
|
/// This Dart class represents a C struct.
|
|
///
|
|
/// Fields in this struct, annotated with a subtype of [NativeType], are
|
|
/// automatically transformed into wrappers to access the fields of the struct
|
|
/// in C memory.
|
|
///
|
|
/// Fields without a [NativeType] annotation are not supported.
|
|
const struct = const Struct();
|
|
|
|
class DartRepresentationOf {
|
|
/// Represents the Dart type corresponding to a [NativeType].
|
|
///
|
|
/// [Int8] -> [int]
|
|
/// [Int16] -> [int]
|
|
/// [Int32] -> [int]
|
|
/// [Int64] -> [int]
|
|
/// [Uint8] -> [int]
|
|
/// [Uint16] -> [int]
|
|
/// [Uint32] -> [int]
|
|
/// [Uint64] -> [int]
|
|
/// [IntPtr] -> [int]
|
|
/// [Double] -> [double]
|
|
/// [Float] -> [double]
|
|
/// [Pointer]<T> -> [Pointer]<T>
|
|
/// T extends [Pointer] -> T
|
|
/// [NativeFunction]<T1 Function(T2, T3) -> S1 Function(S2, S3)
|
|
/// where DartRepresentationOf(Tn) -> Sn
|
|
const DartRepresentationOf(String nativeType);
|
|
}
|
|
|
|
class Unsized {
|
|
const Unsized();
|
|
}
|
|
|
|
/// This [NativeType] does not have predefined size.
|
|
///
|
|
/// Unsized NativeTypes do not support [sizeOf] because their size is unknown.
|
|
/// Consequently, [allocate], [Pointer.load], [Pointer.store], and
|
|
/// [Pointer.elementAt] are not available.
|
|
const unsized = const Unsized();
|