Skip to content

Commit ce9d59e

Browse files
committed
Update tests
1 parent 43765d0 commit ce9d59e

35 files changed

Lines changed: 129 additions & 109 deletions

‎cpp2rust/converter/converter.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,8 +1864,7 @@ void Converter::ConvertVariadicArg(clang::Expr *arg) {
18641864

18651865
void Converter::ConvertVAArgCall(clang::CallExpr *expr) {
18661866
if (IsBuiltinVaStart(expr)) {
1867-
StrCat(ToString(expr->getArg(0)->IgnoreImpCasts()),
1868-
"= __args.as_ptr()");
1867+
StrCat(ToString(expr->getArg(0)->IgnoreImpCasts()), "= __args.as_ptr()");
18691868
return;
18701869
}
18711870
if (IsBuiltinVaEnd(expr)) {

‎tests/unit/out/refcount/va_arg_chain.rs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
pub fn extract_nth_0(mut n: i32, ap: VaList) -> i32 {
10-
let ap: Value<VaList> = Rc::new(RefCell::new(ap));
9+
pub fn extract_nth_0(mut n: i32, ap: Ptr<VaArg>) -> i32 {
10+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(ap));
1111
let mut i: i32 = 0;
1212
'loop_: while (((i < n) as i32) != 0) {
1313
(*ap.borrow_mut()).arg::<i32>();
1414
i.postfix_inc();
1515
}
1616
return (*ap.borrow_mut()).arg::<i32>();
1717
}
18-
pub fn middle_layer_1(mut n: i32, ap: VaList) -> i32 {
19-
let ap: Value<VaList> = Rc::new(RefCell::new(ap));
18+
pub fn middle_layer_1(mut n: i32, ap: Ptr<VaArg>) -> i32 {
19+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(ap));
2020
return ({ extract_nth_0(n, (*ap.borrow()).clone()) });
2121
}
2222
pub fn top_level_2(n: i32, __args: &[VaArg]) -> i32 {
23+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
2324
let n: Value<i32> = Rc::new(RefCell::new(n));
24-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
25-
(*ap.borrow_mut()) = VaList::new(__args);
25+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
26+
(*ap.borrow_mut()) = __args.as_pointer();
2627
let mut result: i32 = ({ middle_layer_1((*n.borrow()), (*ap.borrow()).clone()) });
2728
return result;
2829
}

‎tests/unit/out/refcount/va_arg_concat.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn sum_ints_0(first: i32, __args: &[VaArg]) -> i32 {
10+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
1011
let first: Value<i32> = Rc::new(RefCell::new(first));
11-
let args: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
12+
let args: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
1213
let mut total: i32 = (*first.borrow());
13-
(*args.borrow_mut()) = VaList::new(__args);
14+
(*args.borrow_mut()) = __args.as_pointer();
1415
let mut val: i32 = 0_i32;
1516
'loop_: while (((({
1617
val = (*args.borrow_mut()).arg::<i32>();

‎tests/unit/out/refcount/va_arg_conditional.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn conditional_log_0(mut verbose: i32, fmt: Ptr<i8>, __args: &[VaArg]) -> i32 {
10+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
1011
let fmt: Value<Ptr<i8>> = Rc::new(RefCell::new(fmt));
1112
if (verbose != 0) {
12-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
13-
(*ap.borrow_mut()) = VaList::new(__args);
13+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
14+
(*ap.borrow_mut()) = __args.as_pointer();
1415
let mut result: i32 = (*ap.borrow_mut()).arg::<i32>();
1516
return result;
1617
}

‎tests/unit/out/refcount/va_arg_copy.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn sum_with_copy_0(count: i32, __args: &[VaArg]) -> i32 {
10+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
1011
let count: Value<i32> = Rc::new(RefCell::new(count));
11-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
12-
let aq: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
13-
(*ap.borrow_mut()) = VaList::new(__args);
12+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
13+
let aq: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
14+
(*ap.borrow_mut()) = __args.as_pointer();
1415
(*aq.borrow_mut()) = (*ap.borrow_mut()).clone();
1516
let mut sum1: i32 = 0;
1617
let mut i: i32 = 0;

‎tests/unit/out/refcount/va_arg_fn_ptr.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ pub fn add_2(mut a: i32, mut b: i32) -> i32 {
1616
return (a + b);
1717
}
1818
pub fn apply_unary_3(x: i32, __args: &[VaArg]) -> i32 {
19+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
1920
let x: Value<i32> = Rc::new(RefCell::new(x));
20-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
21-
(*ap.borrow_mut()) = VaList::new(__args);
21+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
22+
(*ap.borrow_mut()) = __args.as_pointer();
2223
let mut fn_: FnPtr<fn(i32) -> i32> = (*ap.borrow_mut()).arg::<FnPtr<fn(i32) -> i32>>();
2324
let mut result: i32 = ({ fn_.call((*x.borrow())) });
2425
return result;
2526
}
2627
pub fn apply_binary_4(mut a: i32, b: i32, __args: &[VaArg]) -> i32 {
28+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
2729
let b: Value<i32> = Rc::new(RefCell::new(b));
28-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
29-
(*ap.borrow_mut()) = VaList::new(__args);
30+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
31+
(*ap.borrow_mut()) = __args.as_pointer();
3032
let mut fn_: FnPtr<fn(i32, i32) -> i32> =
3133
(*ap.borrow_mut()).arg::<FnPtr<fn(i32, i32) -> i32>>();
3234
let mut result: i32 = ({ fn_.call(a, (*b.borrow())) });

‎tests/unit/out/refcount/va_arg_forward.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
pub fn inner_0(mut count: i32, ap: VaList) -> i32 {
10-
let ap: Value<VaList> = Rc::new(RefCell::new(ap));
9+
pub fn inner_0(mut count: i32, ap: Ptr<VaArg>) -> i32 {
10+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(ap));
1111
let mut total: i32 = 0;
1212
let mut i: i32 = 0;
1313
'loop_: while (((i < count) as i32) != 0) {
@@ -17,9 +17,10 @@ pub fn inner_0(mut count: i32, ap: VaList) -> i32 {
1717
return total;
1818
}
1919
pub fn outer_1(count: i32, __args: &[VaArg]) -> i32 {
20+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
2021
let count: Value<i32> = Rc::new(RefCell::new(count));
21-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
22-
(*ap.borrow_mut()) = VaList::new(__args);
22+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
23+
(*ap.borrow_mut()) = __args.as_pointer();
2324
let mut result: i32 = ({ inner_0((*count.borrow()), (*ap.borrow()).clone()) });
2425
return result;
2526
}

‎tests/unit/out/refcount/va_arg_mixed_int_ptr.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn mixed_args_0(count: i32, __args: &[VaArg]) -> i32 {
10+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
1011
let count: Value<i32> = Rc::new(RefCell::new(count));
11-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
12-
(*ap.borrow_mut()) = VaList::new(__args);
12+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
13+
(*ap.borrow_mut()) = __args.as_pointer();
1314
let mut total: i32 = 0;
1415
let mut i: i32 = 0;
1516
'loop_: while (((i < (*count.borrow())) as i32) != 0) {

‎tests/unit/out/refcount/va_arg_mixed_types.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ pub struct pair {
1515
pub b: i32,
1616
}
1717
pub fn sum_mixed_0(count: i32, __args: &[VaArg]) -> i32 {
18+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
1819
let count: Value<i32> = Rc::new(RefCell::new(count));
19-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
20-
(*ap.borrow_mut()) = VaList::new(__args);
20+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
21+
(*ap.borrow_mut()) = __args.as_pointer();
2122
let mut total: i32 = 0;
2223
let mut i: i32 = 0;
2324
'loop_: while (((i < (*count.borrow())) as i32) != 0) {

‎tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ pub const opt_OPT_FILE: opt = 1;
2121
pub const opt_OPT_NODE: opt = 2;
2222
pub const opt_OPT_NODE_OUT: opt = 3;
2323
pub fn dispatch_0(option: i32, __args: &[VaArg]) -> i32 {
24+
let __args: Value<Box<[VaArg]>> = Rc::new(RefCell::new(__args.into()));
2425
let option: Value<i32> = Rc::new(RefCell::new(option));
25-
let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default()));
26-
(*ap.borrow_mut()) = VaList::new(__args);
26+
let ap: Value<Ptr<VaArg>> = Rc::new(RefCell::new(Ptr::<VaArg>::default()));
27+
(*ap.borrow_mut()) = __args.as_pointer();
2728
let mut result: i32 = 0;
2829
'switch: {
2930
match { (*option.borrow()) } {

0 commit comments

Comments
 (0)