isl_rs/bindings/
union_pw_aff_list.rs

1// Automatically generated by isl_bindings_generator.
2// LICENSE: MIT
3
4use super::{Context, Error, LibISLError, UnionPwAff};
5use libc::uintptr_t;
6use std::ffi::{CStr, CString};
7use std::os::raw::c_char;
8
9/// Wraps `isl_union_pw_aff_list`.
10pub struct UnionPwAffList {
11    pub ptr: uintptr_t,
12    pub should_free_on_drop: bool,
13}
14
15extern "C" {
16
17    fn isl_union_pw_aff_list_add(list: uintptr_t, el: uintptr_t) -> uintptr_t;
18
19    fn isl_union_pw_aff_list_alloc(ctx: uintptr_t, n: i32) -> uintptr_t;
20
21    fn isl_union_pw_aff_list_clear(list: uintptr_t) -> uintptr_t;
22
23    fn isl_union_pw_aff_list_concat(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
24
25    fn isl_union_pw_aff_list_copy(list: uintptr_t) -> uintptr_t;
26
27    fn isl_union_pw_aff_list_drop(list: uintptr_t, first: u32, n: u32) -> uintptr_t;
28
29    fn isl_union_pw_aff_list_dump(list: uintptr_t) -> ();
30
31    fn isl_union_pw_aff_list_free(list: uintptr_t) -> uintptr_t;
32
33    fn isl_union_pw_aff_list_from_union_pw_aff(el: uintptr_t) -> uintptr_t;
34
35    fn isl_union_pw_aff_list_get_at(list: uintptr_t, index: i32) -> uintptr_t;
36
37    fn isl_union_pw_aff_list_get_ctx(list: uintptr_t) -> uintptr_t;
38
39    fn isl_union_pw_aff_list_get_union_pw_aff(list: uintptr_t, index: i32) -> uintptr_t;
40
41    fn isl_union_pw_aff_list_insert(list: uintptr_t, pos: u32, el: uintptr_t) -> uintptr_t;
42
43    fn isl_union_pw_aff_list_n_union_pw_aff(list: uintptr_t) -> i32;
44
45    fn isl_union_pw_aff_list_read_from_str(ctx: uintptr_t, str_: *const c_char) -> uintptr_t;
46
47    fn isl_union_pw_aff_list_reverse(list: uintptr_t) -> uintptr_t;
48
49    fn isl_union_pw_aff_list_set_at(list: uintptr_t, index: i32, el: uintptr_t) -> uintptr_t;
50
51    fn isl_union_pw_aff_list_set_union_pw_aff(list: uintptr_t, index: i32, el: uintptr_t)
52                                              -> uintptr_t;
53
54    fn isl_union_pw_aff_list_size(list: uintptr_t) -> i32;
55
56    fn isl_union_pw_aff_list_swap(list: uintptr_t, pos1: u32, pos2: u32) -> uintptr_t;
57
58    fn isl_union_pw_aff_list_to_str(list: uintptr_t) -> *const c_char;
59
60}
61
62impl UnionPwAffList {
63    /// Wraps `isl_union_pw_aff_list_add`.
64    pub fn add(self, el: UnionPwAff) -> Result<UnionPwAffList, 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_aff_list_add(list, el) };
74        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
75                                             should_free_on_drop: true };
76        let err = isl_rs_ctx.last_error();
77        if err != Error::None_ {
78            let err_msg = isl_rs_ctx.last_error_msg();
79            isl_rs_ctx.reset_error();
80            return Err(LibISLError::new(err, err_msg));
81        }
82        Ok(isl_rs_result)
83    }
84
85    /// Wraps `isl_union_pw_aff_list_alloc`.
86    pub fn alloc(ctx: &Context, n: i32) -> Result<UnionPwAffList, LibISLError> {
87        let isl_rs_ctx = Context { ptr: ctx.ptr,
88                                   should_free_on_drop: false };
89        let ctx = ctx.ptr;
90        let isl_rs_result = unsafe { isl_union_pw_aff_list_alloc(ctx, n) };
91        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
92                                             should_free_on_drop: true };
93        let err = isl_rs_ctx.last_error();
94        if err != Error::None_ {
95            let err_msg = isl_rs_ctx.last_error_msg();
96            isl_rs_ctx.reset_error();
97            return Err(LibISLError::new(err, err_msg));
98        }
99        Ok(isl_rs_result)
100    }
101
102    /// Wraps `isl_union_pw_aff_list_clear`.
103    pub fn clear(self) -> Result<UnionPwAffList, LibISLError> {
104        let list = self;
105        let isl_rs_ctx = list.get_ctx();
106        let mut list = list;
107        list.do_not_free_on_drop();
108        let list = list.ptr;
109        let isl_rs_result = unsafe { isl_union_pw_aff_list_clear(list) };
110        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
111                                             should_free_on_drop: true };
112        let err = isl_rs_ctx.last_error();
113        if err != Error::None_ {
114            let err_msg = isl_rs_ctx.last_error_msg();
115            isl_rs_ctx.reset_error();
116            return Err(LibISLError::new(err, err_msg));
117        }
118        Ok(isl_rs_result)
119    }
120
121    /// Wraps `isl_union_pw_aff_list_concat`.
122    pub fn concat(self, list2: UnionPwAffList) -> Result<UnionPwAffList, LibISLError> {
123        let list1 = self;
124        let isl_rs_ctx = list1.get_ctx();
125        let mut list1 = list1;
126        list1.do_not_free_on_drop();
127        let list1 = list1.ptr;
128        let mut list2 = list2;
129        list2.do_not_free_on_drop();
130        let list2 = list2.ptr;
131        let isl_rs_result = unsafe { isl_union_pw_aff_list_concat(list1, list2) };
132        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
133                                             should_free_on_drop: true };
134        let err = isl_rs_ctx.last_error();
135        if err != Error::None_ {
136            let err_msg = isl_rs_ctx.last_error_msg();
137            isl_rs_ctx.reset_error();
138            return Err(LibISLError::new(err, err_msg));
139        }
140        Ok(isl_rs_result)
141    }
142
143    /// Wraps `isl_union_pw_aff_list_copy`.
144    pub fn copy(&self) -> Result<UnionPwAffList, LibISLError> {
145        let list = self;
146        let isl_rs_ctx = list.get_ctx();
147        let list = list.ptr;
148        let isl_rs_result = unsafe { isl_union_pw_aff_list_copy(list) };
149        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
150                                             should_free_on_drop: true };
151        let err = isl_rs_ctx.last_error();
152        if err != Error::None_ {
153            let err_msg = isl_rs_ctx.last_error_msg();
154            isl_rs_ctx.reset_error();
155            return Err(LibISLError::new(err, err_msg));
156        }
157        Ok(isl_rs_result)
158    }
159
160    /// Wraps `isl_union_pw_aff_list_drop`.
161    pub fn drop(self, first: u32, n: u32) -> Result<UnionPwAffList, LibISLError> {
162        let list = self;
163        let isl_rs_ctx = list.get_ctx();
164        let mut list = list;
165        list.do_not_free_on_drop();
166        let list = list.ptr;
167        let isl_rs_result = unsafe { isl_union_pw_aff_list_drop(list, first, n) };
168        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
169                                             should_free_on_drop: true };
170        let err = isl_rs_ctx.last_error();
171        if err != Error::None_ {
172            let err_msg = isl_rs_ctx.last_error_msg();
173            isl_rs_ctx.reset_error();
174            return Err(LibISLError::new(err, err_msg));
175        }
176        Ok(isl_rs_result)
177    }
178
179    /// Wraps `isl_union_pw_aff_list_dump`.
180    pub fn dump(&self) -> Result<(), LibISLError> {
181        let list = self;
182        let isl_rs_ctx = list.get_ctx();
183        let list = list.ptr;
184        let isl_rs_result = unsafe { isl_union_pw_aff_list_dump(list) };
185        let err = isl_rs_ctx.last_error();
186        if err != Error::None_ {
187            let err_msg = isl_rs_ctx.last_error_msg();
188            isl_rs_ctx.reset_error();
189            return Err(LibISLError::new(err, err_msg));
190        }
191        Ok(isl_rs_result)
192    }
193
194    /// Wraps `isl_union_pw_aff_list_free`.
195    pub fn free(self) -> Result<UnionPwAffList, LibISLError> {
196        let list = self;
197        let isl_rs_ctx = list.get_ctx();
198        let mut list = list;
199        list.do_not_free_on_drop();
200        let list = list.ptr;
201        let isl_rs_result = unsafe { isl_union_pw_aff_list_free(list) };
202        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
203                                             should_free_on_drop: true };
204        let err = isl_rs_ctx.last_error();
205        if err != Error::None_ {
206            let err_msg = isl_rs_ctx.last_error_msg();
207            isl_rs_ctx.reset_error();
208            return Err(LibISLError::new(err, err_msg));
209        }
210        Ok(isl_rs_result)
211    }
212
213    /// Wraps `isl_union_pw_aff_list_from_union_pw_aff`.
214    pub fn from_union_pw_aff(el: UnionPwAff) -> Result<UnionPwAffList, LibISLError> {
215        let isl_rs_ctx = el.get_ctx();
216        let mut el = el;
217        el.do_not_free_on_drop();
218        let el = el.ptr;
219        let isl_rs_result = unsafe { isl_union_pw_aff_list_from_union_pw_aff(el) };
220        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
221                                             should_free_on_drop: true };
222        let err = isl_rs_ctx.last_error();
223        if err != Error::None_ {
224            let err_msg = isl_rs_ctx.last_error_msg();
225            isl_rs_ctx.reset_error();
226            return Err(LibISLError::new(err, err_msg));
227        }
228        Ok(isl_rs_result)
229    }
230
231    /// Wraps `isl_union_pw_aff_list_get_at`.
232    pub fn get_at(&self, index: i32) -> Result<UnionPwAff, LibISLError> {
233        let list = self;
234        let isl_rs_ctx = list.get_ctx();
235        let list = list.ptr;
236        let isl_rs_result = unsafe { isl_union_pw_aff_list_get_at(list, index) };
237        let isl_rs_result = UnionPwAff { ptr: isl_rs_result,
238                                         should_free_on_drop: true };
239        let err = isl_rs_ctx.last_error();
240        if err != Error::None_ {
241            let err_msg = isl_rs_ctx.last_error_msg();
242            isl_rs_ctx.reset_error();
243            return Err(LibISLError::new(err, err_msg));
244        }
245        Ok(isl_rs_result)
246    }
247
248    /// Wraps `isl_union_pw_aff_list_get_ctx`.
249    pub fn get_ctx(&self) -> Context {
250        let list = self;
251        let list = list.ptr;
252        let isl_rs_result = unsafe { isl_union_pw_aff_list_get_ctx(list) };
253        let isl_rs_result = Context { ptr: isl_rs_result,
254                                      should_free_on_drop: false };
255        isl_rs_result
256    }
257
258    /// Wraps `isl_union_pw_aff_list_get_union_pw_aff`.
259    pub fn get_union_pw_aff(&self, index: i32) -> Result<UnionPwAff, LibISLError> {
260        let list = self;
261        let isl_rs_ctx = list.get_ctx();
262        let list = list.ptr;
263        let isl_rs_result = unsafe { isl_union_pw_aff_list_get_union_pw_aff(list, index) };
264        let isl_rs_result = UnionPwAff { ptr: isl_rs_result,
265                                         should_free_on_drop: true };
266        let err = isl_rs_ctx.last_error();
267        if err != Error::None_ {
268            let err_msg = isl_rs_ctx.last_error_msg();
269            isl_rs_ctx.reset_error();
270            return Err(LibISLError::new(err, err_msg));
271        }
272        Ok(isl_rs_result)
273    }
274
275    /// Wraps `isl_union_pw_aff_list_insert`.
276    pub fn insert(self, pos: u32, el: UnionPwAff) -> Result<UnionPwAffList, LibISLError> {
277        let list = self;
278        let isl_rs_ctx = list.get_ctx();
279        let mut list = list;
280        list.do_not_free_on_drop();
281        let list = list.ptr;
282        let mut el = el;
283        el.do_not_free_on_drop();
284        let el = el.ptr;
285        let isl_rs_result = unsafe { isl_union_pw_aff_list_insert(list, pos, el) };
286        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
287                                             should_free_on_drop: true };
288        let err = isl_rs_ctx.last_error();
289        if err != Error::None_ {
290            let err_msg = isl_rs_ctx.last_error_msg();
291            isl_rs_ctx.reset_error();
292            return Err(LibISLError::new(err, err_msg));
293        }
294        Ok(isl_rs_result)
295    }
296
297    /// Wraps `isl_union_pw_aff_list_n_union_pw_aff`.
298    pub fn n_union_pw_aff(&self) -> Result<i32, LibISLError> {
299        let list = self;
300        let isl_rs_ctx = list.get_ctx();
301        let list = list.ptr;
302        let isl_rs_result = unsafe { isl_union_pw_aff_list_n_union_pw_aff(list) };
303        let err = isl_rs_ctx.last_error();
304        if err != Error::None_ {
305            let err_msg = isl_rs_ctx.last_error_msg();
306            isl_rs_ctx.reset_error();
307            return Err(LibISLError::new(err, err_msg));
308        }
309        Ok(isl_rs_result)
310    }
311
312    /// Wraps `isl_union_pw_aff_list_read_from_str`.
313    pub fn read_from_str(ctx: &Context, str_: &str) -> Result<UnionPwAffList, LibISLError> {
314        let isl_rs_ctx = Context { ptr: ctx.ptr,
315                                   should_free_on_drop: false };
316        let ctx = ctx.ptr;
317        let str_ = CString::new(str_).unwrap();
318        let str_ = str_.as_ptr();
319        let isl_rs_result = unsafe { isl_union_pw_aff_list_read_from_str(ctx, str_) };
320        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
321                                             should_free_on_drop: true };
322        let err = isl_rs_ctx.last_error();
323        if err != Error::None_ {
324            let err_msg = isl_rs_ctx.last_error_msg();
325            isl_rs_ctx.reset_error();
326            return Err(LibISLError::new(err, err_msg));
327        }
328        Ok(isl_rs_result)
329    }
330
331    /// Wraps `isl_union_pw_aff_list_reverse`.
332    pub fn reverse(self) -> Result<UnionPwAffList, LibISLError> {
333        let list = self;
334        let isl_rs_ctx = list.get_ctx();
335        let mut list = list;
336        list.do_not_free_on_drop();
337        let list = list.ptr;
338        let isl_rs_result = unsafe { isl_union_pw_aff_list_reverse(list) };
339        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
340                                             should_free_on_drop: true };
341        let err = isl_rs_ctx.last_error();
342        if err != Error::None_ {
343            let err_msg = isl_rs_ctx.last_error_msg();
344            isl_rs_ctx.reset_error();
345            return Err(LibISLError::new(err, err_msg));
346        }
347        Ok(isl_rs_result)
348    }
349
350    /// Wraps `isl_union_pw_aff_list_set_at`.
351    pub fn set_at(self, index: i32, el: UnionPwAff) -> Result<UnionPwAffList, LibISLError> {
352        let list = self;
353        let isl_rs_ctx = list.get_ctx();
354        let mut list = list;
355        list.do_not_free_on_drop();
356        let list = list.ptr;
357        let mut el = el;
358        el.do_not_free_on_drop();
359        let el = el.ptr;
360        let isl_rs_result = unsafe { isl_union_pw_aff_list_set_at(list, index, el) };
361        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
362                                             should_free_on_drop: true };
363        let err = isl_rs_ctx.last_error();
364        if err != Error::None_ {
365            let err_msg = isl_rs_ctx.last_error_msg();
366            isl_rs_ctx.reset_error();
367            return Err(LibISLError::new(err, err_msg));
368        }
369        Ok(isl_rs_result)
370    }
371
372    /// Wraps `isl_union_pw_aff_list_set_union_pw_aff`.
373    pub fn set_union_pw_aff(self, index: i32, el: UnionPwAff)
374                            -> Result<UnionPwAffList, LibISLError> {
375        let list = self;
376        let isl_rs_ctx = list.get_ctx();
377        let mut list = list;
378        list.do_not_free_on_drop();
379        let list = list.ptr;
380        let mut el = el;
381        el.do_not_free_on_drop();
382        let el = el.ptr;
383        let isl_rs_result = unsafe { isl_union_pw_aff_list_set_union_pw_aff(list, index, el) };
384        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
385                                             should_free_on_drop: true };
386        let err = isl_rs_ctx.last_error();
387        if err != Error::None_ {
388            let err_msg = isl_rs_ctx.last_error_msg();
389            isl_rs_ctx.reset_error();
390            return Err(LibISLError::new(err, err_msg));
391        }
392        Ok(isl_rs_result)
393    }
394
395    /// Wraps `isl_union_pw_aff_list_size`.
396    pub fn size(&self) -> Result<i32, LibISLError> {
397        let list = self;
398        let isl_rs_ctx = list.get_ctx();
399        let list = list.ptr;
400        let isl_rs_result = unsafe { isl_union_pw_aff_list_size(list) };
401        let err = isl_rs_ctx.last_error();
402        if err != Error::None_ {
403            let err_msg = isl_rs_ctx.last_error_msg();
404            isl_rs_ctx.reset_error();
405            return Err(LibISLError::new(err, err_msg));
406        }
407        Ok(isl_rs_result)
408    }
409
410    /// Wraps `isl_union_pw_aff_list_swap`.
411    pub fn swap(self, pos1: u32, pos2: u32) -> Result<UnionPwAffList, LibISLError> {
412        let list = self;
413        let isl_rs_ctx = list.get_ctx();
414        let mut list = list;
415        list.do_not_free_on_drop();
416        let list = list.ptr;
417        let isl_rs_result = unsafe { isl_union_pw_aff_list_swap(list, pos1, pos2) };
418        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
419                                             should_free_on_drop: true };
420        let err = isl_rs_ctx.last_error();
421        if err != Error::None_ {
422            let err_msg = isl_rs_ctx.last_error_msg();
423            isl_rs_ctx.reset_error();
424            return Err(LibISLError::new(err, err_msg));
425        }
426        Ok(isl_rs_result)
427    }
428
429    /// Wraps `isl_union_pw_aff_list_to_str`.
430    pub fn to_str(&self) -> Result<&str, LibISLError> {
431        let list = self;
432        let isl_rs_ctx = list.get_ctx();
433        let list = list.ptr;
434        let isl_rs_result = unsafe { isl_union_pw_aff_list_to_str(list) };
435        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
436        let isl_rs_result = isl_rs_result.to_str().unwrap();
437        let err = isl_rs_ctx.last_error();
438        if err != Error::None_ {
439            let err_msg = isl_rs_ctx.last_error_msg();
440            isl_rs_ctx.reset_error();
441            return Err(LibISLError::new(err, err_msg));
442        }
443        Ok(isl_rs_result)
444    }
445
446    /// Does not call isl_union_pw_aff_list_free() on being dropped. (For
447    /// internal use only.)
448    pub fn do_not_free_on_drop(&mut self) {
449        self.should_free_on_drop = false;
450    }
451}
452
453impl Drop for UnionPwAffList {
454    fn drop(&mut self) {
455        if self.should_free_on_drop {
456            unsafe {
457                isl_union_pw_aff_list_free(self.ptr);
458            }
459        }
460    }
461}