@@ -148,11 +148,186 @@ 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__Inner_char_ {
239+ pub t : Value < i64 > ,
240+ pub u : Value < u8 > ,
241+ }
242+ impl Clone for Outer_long__Inner_char_ {
243+ fn clone ( & self ) -> Self {
244+ let __this: Value < Outer_long__Inner_char_ > = Rc :: new ( RefCell :: new ( Self {
245+ t : Rc :: new ( RefCell :: new ( ( * self . t . borrow ( ) ) ) ) ,
246+ u : Rc :: new ( RefCell :: new ( ( * self . u . borrow ( ) ) ) ) ,
247+ } ) ) ;
248+ let this: Ptr < Outer_long__Inner_char_ > = __this. as_pointer ( ) ;
249+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
250+ }
251+ }
252+ impl ByteRepr for Outer_long__Inner_char_ {
253+ fn byte_size ( ) -> usize {
254+ 16
255+ }
256+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
257+ ( * self . t . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..8 ] ) ;
258+ ( * self . u . borrow ( ) ) . to_bytes ( & mut buf[ 8 ..9 ] ) ;
259+ }
260+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
261+ Self {
262+ t : Rc :: new ( RefCell :: new ( <i64 >:: from_bytes ( & buf[ 0 ..8 ] ) ) ) ,
263+ u : Rc :: new ( RefCell :: new ( <u8 >:: from_bytes ( & buf[ 8 ..9 ] ) ) ) ,
264+ }
265+ }
266+ }
267+ #[ derive( Default ) ]
268+ pub struct Outer_long_ {
269+ pub v : Value < i64 > ,
270+ }
271+ impl Clone for Outer_long_ {
272+ fn clone ( & self ) -> Self {
273+ let __this: Value < Outer_long_ > = Rc :: new ( RefCell :: new ( Self {
274+ v : Rc :: new ( RefCell :: new ( ( * self . v . borrow ( ) ) ) ) ,
275+ } ) ) ;
276+ let this: Ptr < Outer_long_ > = __this. as_pointer ( ) ;
277+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
278+ }
279+ }
280+ impl ByteRepr for Outer_long_ {
281+ fn byte_size ( ) -> usize {
282+ 8
283+ }
284+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
285+ ( * self . v . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..8 ] ) ;
286+ }
287+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
288+ Self {
289+ v : Rc :: new ( RefCell :: new ( <i64 >:: from_bytes ( & buf[ 0 ..8 ] ) ) ) ,
290+ }
291+ }
292+ }
151293pub fn main ( ) {
152294 __cpp2rust_init_globals ( ) ;
153295 std:: process:: exit ( main_0 ( ) ) ;
154296}
155297fn main_0 ( ) -> i32 {
298+ let oi: Value < Outer_int_ > = Rc :: new ( RefCell :: new ( Outer_int_ {
299+ v : Rc :: new ( RefCell :: new ( 3 ) ) ,
300+ } ) ) ;
301+ assert ! (
302+ ( ( {
303+ Outer_int__Inner_int_Impl :: sum(
304+ & Rc :: new( RefCell :: new(
305+ ( { Outer_int_Impl :: with( & oi. as_pointer( ) , 4 ) } ) ,
306+ ) )
307+ . as_pointer( ) ,
308+ )
309+ } ) == 7 )
310+ ) ;
311+ let ol: Value < Outer_long_ > = Rc :: new ( RefCell :: new ( Outer_long_ {
312+ v : Rc :: new ( RefCell :: new ( 5_i64 ) ) ,
313+ } ) ) ;
314+ let ic: Value < Outer_long__Inner_char_ > = Rc :: new ( RefCell :: new ( Outer_long__Inner_char_ {
315+ t : Rc :: new ( RefCell :: new ( 6_i64 ) ) ,
316+ u : Rc :: new ( RefCell :: new ( ( 'a' as u8 ) ) ) ,
317+ } ) ) ;
318+ assert ! (
319+ ( ( {
320+ Outer_long__Inner_int_Impl :: sum(
321+ & Rc :: new( RefCell :: new(
322+ ( { Outer_long_Impl :: with( & ol. as_pointer( ) , 2 ) } ) ,
323+ ) )
324+ . as_pointer( ) ,
325+ )
326+ } ) == 7 )
327+ ) ;
328+ assert ! (
329+ ( ( { Outer_long__Inner_char_Impl :: sum( & ic. as_pointer( ) , ) } ) == ( 6 + ( ( 'a' as u8 ) as i32 ) ) )
330+ ) ;
156331 assert ! ( ( ( { Boxed_int_ :: twice( 3 , ) } ) == 6 ) ) ;
157332 let bi: Value < Boxed_int_ > = Rc :: new ( RefCell :: new ( Boxed_int_ {
158333 value : Rc :: new ( RefCell :: new ( 4 ) ) ,
@@ -313,4 +488,55 @@ impl MyContainer_int_Impl for Ptr<MyContainer_int_> {
313488 } ;
314489 }
315490}
491+ pub trait Outer_int_Impl {
492+ fn with ( & self , n : i32 ) -> Outer_int__Inner_int_ ;
493+ }
494+ impl Outer_int_Impl for Ptr < Outer_int_ > {
495+ fn with ( & self , n : i32 ) -> Outer_int__Inner_int_ {
496+ let n: Value < i32 > = Rc :: new ( RefCell :: new ( n) ) ;
497+ return Outer_int__Inner_int_ {
498+ t : Rc :: new ( RefCell :: new ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . v . borrow ( ) ) ) ) ,
499+ u : Rc :: new ( RefCell :: new ( ( * n. borrow ( ) ) ) ) ,
500+ } ;
501+ }
502+ }
503+ pub trait Outer_int__Inner_int_Impl {
504+ fn sum ( & self ) -> i32 ;
505+ }
506+ impl Outer_int__Inner_int_Impl for Ptr < Outer_int__Inner_int_ > {
507+ fn sum ( & self ) -> i32 {
508+ return ( ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . t . borrow ( ) ) as i32 )
509+ + ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . u . borrow ( ) ) as i32 ) ) ;
510+ }
511+ }
512+ pub trait Outer_long_Impl {
513+ fn with ( & self , n : i32 ) -> Outer_long__Inner_int_ ;
514+ }
515+ impl Outer_long_Impl for Ptr < Outer_long_ > {
516+ fn with ( & self , n : i32 ) -> Outer_long__Inner_int_ {
517+ let n: Value < i32 > = Rc :: new ( RefCell :: new ( n) ) ;
518+ return Outer_long__Inner_int_ {
519+ t : Rc :: new ( RefCell :: new ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . v . borrow ( ) ) ) ) ,
520+ u : Rc :: new ( RefCell :: new ( ( * n. borrow ( ) ) ) ) ,
521+ } ;
522+ }
523+ }
524+ pub trait Outer_long__Inner_char_Impl {
525+ fn sum ( & self ) -> i32 ;
526+ }
527+ impl Outer_long__Inner_char_Impl for Ptr < Outer_long__Inner_char_ > {
528+ fn sum ( & self ) -> i32 {
529+ return ( ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . t . borrow ( ) ) as i32 )
530+ + ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . u . borrow ( ) ) as i32 ) ) ;
531+ }
532+ }
533+ pub trait Outer_long__Inner_int_Impl {
534+ fn sum ( & self ) -> i32 ;
535+ }
536+ impl Outer_long__Inner_int_Impl for Ptr < Outer_long__Inner_int_ > {
537+ fn sum ( & self ) -> i32 {
538+ return ( ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . t . borrow ( ) ) as i32 )
539+ + ( ( * ( * ( * self ) . upgrade ( ) . deref ( ) ) . u . borrow ( ) ) as i32 ) ) ;
540+ }
541+ }
316542pub fn __cpp2rust_init_globals ( ) { }
0 commit comments