|
| 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(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)] |
| 10 | +#[byte_size(8)] |
| 11 | +pub struct S_2_ { |
| 12 | + #[offset(0)] |
| 13 | + pub v: i32, |
| 14 | + #[offset(4)] |
| 15 | + pub w: i32, |
| 16 | +} |
| 17 | +#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)] |
| 18 | +#[byte_size(4)] |
| 19 | +pub struct S_1_ { |
| 20 | + #[offset(0)] |
| 21 | + pub v: i32, |
| 22 | +} |
| 23 | +#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)] |
| 24 | +#[byte_size(4)] |
| 25 | +pub struct S_3_ { |
| 26 | + #[offset(0)] |
| 27 | + pub v: i32, |
| 28 | +} |
| 29 | +pub fn scale_0(mut x: i32) -> i32 { |
| 30 | + return (x * 1); |
| 31 | +} |
| 32 | +pub fn scale_1(mut x: i32) -> i32 { |
| 33 | + return (x * 3); |
| 34 | +} |
| 35 | +pub fn scale_2(mut x: i32) -> i32 { |
| 36 | + return (x - 2); |
| 37 | +} |
| 38 | +pub fn main() { |
| 39 | + __cpp2rust_init_globals(); |
| 40 | + std::process::exit(main_0()); |
| 41 | +} |
| 42 | +fn main_0() -> i32 { |
| 43 | + let s1: Value<S_1_> = Rc::new(RefCell::new(S_1_ { v: 5 })); |
| 44 | + let s2: Value<S_2_> = Rc::new(RefCell::new(S_2_ { v: 5, w: 1 })); |
| 45 | + let s3: Value<S_3_> = Rc::new(RefCell::new(S_3_ { v: 5 })); |
| 46 | + assert!((({ S_1_Impl::get(&s1.as_pointer(),) }) == 5)); |
| 47 | + assert!((({ S_2_Impl::get(&s2.as_pointer(),) }) == 4)); |
| 48 | + assert!((({ S_3_Impl::get(&s3.as_pointer(),) }) == 15)); |
| 49 | + assert!((({ scale_0(7,) }) == 7)); |
| 50 | + assert!((({ scale_2(7,) }) == 5)); |
| 51 | + assert!((({ scale_1(7,) }) == 21)); |
| 52 | + return 0; |
| 53 | +} |
| 54 | +pub trait S_1_Impl { |
| 55 | + fn get(&self) -> i32; |
| 56 | +} |
| 57 | +impl S_1_Impl for Ptr<S_1_> { |
| 58 | + fn get(&self) -> i32 { |
| 59 | + return ((*self).with(|__s| __s.v) * 1); |
| 60 | + } |
| 61 | +} |
| 62 | +pub trait S_2_Impl { |
| 63 | + fn get(&self) -> i32; |
| 64 | +} |
| 65 | +impl S_2_Impl for Ptr<S_2_> { |
| 66 | + fn get(&self) -> i32 { |
| 67 | + return ((*self).with(|__s| __s.v) - (*self).with(|__s| __s.w)); |
| 68 | + } |
| 69 | +} |
| 70 | +pub trait S_3_Impl { |
| 71 | + fn get(&self) -> i32; |
| 72 | +} |
| 73 | +impl S_3_Impl for Ptr<S_3_> { |
| 74 | + fn get(&self) -> i32 { |
| 75 | + return ((*self).with(|__s| __s.v) * 3); |
| 76 | + } |
| 77 | +} |
| 78 | +pub fn __cpp2rust_init_globals() {} |
0 commit comments