|
| 1 | +extern crate libc; |
| 2 | +use libc::*; |
| 3 | +extern crate libcc2rs; |
| 4 | +use libcc2rs::*; |
| 5 | +use std::collections::BTreeMap; |
| 6 | +use std::io::{Read, Seek, Write}; |
| 7 | +use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; |
| 8 | +use std::rc::Rc; |
| 9 | +#[derive(Clone, Copy, PartialEq, Debug, Default)] |
| 10 | +enum Choice { |
| 11 | + #[default] |
| 12 | + C_LIST = 1, |
| 13 | + C_LETTERS = 2, |
| 14 | + C_INTEGERS = 3, |
| 15 | +} |
| 16 | +#[derive(Copy, Clone, Default)] |
| 17 | +pub struct Branch_anon_0_anon_0 { |
| 18 | + pub items: *mut *mut u8, |
| 19 | + pub count: i64, |
| 20 | + pub cursor: i64, |
| 21 | +} |
| 22 | +#[derive(Copy, Clone, Default)] |
| 23 | +pub struct Branch_anon_0_anon_1 { |
| 24 | + pub lo: i32, |
| 25 | + pub hi: i32, |
| 26 | + pub curr: i32, |
| 27 | + pub step: u8, |
| 28 | +} |
| 29 | +#[derive(Copy, Clone, Default)] |
| 30 | +pub struct Branch_anon_0_anon_2 { |
| 31 | + pub lo: i64, |
| 32 | + pub hi: i64, |
| 33 | + pub curr: i64, |
| 34 | + pub step: i64, |
| 35 | + pub width: i32, |
| 36 | +} |
| 37 | +#[derive(Copy, Clone, Default)] |
| 38 | +pub struct Branch_anon_0 { |
| 39 | + pub list: Branch_anon_0_anon_0, |
| 40 | + pub letters: Branch_anon_0_anon_1, |
| 41 | + pub integers: Branch_anon_0_anon_2, |
| 42 | +} |
| 43 | +#[derive(Copy, Clone, Default)] |
| 44 | +pub struct Branch { |
| 45 | + pub choice: Choice, |
| 46 | + pub index: i32, |
| 47 | + pub v: Branch_anon_0, |
| 48 | +} |
| 49 | +pub fn main() { |
| 50 | + unsafe { |
| 51 | + std::process::exit(main_0() as i32); |
| 52 | + } |
| 53 | +} |
| 54 | +unsafe fn main_0() -> i32 { |
| 55 | + static mut items: [*mut u8; 3] = [ |
| 56 | + b"a\0".as_ptr().cast_mut(), |
| 57 | + b"b\0".as_ptr().cast_mut(), |
| 58 | + b"c\0".as_ptr().cast_mut(), |
| 59 | + ];; |
| 60 | + let mut p_list: Branch = <Branch>::default(); |
| 61 | + p_list.choice = (Choice::C_LIST as Choice); |
| 62 | + p_list.index = 0; |
| 63 | + p_list.v.list.items = items.as_mut_ptr(); |
| 64 | + p_list.v.list.count = 3_i64; |
| 65 | + p_list.v.list.cursor = 1_i64; |
| 66 | + assert!(((p_list.v.list.count) == (3_i64))); |
| 67 | + assert!( |
| 68 | + (((*(*p_list.v.list.items.offset((1) as isize)).offset((0) as isize)) as i32) |
| 69 | + == ('b' as i32)) |
| 70 | + ); |
| 71 | + let mut p_letters: Branch = <Branch>::default(); |
| 72 | + p_letters.choice = (Choice::C_LETTERS as Choice); |
| 73 | + p_letters.index = 1; |
| 74 | + p_letters.v.letters.lo = ('a' as i32); |
| 75 | + p_letters.v.letters.hi = ('z' as i32); |
| 76 | + p_letters.v.letters.curr = ('m' as i32); |
| 77 | + p_letters.v.letters.step = 1_u8; |
| 78 | + assert!((((p_letters.v.letters.hi) - (p_letters.v.letters.lo)) == (25))); |
| 79 | + let mut p_integers: Branch = <Branch>::default(); |
| 80 | + p_integers.choice = (Choice::C_INTEGERS as Choice); |
| 81 | + p_integers.index = 2; |
| 82 | + p_integers.v.integers.lo = 1_i64; |
| 83 | + p_integers.v.integers.hi = 100_i64; |
| 84 | + p_integers.v.integers.curr = 1_i64; |
| 85 | + p_integers.v.integers.step = 1_i64; |
| 86 | + p_integers.v.integers.width = 3; |
| 87 | + assert!(((p_integers.v.integers.hi) == (100_i64))); |
| 88 | + assert!(((p_integers.v.integers.width) == (3))); |
| 89 | + return 0; |
| 90 | +} |
0 commit comments