|
| 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 | +pub fn test_0() { |
| 10 | + let mut source: i32 = 1; |
| 11 | + let mut target: i32 = source; |
| 12 | + assert!((target == 1)); |
| 13 | + assert!((source == 1)); |
| 14 | +} |
| 15 | +#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Default)] |
| 16 | +#[byte_size(8)] |
| 17 | +pub struct p9_move_trivially_copyable_Point { |
| 18 | + #[offset(0)] |
| 19 | + pub x: i32, |
| 20 | + #[offset(4)] |
| 21 | + pub y: i32, |
| 22 | +} |
| 23 | +pub fn test_1() { |
| 24 | + let mut source: p9_move_trivially_copyable_Point = |
| 25 | + p9_move_trivially_copyable_Point { x: 1, y: 2 }; |
| 26 | + let mut target: p9_move_trivially_copyable_Point = (source).clone(); |
| 27 | + assert!((target.x == 1) && (target.y == 2)); |
| 28 | + assert!((source.x == 1) && (source.y == 2)); |
| 29 | + let mut assigned: p9_move_trivially_copyable_Point = |
| 30 | + p9_move_trivially_copyable_Point { x: 0, y: 0 }; |
| 31 | + let mut other: p9_move_trivially_copyable_Point = |
| 32 | + p9_move_trivially_copyable_Point { x: 3, y: 4 }; |
| 33 | + assigned = (other).clone(); |
| 34 | + assert!((assigned.x == 3) && (assigned.y == 4)); |
| 35 | + assert!((other.x == 3) && (other.y == 4)); |
| 36 | + let mut points: Vec<p9_move_trivially_copyable_Point> = Vec::new(); |
| 37 | + let mut element: p9_move_trivially_copyable_Point = |
| 38 | + p9_move_trivially_copyable_Point { x: 5, y: 6 }; |
| 39 | + { |
| 40 | + let __a1 = (element).clone(); |
| 41 | + points.push(__a1) |
| 42 | + }; |
| 43 | + assert!((points[0_usize].x == 5) && (points[0_usize].y == 6)); |
| 44 | + assert!((element.x == 5) && (element.y == 6)); |
| 45 | +} |
| 46 | +#[derive(Record, ByteRepr, FnPtrArg, MoveCtor, CppFrom, Default)] |
| 47 | +#[cpp_from(i32, new, value)] |
| 48 | +#[byte_size(4)] |
| 49 | +pub struct p10_move_constructor_A { |
| 50 | + #[offset(0)] |
| 51 | + pub value: i32, |
| 52 | +} |
| 53 | +impl p10_move_constructor_A { |
| 54 | + pub fn new(mut value: i32) -> Self { |
| 55 | + Self { value: value } |
| 56 | + } |
| 57 | + pub fn move_from(other: Ptr<p10_move_constructor_A>) -> Self { |
| 58 | + let __this: p10_move_constructor_A = Self { |
| 59 | + value: other.with(|__s| __s.value), |
| 60 | + }; |
| 61 | + field!(other, value).write(0); |
| 62 | + __this |
| 63 | + } |
| 64 | +} |
| 65 | +pub fn test_2() { |
| 66 | + let source: Value<p10_move_constructor_A> = |
| 67 | + Rc::new(RefCell::new(p10_move_constructor_A::new({ 1 }))); |
| 68 | + let mut target: p10_move_constructor_A = |
| 69 | + p10_move_constructor_A::move_from({ source.as_pointer() }); |
| 70 | + assert!((target.value == 1)); |
| 71 | + assert!(({ ({ (*source.borrow()).value } == 0) })); |
| 72 | + let mut values: Vec<p10_move_constructor_A> = Vec::new(); |
| 73 | + let element: Value<p10_move_constructor_A> = |
| 74 | + Rc::new(RefCell::new(p10_move_constructor_A::new({ 2 }))); |
| 75 | + { |
| 76 | + let __a1 = p10_move_constructor_A::move_from({ element.as_pointer() }); |
| 77 | + values.push(__a1) |
| 78 | + }; |
| 79 | + assert!((values[0_usize].value == 2)); |
| 80 | + assert!(({ ({ (*element.borrow()).value } == 0) })); |
| 81 | +} |
| 82 | +pub fn main() { |
| 83 | + __cpp2rust_init_globals(); |
| 84 | + std::process::exit(main_0()); |
| 85 | +} |
| 86 | +fn main_0() -> i32 { |
| 87 | + ({ test_0() }); |
| 88 | + ({ test_1() }); |
| 89 | + ({ test_2() }); |
| 90 | + return 0; |
| 91 | +} |
| 92 | +pub fn __cpp2rust_init_globals() {} |
0 commit comments