|
| 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(Default)] |
| 10 | +pub struct Wrapper_Probe_ { |
| 11 | + pub base_: Value<Probe>, |
| 12 | + pub tag: Value<i32>, |
| 13 | +} |
| 14 | +impl Clone for Wrapper_Probe_ { |
| 15 | + fn clone(&self) -> Self { |
| 16 | + let __this: Value<Wrapper_Probe_> = Rc::new(RefCell::new(Self { |
| 17 | + base_: Rc::new(RefCell::new((*self.base_.borrow()).clone())), |
| 18 | + tag: Rc::new(RefCell::new((*self.tag.borrow()))), |
| 19 | + })); |
| 20 | + let this: Ptr<Wrapper_Probe_> = __this.as_pointer(); |
| 21 | + Rc::try_unwrap(__this).ok().unwrap().into_inner() |
| 22 | + } |
| 23 | +} |
| 24 | +impl ByteRepr for Wrapper_Probe_ { |
| 25 | + fn byte_size() -> usize { |
| 26 | + 8 |
| 27 | + } |
| 28 | + fn to_bytes(&self, buf: &mut [u8]) { |
| 29 | + (*self.base_.borrow()).to_bytes(&mut buf[0..1]); |
| 30 | + (*self.tag.borrow()).to_bytes(&mut buf[4..8]); |
| 31 | + } |
| 32 | + fn from_bytes(buf: &[u8]) -> Self { |
| 33 | + Self { |
| 34 | + base_: Rc::new(RefCell::new(<Probe>::from_bytes(&buf[0..1]))), |
| 35 | + tag: Rc::new(RefCell::new(<i32>::from_bytes(&buf[4..8]))), |
| 36 | + } |
| 37 | + } |
| 38 | +} |
| 39 | +pub fn main() { |
| 40 | + std::process::exit(main_0()); |
| 41 | +} |
| 42 | +fn main_0() -> i32 { |
| 43 | + let a: Value<Wrapper_Probe_> = Rc::new(RefCell::new(Wrapper_Probe_ { |
| 44 | + base_: Rc::new(RefCell::new(Probe {})), |
| 45 | + tag: Rc::new(RefCell::new(<i32>::default())), |
| 46 | + })); |
| 47 | + (*(*a.borrow()).tag.borrow_mut()) = 3; |
| 48 | + let b: Value<Wrapper_Probe_> = Rc::new(RefCell::new((*a.borrow()).clone())); |
| 49 | + assert!(((*(*b.borrow()).tag.borrow()) == 3)); |
| 50 | + return 0; |
| 51 | +} |
| 52 | +#[derive(Clone, Copy, Default, ByteRepr)] |
| 53 | +pub struct Probe; |
0 commit comments