Skip to content

Commit

Permalink
Merge pull request #2392 from fzyzcjy/feat/2292
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy authored Nov 5, 2024
2 parents 57eb253 + 70fb179 commit a55bed7
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 117 deletions.
2 changes: 1 addition & 1 deletion frb_codegen/src/library/internal/frb_rust_source_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
28 changes: 14 additions & 14 deletions frb_dart/lib/src/ffigen_generated/intermediate/frb_rust.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ 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,
uint8_t *ptr_,
int32_t rust_vec_len_,
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_);

int32_t frb_get_rust_content_hash(void);

Expand All @@ -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,
MessagePort dart_handler_port);
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);
115 changes: 59 additions & 56 deletions frb_dart/lib/src/ffigen_generated/multi_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,25 +267,25 @@ class MultiPackageCBinding {
WireSyncRust2DartSse Function(
int, ffi.Pointer<ffi.Uint8>, int, int)>();

void dart_fn_deliver_output(
void frb_dart_fn_deliver_output(
int call_id,
ffi.Pointer<ffi.Uint8> 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_,
data_len_,
);
}

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.Uint8>, 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<void Function(int, ffi.Pointer<ffi.Uint8>, int, int)>();

int frb_get_rust_content_hash() {
Expand All @@ -301,152 +301,155 @@ 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(
ffi.Pointer<ffi.Uint8> 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<ffi.NativeFunction<ffi.Pointer<ffi.Uint8> Function(ffi.Int32)>>(
'rust_vec_u8_new');
late final _rust_vec_u8_new =
_rust_vec_u8_newPtr.asFunction<ffi.Pointer<ffi.Uint8> Function(int)>();
'frb_rust_vec_u8_new');
late final _frb_rust_vec_u8_new = _frb_rust_vec_u8_newPtr
.asFunction<ffi.Pointer<ffi.Uint8> Function(int)>();

ffi.Pointer<ffi.Uint8> rust_vec_u8_resize(
ffi.Pointer<ffi.Uint8> frb_rust_vec_u8_resize(
ffi.Pointer<ffi.Uint8> 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<ffi.Uint8> Function(ffi.Pointer<ffi.Uint8>, 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<ffi.Uint8> Function(ffi.Pointer<ffi.Uint8>, int, int)>();

void rust_vec_u8_free(
void frb_rust_vec_u8_free(
ffi.Pointer<ffi.Uint8> 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.Uint8>, ffi.Int32)>>('rust_vec_u8_free');
late final _rust_vec_u8_free = _rust_vec_u8_freePtr
ffi.Pointer<ffi.Uint8>, ffi.Int32)>>('frb_rust_vec_u8_free');
late final _frb_rust_vec_u8_free = _frb_rust_vec_u8_freePtr
.asFunction<void Function(ffi.Pointer<ffi.Uint8>, int)>();

/// # Safety
///
/// This function should never be called manually.
int init_frb_dart_api_dl(
int frb_init_frb_dart_api_dl(
ffi.Pointer<ffi.Void> 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<ffi.NativeFunction<ffi.IntPtr Function(ffi.Pointer<ffi.Void>)>>(
'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<int Function(ffi.Pointer<ffi.Void>)>();

/// # 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<ffi.NativeFunction<ffi.Void Function(WireSyncRust2DartDco)>>(
'free_wire_sync_rust2dart_dco');
late final _free_wire_sync_rust2dart_dco = _free_wire_sync_rust2dart_dcoPtr
.asFunction<void Function(WireSyncRust2DartDco)>();
'frb_free_wire_sync_rust2dart_dco');
late final _frb_free_wire_sync_rust2dart_dco =
_frb_free_wire_sync_rust2dart_dcoPtr
.asFunction<void Function(WireSyncRust2DartDco)>();

/// # 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<ffi.NativeFunction<ffi.Void Function(WireSyncRust2DartSse)>>(
'free_wire_sync_rust2dart_sse');
late final _free_wire_sync_rust2dart_sse = _free_wire_sync_rust2dart_ssePtr
.asFunction<void Function(WireSyncRust2DartSse)>();
'frb_free_wire_sync_rust2dart_sse');
late final _frb_free_wire_sync_rust2dart_sse =
_frb_free_wire_sync_rust2dart_ssePtr
.asFunction<void Function(WireSyncRust2DartSse)>();
}

/// A Dart_CObject is used for representing Dart objects as native C
Expand Down
22 changes: 12 additions & 10 deletions frb_dart/lib/src/generalized_frb_rust_binding/_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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}
Expand All @@ -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<ffi.Uint8> rustVecU8New(int len) => _binding.rust_vec_u8_new(len);
ffi.Pointer<ffi.Uint8> rustVecU8New(int len) =>
_binding.frb_rust_vec_u8_new(len);

/// {@macro flutter_rust_bridge.only_for_generated_code}
ffi.Pointer<ffi.Uint8> rustVecU8Resize(
ffi.Pointer<ffi.Uint8> 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<ffi.Uint8> ptr, int len) =>
_binding.rust_vec_u8_free(ptr, len);
_binding.frb_rust_vec_u8_free(ptr, len);

void _userFriendlyDynamicLibraryErrorReporting(
ArgumentError e, StackTrace s) {
Expand Down
Loading

0 comments on commit a55bed7

Please sign in to comment.