isl_rs/bindings/
union_flow.rs

1// Automatically generated by isl_bindings_generator.
2// LICENSE: MIT
3
4use super::{Context, Error, LibISLError, UnionMap};
5use libc::uintptr_t;
6use std::ffi::CStr;
7use std::os::raw::c_char;
8
9/// Wraps `isl_union_flow`.
10pub struct UnionFlow {
11    pub ptr: uintptr_t,
12    pub should_free_on_drop: bool,
13}
14
15extern "C" {
16
17    fn isl_union_flow_copy(flow: uintptr_t) -> uintptr_t;
18
19    fn isl_union_flow_free(flow: uintptr_t) -> uintptr_t;
20
21    fn isl_union_flow_get_ctx(flow: uintptr_t) -> uintptr_t;
22
23    fn isl_union_flow_get_full_may_dependence(flow: uintptr_t) -> uintptr_t;
24
25    fn isl_union_flow_get_full_must_dependence(flow: uintptr_t) -> uintptr_t;
26
27    fn isl_union_flow_get_may_dependence(flow: uintptr_t) -> uintptr_t;
28
29    fn isl_union_flow_get_may_no_source(flow: uintptr_t) -> uintptr_t;
30
31    fn isl_union_flow_get_must_dependence(flow: uintptr_t) -> uintptr_t;
32
33    fn isl_union_flow_get_must_no_source(flow: uintptr_t) -> uintptr_t;
34
35    fn isl_union_flow_to_str(flow: uintptr_t) -> *const c_char;
36
37}
38
39impl UnionFlow {
40    /// Wraps `isl_union_flow_copy`.
41    pub fn copy(&self) -> Result<UnionFlow, LibISLError> {
42        let flow = self;
43        let isl_rs_ctx = flow.get_ctx();
44        let flow = flow.ptr;
45        let isl_rs_result = unsafe { isl_union_flow_copy(flow) };
46        let isl_rs_result = UnionFlow { ptr: isl_rs_result,
47                                        should_free_on_drop: true };
48        let err = isl_rs_ctx.last_error();
49        if err != Error::None_ {
50            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
51        }
52        Ok(isl_rs_result)
53    }
54
55    /// Wraps `isl_union_flow_free`.
56    pub fn free(self) -> Result<UnionFlow, LibISLError> {
57        let flow = self;
58        let isl_rs_ctx = flow.get_ctx();
59        let mut flow = flow;
60        flow.do_not_free_on_drop();
61        let flow = flow.ptr;
62        let isl_rs_result = unsafe { isl_union_flow_free(flow) };
63        let isl_rs_result = UnionFlow { ptr: isl_rs_result,
64                                        should_free_on_drop: true };
65        let err = isl_rs_ctx.last_error();
66        if err != Error::None_ {
67            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
68        }
69        Ok(isl_rs_result)
70    }
71
72    /// Wraps `isl_union_flow_get_ctx`.
73    pub fn get_ctx(&self) -> Context {
74        let flow = self;
75        let flow = flow.ptr;
76        let isl_rs_result = unsafe { isl_union_flow_get_ctx(flow) };
77        let isl_rs_result = Context { ptr: isl_rs_result,
78                                      should_free_on_drop: false };
79        isl_rs_result
80    }
81
82    /// Wraps `isl_union_flow_get_full_may_dependence`.
83    pub fn get_full_may_dependence(&self) -> Result<UnionMap, LibISLError> {
84        let flow = self;
85        let isl_rs_ctx = flow.get_ctx();
86        let flow = flow.ptr;
87        let isl_rs_result = unsafe { isl_union_flow_get_full_may_dependence(flow) };
88        let isl_rs_result = UnionMap { ptr: isl_rs_result,
89                                       should_free_on_drop: true };
90        let err = isl_rs_ctx.last_error();
91        if err != Error::None_ {
92            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
93        }
94        Ok(isl_rs_result)
95    }
96
97    /// Wraps `isl_union_flow_get_full_must_dependence`.
98    pub fn get_full_must_dependence(&self) -> Result<UnionMap, LibISLError> {
99        let flow = self;
100        let isl_rs_ctx = flow.get_ctx();
101        let flow = flow.ptr;
102        let isl_rs_result = unsafe { isl_union_flow_get_full_must_dependence(flow) };
103        let isl_rs_result = UnionMap { ptr: isl_rs_result,
104                                       should_free_on_drop: true };
105        let err = isl_rs_ctx.last_error();
106        if err != Error::None_ {
107            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
108        }
109        Ok(isl_rs_result)
110    }
111
112    /// Wraps `isl_union_flow_get_may_dependence`.
113    pub fn get_may_dependence(&self) -> Result<UnionMap, LibISLError> {
114        let flow = self;
115        let isl_rs_ctx = flow.get_ctx();
116        let flow = flow.ptr;
117        let isl_rs_result = unsafe { isl_union_flow_get_may_dependence(flow) };
118        let isl_rs_result = UnionMap { ptr: isl_rs_result,
119                                       should_free_on_drop: true };
120        let err = isl_rs_ctx.last_error();
121        if err != Error::None_ {
122            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
123        }
124        Ok(isl_rs_result)
125    }
126
127    /// Wraps `isl_union_flow_get_may_no_source`.
128    pub fn get_may_no_source(&self) -> Result<UnionMap, LibISLError> {
129        let flow = self;
130        let isl_rs_ctx = flow.get_ctx();
131        let flow = flow.ptr;
132        let isl_rs_result = unsafe { isl_union_flow_get_may_no_source(flow) };
133        let isl_rs_result = UnionMap { ptr: isl_rs_result,
134                                       should_free_on_drop: true };
135        let err = isl_rs_ctx.last_error();
136        if err != Error::None_ {
137            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
138        }
139        Ok(isl_rs_result)
140    }
141
142    /// Wraps `isl_union_flow_get_must_dependence`.
143    pub fn get_must_dependence(&self) -> Result<UnionMap, LibISLError> {
144        let flow = self;
145        let isl_rs_ctx = flow.get_ctx();
146        let flow = flow.ptr;
147        let isl_rs_result = unsafe { isl_union_flow_get_must_dependence(flow) };
148        let isl_rs_result = UnionMap { ptr: isl_rs_result,
149                                       should_free_on_drop: true };
150        let err = isl_rs_ctx.last_error();
151        if err != Error::None_ {
152            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
153        }
154        Ok(isl_rs_result)
155    }
156
157    /// Wraps `isl_union_flow_get_must_no_source`.
158    pub fn get_must_no_source(&self) -> Result<UnionMap, LibISLError> {
159        let flow = self;
160        let isl_rs_ctx = flow.get_ctx();
161        let flow = flow.ptr;
162        let isl_rs_result = unsafe { isl_union_flow_get_must_no_source(flow) };
163        let isl_rs_result = UnionMap { ptr: isl_rs_result,
164                                       should_free_on_drop: true };
165        let err = isl_rs_ctx.last_error();
166        if err != Error::None_ {
167            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
168        }
169        Ok(isl_rs_result)
170    }
171
172    /// Wraps `isl_union_flow_to_str`.
173    pub fn to_str(&self) -> Result<&str, LibISLError> {
174        let flow = self;
175        let isl_rs_ctx = flow.get_ctx();
176        let flow = flow.ptr;
177        let isl_rs_result = unsafe { isl_union_flow_to_str(flow) };
178        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
179        let isl_rs_result = isl_rs_result.to_str().unwrap();
180        let err = isl_rs_ctx.last_error();
181        if err != Error::None_ {
182            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
183        }
184        Ok(isl_rs_result)
185    }
186
187    /// Does not call isl_union_flow_free() on being dropped. (For internal use
188    /// only.)
189    pub fn do_not_free_on_drop(&mut self) {
190        self.should_free_on_drop = false;
191    }
192}
193
194impl Drop for UnionFlow {
195    fn drop(&mut self) {
196        if self.should_free_on_drop {
197            unsafe {
198                isl_union_flow_free(self.ptr);
199            }
200        }
201    }
202}