File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -98,14 +98,22 @@ impl FFITestOutputStruct {
98
98
#[ cfg( debug_assertions) ]
99
99
type FFITestOutputStructHandle < ' a > = HandleShared < ' a , FFITestOutputStruct > ;
100
100
101
+ type FFIFunctionPointer = extern "C" fn ( * const FFITestInputStruct ) ;
102
+
101
103
#[ cfg( debug_assertions) ]
102
104
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
+ }
103
111
fn ffi_test_simple_struct_with_function_pointer(
104
- // input: Ref<FFITestInputStruct>,
112
+ input: Ref <FFITestInputStruct >,
105
113
output: Out <FFITestOutputStructHandle >
106
114
) -> 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 } ;
109
117
// result.field.call();
110
118
// unsafe_block!("We know output is not null by wrapper macro. And we know `Out` is writable" => output.init(HandleShared::alloc(result)));
111
119
FFIResult :: ok( )
You can’t perform that action at this time.
0 commit comments