isl_rs/bindings/
union_pw_multi_aff_list.rs

1// Automatically generated by isl_bindings_generator.
2// LICENSE: MIT
3
4use super::{Context, Error, LibISLError, UnionPwMultiAff};
5use libc::uintptr_t;
6use std::ffi::CStr;
7use std::os::raw::c_char;
8
9/// Wraps `isl_union_pw_multi_aff_list`.
10pub struct UnionPwMultiAffList {
11    pub ptr: uintptr_t,
12    pub should_free_on_drop: bool,
13}
14
15extern "C" {
16
17    fn isl_union_pw_multi_aff_list_add(list: uintptr_t, el: uintptr_t) -> uintptr_t;
18
19    fn isl_union_pw_multi_aff_list_alloc(ctx: uintptr_t, n: i32) -> uintptr_t;
20
21    fn isl_union_pw_multi_aff_list_clear(list: uintptr_t) -> uintptr_t;
22
23    fn isl_union_pw_multi_aff_list_concat(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
24
25    fn isl_union_pw_multi_aff_list_copy(list: uintptr_t) -> uintptr_t;
26
27    fn isl_union_pw_multi_aff_list_drop(list: uintptr_t, first: u32, n: u32) -> uintptr_t;
28
29    fn isl_union_pw_multi_aff_list_dump(list: uintptr_t) -> ();
30
31    fn isl_union_pw_multi_aff_list_free(list: uintptr_t) -> uintptr_t;
32
33    fn isl_union_pw_multi_aff_list_from_union_pw_multi_aff(el: uintptr_t) -> uintptr_t;
34
35    fn isl_union_pw_multi_aff_list_get_at(list: uintptr_t, index: i32) -> uintptr_t;
36
37    fn isl_union_pw_multi_aff_list_get_ctx(list: uintptr_t) -> uintptr_t;
38
39    fn isl_union_pw_multi_aff_list_get_union_pw_multi_aff(list: uintptr_t, index: i32)
40                                                          -> uintptr_t;
41
42    fn isl_union_pw_multi_aff_list_insert(list: uintptr_t, pos: u32, el: uintptr_t) -> uintptr_t;
43
44    fn isl_union_pw_multi_aff_list_n_union_pw_multi_aff(list: uintptr_t) -> i32;
45
46    fn isl_union_pw_multi_aff_list_reverse(list: uintptr_t) -> uintptr_t;
47
48    fn isl_union_pw_multi_aff_list_set_at(list: uintptr_t, index: i32, el: uintptr_t) -> uintptr_t;
49
50    fn isl_union_pw_multi_aff_list_set_union_pw_multi_aff(list: uintptr_t, index: i32,
51                                                          el: uintptr_t)
52                                                          -> uintptr_t;
53
54    fn isl_union_pw_multi_aff_list_size(list: uintptr_t) -> i32;
55
56    fn isl_union_pw_multi_aff_list_swap(list: uintptr_t, pos1: u32, pos2: u32) -> uintptr_t;
57
58    fn isl_union_pw_multi_aff_list_to_str(list: uintptr_t) -> *const c_char;
59
60}
61
62impl UnionPwMultiAffList {
63    /// Wraps `isl_union_pw_multi_aff_list_add`.
64    pub fn add(self, el: UnionPwMultiAff) -> Result<UnionPwMultiAffList, LibISLError> {
65        let list = self;
66        let isl_rs_ctx = list.get_ctx();
67        let mut list = list;
68        list.do_not_free_on_drop();
69        let list = list.ptr;
70        let mut el = el;
71        el.do_not_free_on_drop();
72        let el = el.ptr;
73        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_add(list, el) };
74        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
75                                                  should_free_on_drop: true };
76        let err = isl_rs_ctx.last_error();
77        if err != Error::None_ {
78            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
79        }
80        Ok(isl_rs_result)
81    }
82
83    /// Wraps `isl_union_pw_multi_aff_list_alloc`.
84    pub fn alloc(ctx: &Context, n: i32) -> Result<UnionPwMultiAffList, LibISLError> {
85        let isl_rs_ctx = Context { ptr: ctx.ptr,
86                                   should_free_on_drop: false };
87        let ctx = ctx.ptr;
88        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_alloc(ctx, n) };
89        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
90                                                  should_free_on_drop: true };
91        let err = isl_rs_ctx.last_error();
92        if err != Error::None_ {
93            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
94        }
95        Ok(isl_rs_result)
96    }
97
98    /// Wraps `isl_union_pw_multi_aff_list_clear`.
99    pub fn clear(self) -> Result<UnionPwMultiAffList, LibISLError> {
100        let list = self;
101        let isl_rs_ctx = list.get_ctx();
102        let mut list = list;
103        list.do_not_free_on_drop();
104        let list = list.ptr;
105        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_clear(list) };
106        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
107                                                  should_free_on_drop: true };
108        let err = isl_rs_ctx.last_error();
109        if err != Error::None_ {
110            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
111        }
112        Ok(isl_rs_result)
113    }
114
115    /// Wraps `isl_union_pw_multi_aff_list_concat`.
116    pub fn concat(self, list2: UnionPwMultiAffList) -> Result<UnionPwMultiAffList, LibISLError> {
117        let list1 = self;
118        let isl_rs_ctx = list1.get_ctx();
119        let mut list1 = list1;
120        list1.do_not_free_on_drop();
121        let list1 = list1.ptr;
122        let mut list2 = list2;
123        list2.do_not_free_on_drop();
124        let list2 = list2.ptr;
125        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_concat(list1, list2) };
126        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
127                                                  should_free_on_drop: true };
128        let err = isl_rs_ctx.last_error();
129        if err != Error::None_ {
130            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
131        }
132        Ok(isl_rs_result)
133    }
134
135    /// Wraps `isl_union_pw_multi_aff_list_copy`.
136    pub fn copy(&self) -> Result<UnionPwMultiAffList, LibISLError> {
137        let list = self;
138        let isl_rs_ctx = list.get_ctx();
139        let list = list.ptr;
140        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_copy(list) };
141        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
142                                                  should_free_on_drop: true };
143        let err = isl_rs_ctx.last_error();
144        if err != Error::None_ {
145            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
146        }
147        Ok(isl_rs_result)
148    }
149
150    /// Wraps `isl_union_pw_multi_aff_list_drop`.
151    pub fn drop(self, first: u32, n: u32) -> Result<UnionPwMultiAffList, LibISLError> {
152        let list = self;
153        let isl_rs_ctx = list.get_ctx();
154        let mut list = list;
155        list.do_not_free_on_drop();
156        let list = list.ptr;
157        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_drop(list, first, n) };
158        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
159                                                  should_free_on_drop: true };
160        let err = isl_rs_ctx.last_error();
161        if err != Error::None_ {
162            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
163        }
164        Ok(isl_rs_result)
165    }
166
167    /// Wraps `isl_union_pw_multi_aff_list_dump`.
168    pub fn dump(&self) -> Result<(), LibISLError> {
169        let list = self;
170        let isl_rs_ctx = list.get_ctx();
171        let list = list.ptr;
172        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_dump(list) };
173        let err = isl_rs_ctx.last_error();
174        if err != Error::None_ {
175            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
176        }
177        Ok(isl_rs_result)
178    }
179
180    /// Wraps `isl_union_pw_multi_aff_list_free`.
181    pub fn free(self) -> Result<UnionPwMultiAffList, LibISLError> {
182        let list = self;
183        let isl_rs_ctx = list.get_ctx();
184        let mut list = list;
185        list.do_not_free_on_drop();
186        let list = list.ptr;
187        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_free(list) };
188        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
189                                                  should_free_on_drop: true };
190        let err = isl_rs_ctx.last_error();
191        if err != Error::None_ {
192            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
193        }
194        Ok(isl_rs_result)
195    }
196
197    /// Wraps `isl_union_pw_multi_aff_list_from_union_pw_multi_aff`.
198    pub fn from_union_pw_multi_aff(el: UnionPwMultiAff)
199                                   -> Result<UnionPwMultiAffList, LibISLError> {
200        let isl_rs_ctx = el.get_ctx();
201        let mut el = el;
202        el.do_not_free_on_drop();
203        let el = el.ptr;
204        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_from_union_pw_multi_aff(el) };
205        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
206                                                  should_free_on_drop: true };
207        let err = isl_rs_ctx.last_error();
208        if err != Error::None_ {
209            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
210        }
211        Ok(isl_rs_result)
212    }
213
214    /// Wraps `isl_union_pw_multi_aff_list_get_at`.
215    pub fn get_at(&self, index: i32) -> Result<UnionPwMultiAff, LibISLError> {
216        let list = self;
217        let isl_rs_ctx = list.get_ctx();
218        let list = list.ptr;
219        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_get_at(list, index) };
220        let isl_rs_result = UnionPwMultiAff { ptr: isl_rs_result,
221                                              should_free_on_drop: true };
222        let err = isl_rs_ctx.last_error();
223        if err != Error::None_ {
224            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
225        }
226        Ok(isl_rs_result)
227    }
228
229    /// Wraps `isl_union_pw_multi_aff_list_get_ctx`.
230    pub fn get_ctx(&self) -> Context {
231        let list = self;
232        let list = list.ptr;
233        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_get_ctx(list) };
234        let isl_rs_result = Context { ptr: isl_rs_result,
235                                      should_free_on_drop: false };
236        isl_rs_result
237    }
238
239    /// Wraps `isl_union_pw_multi_aff_list_get_union_pw_multi_aff`.
240    pub fn get_union_pw_multi_aff(&self, index: i32) -> Result<UnionPwMultiAff, LibISLError> {
241        let list = self;
242        let isl_rs_ctx = list.get_ctx();
243        let list = list.ptr;
244        let isl_rs_result =
245            unsafe { isl_union_pw_multi_aff_list_get_union_pw_multi_aff(list, index) };
246        let isl_rs_result = UnionPwMultiAff { ptr: isl_rs_result,
247                                              should_free_on_drop: true };
248        let err = isl_rs_ctx.last_error();
249        if err != Error::None_ {
250            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
251        }
252        Ok(isl_rs_result)
253    }
254
255    /// Wraps `isl_union_pw_multi_aff_list_insert`.
256    pub fn insert(self, pos: u32, el: UnionPwMultiAff) -> Result<UnionPwMultiAffList, LibISLError> {
257        let list = self;
258        let isl_rs_ctx = list.get_ctx();
259        let mut list = list;
260        list.do_not_free_on_drop();
261        let list = list.ptr;
262        let mut el = el;
263        el.do_not_free_on_drop();
264        let el = el.ptr;
265        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_insert(list, pos, el) };
266        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
267                                                  should_free_on_drop: true };
268        let err = isl_rs_ctx.last_error();
269        if err != Error::None_ {
270            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
271        }
272        Ok(isl_rs_result)
273    }
274
275    /// Wraps `isl_union_pw_multi_aff_list_n_union_pw_multi_aff`.
276    pub fn n_union_pw_multi_aff(&self) -> Result<i32, LibISLError> {
277        let list = self;
278        let isl_rs_ctx = list.get_ctx();
279        let list = list.ptr;
280        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_n_union_pw_multi_aff(list) };
281        let err = isl_rs_ctx.last_error();
282        if err != Error::None_ {
283            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
284        }
285        Ok(isl_rs_result)
286    }
287
288    /// Wraps `isl_union_pw_multi_aff_list_reverse`.
289    pub fn reverse(self) -> Result<UnionPwMultiAffList, LibISLError> {
290        let list = self;
291        let isl_rs_ctx = list.get_ctx();
292        let mut list = list;
293        list.do_not_free_on_drop();
294        let list = list.ptr;
295        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_reverse(list) };
296        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
297                                                  should_free_on_drop: true };
298        let err = isl_rs_ctx.last_error();
299        if err != Error::None_ {
300            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
301        }
302        Ok(isl_rs_result)
303    }
304
305    /// Wraps `isl_union_pw_multi_aff_list_set_at`.
306    pub fn set_at(self, index: i32, el: UnionPwMultiAff)
307                  -> Result<UnionPwMultiAffList, LibISLError> {
308        let list = self;
309        let isl_rs_ctx = list.get_ctx();
310        let mut list = list;
311        list.do_not_free_on_drop();
312        let list = list.ptr;
313        let mut el = el;
314        el.do_not_free_on_drop();
315        let el = el.ptr;
316        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_set_at(list, index, el) };
317        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
318                                                  should_free_on_drop: true };
319        let err = isl_rs_ctx.last_error();
320        if err != Error::None_ {
321            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
322        }
323        Ok(isl_rs_result)
324    }
325
326    /// Wraps `isl_union_pw_multi_aff_list_set_union_pw_multi_aff`.
327    pub fn set_union_pw_multi_aff(self, index: i32, el: UnionPwMultiAff)
328                                  -> Result<UnionPwMultiAffList, LibISLError> {
329        let list = self;
330        let isl_rs_ctx = list.get_ctx();
331        let mut list = list;
332        list.do_not_free_on_drop();
333        let list = list.ptr;
334        let mut el = el;
335        el.do_not_free_on_drop();
336        let el = el.ptr;
337        let isl_rs_result =
338            unsafe { isl_union_pw_multi_aff_list_set_union_pw_multi_aff(list, index, el) };
339        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
340                                                  should_free_on_drop: true };
341        let err = isl_rs_ctx.last_error();
342        if err != Error::None_ {
343            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
344        }
345        Ok(isl_rs_result)
346    }
347
348    /// Wraps `isl_union_pw_multi_aff_list_size`.
349    pub fn size(&self) -> Result<i32, LibISLError> {
350        let list = self;
351        let isl_rs_ctx = list.get_ctx();
352        let list = list.ptr;
353        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_size(list) };
354        let err = isl_rs_ctx.last_error();
355        if err != Error::None_ {
356            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
357        }
358        Ok(isl_rs_result)
359    }
360
361    /// Wraps `isl_union_pw_multi_aff_list_swap`.
362    pub fn swap(self, pos1: u32, pos2: u32) -> Result<UnionPwMultiAffList, LibISLError> {
363        let list = self;
364        let isl_rs_ctx = list.get_ctx();
365        let mut list = list;
366        list.do_not_free_on_drop();
367        let list = list.ptr;
368        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_swap(list, pos1, pos2) };
369        let isl_rs_result = UnionPwMultiAffList { ptr: isl_rs_result,
370                                                  should_free_on_drop: true };
371        let err = isl_rs_ctx.last_error();
372        if err != Error::None_ {
373            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
374        }
375        Ok(isl_rs_result)
376    }
377
378    /// Wraps `isl_union_pw_multi_aff_list_to_str`.
379    pub fn to_str(&self) -> Result<&str, LibISLError> {
380        let list = self;
381        let isl_rs_ctx = list.get_ctx();
382        let list = list.ptr;
383        let isl_rs_result = unsafe { isl_union_pw_multi_aff_list_to_str(list) };
384        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
385        let isl_rs_result = isl_rs_result.to_str().unwrap();
386        let err = isl_rs_ctx.last_error();
387        if err != Error::None_ {
388            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
389        }
390        Ok(isl_rs_result)
391    }
392
393    /// Does not call isl_union_pw_multi_aff_list_free() on being dropped. (For
394    /// internal use only.)
395    pub fn do_not_free_on_drop(&mut self) {
396        self.should_free_on_drop = false;
397    }
398}
399
400impl Drop for UnionPwMultiAffList {
401    fn drop(&mut self) {
402        if self.should_free_on_drop {
403            unsafe {
404                isl_union_pw_multi_aff_list_free(self.ptr);
405            }
406        }
407    }
408}