mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 22:32:20 +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:
parent
789971863e
commit
14e4a52657
|
@ -50,13 +50,15 @@ typedef enum {
|
||||||
Dart_CObject_kArray,
|
Dart_CObject_kArray,
|
||||||
Dart_CObject_kTypedData,
|
Dart_CObject_kTypedData,
|
||||||
Dart_CObject_kExternalTypedData,
|
Dart_CObject_kExternalTypedData,
|
||||||
Dart_CObject_kUnmodifiableExternalTypedData,
|
|
||||||
Dart_CObject_kSendPort,
|
Dart_CObject_kSendPort,
|
||||||
Dart_CObject_kCapability,
|
Dart_CObject_kCapability,
|
||||||
Dart_CObject_kNativePointer,
|
Dart_CObject_kNativePointer,
|
||||||
Dart_CObject_kUnsupported,
|
Dart_CObject_kUnsupported,
|
||||||
|
Dart_CObject_kUnmodifiableExternalTypedData,
|
||||||
Dart_CObject_kNumberOfTypes
|
Dart_CObject_kNumberOfTypes
|
||||||
} Dart_CObject_Type;
|
} 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 {
|
typedef struct _Dart_CObject {
|
||||||
Dart_CObject_Type type;
|
Dart_CObject_Type type;
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
// On backwards compatible changes the minor version is increased.
|
// On backwards compatible changes the minor version is increased.
|
||||||
// The versioning covers the symbols exposed in dart_api_dl.h
|
// The versioning covers the symbols exposed in dart_api_dl.h
|
||||||
#define DART_API_DL_MAJOR_VERSION 2
|
#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 */
|
#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */
|
||||||
|
|
|
@ -27,7 +27,7 @@ main() async {
|
||||||
print("C = C T1 or C T2.");
|
print("C = C T1 or C T2.");
|
||||||
print("Dart: Setup.");
|
print("Dart: Setup.");
|
||||||
Expect.isTrue(NativeApi.majorVersion == 2);
|
Expect.isTrue(NativeApi.majorVersion == 2);
|
||||||
Expect.isTrue(NativeApi.minorVersion >= 1);
|
Expect.isTrue(NativeApi.minorVersion >= 2);
|
||||||
final initializeApi = dl.lookupFunction<IntPtr Function(Pointer<Void>),
|
final initializeApi = dl.lookupFunction<IntPtr Function(Pointer<Void>),
|
||||||
int Function(Pointer<Void>)>("InitDartApiDL");
|
int Function(Pointer<Void>)>("InitDartApiDL");
|
||||||
Expect.isTrue(initializeApi(NativeApi.initializeApiDLData) == 0);
|
Expect.isTrue(initializeApi(NativeApi.initializeApiDLData) == 0);
|
||||||
|
|
|
@ -36,7 +36,7 @@ main() async {
|
||||||
print("C = C T1 or C T2.");
|
print("C = C T1 or C T2.");
|
||||||
print("Dart: Setup.");
|
print("Dart: Setup.");
|
||||||
Expect.isTrue(NativeApi.majorVersion == 2);
|
Expect.isTrue(NativeApi.majorVersion == 2);
|
||||||
Expect.isTrue(NativeApi.minorVersion >= 1);
|
Expect.isTrue(NativeApi.minorVersion >= 2);
|
||||||
final initializeApi = dl.lookupFunction<IntPtr Function(Pointer<Void>),
|
final initializeApi = dl.lookupFunction<IntPtr Function(Pointer<Void>),
|
||||||
int Function(Pointer<Void>)>("InitDartApiDL");
|
int Function(Pointer<Void>)>("InitDartApiDL");
|
||||||
Expect.isTrue(initializeApi(NativeApi.initializeApiDLData) == 0);
|
Expect.isTrue(initializeApi(NativeApi.initializeApiDLData) == 0);
|
||||||
|
|
|
@ -54,7 +54,7 @@ final closureCallbackPointer =
|
||||||
|
|
||||||
void doDynamicLinking() {
|
void doDynamicLinking() {
|
||||||
Expect.isTrue(NativeApi.majorVersion == 2);
|
Expect.isTrue(NativeApi.majorVersion == 2);
|
||||||
Expect.isTrue(NativeApi.minorVersion >= 1);
|
Expect.isTrue(NativeApi.minorVersion >= 2);
|
||||||
final initializeApi = testLibrary.lookupFunction<
|
final initializeApi = testLibrary.lookupFunction<
|
||||||
IntPtr Function(Pointer<Void>),
|
IntPtr Function(Pointer<Void>),
|
||||||
int Function(Pointer<Void>)>("InitDartApiDL");
|
int Function(Pointer<Void>)>("InitDartApiDL");
|
||||||
|
|
|
@ -18,7 +18,7 @@ void main() {
|
||||||
|
|
||||||
void doDynamicLinking() {
|
void doDynamicLinking() {
|
||||||
Expect.isTrue(NativeApi.majorVersion == 2);
|
Expect.isTrue(NativeApi.majorVersion == 2);
|
||||||
Expect.isTrue(NativeApi.minorVersion >= 1);
|
Expect.isTrue(NativeApi.minorVersion >= 2);
|
||||||
final initializeApi = testLibrary.lookupFunction<
|
final initializeApi = testLibrary.lookupFunction<
|
||||||
IntPtr Function(Pointer<Void>),
|
IntPtr Function(Pointer<Void>),
|
||||||
int Function(Pointer<Void>)>("InitDartApiDL");
|
int Function(Pointer<Void>)>("InitDartApiDL");
|
||||||
|
@ -35,9 +35,8 @@ void testHandle() {
|
||||||
|
|
||||||
void testNativeAPIs() {
|
void testNativeAPIs() {
|
||||||
// No need to expect here, `lookupFunction` throws an argument error if lookup fails.
|
// No need to expect here, `lookupFunction` throws an argument error if lookup fails.
|
||||||
testLibrary.lookupFunction<
|
testLibrary.lookupFunction<Bool Function(Handle), bool Function(Object)>(
|
||||||
Bool Function(Handle),
|
"Dart_IsNull_DL");
|
||||||
bool Function(Object)>("Dart_IsNull_DL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SomeClass {
|
class SomeClass {
|
||||||
|
|
|
@ -20,7 +20,7 @@ void main() {
|
||||||
|
|
||||||
void doDynamicLinking() {
|
void doDynamicLinking() {
|
||||||
Expect.isTrue(NativeApi.majorVersion == 2);
|
Expect.isTrue(NativeApi.majorVersion == 2);
|
||||||
Expect.isTrue(NativeApi.minorVersion >= 1);
|
Expect.isTrue(NativeApi.minorVersion >= 2);
|
||||||
final initializeApi = testLibrary.lookupFunction<
|
final initializeApi = testLibrary.lookupFunction<
|
||||||
IntPtr Function(Pointer<Void>),
|
IntPtr Function(Pointer<Void>),
|
||||||
int Function(Pointer<Void>)>("InitDartApiDL");
|
int Function(Pointer<Void>)>("InitDartApiDL");
|
||||||
|
@ -37,9 +37,8 @@ void testHandle() {
|
||||||
|
|
||||||
void testNativeAPIs() {
|
void testNativeAPIs() {
|
||||||
// No need to expect here, `lookupFunction` throws an argument error if lookup fails.
|
// No need to expect here, `lookupFunction` throws an argument error if lookup fails.
|
||||||
testLibrary.lookupFunction<
|
testLibrary.lookupFunction<Bool Function(Handle), bool Function(Object)>(
|
||||||
Bool Function(Handle),
|
"Dart_IsNull_DL");
|
||||||
bool Function(Object)>("Dart_IsNull_DL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SomeClass {
|
class SomeClass {
|
||||||
|
|
Loading…
Reference in a new issue