1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 20:16:39 +00:00

[vm] Fix Dart_CObject_Type breaking change

https://dart-review.googlesource.com/c/sdk/+/257925 added a new entry
in the middle of the `Dart_CObject_Type` enum, which changed the
value of the entries below. However, this enum is part of
`dart_api_dl.h` and versioned by `dart_version.h`.

New entries to `Dart_CObject_Type` should be added at the end of the
enum to avoid making breaking changes to the type.

TEST=tests/ffi/vmspecific_handle_dynamically_linked_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51459

Change-Id: I367b54f62e59ddf925e255bb56c0f8660be7c227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284161
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Daco Harkes 2023-02-20 11:59:19 +00:00 committed by Commit Queue
parent 789971863e
commit 14e4a52657
7 changed files with 13 additions and 13 deletions

View File

@ -50,13 +50,15 @@ typedef enum {
Dart_CObject_kArray,
Dart_CObject_kTypedData,
Dart_CObject_kExternalTypedData,
Dart_CObject_kUnmodifiableExternalTypedData,
Dart_CObject_kSendPort,
Dart_CObject_kCapability,
Dart_CObject_kNativePointer,
Dart_CObject_kUnsupported,
Dart_CObject_kUnmodifiableExternalTypedData,
Dart_CObject_kNumberOfTypes
} Dart_CObject_Type;
// This enum is versioned by DART_API_DL_MAJOR_VERSION, only add at the end
// and bump the DART_API_DL_MINOR_VERSION.
typedef struct _Dart_CObject {
Dart_CObject_Type type;

View File

@ -11,6 +11,6 @@
// On backwards compatible changes the minor version is increased.
// The versioning covers the symbols exposed in dart_api_dl.h
#define DART_API_DL_MAJOR_VERSION 2
#define DART_API_DL_MINOR_VERSION 1
#define DART_API_DL_MINOR_VERSION 2
#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */

View File

@ -27,7 +27,7 @@ main() async {
print("C = C T1 or C T2.");
print("Dart: Setup.");
Expect.isTrue(NativeApi.majorVersion == 2);
Expect.isTrue(NativeApi.minorVersion >= 1);
Expect.isTrue(NativeApi.minorVersion >= 2);
final initializeApi = dl.lookupFunction<IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("InitDartApiDL");
Expect.isTrue(initializeApi(NativeApi.initializeApiDLData) == 0);

View File

@ -36,7 +36,7 @@ main() async {
print("C = C T1 or C T2.");
print("Dart: Setup.");
Expect.isTrue(NativeApi.majorVersion == 2);
Expect.isTrue(NativeApi.minorVersion >= 1);
Expect.isTrue(NativeApi.minorVersion >= 2);
final initializeApi = dl.lookupFunction<IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("InitDartApiDL");
Expect.isTrue(initializeApi(NativeApi.initializeApiDLData) == 0);

View File

@ -54,7 +54,7 @@ final closureCallbackPointer =
void doDynamicLinking() {
Expect.isTrue(NativeApi.majorVersion == 2);
Expect.isTrue(NativeApi.minorVersion >= 1);
Expect.isTrue(NativeApi.minorVersion >= 2);
final initializeApi = testLibrary.lookupFunction<
IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("InitDartApiDL");

View File

@ -18,7 +18,7 @@ void main() {
void doDynamicLinking() {
Expect.isTrue(NativeApi.majorVersion == 2);
Expect.isTrue(NativeApi.minorVersion >= 1);
Expect.isTrue(NativeApi.minorVersion >= 2);
final initializeApi = testLibrary.lookupFunction<
IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("InitDartApiDL");
@ -35,9 +35,8 @@ void testHandle() {
void testNativeAPIs() {
// No need to expect here, `lookupFunction` throws an argument error if lookup fails.
testLibrary.lookupFunction<
Bool Function(Handle),
bool Function(Object)>("Dart_IsNull_DL");
testLibrary.lookupFunction<Bool Function(Handle), bool Function(Object)>(
"Dart_IsNull_DL");
}
class SomeClass {

View File

@ -20,7 +20,7 @@ void main() {
void doDynamicLinking() {
Expect.isTrue(NativeApi.majorVersion == 2);
Expect.isTrue(NativeApi.minorVersion >= 1);
Expect.isTrue(NativeApi.minorVersion >= 2);
final initializeApi = testLibrary.lookupFunction<
IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("InitDartApiDL");
@ -37,9 +37,8 @@ void testHandle() {
void testNativeAPIs() {
// No need to expect here, `lookupFunction` throws an argument error if lookup fails.
testLibrary.lookupFunction<
Bool Function(Handle),
bool Function(Object)>("Dart_IsNull_DL");
testLibrary.lookupFunction<Bool Function(Handle), bool Function(Object)>(
"Dart_IsNull_DL");
}
class SomeClass {