mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:41:41 +00:00
[vm/ffi] Migrate dart:ffi to nnbd
Everything in FFI is nonnullable, because C does not accept null values or return null values (nullptr == 0, not null). The only thing that needed migration in the FFI api is operator == (dynamic other) --> operator == (Object other). This CL does not migrate any tests as the VM cannot run any tests yet. Fixes: https://github.com/dart-lang/sdk/issues/39144 Change-Id: I5efc772b61228bd1bd4d95be1b7bcd969f0c9ac8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131380 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
parent
ca565d946f
commit
8ee8f882ea
|
@ -44,9 +44,10 @@ class DynamicLibrary {
|
|||
int getHandle() native "Ffi_dl_getHandle";
|
||||
|
||||
@patch
|
||||
bool operator ==(other) {
|
||||
if (other == null) return false;
|
||||
return getHandle() == other.getHandle();
|
||||
bool operator ==(Object other) {
|
||||
if (other is! DynamicLibrary) return false;
|
||||
DynamicLibrary otherLib = other;
|
||||
return getHandle() == otherLib.getHandle();
|
||||
}
|
||||
|
||||
@patch
|
||||
|
|
|
@ -2,8 +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.
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
part of dart.ffi;
|
||||
|
||||
class DartRepresentationOf {
|
||||
|
|
|
@ -2,8 +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.
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
part of dart.ffi;
|
||||
|
||||
/// Represents a dynamically loaded C library.
|
||||
|
@ -35,7 +33,7 @@ class DynamicLibrary {
|
|||
String symbolName);
|
||||
|
||||
/// Dynamic libraries are equal if they load the same library.
|
||||
external bool operator ==(other);
|
||||
external bool operator ==(Object other);
|
||||
|
||||
/// The hash code for a DynamicLibrary only depends on the loaded library
|
||||
external int get hashCode;
|
||||
|
|
|
@ -2,8 +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
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
/**
|
||||
* Foreign Function Interface for interoperability with the C programming language.
|
||||
*
|
||||
|
@ -15,6 +13,7 @@
|
|||
*/
|
||||
library dart.ffi;
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
|
||||
part "native_type.dart";
|
||||
|
@ -75,9 +74,10 @@ class Pointer<T extends NativeType> extends NativeType {
|
|||
external R asFunction<@DartRepresentationOf("T") R extends Function>();
|
||||
|
||||
/// Equality for Pointers only depends on their address.
|
||||
bool operator ==(other) {
|
||||
if (other == null) return false;
|
||||
return address == other.address;
|
||||
bool operator ==(Object other) {
|
||||
if (other is! Pointer) return false;
|
||||
Pointer otherPointer = other;
|
||||
return address == otherPointer.address;
|
||||
}
|
||||
|
||||
/// The hash code for a Pointer only depends on its address.
|
||||
|
|
|
@ -2,8 +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.
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
part of dart.ffi;
|
||||
|
||||
/// [NativeType]'s subtypes represent a native type in C.
|
||||
|
|
|
@ -2,8 +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.
|
||||
|
||||
// @dart = 2.5
|
||||
|
||||
part of dart.ffi;
|
||||
|
||||
/// This class is extended to define structs.
|
||||
|
|
|
@ -83,11 +83,11 @@
|
|||
]
|
||||
},
|
||||
"ffi": {
|
||||
"uri": "../../sdk/lib/ffi/ffi.dart",
|
||||
"uri": "ffi/ffi.dart",
|
||||
"patches": [
|
||||
"../../sdk/lib/_internal/vm/lib/ffi_patch.dart",
|
||||
"../../sdk/lib/_internal/vm/lib/ffi_dynamic_library_patch.dart",
|
||||
"../../sdk/lib/_internal/vm/lib/ffi_native_type_patch.dart"
|
||||
"_internal/vm/lib/ffi_patch.dart",
|
||||
"_internal/vm/lib/ffi_dynamic_library_patch.dart",
|
||||
"_internal/vm/lib/ffi_native_type_patch.dart"
|
||||
]
|
||||
},
|
||||
"wasm": {
|
||||
|
|
|
@ -88,11 +88,11 @@ vm:
|
|||
- "../../sdk/lib/_internal/vm/lib/timeline.dart"
|
||||
|
||||
ffi:
|
||||
uri: "../../sdk/lib/ffi/ffi.dart"
|
||||
uri: "ffi/ffi.dart"
|
||||
patches:
|
||||
- "../../sdk/lib/_internal/vm/lib/ffi_patch.dart"
|
||||
- "../../sdk/lib/_internal/vm/lib/ffi_dynamic_library_patch.dart"
|
||||
- "../../sdk/lib/_internal/vm/lib/ffi_native_type_patch.dart"
|
||||
- "_internal/vm/lib/ffi_patch.dart"
|
||||
- "_internal/vm/lib/ffi_dynamic_library_patch.dart"
|
||||
- "_internal/vm/lib/ffi_native_type_patch.dart"
|
||||
|
||||
wasm:
|
||||
uri: "wasm/wasm.dart"
|
||||
|
|
Loading…
Reference in a new issue