From 54903e5bf09f2f88aa3ae041fe20057db084e511 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Wed, 4 Mar 2020 15:21:55 +0000 Subject: [PATCH] [vm/ffi] Rename members in NativeApi to not contain nativeApi Follow up of: https://dart-review.googlesource.com/c/sdk/+/136962 Change-Id: Icdc8e7f701b0dbc7e476a140e68bcb15b3ac64ae Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138283 Commit-Queue: Daco Harkes Reviewed-by: Martin Kustermann --- samples/ffi/async/sample_async_callback.dart | 2 +- samples/ffi/async/sample_native_port_call.dart | 6 +++--- sdk/lib/_internal/vm/lib/ffi_patch.dart | 11 +++++------ sdk/lib/ffi/ffi.dart | 8 ++++---- sdk_nnbd/lib/_internal/vm/lib/ffi_patch.dart | 11 +++++------ sdk_nnbd/lib/ffi/ffi.dart | 8 ++++---- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/samples/ffi/async/sample_async_callback.dart b/samples/ffi/async/sample_async_callback.dart index 697693b02ee..f9d8ea46539 100644 --- a/samples/ffi/async/sample_async_callback.dart +++ b/samples/ffi/async/sample_async_callback.dart @@ -26,7 +26,7 @@ main() async { print("C T2 = Some C thread executing C."); print("C = C T1 or C T2."); print("Dart: Setup."); - registerDart_PostCObject(NativeApi.nativeApiPostCObject); + registerDart_PostCObject(NativeApi.postCObject); final interactiveCppRequests = ReceivePort()..listen(requestExecuteCallback); final int nativePort = interactiveCppRequests.sendPort.nativePort; diff --git a/samples/ffi/async/sample_native_port_call.dart b/samples/ffi/async/sample_native_port_call.dart index 661d509600e..1e654ef8498 100644 --- a/samples/ffi/async/sample_native_port_call.dart +++ b/samples/ffi/async/sample_native_port_call.dart @@ -35,9 +35,9 @@ main() async { print("C T2 = Some C thread executing C."); print("C = C T1 or C T2."); print("Dart: Setup."); - registerDart_PostCObject(NativeApi.nativeApiPostCObject); - registerDart_NewNativePort(NativeApi.nativeApiNewNativePort); - registerDart_CloseNativePort(NativeApi.nativeApiCloseNativePort); + registerDart_PostCObject(NativeApi.postCObject); + registerDart_NewNativePort(NativeApi.newNativePort); + registerDart_CloseNativePort(NativeApi.closeNativePort); final interactiveCppRequests = ReceivePort()..listen(handleCppRequests); final int nativePort = interactiveCppRequests.sendPort.nativePort; diff --git a/sdk/lib/_internal/vm/lib/ffi_patch.dart b/sdk/lib/_internal/vm/lib/ffi_patch.dart index 4d21fb2ed2f..726f6198969 100644 --- a/sdk/lib/_internal/vm/lib/ffi_patch.dart +++ b/sdk/lib/_internal/vm/lib/ffi_patch.dart @@ -456,10 +456,10 @@ extension NativePort on SendPort { int _nativeApiFunctionPointer(String symbol) native "NativeApiFunctionPointer"; @patch -class NativeApi { +abstract class NativeApi { @patch static Pointer)>> - get nativeApiPostCObject => + get postCObject => Pointer.fromAddress(_nativeApiFunctionPointer("Dart_PostCObject")); @patch @@ -468,11 +468,10 @@ class NativeApi { Int64 Function( Pointer, Pointer>, - Int8)>> get nativeApiNewNativePort => + Int8)>> get newNativePort => Pointer.fromAddress(_nativeApiFunctionPointer("Dart_NewNativePort")); @patch - static Pointer> - get nativeApiCloseNativePort => Pointer.fromAddress( - _nativeApiFunctionPointer("Dart_CloseNativePort")); + static Pointer> get closeNativePort => + Pointer.fromAddress(_nativeApiFunctionPointer("Dart_CloseNativePort")); } diff --git a/sdk/lib/ffi/ffi.dart b/sdk/lib/ffi/ffi.dart index 26f5ff6ee45..f9f0f63e54f 100644 --- a/sdk/lib/ffi/ffi.dart +++ b/sdk/lib/ffi/ffi.dart @@ -629,13 +629,13 @@ class Dart_CObject extends Struct {} typedef Dart_NativeMessageHandler = Void Function(Int64, Pointer); /// Exposes function pointers to functions in `dart_native_api.h`. -class NativeApi { +abstract class NativeApi { /// A function pointer to /// `bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message)` /// in `dart_native_api.h`. external static Pointer< NativeFunction)>> - get nativeApiPostCObject; + get postCObject; /// A function pointer to /// ``` @@ -649,11 +649,11 @@ class NativeApi { Int64 Function( Pointer, Pointer>, - Int8)>> get nativeApiNewNativePort; + Int8)>> get newNativePort; /// A function pointer to /// `bool Dart_CloseNativePort(Dart_Port native_port_id)` /// in `dart_native_api.h`. external static Pointer> - get nativeApiCloseNativePort; + get closeNativePort; } diff --git a/sdk_nnbd/lib/_internal/vm/lib/ffi_patch.dart b/sdk_nnbd/lib/_internal/vm/lib/ffi_patch.dart index 00134bd5a23..d5749b093c9 100644 --- a/sdk_nnbd/lib/_internal/vm/lib/ffi_patch.dart +++ b/sdk_nnbd/lib/_internal/vm/lib/ffi_patch.dart @@ -454,10 +454,10 @@ extension NativePort on SendPort { int _nativeApiFunctionPointer(String symbol) native "NativeApiFunctionPointer"; @patch -class NativeApi { +abstract class NativeApi { @patch static Pointer)>> - get nativeApiPostCObject => + get postCObject => Pointer.fromAddress(_nativeApiFunctionPointer("Dart_PostCObject")); @patch @@ -466,11 +466,10 @@ class NativeApi { Int64 Function( Pointer, Pointer>, - Int8)>> get nativeApiNewNativePort => + Int8)>> get newNativePort => Pointer.fromAddress(_nativeApiFunctionPointer("Dart_NewNativePort")); @patch - static Pointer> - get nativeApiCloseNativePort => Pointer.fromAddress( - _nativeApiFunctionPointer("Dart_CloseNativePort")); + static Pointer> get closeNativePort => + Pointer.fromAddress(_nativeApiFunctionPointer("Dart_CloseNativePort")); } diff --git a/sdk_nnbd/lib/ffi/ffi.dart b/sdk_nnbd/lib/ffi/ffi.dart index c7ded4d4133..202f4f6b5be 100644 --- a/sdk_nnbd/lib/ffi/ffi.dart +++ b/sdk_nnbd/lib/ffi/ffi.dart @@ -628,13 +628,13 @@ class Dart_CObject extends Struct {} typedef Dart_NativeMessageHandler = Void Function(Int64, Pointer); /// Exposes function pointers to functions in `dart_native_api.h`. -class NativeApi { +abstract class NativeApi { /// A function pointer to /// `bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message)` /// in `dart_native_api.h`. external static Pointer< NativeFunction)>> - get nativeApiPostCObject; + get postCObject; /// A function pointer to /// ``` @@ -648,11 +648,11 @@ class NativeApi { Int64 Function( Pointer, Pointer>, - Int8)>> get nativeApiNewNativePort; + Int8)>> get newNativePort; /// A function pointer to /// `bool Dart_CloseNativePort(Dart_Port native_port_id)` /// in `dart_native_api.h`. external static Pointer> - get nativeApiCloseNativePort; + get closeNativePort; }