Skip to content

Commit

Permalink
rename dart_opaque_*
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed Nov 5, 2024
1 parent 0dd8486 commit ab3549c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 49 deletions.
6 changes: 3 additions & 3 deletions frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
37 changes: 19 additions & 18 deletions frb_dart/lib/src/ffigen_generated/multi_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,51 +301,52 @@ class MultiPackageCBinding {
/// # Safety
///
/// This should never be called manually.
ffi.Pointer<ffi.Void> dart_opaque_dart2rust_encode(
ffi.Pointer<ffi.Void> 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<ffi.Void> Function(
ffi.Handle, MessagePort)>>('dart_opaque_dart2rust_encode');
late final _dart_opaque_dart2rust_encode = _dart_opaque_dart2rust_encodePtr
.asFunction<ffi.Pointer<ffi.Void> Function(Object, int)>();
ffi.Handle, MessagePort)>>('frb_dart_opaque_dart2rust_encode');
late final _frb_dart_opaque_dart2rust_encode =
_frb_dart_opaque_dart2rust_encodePtr
.asFunction<ffi.Pointer<ffi.Void> 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<ffi.NativeFunction<ffi.Void Function(ffi.UintPtr)>>(
'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<void Function(int)>();

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<ffi.NativeFunction<ffi.Handle Function(ffi.UintPtr)>>(
'dart_opaque_rust2dart_decode');
late final _dart_opaque_rust2dart_decode =
_dart_opaque_rust2dart_decodePtr.asFunction<Object Function(int)>();
'frb_dart_opaque_rust2dart_decode');
late final _frb_dart_opaque_rust2dart_decode =
_frb_dart_opaque_rust2dart_decodePtr.asFunction<Object Function(int)>();

ffi.Pointer<ffi.Uint8> rust_vec_u8_new(
int len,
Expand Down
6 changes: 3 additions & 3 deletions frb_dart/lib/src/generalized_frb_rust_binding/_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
18 changes: 9 additions & 9 deletions frb_dart/lib/src/generalized_frb_rust_binding/_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -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);
10 changes: 5 additions & 5 deletions frb_rust/src/dart_opaque/dart2rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ 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
///
/// 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 {
Expand Down
12 changes: 6 additions & 6 deletions frb_rust/src/dart_opaque/non_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GeneralizedAutoDropDartPersistentHandle>,
dart_handler_port: &SendableMessagePortHandle,
Expand All @@ -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<GeneralizedAutoDropDartPersistentHandle> =
*box_from_leak_ptr(ptr as _);
drop(value);
Expand Down
10 changes: 5 additions & 5 deletions frb_rust/src/dart_opaque/rust2dart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit ab3549c

Please sign in to comment.