|
| 1 | +extern crate libcc2rs; |
| 2 | +use libcc2rs::*; |
| 3 | +use std::cell::RefCell; |
| 4 | +use std::collections::BTreeMap; |
| 5 | +use std::io::prelude::*; |
| 6 | +use std::io::{Read, Seek, Write}; |
| 7 | +use std::os::fd::AsFd; |
| 8 | +use std::rc::{Rc, Weak}; |
| 9 | +#[derive()] |
| 10 | +pub struct shape_a { |
| 11 | + pub code: Value<u16>, |
| 12 | + pub pad: Value<Box<[u8]>>, |
| 13 | +} |
| 14 | +impl ByteRepr for shape_a {} |
| 15 | +#[derive()] |
| 16 | +pub struct shape_b { |
| 17 | + pub code: Value<u16>, |
| 18 | + pub lo: Value<u16>, |
| 19 | + pub hi: Value<u32>, |
| 20 | + pub fill: Value<Box<[u8]>>, |
| 21 | +} |
| 22 | +impl ByteRepr for shape_b {} |
| 23 | +#[derive()] |
| 24 | +pub struct Container_anon_0 { |
| 25 | + pub a: Value<shape_a>, |
| 26 | + pub b: Value<shape_b>, |
| 27 | + pub raw_: Value<Box<[u8]>>, |
| 28 | +} |
| 29 | +impl ByteRepr for Container_anon_0 {} |
| 30 | +#[derive(Default)] |
| 31 | +pub struct Container { |
| 32 | + pub view: Value<Container_anon_0>, |
| 33 | +} |
| 34 | +impl ByteRepr for Container {} |
| 35 | +pub fn main() { |
| 36 | + std::process::exit(main_0()); |
| 37 | +} |
| 38 | +fn main_0() -> i32 { |
| 39 | + let c: Value<Container> = <Value<Container>>::default(); |
| 40 | + { |
| 41 | + ((c.as_pointer()) as Ptr<Container>).to_any().memset( |
| 42 | + (0) as u8, |
| 43 | + ::std::mem::size_of::<Container>() as u64 as usize, |
| 44 | + ); |
| 45 | + ((c.as_pointer()) as Ptr<Container>).to_any().clone() |
| 46 | + }; |
| 47 | + assert!((((*(*(*(*c.borrow()).view.borrow()).a.borrow()).code.borrow()) as i32) == 0)); |
| 48 | + assert!((((*(*(*(*c.borrow()).view.borrow()).b.borrow()).lo.borrow()) as i32) == 0)); |
| 49 | + assert!((((*(*(*c.borrow()).view.borrow()).raw_.borrow())[(0) as usize] as i32) == 0)); |
| 50 | + assert!((((*(*(*c.borrow()).view.borrow()).raw_.borrow())[(255) as usize] as i32) == 0)); |
| 51 | + let src: Value<Box<[u8]>> = Rc::new(RefCell::new(Box::new([ |
| 52 | + 0_u8, |
| 53 | + <u8>::default(), |
| 54 | + <u8>::default(), |
| 55 | + <u8>::default(), |
| 56 | + <u8>::default(), |
| 57 | + <u8>::default(), |
| 58 | + <u8>::default(), |
| 59 | + <u8>::default(), |
| 60 | + <u8>::default(), |
| 61 | + <u8>::default(), |
| 62 | + <u8>::default(), |
| 63 | + <u8>::default(), |
| 64 | + <u8>::default(), |
| 65 | + <u8>::default(), |
| 66 | + <u8>::default(), |
| 67 | + <u8>::default(), |
| 68 | + ]))); |
| 69 | + (*src.borrow_mut())[(0) as usize] = 2_u8; |
| 70 | + (*src.borrow_mut())[(2) as usize] = 80_u8; |
| 71 | + (*src.borrow_mut())[(3) as usize] = 0_u8; |
| 72 | + (*src.borrow_mut())[(4) as usize] = 127_u8; |
| 73 | + (*src.borrow_mut())[(5) as usize] = 0_u8; |
| 74 | + (*src.borrow_mut())[(6) as usize] = 0_u8; |
| 75 | + (*src.borrow_mut())[(7) as usize] = 1_u8; |
| 76 | + let len: Value<u64> = Rc::new(RefCell::new(16_u64)); |
| 77 | + assert!(((*len.borrow()) <= ::std::mem::size_of::<[u8; 256]>() as u64)); |
| 78 | + { |
| 79 | + (((*(*c.borrow()).view.borrow()).raw_.as_pointer()) as Ptr<u8>) |
| 80 | + .to_any() |
| 81 | + .memcpy( |
| 82 | + &((src.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any(), |
| 83 | + (*len.borrow()) as usize, |
| 84 | + ); |
| 85 | + (((*(*c.borrow()).view.borrow()).raw_.as_pointer()) as Ptr<u8>) |
| 86 | + .to_any() |
| 87 | + .clone() |
| 88 | + }; |
| 89 | + assert!((((*(*(*(*c.borrow()).view.borrow()).b.borrow()).code.borrow()) as i32) == 2)); |
| 90 | + assert!( |
| 91 | + ((((((*(*(*c.borrow()).view.borrow()).b.borrow()).lo.as_pointer()) |
| 92 | + .to_strong() |
| 93 | + .as_pointer() as Ptr::<u8>) |
| 94 | + .offset((0) as isize) |
| 95 | + .read()) as i32) |
| 96 | + == 80) |
| 97 | + ); |
| 98 | + { |
| 99 | + ((c.as_pointer()) as Ptr<Container>).to_any().memset( |
| 100 | + (0) as u8, |
| 101 | + ::std::mem::size_of::<Container>() as u64 as usize, |
| 102 | + ); |
| 103 | + ((c.as_pointer()) as Ptr<Container>).to_any().clone() |
| 104 | + }; |
| 105 | + assert!((((*(*(*(*c.borrow()).view.borrow()).b.borrow()).code.borrow()) as i32) == 0)); |
| 106 | + return 0; |
| 107 | +} |
0 commit comments