@@ -15,6 +15,42 @@ pub fn foo_1(fn_: FnPtr<fn(AnyPtr) -> i32>, pi: Ptr<i32>) -> i32 {
1515 let pi: Value < Ptr < i32 > > = Rc :: new ( RefCell :: new ( pi) ) ;
1616 return ( { ( * fn_. borrow ( ) ) . call ( ( * pi. borrow ( ) ) . to_any ( ) ) } ) ;
1717}
18+ pub fn ret_size_2 ( v : i32 ) -> usize {
19+ let v: Value < i32 > = Rc :: new ( RefCell :: new ( v) ) ;
20+ return ( ( ( * v. borrow ( ) ) + 1 ) as usize ) ;
21+ }
22+ pub fn call_fn_3 ( f : FnPtr < fn ( i32 ) -> usize > , v : i32 ) -> usize {
23+ let f: Value < FnPtr < fn ( i32 ) -> usize > > = Rc :: new ( RefCell :: new ( f) ) ;
24+ let v: Value < i32 > = Rc :: new ( RefCell :: new ( v) ) ;
25+ return ( { ( * f. borrow ( ) ) . call ( ( * v. borrow ( ) ) ) } ) . wrapping_mul ( 2_usize ) ;
26+ }
27+ pub fn identity_hash_4 ( v : bool ) -> usize {
28+ let v: Value < bool > = Rc :: new ( RefCell :: new ( v) ) ;
29+ return ( ( * v. borrow ( ) ) as usize ) ;
30+ }
31+ #[ derive( Clone , Record , ByteRepr , VaArg , FnPtrArg ) ]
32+ #[ byte_size( 8 ) ]
33+ pub struct HashHolder_unsigned_long__ptr__bool__ {
34+ #[ offset( 0 ) ]
35+ #[ byte_size( 8 ) ]
36+ pub h : FnPtr < fn ( bool ) -> u64 > ,
37+ }
38+ impl HashHolder_unsigned_long__ptr__bool__ {
39+ pub fn new ( h : Ptr < FnPtr < fn ( bool ) -> u64 > > ) -> Self {
40+ let __this: Value < HashHolder_unsigned_long__ptr__bool__ > = Rc :: new ( RefCell :: new ( Self {
41+ h : ( h. read ( ) ) . clone ( ) ,
42+ } ) ) ;
43+ let this: Ptr < HashHolder_unsigned_long__ptr__bool__ > = __this. as_pointer ( ) ;
44+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
45+ }
46+ }
47+ impl Default for HashHolder_unsigned_long__ptr__bool__ {
48+ fn default ( ) -> Self {
49+ HashHolder_unsigned_long__ptr__bool__ {
50+ h : FnPtr :: < fn ( bool ) -> u64 > :: null ( ) ,
51+ }
52+ }
53+ }
1854pub fn main ( ) {
1955 __cpp2rust_init_globals ( ) ;
2056 std:: process:: exit ( main_0 ( ) ) ;
@@ -29,6 +65,14 @@ fn main_0() -> i32 {
2965 assert ! ( ( { ( * fn_. borrow( ) ) . clone( ) } == { FnPtr :: <fn ( AnyPtr ) -> i32 >:: new( my_foo_0) } ) ) ;
3066 let a: Value < i32 > = Rc :: new ( RefCell :: new ( 10 ) ) ;
3167 assert ! ( ( { ( { foo_1( ( * fn_. borrow( ) ) . clone( ) , ( a. as_pointer( ) ) , ) } ) } == { ( * a. borrow( ) ) } ) ) ;
68+ assert ! ( ( ( { call_fn_3( FnPtr :: <fn ( i32 ) -> usize >:: new( ret_size_2) , 3 , ) } ) == 8_usize ) ) ;
69+ let hh: Value < HashHolder_unsigned_long__ptr__bool__ > = Rc :: new ( RefCell :: new ( {
70+ let __tmp_0: Value < FnPtr < fn ( bool ) -> u64 > > = Rc :: new ( RefCell :: new (
71+ FnPtr :: < fn ( bool ) -> usize > :: new ( identity_hash_4) . cast :: < fn ( bool ) -> u64 > ( ) ,
72+ ) ) ;
73+ HashHolder_unsigned_long__ptr__bool__ :: new ( { __tmp_0. as_pointer ( ) } )
74+ } ) ) ;
75+ assert ! ( ( ( { { ( * hh. borrow( ) ) . h. clone( ) } . call( true , ) } ) == 1_u64 ) ) ;
3276 return 0 ;
3377}
3478pub fn __cpp2rust_init_globals ( ) { }
0 commit comments