From ab3549c810ba23802392b06745bb8de0c0edde0d Mon Sep 17 00:00:00 2001 From: fzyzcjy Date: Tue, 5 Nov 2024 13:04:49 +0800 Subject: [PATCH 1/5] rename dart_opaque_* --- .../ffigen_generated/intermediate/frb_rust.h | 6 +-- .../src/ffigen_generated/multi_package.dart | 37 ++++++++++--------- .../src/generalized_frb_rust_binding/_io.dart | 6 +-- .../generalized_frb_rust_binding/_web.dart | 18 ++++----- frb_rust/src/dart_opaque/dart2rust.rs | 10 ++--- frb_rust/src/dart_opaque/non_clone.rs | 12 +++--- frb_rust/src/dart_opaque/rust2dart.rs | 10 ++--- 7 files changed, 50 insertions(+), 49 deletions(-) diff --git a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h index cb4f9aa188..cf901e7578 100644 --- a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h +++ b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h @@ -39,12 +39,12 @@ int32_t frb_get_rust_content_hash(void); * * This should never be called manually. */ -const void *dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, +const void *frb_dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, MessagePort dart_handler_port); -void dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr); +void frb_dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr); -GeneralizedDartHandle dart_opaque_rust2dart_decode(uintptr_t ptr); +GeneralizedDartHandle frb_dart_opaque_rust2dart_decode(uintptr_t ptr); uint8_t *rust_vec_u8_new(int32_t len); diff --git a/frb_dart/lib/src/ffigen_generated/multi_package.dart b/frb_dart/lib/src/ffigen_generated/multi_package.dart index b72393b53a..ccc0ab7b7d 100644 --- a/frb_dart/lib/src/ffigen_generated/multi_package.dart +++ b/frb_dart/lib/src/ffigen_generated/multi_package.dart @@ -301,51 +301,52 @@ class MultiPackageCBinding { /// # Safety /// /// This should never be called manually. - ffi.Pointer dart_opaque_dart2rust_encode( + ffi.Pointer frb_dart_opaque_dart2rust_encode( Object handle, int dart_handler_port, ) { - return _dart_opaque_dart2rust_encode( + return _frb_dart_opaque_dart2rust_encode( handle, dart_handler_port, ); } - late final _dart_opaque_dart2rust_encodePtr = _lookup< + late final _frb_dart_opaque_dart2rust_encodePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( - ffi.Handle, MessagePort)>>('dart_opaque_dart2rust_encode'); - late final _dart_opaque_dart2rust_encode = _dart_opaque_dart2rust_encodePtr - .asFunction Function(Object, int)>(); + ffi.Handle, MessagePort)>>('frb_dart_opaque_dart2rust_encode'); + late final _frb_dart_opaque_dart2rust_encode = + _frb_dart_opaque_dart2rust_encodePtr + .asFunction Function(Object, int)>(); - void dart_opaque_drop_thread_box_persistent_handle( + void frb_dart_opaque_drop_thread_box_persistent_handle( int ptr, ) { - return _dart_opaque_drop_thread_box_persistent_handle( + return _frb_dart_opaque_drop_thread_box_persistent_handle( ptr, ); } - late final _dart_opaque_drop_thread_box_persistent_handlePtr = + late final _frb_dart_opaque_drop_thread_box_persistent_handlePtr = _lookup>( - 'dart_opaque_drop_thread_box_persistent_handle'); - late final _dart_opaque_drop_thread_box_persistent_handle = - _dart_opaque_drop_thread_box_persistent_handlePtr + 'frb_dart_opaque_drop_thread_box_persistent_handle'); + late final _frb_dart_opaque_drop_thread_box_persistent_handle = + _frb_dart_opaque_drop_thread_box_persistent_handlePtr .asFunction(); - Object dart_opaque_rust2dart_decode( + Object frb_dart_opaque_rust2dart_decode( int ptr, ) { - return _dart_opaque_rust2dart_decode( + return _frb_dart_opaque_rust2dart_decode( ptr, ); } - late final _dart_opaque_rust2dart_decodePtr = + late final _frb_dart_opaque_rust2dart_decodePtr = _lookup>( - 'dart_opaque_rust2dart_decode'); - late final _dart_opaque_rust2dart_decode = - _dart_opaque_rust2dart_decodePtr.asFunction(); + 'frb_dart_opaque_rust2dart_decode'); + late final _frb_dart_opaque_rust2dart_decode = + _frb_dart_opaque_rust2dart_decodePtr.asFunction(); ffi.Pointer rust_vec_u8_new( int len, diff --git a/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart b/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart index 3e0592c98a..979cc02c94 100644 --- a/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart +++ b/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart @@ -75,15 +75,15 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} PlatformPointer dartOpaqueDart2RustEncode( Object object, NativePortType dartHandlerPort) => - _binding.dart_opaque_dart2rust_encode(object, dartHandlerPort); + _binding.frb_dart_opaque_dart2rust_encode(object, dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} Object dartOpaqueRust2DartDecode(int ptr) => - _binding.dart_opaque_rust2dart_decode(ptr); + _binding.frb_dart_opaque_rust2dart_decode(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void dartOpaqueDropThreadBoxPersistentHandle(int ptr) => - _binding.dart_opaque_drop_thread_box_persistent_handle(ptr); + _binding.frb_dart_opaque_drop_thread_box_persistent_handle(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartDco(WireSyncRust2DartDco val) => diff --git a/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart b/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart index 42a90e6b68..300c9b096f 100644 --- a/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart +++ b/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart @@ -53,15 +53,15 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} PlatformPointer dartOpaqueDart2RustEncode( Object object, NativePortType dartHandlerPort) => - _dart_opaque_dart2rust_encode(object.jsify()!, dartHandlerPort); + _frb_dart_opaque_dart2rust_encode(object.jsify()!, dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} Object dartOpaqueRust2DartDecode(int ptr) => - _dart_opaque_rust2dart_decode(ptr).dartify()!; + _frb_dart_opaque_rust2dart_decode(ptr).dartify()!; /// {@macro flutter_rust_bridge.only_for_generated_code} void dartOpaqueDropThreadBoxPersistentHandle(int ptr) => - _dart_opaque_drop_thread_box_persistent_handle(ptr); + _frb_dart_opaque_drop_thread_box_persistent_handle(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartDco(WireSyncRust2DartDco raw) {} @@ -103,14 +103,14 @@ external void _dart_fn_deliver_output( external int _frb_get_rust_content_hash(); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_opaque_dart2rust_encode") -external int _dart_opaque_dart2rust_encode( +@JS("wasm_bindgen.frb_dart_opaque_dart2rust_encode") +external int _frb_dart_opaque_dart2rust_encode( JSAny object, NativePortType dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_opaque_rust2dart_decode") -external JSAny _dart_opaque_rust2dart_decode(int ptr); +@JS("wasm_bindgen.frb_dart_opaque_rust2dart_decode") +external JSAny _frb_dart_opaque_rust2dart_decode(int ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_opaque_drop_thread_box_persistent_handle") -external void _dart_opaque_drop_thread_box_persistent_handle(int ptr); +@JS("wasm_bindgen.frb_dart_opaque_drop_thread_box_persistent_handle") +external void _frb_dart_opaque_drop_thread_box_persistent_handle(int ptr); diff --git a/frb_rust/src/dart_opaque/dart2rust.rs b/frb_rust/src/dart_opaque/dart2rust.rs index faf20c73af..a2c862c70d 100644 --- a/frb_rust/src/dart_opaque/dart2rust.rs +++ b/frb_rust/src/dart_opaque/dart2rust.rs @@ -36,11 +36,11 @@ pub unsafe fn sse_decode_dart_opaque(raw: usize) -> DartOpaque { /// This should never be called manually. #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe fn dart_opaque_dart2rust_encode( +pub unsafe fn frb_dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> usize { - dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) as _ + frb_dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) as _ } /// # Safety @@ -48,14 +48,14 @@ pub unsafe fn dart_opaque_dart2rust_encode( /// This should never be called manually. #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn dart_opaque_dart2rust_encode( +pub unsafe extern "C" fn frb_dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> *const std::ffi::c_void { - dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) + frb_dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) } -unsafe fn dart_opaque_dart2rust_encode_inner( +unsafe fn frb_dart_opaque_dart2rust_encode_inner( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> *const std::ffi::c_void { diff --git a/frb_rust/src/dart_opaque/non_clone.rs b/frb_rust/src/dart_opaque/non_clone.rs index 89b477f410..d12db9c450 100644 --- a/frb_rust/src/dart_opaque/non_clone.rs +++ b/frb_rust/src/dart_opaque/non_clone.rs @@ -68,7 +68,7 @@ impl Drop for DartOpaqueNonClone { } } -/// Drop by sending to a Dart port and let the handler there call [dart_opaque_drop_thread_box_persistent_handle] +/// Drop by sending to a Dart port and let the handler there call [frb_dart_opaque_drop_thread_box_persistent_handle] fn drop_thread_box_persistent_handle_via_port( persistent_handle: GeneralizedDartHandleBox, dart_handler_port: &SendableMessagePortHandle, @@ -93,17 +93,17 @@ fn drop_thread_box_persistent_handle_via_port( #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { - dart_opaque_drop_thread_box_persistent_handle_inner(ptr) +pub unsafe extern "C" fn frb_dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { + frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { - dart_opaque_drop_thread_box_persistent_handle_inner(ptr) +pub unsafe extern "C" fn frb_dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { + frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } -unsafe fn dart_opaque_drop_thread_box_persistent_handle_inner(ptr: usize) { +unsafe fn frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr: usize) { let value: GeneralizedDartHandleBox = *box_from_leak_ptr(ptr as _); drop(value); diff --git a/frb_rust/src/dart_opaque/rust2dart.rs b/frb_rust/src/dart_opaque/rust2dart.rs index fd582423e5..fa0080c090 100644 --- a/frb_rust/src/dart_opaque/rust2dart.rs +++ b/frb_rust/src/dart_opaque/rust2dart.rs @@ -18,17 +18,17 @@ impl DartOpaque { #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { - dart_opaque_rust2dart_decode_inner(ptr) +pub unsafe fn frb_dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { + frb_dart_opaque_rust2dart_decode_inner(ptr) } #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { - dart_opaque_rust2dart_decode_inner(ptr) +pub unsafe extern "C" fn frb_dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { + frb_dart_opaque_rust2dart_decode_inner(ptr) } -unsafe fn dart_opaque_rust2dart_decode_inner(ptr: usize) -> GeneralizedDartHandle { +unsafe fn frb_dart_opaque_rust2dart_decode_inner(ptr: usize) -> GeneralizedDartHandle { let opaque = DartOpaque::from_raw(ptr as _); opaque.create_dart_handle() } From ed7635071262ecc894a91691eb05dc250f4da19c Mon Sep 17 00:00:00 2001 From: fzyzcjy Date: Tue, 5 Nov 2024 13:05:31 +0800 Subject: [PATCH 2/5] Revert "rename dart_opaque_*" This reverts commit ab3549c810ba23802392b06745bb8de0c0edde0d. --- .../ffigen_generated/intermediate/frb_rust.h | 6 +-- .../src/ffigen_generated/multi_package.dart | 37 +++++++++---------- .../src/generalized_frb_rust_binding/_io.dart | 6 +-- .../generalized_frb_rust_binding/_web.dart | 18 ++++----- frb_rust/src/dart_opaque/dart2rust.rs | 10 ++--- frb_rust/src/dart_opaque/non_clone.rs | 12 +++--- frb_rust/src/dart_opaque/rust2dart.rs | 10 ++--- 7 files changed, 49 insertions(+), 50 deletions(-) diff --git a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h index cf901e7578..cb4f9aa188 100644 --- a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h +++ b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h @@ -39,12 +39,12 @@ int32_t frb_get_rust_content_hash(void); * * This should never be called manually. */ -const void *frb_dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, +const void *dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, MessagePort dart_handler_port); -void frb_dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr); +void dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr); -GeneralizedDartHandle frb_dart_opaque_rust2dart_decode(uintptr_t ptr); +GeneralizedDartHandle dart_opaque_rust2dart_decode(uintptr_t ptr); uint8_t *rust_vec_u8_new(int32_t len); diff --git a/frb_dart/lib/src/ffigen_generated/multi_package.dart b/frb_dart/lib/src/ffigen_generated/multi_package.dart index ccc0ab7b7d..b72393b53a 100644 --- a/frb_dart/lib/src/ffigen_generated/multi_package.dart +++ b/frb_dart/lib/src/ffigen_generated/multi_package.dart @@ -301,52 +301,51 @@ class MultiPackageCBinding { /// # Safety /// /// This should never be called manually. - ffi.Pointer frb_dart_opaque_dart2rust_encode( + ffi.Pointer dart_opaque_dart2rust_encode( Object handle, int dart_handler_port, ) { - return _frb_dart_opaque_dart2rust_encode( + return _dart_opaque_dart2rust_encode( handle, dart_handler_port, ); } - late final _frb_dart_opaque_dart2rust_encodePtr = _lookup< + late final _dart_opaque_dart2rust_encodePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( - ffi.Handle, MessagePort)>>('frb_dart_opaque_dart2rust_encode'); - late final _frb_dart_opaque_dart2rust_encode = - _frb_dart_opaque_dart2rust_encodePtr - .asFunction Function(Object, int)>(); + ffi.Handle, MessagePort)>>('dart_opaque_dart2rust_encode'); + late final _dart_opaque_dart2rust_encode = _dart_opaque_dart2rust_encodePtr + .asFunction Function(Object, int)>(); - void frb_dart_opaque_drop_thread_box_persistent_handle( + void dart_opaque_drop_thread_box_persistent_handle( int ptr, ) { - return _frb_dart_opaque_drop_thread_box_persistent_handle( + return _dart_opaque_drop_thread_box_persistent_handle( ptr, ); } - late final _frb_dart_opaque_drop_thread_box_persistent_handlePtr = + late final _dart_opaque_drop_thread_box_persistent_handlePtr = _lookup>( - 'frb_dart_opaque_drop_thread_box_persistent_handle'); - late final _frb_dart_opaque_drop_thread_box_persistent_handle = - _frb_dart_opaque_drop_thread_box_persistent_handlePtr + 'dart_opaque_drop_thread_box_persistent_handle'); + late final _dart_opaque_drop_thread_box_persistent_handle = + _dart_opaque_drop_thread_box_persistent_handlePtr .asFunction(); - Object frb_dart_opaque_rust2dart_decode( + Object dart_opaque_rust2dart_decode( int ptr, ) { - return _frb_dart_opaque_rust2dart_decode( + return _dart_opaque_rust2dart_decode( ptr, ); } - late final _frb_dart_opaque_rust2dart_decodePtr = + late final _dart_opaque_rust2dart_decodePtr = _lookup>( - 'frb_dart_opaque_rust2dart_decode'); - late final _frb_dart_opaque_rust2dart_decode = - _frb_dart_opaque_rust2dart_decodePtr.asFunction(); + 'dart_opaque_rust2dart_decode'); + late final _dart_opaque_rust2dart_decode = + _dart_opaque_rust2dart_decodePtr.asFunction(); ffi.Pointer rust_vec_u8_new( int len, diff --git a/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart b/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart index 979cc02c94..3e0592c98a 100644 --- a/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart +++ b/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart @@ -75,15 +75,15 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} PlatformPointer dartOpaqueDart2RustEncode( Object object, NativePortType dartHandlerPort) => - _binding.frb_dart_opaque_dart2rust_encode(object, dartHandlerPort); + _binding.dart_opaque_dart2rust_encode(object, dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} Object dartOpaqueRust2DartDecode(int ptr) => - _binding.frb_dart_opaque_rust2dart_decode(ptr); + _binding.dart_opaque_rust2dart_decode(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void dartOpaqueDropThreadBoxPersistentHandle(int ptr) => - _binding.frb_dart_opaque_drop_thread_box_persistent_handle(ptr); + _binding.dart_opaque_drop_thread_box_persistent_handle(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartDco(WireSyncRust2DartDco val) => diff --git a/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart b/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart index 300c9b096f..42a90e6b68 100644 --- a/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart +++ b/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart @@ -53,15 +53,15 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} PlatformPointer dartOpaqueDart2RustEncode( Object object, NativePortType dartHandlerPort) => - _frb_dart_opaque_dart2rust_encode(object.jsify()!, dartHandlerPort); + _dart_opaque_dart2rust_encode(object.jsify()!, dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} Object dartOpaqueRust2DartDecode(int ptr) => - _frb_dart_opaque_rust2dart_decode(ptr).dartify()!; + _dart_opaque_rust2dart_decode(ptr).dartify()!; /// {@macro flutter_rust_bridge.only_for_generated_code} void dartOpaqueDropThreadBoxPersistentHandle(int ptr) => - _frb_dart_opaque_drop_thread_box_persistent_handle(ptr); + _dart_opaque_drop_thread_box_persistent_handle(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartDco(WireSyncRust2DartDco raw) {} @@ -103,14 +103,14 @@ external void _dart_fn_deliver_output( external int _frb_get_rust_content_hash(); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.frb_dart_opaque_dart2rust_encode") -external int _frb_dart_opaque_dart2rust_encode( +@JS("wasm_bindgen.dart_opaque_dart2rust_encode") +external int _dart_opaque_dart2rust_encode( JSAny object, NativePortType dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.frb_dart_opaque_rust2dart_decode") -external JSAny _frb_dart_opaque_rust2dart_decode(int ptr); +@JS("wasm_bindgen.dart_opaque_rust2dart_decode") +external JSAny _dart_opaque_rust2dart_decode(int ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.frb_dart_opaque_drop_thread_box_persistent_handle") -external void _frb_dart_opaque_drop_thread_box_persistent_handle(int ptr); +@JS("wasm_bindgen.dart_opaque_drop_thread_box_persistent_handle") +external void _dart_opaque_drop_thread_box_persistent_handle(int ptr); diff --git a/frb_rust/src/dart_opaque/dart2rust.rs b/frb_rust/src/dart_opaque/dart2rust.rs index a2c862c70d..faf20c73af 100644 --- a/frb_rust/src/dart_opaque/dart2rust.rs +++ b/frb_rust/src/dart_opaque/dart2rust.rs @@ -36,11 +36,11 @@ pub unsafe fn sse_decode_dart_opaque(raw: usize) -> DartOpaque { /// This should never be called manually. #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe fn frb_dart_opaque_dart2rust_encode( +pub unsafe fn dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> usize { - frb_dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) as _ + dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) as _ } /// # Safety @@ -48,14 +48,14 @@ pub unsafe fn frb_dart_opaque_dart2rust_encode( /// This should never be called manually. #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn frb_dart_opaque_dart2rust_encode( +pub unsafe extern "C" fn dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> *const std::ffi::c_void { - frb_dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) + dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) } -unsafe fn frb_dart_opaque_dart2rust_encode_inner( +unsafe fn dart_opaque_dart2rust_encode_inner( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> *const std::ffi::c_void { diff --git a/frb_rust/src/dart_opaque/non_clone.rs b/frb_rust/src/dart_opaque/non_clone.rs index d12db9c450..89b477f410 100644 --- a/frb_rust/src/dart_opaque/non_clone.rs +++ b/frb_rust/src/dart_opaque/non_clone.rs @@ -68,7 +68,7 @@ impl Drop for DartOpaqueNonClone { } } -/// Drop by sending to a Dart port and let the handler there call [frb_dart_opaque_drop_thread_box_persistent_handle] +/// Drop by sending to a Dart port and let the handler there call [dart_opaque_drop_thread_box_persistent_handle] fn drop_thread_box_persistent_handle_via_port( persistent_handle: GeneralizedDartHandleBox, dart_handler_port: &SendableMessagePortHandle, @@ -93,17 +93,17 @@ fn drop_thread_box_persistent_handle_via_port( #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn frb_dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { - frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr) +pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { + dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe extern "C" fn frb_dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { - frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr) +pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { + dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } -unsafe fn frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr: usize) { +unsafe fn dart_opaque_drop_thread_box_persistent_handle_inner(ptr: usize) { let value: GeneralizedDartHandleBox = *box_from_leak_ptr(ptr as _); drop(value); diff --git a/frb_rust/src/dart_opaque/rust2dart.rs b/frb_rust/src/dart_opaque/rust2dart.rs index fa0080c090..fd582423e5 100644 --- a/frb_rust/src/dart_opaque/rust2dart.rs +++ b/frb_rust/src/dart_opaque/rust2dart.rs @@ -18,17 +18,17 @@ impl DartOpaque { #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe fn frb_dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { - frb_dart_opaque_rust2dart_decode_inner(ptr) +pub unsafe fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { + dart_opaque_rust2dart_decode_inner(ptr) } #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn frb_dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { - frb_dart_opaque_rust2dart_decode_inner(ptr) +pub unsafe extern "C" fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { + dart_opaque_rust2dart_decode_inner(ptr) } -unsafe fn frb_dart_opaque_rust2dart_decode_inner(ptr: usize) -> GeneralizedDartHandle { +unsafe fn dart_opaque_rust2dart_decode_inner(ptr: usize) -> GeneralizedDartHandle { let opaque = DartOpaque::from_raw(ptr as _); opaque.create_dart_handle() } From fca263ff07a88ad19654d11708143c970e33d156 Mon Sep 17 00:00:00 2001 From: fzyzcjy Date: Tue, 5 Nov 2024 13:06:18 +0800 Subject: [PATCH 3/5] replace --- .../ffigen_generated/intermediate/frb_rust.h | 20 +-- .../src/ffigen_generated/multi_package.dart | 115 +++++++++--------- .../src/generalized_frb_rust_binding/_io.dart | 22 ++-- .../generalized_frb_rust_binding/_web.dart | 24 ++-- frb_rust/src/dart_opaque/dart2rust.rs | 10 +- frb_rust/src/dart_opaque/non_clone.rs | 12 +- frb_rust/src/dart_opaque/rust2dart.rs | 10 +- frb_rust/src/ffi_binding/io.rs | 6 +- frb_rust/src/ffi_binding/mod.rs | 10 +- frb_rust/src/internal_generated/mod.rs | 4 +- 10 files changed, 121 insertions(+), 112 deletions(-) diff --git a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h index cb4f9aa188..0519cbf906 100644 --- a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h +++ b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h @@ -27,7 +27,7 @@ struct WireSyncRust2DartSse frb_pde_ffi_dispatcher_sync(int32_t func_id, int32_t rust_vec_len_, int32_t data_len_); -void dart_fn_deliver_output(int32_t call_id, +void frb_dart_fn_deliver_output(int32_t call_id, uint8_t *ptr_, int32_t rust_vec_len_, int32_t data_len_); @@ -39,36 +39,36 @@ int32_t frb_get_rust_content_hash(void); * * This should never be called manually. */ -const void *dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, +const void *frb_dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, MessagePort dart_handler_port); -void dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr); +void frb_dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr); -GeneralizedDartHandle dart_opaque_rust2dart_decode(uintptr_t ptr); +GeneralizedDartHandle frb_dart_opaque_rust2dart_decode(uintptr_t ptr); -uint8_t *rust_vec_u8_new(int32_t len); +uint8_t *frb_rust_vec_u8_new(int32_t len); -uint8_t *rust_vec_u8_resize(uint8_t *ptr, int32_t old_len, int32_t new_len); +uint8_t *frb_rust_vec_u8_resize(uint8_t *ptr, int32_t old_len, int32_t new_len); -void rust_vec_u8_free(uint8_t *ptr, int32_t len); +void frb_rust_vec_u8_free(uint8_t *ptr, int32_t len); /** * # Safety * * This function should never be called manually. */ -intptr_t init_frb_dart_api_dl(void *data); +intptr_t frb_init_frb_dart_api_dl(void *data); /** * # Safety * * This function should never be called manually. */ -void free_wire_sync_rust2dart_dco(WireSyncRust2DartDco value); +void frb_free_wire_sync_rust2dart_dco(WireSyncRust2DartDco value); /** * # Safety * * This function should never be called manually. */ -void free_wire_sync_rust2dart_sse(struct WireSyncRust2DartSse value); +void frb_free_wire_sync_rust2dart_sse(struct WireSyncRust2DartSse value); diff --git a/frb_dart/lib/src/ffigen_generated/multi_package.dart b/frb_dart/lib/src/ffigen_generated/multi_package.dart index b72393b53a..6836a45a4a 100644 --- a/frb_dart/lib/src/ffigen_generated/multi_package.dart +++ b/frb_dart/lib/src/ffigen_generated/multi_package.dart @@ -267,13 +267,13 @@ class MultiPackageCBinding { WireSyncRust2DartSse Function( int, ffi.Pointer, int, int)>(); - void dart_fn_deliver_output( + void frb_dart_fn_deliver_output( int call_id, ffi.Pointer ptr_, int rust_vec_len_, int data_len_, ) { - return _dart_fn_deliver_output( + return _frb_dart_fn_deliver_output( call_id, ptr_, rust_vec_len_, @@ -281,11 +281,11 @@ class MultiPackageCBinding { ); } - late final _dart_fn_deliver_outputPtr = _lookup< + late final _frb_dart_fn_deliver_outputPtr = _lookup< ffi.NativeFunction< ffi.Void Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('dart_fn_deliver_output'); - late final _dart_fn_deliver_output = _dart_fn_deliver_outputPtr + ffi.Int32)>>('frb_dart_fn_deliver_output'); + late final _frb_dart_fn_deliver_output = _frb_dart_fn_deliver_outputPtr .asFunction, int, int)>(); int frb_get_rust_content_hash() { @@ -301,152 +301,155 @@ class MultiPackageCBinding { /// # Safety /// /// This should never be called manually. - ffi.Pointer dart_opaque_dart2rust_encode( + ffi.Pointer frb_dart_opaque_dart2rust_encode( Object handle, int dart_handler_port, ) { - return _dart_opaque_dart2rust_encode( + return _frb_dart_opaque_dart2rust_encode( handle, dart_handler_port, ); } - late final _dart_opaque_dart2rust_encodePtr = _lookup< + late final _frb_dart_opaque_dart2rust_encodePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( - ffi.Handle, MessagePort)>>('dart_opaque_dart2rust_encode'); - late final _dart_opaque_dart2rust_encode = _dart_opaque_dart2rust_encodePtr - .asFunction Function(Object, int)>(); + ffi.Handle, MessagePort)>>('frb_dart_opaque_dart2rust_encode'); + late final _frb_dart_opaque_dart2rust_encode = + _frb_dart_opaque_dart2rust_encodePtr + .asFunction Function(Object, int)>(); - void dart_opaque_drop_thread_box_persistent_handle( + void frb_dart_opaque_drop_thread_box_persistent_handle( int ptr, ) { - return _dart_opaque_drop_thread_box_persistent_handle( + return _frb_dart_opaque_drop_thread_box_persistent_handle( ptr, ); } - late final _dart_opaque_drop_thread_box_persistent_handlePtr = + late final _frb_dart_opaque_drop_thread_box_persistent_handlePtr = _lookup>( - 'dart_opaque_drop_thread_box_persistent_handle'); - late final _dart_opaque_drop_thread_box_persistent_handle = - _dart_opaque_drop_thread_box_persistent_handlePtr + 'frb_dart_opaque_drop_thread_box_persistent_handle'); + late final _frb_dart_opaque_drop_thread_box_persistent_handle = + _frb_dart_opaque_drop_thread_box_persistent_handlePtr .asFunction(); - Object dart_opaque_rust2dart_decode( + Object frb_dart_opaque_rust2dart_decode( int ptr, ) { - return _dart_opaque_rust2dart_decode( + return _frb_dart_opaque_rust2dart_decode( ptr, ); } - late final _dart_opaque_rust2dart_decodePtr = + late final _frb_dart_opaque_rust2dart_decodePtr = _lookup>( - 'dart_opaque_rust2dart_decode'); - late final _dart_opaque_rust2dart_decode = - _dart_opaque_rust2dart_decodePtr.asFunction(); + 'frb_dart_opaque_rust2dart_decode'); + late final _frb_dart_opaque_rust2dart_decode = + _frb_dart_opaque_rust2dart_decodePtr.asFunction(); - ffi.Pointer rust_vec_u8_new( + ffi.Pointer frb_rust_vec_u8_new( int len, ) { - return _rust_vec_u8_new( + return _frb_rust_vec_u8_new( len, ); } - late final _rust_vec_u8_newPtr = + late final _frb_rust_vec_u8_newPtr = _lookup Function(ffi.Int32)>>( - 'rust_vec_u8_new'); - late final _rust_vec_u8_new = - _rust_vec_u8_newPtr.asFunction Function(int)>(); + 'frb_rust_vec_u8_new'); + late final _frb_rust_vec_u8_new = _frb_rust_vec_u8_newPtr + .asFunction Function(int)>(); - ffi.Pointer rust_vec_u8_resize( + ffi.Pointer frb_rust_vec_u8_resize( ffi.Pointer ptr, int old_len, int new_len, ) { - return _rust_vec_u8_resize( + return _frb_rust_vec_u8_resize( ptr, old_len, new_len, ); } - late final _rust_vec_u8_resizePtr = _lookup< + late final _frb_rust_vec_u8_resizePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer, ffi.Int32, - ffi.Int32)>>('rust_vec_u8_resize'); - late final _rust_vec_u8_resize = _rust_vec_u8_resizePtr.asFunction< + ffi.Int32)>>('frb_rust_vec_u8_resize'); + late final _frb_rust_vec_u8_resize = _frb_rust_vec_u8_resizePtr.asFunction< ffi.Pointer Function(ffi.Pointer, int, int)>(); - void rust_vec_u8_free( + void frb_rust_vec_u8_free( ffi.Pointer ptr, int len, ) { - return _rust_vec_u8_free( + return _frb_rust_vec_u8_free( ptr, len, ); } - late final _rust_vec_u8_freePtr = _lookup< + late final _frb_rust_vec_u8_freePtr = _lookup< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer, ffi.Int32)>>('rust_vec_u8_free'); - late final _rust_vec_u8_free = _rust_vec_u8_freePtr + ffi.Pointer, ffi.Int32)>>('frb_rust_vec_u8_free'); + late final _frb_rust_vec_u8_free = _frb_rust_vec_u8_freePtr .asFunction, int)>(); /// # Safety /// /// This function should never be called manually. - int init_frb_dart_api_dl( + int frb_init_frb_dart_api_dl( ffi.Pointer data, ) { - return _init_frb_dart_api_dl( + return _frb_init_frb_dart_api_dl( data, ); } - late final _init_frb_dart_api_dlPtr = + late final _frb_init_frb_dart_api_dlPtr = _lookup)>>( - 'init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr + 'frb_init_frb_dart_api_dl'); + late final _frb_init_frb_dart_api_dl = _frb_init_frb_dart_api_dlPtr .asFunction)>(); /// # Safety /// /// This function should never be called manually. - void free_wire_sync_rust2dart_dco( + void frb_free_wire_sync_rust2dart_dco( WireSyncRust2DartDco value, ) { - return _free_wire_sync_rust2dart_dco( + return _frb_free_wire_sync_rust2dart_dco( value, ); } - late final _free_wire_sync_rust2dart_dcoPtr = + late final _frb_free_wire_sync_rust2dart_dcoPtr = _lookup>( - 'free_wire_sync_rust2dart_dco'); - late final _free_wire_sync_rust2dart_dco = _free_wire_sync_rust2dart_dcoPtr - .asFunction(); + 'frb_free_wire_sync_rust2dart_dco'); + late final _frb_free_wire_sync_rust2dart_dco = + _frb_free_wire_sync_rust2dart_dcoPtr + .asFunction(); /// # Safety /// /// This function should never be called manually. - void free_wire_sync_rust2dart_sse( + void frb_free_wire_sync_rust2dart_sse( WireSyncRust2DartSse value, ) { - return _free_wire_sync_rust2dart_sse( + return _frb_free_wire_sync_rust2dart_sse( value, ); } - late final _free_wire_sync_rust2dart_ssePtr = + late final _frb_free_wire_sync_rust2dart_ssePtr = _lookup>( - 'free_wire_sync_rust2dart_sse'); - late final _free_wire_sync_rust2dart_sse = _free_wire_sync_rust2dart_ssePtr - .asFunction(); + 'frb_free_wire_sync_rust2dart_sse'); + late final _frb_free_wire_sync_rust2dart_sse = + _frb_free_wire_sync_rust2dart_ssePtr + .asFunction(); } /// A Dart_CObject is used for representing Dart objects as native C diff --git a/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart b/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart index 3e0592c98a..18c858c8bb 100644 --- a/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart +++ b/frb_dart/lib/src/generalized_frb_rust_binding/_io.dart @@ -27,7 +27,7 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} void initFrbDartApiDl() => - _binding.init_frb_dart_api_dl(ffi.NativeApi.initializeApiDLData); + _binding.frb_init_frb_dart_api_dl(ffi.NativeApi.initializeApiDLData); /// {@macro flutter_rust_bridge.only_for_generated_code} void pdeFfiDispatcherPrimary({ @@ -59,7 +59,8 @@ class GeneralizedFrbRustBinding { required int rustVecLen, required int dataLen, }) { - return _binding.dart_fn_deliver_output(callId, ptr, rustVecLen, dataLen); + return _binding.frb_dart_fn_deliver_output( + callId, ptr, rustVecLen, dataLen); } /// {@macro flutter_rust_bridge.only_for_generated_code} @@ -75,35 +76,36 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} PlatformPointer dartOpaqueDart2RustEncode( Object object, NativePortType dartHandlerPort) => - _binding.dart_opaque_dart2rust_encode(object, dartHandlerPort); + _binding.frb_dart_opaque_dart2rust_encode(object, dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} Object dartOpaqueRust2DartDecode(int ptr) => - _binding.dart_opaque_rust2dart_decode(ptr); + _binding.frb_dart_opaque_rust2dart_decode(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void dartOpaqueDropThreadBoxPersistentHandle(int ptr) => - _binding.dart_opaque_drop_thread_box_persistent_handle(ptr); + _binding.frb_dart_opaque_drop_thread_box_persistent_handle(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartDco(WireSyncRust2DartDco val) => - _binding.free_wire_sync_rust2dart_dco(val); + _binding.frb_free_wire_sync_rust2dart_dco(val); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartSse(WireSyncRust2DartSse val) => - _binding.free_wire_sync_rust2dart_sse(val); + _binding.frb_free_wire_sync_rust2dart_sse(val); /// {@macro flutter_rust_bridge.only_for_generated_code} - ffi.Pointer rustVecU8New(int len) => _binding.rust_vec_u8_new(len); + ffi.Pointer rustVecU8New(int len) => + _binding.frb_rust_vec_u8_new(len); /// {@macro flutter_rust_bridge.only_for_generated_code} ffi.Pointer rustVecU8Resize( ffi.Pointer ptr, int oldLen, int newLen) => - _binding.rust_vec_u8_resize(ptr, oldLen, newLen); + _binding.frb_rust_vec_u8_resize(ptr, oldLen, newLen); /// {@macro flutter_rust_bridge.only_for_generated_code} void rustVecU8Free(ffi.Pointer ptr, int len) => - _binding.rust_vec_u8_free(ptr, len); + _binding.frb_rust_vec_u8_free(ptr, len); void _userFriendlyDynamicLibraryErrorReporting( ArgumentError e, StackTrace s) { diff --git a/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart b/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart index 42a90e6b68..3e8ccb4a3e 100644 --- a/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart +++ b/frb_dart/lib/src/generalized_frb_rust_binding/_web.dart @@ -44,7 +44,7 @@ class GeneralizedFrbRustBinding { required int rustVecLen, required int dataLen, }) { - return _dart_fn_deliver_output(callId, ptr, rustVecLen, dataLen); + return _frb_dart_fn_deliver_output(callId, ptr, rustVecLen, dataLen); } /// {@macro flutter_rust_bridge.only_for_generated_code} @@ -53,15 +53,15 @@ class GeneralizedFrbRustBinding { /// {@macro flutter_rust_bridge.only_for_generated_code} PlatformPointer dartOpaqueDart2RustEncode( Object object, NativePortType dartHandlerPort) => - _dart_opaque_dart2rust_encode(object.jsify()!, dartHandlerPort); + _frb_dart_opaque_dart2rust_encode(object.jsify()!, dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} Object dartOpaqueRust2DartDecode(int ptr) => - _dart_opaque_rust2dart_decode(ptr).dartify()!; + _frb_dart_opaque_rust2dart_decode(ptr).dartify()!; /// {@macro flutter_rust_bridge.only_for_generated_code} void dartOpaqueDropThreadBoxPersistentHandle(int ptr) => - _dart_opaque_drop_thread_box_persistent_handle(ptr); + _frb_dart_opaque_drop_thread_box_persistent_handle(ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} void freeWireSyncRust2DartDco(WireSyncRust2DartDco raw) {} @@ -90,8 +90,8 @@ external WireSyncRust2DartSse _frb_pde_ffi_dispatcher_sync( ); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_fn_deliver_output") -external void _dart_fn_deliver_output( +@JS("wasm_bindgen.frb_dart_fn_deliver_output") +external void _frb_dart_fn_deliver_output( int callId, PlatformGeneralizedUint8ListPtr ptr, int rustVecLen, @@ -103,14 +103,14 @@ external void _dart_fn_deliver_output( external int _frb_get_rust_content_hash(); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_opaque_dart2rust_encode") -external int _dart_opaque_dart2rust_encode( +@JS("wasm_bindgen.frb_dart_opaque_dart2rust_encode") +external int _frb_dart_opaque_dart2rust_encode( JSAny object, NativePortType dartHandlerPort); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_opaque_rust2dart_decode") -external JSAny _dart_opaque_rust2dart_decode(int ptr); +@JS("wasm_bindgen.frb_dart_opaque_rust2dart_decode") +external JSAny _frb_dart_opaque_rust2dart_decode(int ptr); /// {@macro flutter_rust_bridge.only_for_generated_code} -@JS("wasm_bindgen.dart_opaque_drop_thread_box_persistent_handle") -external void _dart_opaque_drop_thread_box_persistent_handle(int ptr); +@JS("wasm_bindgen.frb_dart_opaque_drop_thread_box_persistent_handle") +external void _frb_dart_opaque_drop_thread_box_persistent_handle(int ptr); diff --git a/frb_rust/src/dart_opaque/dart2rust.rs b/frb_rust/src/dart_opaque/dart2rust.rs index faf20c73af..a2c862c70d 100644 --- a/frb_rust/src/dart_opaque/dart2rust.rs +++ b/frb_rust/src/dart_opaque/dart2rust.rs @@ -36,11 +36,11 @@ pub unsafe fn sse_decode_dart_opaque(raw: usize) -> DartOpaque { /// This should never be called manually. #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe fn dart_opaque_dart2rust_encode( +pub unsafe fn frb_dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> usize { - dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) as _ + frb_dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) as _ } /// # Safety @@ -48,14 +48,14 @@ pub unsafe fn dart_opaque_dart2rust_encode( /// This should never be called manually. #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn dart_opaque_dart2rust_encode( +pub unsafe extern "C" fn frb_dart_opaque_dart2rust_encode( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> *const std::ffi::c_void { - dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) + frb_dart_opaque_dart2rust_encode_inner(handle, dart_handler_port) } -unsafe fn dart_opaque_dart2rust_encode_inner( +unsafe fn frb_dart_opaque_dart2rust_encode_inner( handle: GeneralizedDartHandle, dart_handler_port: MessagePort, ) -> *const std::ffi::c_void { diff --git a/frb_rust/src/dart_opaque/non_clone.rs b/frb_rust/src/dart_opaque/non_clone.rs index 89b477f410..d12db9c450 100644 --- a/frb_rust/src/dart_opaque/non_clone.rs +++ b/frb_rust/src/dart_opaque/non_clone.rs @@ -68,7 +68,7 @@ impl Drop for DartOpaqueNonClone { } } -/// Drop by sending to a Dart port and let the handler there call [dart_opaque_drop_thread_box_persistent_handle] +/// Drop by sending to a Dart port and let the handler there call [frb_dart_opaque_drop_thread_box_persistent_handle] fn drop_thread_box_persistent_handle_via_port( persistent_handle: GeneralizedDartHandleBox, dart_handler_port: &SendableMessagePortHandle, @@ -93,17 +93,17 @@ fn drop_thread_box_persistent_handle_via_port( #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { - dart_opaque_drop_thread_box_persistent_handle_inner(ptr) +pub unsafe extern "C" fn frb_dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { + frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe extern "C" fn dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { - dart_opaque_drop_thread_box_persistent_handle_inner(ptr) +pub unsafe extern "C" fn frb_dart_opaque_drop_thread_box_persistent_handle(ptr: usize) { + frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr) } -unsafe fn dart_opaque_drop_thread_box_persistent_handle_inner(ptr: usize) { +unsafe fn frb_dart_opaque_drop_thread_box_persistent_handle_inner(ptr: usize) { let value: GeneralizedDartHandleBox = *box_from_leak_ptr(ptr as _); drop(value); diff --git a/frb_rust/src/dart_opaque/rust2dart.rs b/frb_rust/src/dart_opaque/rust2dart.rs index fd582423e5..fa0080c090 100644 --- a/frb_rust/src/dart_opaque/rust2dart.rs +++ b/frb_rust/src/dart_opaque/rust2dart.rs @@ -18,17 +18,17 @@ impl DartOpaque { #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub unsafe fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { - dart_opaque_rust2dart_decode_inner(ptr) +pub unsafe fn frb_dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { + frb_dart_opaque_rust2dart_decode_inner(ptr) } #[cfg(not(target_family = "wasm"))] #[no_mangle] -pub unsafe extern "C" fn dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { - dart_opaque_rust2dart_decode_inner(ptr) +pub unsafe extern "C" fn frb_dart_opaque_rust2dart_decode(ptr: usize) -> GeneralizedDartHandle { + frb_dart_opaque_rust2dart_decode_inner(ptr) } -unsafe fn dart_opaque_rust2dart_decode_inner(ptr: usize) -> GeneralizedDartHandle { +unsafe fn frb_dart_opaque_rust2dart_decode_inner(ptr: usize) -> GeneralizedDartHandle { let opaque = DartOpaque::from_raw(ptr as _); opaque.create_dart_handle() } diff --git a/frb_rust/src/ffi_binding/io.rs b/frb_rust/src/ffi_binding/io.rs index a0198f0da0..c8321de6ef 100644 --- a/frb_rust/src/ffi_binding/io.rs +++ b/frb_rust/src/ffi_binding/io.rs @@ -7,7 +7,7 @@ use crate::platform_types::{WireSyncRust2DartDco, WireSyncRust2DartSse}; /// /// This function should never be called manually. #[no_mangle] -pub unsafe extern "C" fn init_frb_dart_api_dl(data: *mut std::ffi::c_void) -> isize { +pub unsafe extern "C" fn frb_init_frb_dart_api_dl(data: *mut std::ffi::c_void) -> isize { #[cfg(feature = "dart-opaque")] return dart_sys_fork::Dart_InitializeApiDL(data); #[cfg(not(feature = "dart-opaque"))] @@ -18,7 +18,7 @@ pub unsafe extern "C" fn init_frb_dart_api_dl(data: *mut std::ffi::c_void) -> is /// /// This function should never be called manually. #[no_mangle] -pub unsafe extern "C" fn free_wire_sync_rust2dart_dco(value: WireSyncRust2DartDco) { +pub unsafe extern "C" fn frb_free_wire_sync_rust2dart_dco(value: WireSyncRust2DartDco) { let _ = Rust2DartMessageDco::from_raw_wire_sync(value); } @@ -26,6 +26,6 @@ pub unsafe extern "C" fn free_wire_sync_rust2dart_dco(value: WireSyncRust2DartDc /// /// This function should never be called manually. #[no_mangle] -pub unsafe extern "C" fn free_wire_sync_rust2dart_sse(value: WireSyncRust2DartSse) { +pub unsafe extern "C" fn frb_free_wire_sync_rust2dart_sse(value: WireSyncRust2DartSse) { let _ = Rust2DartMessageSse::from_raw_wire_sync(value); } diff --git a/frb_rust/src/ffi_binding/mod.rs b/frb_rust/src/ffi_binding/mod.rs index 7456d4bb8f..0abcccf34d 100644 --- a/frb_rust/src/ffi_binding/mod.rs +++ b/frb_rust/src/ffi_binding/mod.rs @@ -13,12 +13,16 @@ mod web; pub use web::*; #[no_mangle] -pub unsafe extern "C" fn rust_vec_u8_new(len: i32) -> *mut u8 { +pub unsafe extern "C" fn frb_rust_vec_u8_new(len: i32) -> *mut u8 { new_leak_vec_ptr::(0, len) } #[no_mangle] -pub unsafe extern "C" fn rust_vec_u8_resize(ptr: *mut u8, old_len: i32, new_len: i32) -> *mut u8 { +pub unsafe extern "C" fn frb_rust_vec_u8_resize( + ptr: *mut u8, + old_len: i32, + new_len: i32, +) -> *mut u8 { let mut vec = vec_from_leak_ptr(ptr, old_len); vec_resize(&mut vec, new_len); into_leak_vec_ptr(vec).0 @@ -37,6 +41,6 @@ fn vec_resize(vec: &mut Vec, new_len: i32) { } #[no_mangle] -pub unsafe extern "C" fn rust_vec_u8_free(ptr: *mut u8, len: i32) { +pub unsafe extern "C" fn frb_rust_vec_u8_free(ptr: *mut u8, len: i32) { vec_from_leak_ptr(ptr, len); } diff --git a/frb_rust/src/internal_generated/mod.rs b/frb_rust/src/internal_generated/mod.rs index da16cd2d77..f8daa4f8a1 100644 --- a/frb_rust/src/internal_generated/mod.rs +++ b/frb_rust/src/internal_generated/mod.rs @@ -26,7 +26,7 @@ macro_rules! frb_generated_io_extern_func { } #[no_mangle] - pub extern "C" fn dart_fn_deliver_output( + pub extern "C" fn frb_dart_fn_deliver_output( call_id: i32, ptr_: *mut u8, rust_vec_len_: i32, @@ -70,7 +70,7 @@ macro_rules! frb_generated_web_extern_func { } #[wasm_bindgen] - pub fn dart_fn_deliver_output( + pub fn frb_dart_fn_deliver_output( call_id: i32, ptr_: $crate::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, From 65e008db6c510b26cbcc7e98eed8a5093b174013 Mon Sep 17 00:00:00 2001 From: fzyzcjy Date: Tue, 5 Nov 2024 13:09:58 +0800 Subject: [PATCH 4/5] fix --- frb_codegen/src/library/internal/frb_rust_source_code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frb_codegen/src/library/internal/frb_rust_source_code.rs b/frb_codegen/src/library/internal/frb_rust_source_code.rs index 4b2f63e78b..7658ce6970 100644 --- a/frb_codegen/src/library/internal/frb_rust_source_code.rs +++ b/frb_codegen/src/library/internal/frb_rust_source_code.rs @@ -113,7 +113,7 @@ fn generate_dart_fn_deliver_output(target: Target) -> ExternFunc { }; ExternFunc { - partial_func_name: "dart_fn_deliver_output".into(), + partial_func_name: "frb_dart_fn_deliver_output".into(), params, return_type: None, body: format!( From 95c0527436715a15dd5dcbf23b6b6ea1cf37c755 Mon Sep 17 00:00:00 2001 From: fzyzcjy Date: Tue, 5 Nov 2024 13:10:44 +0800 Subject: [PATCH 5/5] gen --- frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h index 0519cbf906..3b9b54dd78 100644 --- a/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h +++ b/frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h @@ -28,9 +28,9 @@ struct WireSyncRust2DartSse frb_pde_ffi_dispatcher_sync(int32_t func_id, int32_t data_len_); void frb_dart_fn_deliver_output(int32_t call_id, - uint8_t *ptr_, - int32_t rust_vec_len_, - int32_t data_len_); + uint8_t *ptr_, + int32_t rust_vec_len_, + int32_t data_len_); int32_t frb_get_rust_content_hash(void); @@ -40,7 +40,7 @@ int32_t frb_get_rust_content_hash(void); * This should never be called manually. */ const void *frb_dart_opaque_dart2rust_encode(GeneralizedDartHandle handle, - MessagePort dart_handler_port); + MessagePort dart_handler_port); void frb_dart_opaque_drop_thread_box_persistent_handle(uintptr_t ptr);