1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use log::debug;

use crate::ir::IrType::*;
use crate::ir::*;

pub fn transform(src: IrFile) -> IrFile {
    let dst_funcs = src
        .funcs
        .into_iter()
        .map(|src_func| IrFunc {
            inputs: src_func
                .inputs
                .into_iter()
                .map(transform_func_input_add_boxed)
                .collect(),
            ..src_func
        })
        .collect();

    IrFile {
        funcs: dst_funcs,
        ..src
    }
}

fn transform_func_input_add_boxed(input: IrField) -> IrField {
    if input.ty.is_struct() {
        debug!(
            "transform_func_input_add_boxed wrap Boxed to field={:?}",
            input
        );
        IrField {
            ty: Boxed(IrTypeBoxed {
                exist_in_real_api: false, // <--
                inner: Box::new(input.ty.clone()),
            }),
            ..input
        }
    } else {
        input
    }
}