|
| 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 MyContainer_int_ { |
| 11 | + vec_: Value<Vec<i32>>, |
| 12 | +} |
| 13 | +impl MyContainer_int_ { |
| 14 | + pub fn empty(&self) -> bool { |
| 15 | + return (*self.vec_.borrow()).is_empty(); |
| 16 | + } |
| 17 | + pub fn size(&self) -> usize { |
| 18 | + return (*self.vec_.borrow()).len(); |
| 19 | + } |
| 20 | + pub fn back_const(&self) -> Ptr<i32> { |
| 21 | + return (self.vec_.as_pointer() as Ptr<i32>).to_last(); |
| 22 | + } |
| 23 | + pub fn back(&self) -> Ptr<i32> { |
| 24 | + return (self.vec_.as_pointer() as Ptr<i32>).to_last(); |
| 25 | + } |
| 26 | + pub fn pop_back(&self) { |
| 27 | + (*self.vec_.borrow_mut()).pop(); |
| 28 | + return; |
| 29 | + } |
| 30 | + pub fn push_back(&self, item: Ptr<i32>) { |
| 31 | + { |
| 32 | + let a0_clone = (item.read()).clone(); |
| 33 | + (*self.vec_.borrow_mut()).push(a0_clone) |
| 34 | + }; |
| 35 | + } |
| 36 | +} |
| 37 | +impl Clone for MyContainer_int_ { |
| 38 | + fn clone(&self) -> Self { |
| 39 | + let mut this = Self { |
| 40 | + vec_: Rc::new(RefCell::new((*self.vec_.borrow()).clone())), |
| 41 | + }; |
| 42 | + this |
| 43 | + } |
| 44 | +} |
| 45 | +impl ByteRepr for MyContainer_int_ {} |
| 46 | +#[derive(Default)] |
| 47 | +pub struct MyContainer_char_ { |
| 48 | + vec_: Value<Vec<u8>>, |
| 49 | +} |
| 50 | +impl MyContainer_char_ { |
| 51 | + pub fn empty(&self) -> bool { |
| 52 | + return (*self.vec_.borrow()).is_empty(); |
| 53 | + } |
| 54 | + pub fn size(&self) -> usize { |
| 55 | + return (*self.vec_.borrow()).len(); |
| 56 | + } |
| 57 | + pub fn back_const(&self) -> Ptr<u8> { |
| 58 | + return (self.vec_.as_pointer() as Ptr<u8>).to_last(); |
| 59 | + } |
| 60 | + pub fn back(&self) -> Ptr<u8> { |
| 61 | + return (self.vec_.as_pointer() as Ptr<u8>).to_last(); |
| 62 | + } |
| 63 | + pub fn pop_back(&self) { |
| 64 | + (*self.vec_.borrow_mut()).pop(); |
| 65 | + return; |
| 66 | + } |
| 67 | + pub fn push_back(&self, item: Ptr<u8>) { |
| 68 | + { |
| 69 | + let a0_clone = (item.read()).clone(); |
| 70 | + (*self.vec_.borrow_mut()).push(a0_clone) |
| 71 | + }; |
| 72 | + } |
| 73 | +} |
| 74 | +impl Clone for MyContainer_char_ { |
| 75 | + fn clone(&self) -> Self { |
| 76 | + let mut this = Self { |
| 77 | + vec_: Rc::new(RefCell::new((*self.vec_.borrow()).clone())), |
| 78 | + }; |
| 79 | + this |
| 80 | + } |
| 81 | +} |
| 82 | +impl ByteRepr for MyContainer_char_ {} |
| 83 | +#[derive(Default)] |
| 84 | +pub struct MyContainer_float_ { |
| 85 | + vec_: Value<Vec<f32>>, |
| 86 | +} |
| 87 | +impl MyContainer_float_ { |
| 88 | + pub fn empty(&self) -> bool { |
| 89 | + return (*self.vec_.borrow()).is_empty(); |
| 90 | + } |
| 91 | + pub fn size(&self) -> usize { |
| 92 | + return (*self.vec_.borrow()).len(); |
| 93 | + } |
| 94 | + pub fn back_const(&self) -> Ptr<f32> { |
| 95 | + return (self.vec_.as_pointer() as Ptr<f32>).to_last(); |
| 96 | + } |
| 97 | + pub fn back(&self) -> Ptr<f32> { |
| 98 | + return (self.vec_.as_pointer() as Ptr<f32>).to_last(); |
| 99 | + } |
| 100 | + pub fn pop_back(&self) { |
| 101 | + (*self.vec_.borrow_mut()).pop(); |
| 102 | + return; |
| 103 | + } |
| 104 | + pub fn push_back(&self, item: Ptr<f32>) { |
| 105 | + { |
| 106 | + let a0_clone = (item.read()).clone(); |
| 107 | + (*self.vec_.borrow_mut()).push(a0_clone) |
| 108 | + }; |
| 109 | + } |
| 110 | +} |
| 111 | +impl Clone for MyContainer_float_ { |
| 112 | + fn clone(&self) -> Self { |
| 113 | + let mut this = Self { |
| 114 | + vec_: Rc::new(RefCell::new((*self.vec_.borrow()).clone())), |
| 115 | + }; |
| 116 | + this |
| 117 | + } |
| 118 | +} |
| 119 | +impl ByteRepr for MyContainer_float_ {} |
| 120 | +pub fn main() { |
| 121 | + std::process::exit(main_0()); |
| 122 | +} |
| 123 | +fn main_0() -> i32 { |
| 124 | + let imc: Value<MyContainer_int_> = Rc::new(RefCell::new(<MyContainer_int_>::default())); |
| 125 | + assert!(({ (*imc.borrow()).empty() })); |
| 126 | + ({ |
| 127 | + let _item: Value<i32> = Rc::new(RefCell::new(1)); |
| 128 | + (*imc.borrow()).push_back(_item.as_pointer()) |
| 129 | + }); |
| 130 | + assert!( |
| 131 | + (({ (*imc.borrow()).size() }) == 1_usize) && ((({ (*imc.borrow()).back() }).read()) == 1) |
| 132 | + ); |
| 133 | + ({ (*imc.borrow()).pop_back() }); |
| 134 | + assert!(({ (*imc.borrow()).empty() })); |
| 135 | + let cmc: Value<MyContainer_char_> = Rc::new(RefCell::new(<MyContainer_char_>::default())); |
| 136 | + assert!(({ (*cmc.borrow()).empty() })); |
| 137 | + ({ |
| 138 | + let _item: Value<u8> = Rc::new(RefCell::new(('a' as u8))); |
| 139 | + (*cmc.borrow()).push_back(_item.as_pointer()) |
| 140 | + }); |
| 141 | + assert!( |
| 142 | + (({ (*cmc.borrow()).size() }) == 1_usize) |
| 143 | + && (((({ (*cmc.borrow()).back() }).read()) as i32) == (('a' as u8) as i32)) |
| 144 | + ); |
| 145 | + ({ (*cmc.borrow()).pop_back() }); |
| 146 | + assert!(({ (*cmc.borrow()).empty() })); |
| 147 | + let fmc: Value<MyContainer_float_> = Rc::new(RefCell::new(<MyContainer_float_>::default())); |
| 148 | + assert!(({ (*fmc.borrow()).empty() })); |
| 149 | + ({ |
| 150 | + let _item: Value<f32> = Rc::new(RefCell::new((1.0E+0 as f32))); |
| 151 | + (*fmc.borrow()).push_back(_item.as_pointer()) |
| 152 | + }); |
| 153 | + assert!( |
| 154 | + (({ (*fmc.borrow()).size() }) == 1_usize) |
| 155 | + && (((({ (*fmc.borrow()).back() }).read()) as f64) == 1.0E+0) |
| 156 | + ); |
| 157 | + ({ (*fmc.borrow()).pop_back() }); |
| 158 | + assert!(({ (*fmc.borrow()).empty() })); |
| 159 | + return 0; |
| 160 | +} |
0 commit comments