@@ -148,11 +148,156 @@ impl ByteRepr for Boxed_long_ {
148148 }
149149 }
150150}
151+ #[ derive( Default ) ]
152+ pub struct Outer_int__Inner_int_ {
153+ pub t : Value < i32 > ,
154+ pub u : Value < i32 > ,
155+ }
156+ impl Clone for Outer_int__Inner_int_ {
157+ fn clone ( & self ) -> Self {
158+ let __this: Value < Outer_int__Inner_int_ > = Rc :: new ( RefCell :: new ( Self {
159+ t : Rc :: new ( RefCell :: new ( ( * self . t . borrow ( ) ) ) ) ,
160+ u : Rc :: new ( RefCell :: new ( ( * self . u . borrow ( ) ) ) ) ,
161+ } ) ) ;
162+ let this: Ptr < Outer_int__Inner_int_ > = __this. as_pointer ( ) ;
163+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
164+ }
165+ }
166+ impl ByteRepr for Outer_int__Inner_int_ {
167+ fn byte_size ( ) -> usize {
168+ 8
169+ }
170+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
171+ ( * self . t . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
172+ ( * self . u . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
173+ }
174+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
175+ Self {
176+ t : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
177+ u : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 4 ..8 ] ) ) ) ,
178+ }
179+ }
180+ }
181+ #[ derive( Default ) ]
182+ pub struct Outer_int_ {
183+ pub v : Value < i32 > ,
184+ }
185+ impl Clone for Outer_int_ {
186+ fn clone ( & self ) -> Self {
187+ let __this: Value < Outer_int_ > = Rc :: new ( RefCell :: new ( Self {
188+ v : Rc :: new ( RefCell :: new ( ( * self . v . borrow ( ) ) ) ) ,
189+ } ) ) ;
190+ let this: Ptr < Outer_int_ > = __this. as_pointer ( ) ;
191+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
192+ }
193+ }
194+ impl ByteRepr for Outer_int_ {
195+ fn byte_size ( ) -> usize {
196+ 4
197+ }
198+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
199+ ( * self . v . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
200+ }
201+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
202+ Self {
203+ v : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
204+ }
205+ }
206+ }
207+ #[ derive( Default ) ]
208+ pub struct Outer_long__Inner_int_ {
209+ pub t : Value < i64 > ,
210+ pub u : Value < i32 > ,
211+ }
212+ impl Clone for Outer_long__Inner_int_ {
213+ fn clone ( & self ) -> Self {
214+ let __this: Value < Outer_long__Inner_int_ > = Rc :: new ( RefCell :: new ( Self {
215+ t : Rc :: new ( RefCell :: new ( ( * self . t . borrow ( ) ) ) ) ,
216+ u : Rc :: new ( RefCell :: new ( ( * self . u . borrow ( ) ) ) ) ,
217+ } ) ) ;
218+ let this: Ptr < Outer_long__Inner_int_ > = __this. as_pointer ( ) ;
219+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
220+ }
221+ }
222+ impl ByteRepr for Outer_long__Inner_int_ {
223+ fn byte_size ( ) -> usize {
224+ 16
225+ }
226+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
227+ ( * self . t . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..8 ] ) ;
228+ ( * self . u . borrow ( ) ) . to_bytes ( & mut buf[ 8 ..12 ] ) ;
229+ }
230+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
231+ Self {
232+ t : Rc :: new ( RefCell :: new ( <i64 >:: from_bytes ( & buf[ 0 ..8 ] ) ) ) ,
233+ u : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 8 ..12 ] ) ) ) ,
234+ }
235+ }
236+ }
237+ #[ derive( Default ) ]
238+ pub struct Outer_long_ {
239+ pub v : Value < i64 > ,
240+ }
241+ impl Clone for Outer_long_ {
242+ fn clone ( & self ) -> Self {
243+ let __this: Value < Outer_long_ > = Rc :: new ( RefCell :: new ( Self {
244+ v : Rc :: new ( RefCell :: new ( ( * self . v . borrow ( ) ) ) ) ,
245+ } ) ) ;
246+ let this: Ptr < Outer_long_ > = __this. as_pointer ( ) ;
247+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
248+ }
249+ }
250+ impl ByteRepr for Outer_long_ {
251+ fn byte_size ( ) -> usize {
252+ 8
253+ }
254+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
255+ ( * self . v . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..8 ] ) ;
256+ }
257+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
258+ Self {
259+ v : Rc :: new ( RefCell :: new ( <i64 >:: from_bytes ( & buf[ 0 ..8 ] ) ) ) ,
260+ }
261+ }
262+ }
151263pub fn main ( ) {
152264 __cpp2rust_init_globals ( ) ;
153265 std:: process:: exit ( main_0 ( ) ) ;
154266}
155267fn main_0 ( ) -> i32 {
268+ let oi: Value < Outer_int_ > = Rc :: new ( RefCell :: new ( Outer_int_ {
269+ v : Rc :: new ( RefCell :: new ( 3 ) ) ,
270+ } ) ) ;
271+ assert ! (
272+ ( ( {
273+ Outer_int__Inner_int_Impl :: sum(
274+ & Rc :: new( RefCell :: new(
275+ ( { Outer_int_Impl :: with( & oi. as_pointer( ) , 4 ) } ) ,
276+ ) )
277+ . as_pointer( ) ,
278+ )
279+ } ) == 7 )
280+ ) ;
281+ let ol: Value < Outer_long_ > = Rc :: new ( RefCell :: new ( Outer_long_ {
282+ v : Rc :: new ( RefCell :: new ( 5_i64 ) ) ,
283+ } ) ) ;
284+ let ic: Value < Outer_long__Inner_char_ > = Rc :: new ( RefCell :: new ( Outer_long__Inner_char_ {
285+ t : Rc :: new ( RefCell :: new ( 6_i64 ) ) ,
286+ u : Rc :: new ( RefCell :: new ( ( 'a' as u8 ) ) ) ,
287+ } ) ) ;
288+ assert ! (
289+ ( ( {
290+ Outer_long__Inner_int_Impl :: sum(
291+ & Rc :: new( RefCell :: new(
292+ ( { Outer_long_Impl :: with( & ol. as_pointer( ) , 2 ) } ) ,
293+ ) )
294+ . as_pointer( ) ,
295+ )
296+ } ) == 7 )
297+ ) ;
298+ assert ! (
299+ ( ( { Outer_long__Inner_int_Impl :: sum( & ic. as_pointer( ) , ) } ) == ( 6 + ( ( 'a' as u8 ) as i32 ) ) )
300+ ) ;
156301 assert ! ( ( ( { Boxed_int_ :: twice( 3 , ) } ) == 6 ) ) ;
157302 let bi: Value < Boxed_int_ > = Rc :: new ( RefCell :: new ( Boxed_int_ {
158303 value : Rc :: new ( RefCell :: new ( 4 ) ) ,
@@ -313,4 +458,50 @@ impl MyContainer_int_Impl for Ptr<MyContainer_int_> {
313458 } ;
314459 }
315460}
461+ pub trait Outer_int_Impl {
462+ fn with ( & self , n : i32 ) -> Outer_int__Inner_int_ ;
463+ }
464+ impl Outer_int_Impl for Ptr < Outer_int_ > {
465+ fn with ( & self , n : i32 ) -> Outer_int__Inner_int_ {
466+ let n: Value < i32 > = Rc :: new ( RefCell :: new ( n) ) ;
467+ return Outer_int__Inner_int_ {
468+ t : Rc :: new ( RefCell :: new ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . v . borrow ( ) ) ) ) ,
469+ u : Rc :: new ( RefCell :: new ( ( * n. borrow ( ) ) ) ) ,
470+ } ;
471+ }
472+ }
473+ pub trait Outer_int__Inner_int_Impl {
474+ fn sum ( & self ) -> i32 ;
475+ }
476+ impl Outer_int__Inner_int_Impl for Ptr < Outer_int__Inner_int_ > {
477+ fn sum ( & self ) -> i32 {
478+ return ( ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . t . borrow ( ) ) as i32 )
479+ + ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . u . borrow ( ) ) as i32 ) ) ;
480+ }
481+ }
482+ pub trait Outer_long_Impl {
483+ fn with ( & self , n : i32 ) -> Outer_long__Inner_int_ ;
484+ }
485+ impl Outer_long_Impl for Ptr < Outer_long_ > {
486+ fn with ( & self , n : i32 ) -> Outer_long__Inner_int_ {
487+ let n: Value < i32 > = Rc :: new ( RefCell :: new ( n) ) ;
488+ return Outer_long__Inner_int_ {
489+ t : Rc :: new ( RefCell :: new ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . v . borrow ( ) ) ) ) ,
490+ u : Rc :: new ( RefCell :: new ( ( * n. borrow ( ) ) ) ) ,
491+ } ;
492+ }
493+ }
494+ pub trait Outer_long__Inner_int_Impl {
495+ fn sum ( & self ) -> i32 ;
496+ }
497+ impl Outer_long__Inner_int_Impl for Ptr < Outer_long__Inner_int_ > {
498+ fn sum ( & self ) -> i32 {
499+ return ( ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . t . borrow ( ) ) as i32 )
500+ + ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . u . borrow ( ) ) as i32 ) ) ;
501+ }
502+ fn sum ( & self ) -> i32 {
503+ return ( ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . t . borrow ( ) ) as i32 )
504+ + ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . u . borrow ( ) ) as i32 ) ) ;
505+ }
506+ }
316507pub fn __cpp2rust_init_globals ( ) { }
0 commit comments