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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
cpp! {{
  #include <CNTKLibrary.h>
  #include <cstdio>
  #include <vector>

  using namespace CNTK;
  using namespace std;
}}

pub(super) type AxisInner = [u64; 3usize];

pub struct Axis {
    pub(super) payload: AxisInner
}

impl Axis {
    pub fn all() -> Axis {
        Axis {
            payload: unsafe {
                cpp!([] -> AxisInner as "Axis" {
                    return Axis::AllAxes();
                })
            }
        }
    }

    pub fn default_batch_axis() -> Axis {
        Axis {
            payload: unsafe {
                cpp!([] -> AxisInner as "Axis" {
                    return Axis::DefaultBatchAxis();
                })
            }
        }
    }

    pub fn named_dynamic(name: &str) -> Axis {
        let name_ptr = name.as_ptr();
        let name_len = name.len();
        Axis {
            payload: unsafe {
                cpp!([name_ptr as "char*", name_len as "size_t"] -> AxisInner as "Axis" {
                    string name(name_ptr, name_ptr + name_len);
                    wstring wname;
                    wname.assign(name.begin(), name.end());
                    return Axis(wname);
                })
            }
        }
    }

    pub fn all_static() -> Axis {
        Axis {
            payload: unsafe {
                cpp!([] -> AxisInner as "Axis" {
                    return Axis::AllStaticAxes();
                })
            }
        }
    }

    pub fn new(number: i32) -> Axis {
        Axis {
            payload: unsafe {
                cpp!([number as "int"] -> AxisInner as "Axis" {
                    return Axis(number);
                })
            }
        }
    }
}

impl Drop for Axis {
    fn drop(&mut self) {
        let payload = self.payload;
        unsafe {
            cpp!([payload as "Axis"] {
                payload.~Axis();
            })
        };
    }
}

impl Clone for Axis {
    fn clone(&self) -> Self {
        let xpayload = self.payload;
        let payload = unsafe {
            cpp!([xpayload as "Axis"] -> AxisInner as "Axis" {
                return xpayload;
            })
        };
        Axis {payload}
    }
}