Skip to content

Commit ac7d6bf

Browse files
committed
update
1 parent 1951d72 commit ac7d6bf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bindings/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,22 @@ impl FFITestOutputStruct {
9898
#[cfg(debug_assertions)]
9999
type FFITestOutputStructHandle<'a> = HandleShared<'a, FFITestOutputStruct>;
100100

101+
type FFIFunctionPointer = extern "C" fn (*const FFITestInputStruct);
102+
101103
#[cfg(debug_assertions)]
102104
ffi! {
105+
fn ffi_test_funcion_ptr(struct_arg_ptr: Ref<FFITestInputStruct>, fn_ptr: Ref<FFIFunctionPointer>) -> FFIResult {
106+
let func = unsafe_block!("" => fn_ptr.as_ref());
107+
let struct_arg = unsafe_block!("" => struct_arg_ptr.as_ref());
108+
(func)(struct_arg);
109+
FFIResult::ok()
110+
}
103111
fn ffi_test_simple_struct_with_function_pointer(
104-
// input: Ref<FFITestInputStruct>,
112+
input: Ref<FFITestInputStruct>,
105113
output: Out<FFITestOutputStructHandle>
106114
) -> FFIResult {
107-
// let input_arc = unsafe_block!(" " => input.as_arc());
108-
// let result = FFITestOutputStruct{ field: input_arc };
115+
let input_arc = unsafe_block!(" " => input.as_arc());
116+
let result = FFITestOutputStruct{ field: input_arc };
109117
// result.field.call();
110118
// unsafe_block!("We know output is not null by wrapper macro. And we know `Out` is writable" => output.init(HandleShared::alloc(result)));
111119
FFIResult::ok()

0 commit comments

Comments
 (0)