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            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
79        }
80        Ok(isl_rs_result)
81    }
82
83    /// Wraps `isl_union_pw_aff_list_alloc`.
84    pub fn alloc(ctx: &Context, n: i32) -> Result<UnionPwAffList, 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_aff_list_alloc(ctx, n) };
89        let isl_rs_result = UnionPwAffList { 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_aff_list_clear`.
99    pub fn clear(self) -> Result<UnionPwAffList, 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_aff_list_clear(list) };
106        let isl_rs_result = UnionPwAffList { 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_aff_list_concat`.
116    pub fn concat(self, list2: UnionPwAffList) -> Result<UnionPwAffList, 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_aff_list_concat(list1, list2) };
126        let isl_rs_result = UnionPwAffList { 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_aff_list_copy`.
136    pub fn copy(&self) -> Result<UnionPwAffList, 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_aff_list_copy(list) };
141        let isl_rs_result = UnionPwAffList { 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_aff_list_drop`.
151    pub fn drop(self, first: u32, n: u32) -> Result<UnionPwAffList, 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_aff_list_drop(list, first, n) };
158        let isl_rs_result = UnionPwAffList { 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_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_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_aff_list_free`.
181    pub fn free(self) -> Result<UnionPwAffList, 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_aff_list_free(list) };
188        let isl_rs_result = UnionPwAffList { 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_aff_list_from_union_pw_aff`.
198    pub fn from_union_pw_aff(el: UnionPwAff) -> Result<UnionPwAffList, LibISLError> {
199        let isl_rs_ctx = el.get_ctx();
200        let mut el = el;
201        el.do_not_free_on_drop();
202        let el = el.ptr;
203        let isl_rs_result = unsafe { isl_union_pw_aff_list_from_union_pw_aff(el) };
204        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
205                                             should_free_on_drop: true };
206        let err = isl_rs_ctx.last_error();
207        if err != Error::None_ {
208            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
209        }
210        Ok(isl_rs_result)
211    }
212
213    /// Wraps `isl_union_pw_aff_list_get_at`.
214    pub fn get_at(&self, index: i32) -> Result<UnionPwAff, LibISLError> {
215        let list = self;
216        let isl_rs_ctx = list.get_ctx();
217        let list = list.ptr;
218        let isl_rs_result = unsafe { isl_union_pw_aff_list_get_at(list, index) };
219        let isl_rs_result = UnionPwAff { ptr: isl_rs_result,
220                                         should_free_on_drop: true };
221        let err = isl_rs_ctx.last_error();
222        if err != Error::None_ {
223            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
224        }
225        Ok(isl_rs_result)
226    }
227
228    /// Wraps `isl_union_pw_aff_list_get_ctx`.
229    pub fn get_ctx(&self) -> Context {
230        let list = self;
231        let list = list.ptr;
232        let isl_rs_result = unsafe { isl_union_pw_aff_list_get_ctx(list) };
233        let isl_rs_result = Context { ptr: isl_rs_result,
234                                      should_free_on_drop: false };
235        isl_rs_result
236    }
237
238    /// Wraps `isl_union_pw_aff_list_get_union_pw_aff`.
239    pub fn get_union_pw_aff(&self, index: i32) -> Result<UnionPwAff, LibISLError> {
240        let list = self;
241        let isl_rs_ctx = list.get_ctx();
242        let list = list.ptr;
243        let isl_rs_result = unsafe { isl_union_pw_aff_list_get_union_pw_aff(list, index) };
244        let isl_rs_result = UnionPwAff { ptr: isl_rs_result,
245                                         should_free_on_drop: true };
246        let err = isl_rs_ctx.last_error();
247        if err != Error::None_ {
248            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
249        }
250        Ok(isl_rs_result)
251    }
252
253    /// Wraps `isl_union_pw_aff_list_insert`.
254    pub fn insert(self, pos: u32, el: UnionPwAff) -> Result<UnionPwAffList, LibISLError> {
255        let list = self;
256        let isl_rs_ctx = list.get_ctx();
257        let mut list = list;
258        list.do_not_free_on_drop();
259        let list = list.ptr;
260        let mut el = el;
261        el.do_not_free_on_drop();
262        let el = el.ptr;
263        let isl_rs_result = unsafe { isl_union_pw_aff_list_insert(list, pos, el) };
264        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
265                                             should_free_on_drop: true };
266        let err = isl_rs_ctx.last_error();
267        if err != Error::None_ {
268            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
269        }
270        Ok(isl_rs_result)
271    }
272
273    /// Wraps `isl_union_pw_aff_list_n_union_pw_aff`.
274    pub fn n_union_pw_aff(&self) -> Result<i32, LibISLError> {
275        let list = self;
276        let isl_rs_ctx = list.get_ctx();
277        let list = list.ptr;
278        let isl_rs_result = unsafe { isl_union_pw_aff_list_n_union_pw_aff(list) };
279        let err = isl_rs_ctx.last_error();
280        if err != Error::None_ {
281            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
282        }
283        Ok(isl_rs_result)
284    }
285
286    /// Wraps `isl_union_pw_aff_list_read_from_str`.
287    pub fn read_from_str(ctx: &Context, str_: &str) -> Result<UnionPwAffList, LibISLError> {
288        let isl_rs_ctx = Context { ptr: ctx.ptr,
289                                   should_free_on_drop: false };
290        let ctx = ctx.ptr;
291        let str_ = CString::new(str_).unwrap();
292        let str_ = str_.as_ptr();
293        let isl_rs_result = unsafe { isl_union_pw_aff_list_read_from_str(ctx, str_) };
294        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
295                                             should_free_on_drop: true };
296        let err = isl_rs_ctx.last_error();
297        if err != Error::None_ {
298            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
299        }
300        Ok(isl_rs_result)
301    }
302
303    /// Wraps `isl_union_pw_aff_list_reverse`.
304    pub fn reverse(self) -> Result<UnionPwAffList, LibISLError> {
305        let list = self;
306        let isl_rs_ctx = list.get_ctx();
307        let mut list = list;
308        list.do_not_free_on_drop();
309        let list = list.ptr;
310        let isl_rs_result = unsafe { isl_union_pw_aff_list_reverse(list) };
311        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
312                                             should_free_on_drop: true };
313        let err = isl_rs_ctx.last_error();
314        if err != Error::None_ {
315            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
316        }
317        Ok(isl_rs_result)
318    }
319
320    /// Wraps `isl_union_pw_aff_list_set_at`.
321    pub fn set_at(self, index: i32, el: UnionPwAff) -> Result<UnionPwAffList, LibISLError> {
322        let list = self;
323        let isl_rs_ctx = list.get_ctx();
324        let mut list = list;
325        list.do_not_free_on_drop();
326        let list = list.ptr;
327        let mut el = el;
328        el.do_not_free_on_drop();
329        let el = el.ptr;
330        let isl_rs_result = unsafe { isl_union_pw_aff_list_set_at(list, index, el) };
331        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
332                                             should_free_on_drop: true };
333        let err = isl_rs_ctx.last_error();
334        if err != Error::None_ {
335            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
336        }
337        Ok(isl_rs_result)
338    }
339
340    /// Wraps `isl_union_pw_aff_list_set_union_pw_aff`.
341    pub fn set_union_pw_aff(self, index: i32, el: UnionPwAff)
342                            -> Result<UnionPwAffList, LibISLError> {
343        let list = self;
344        let isl_rs_ctx = list.get_ctx();
345        let mut list = list;
346        list.do_not_free_on_drop();
347        let list = list.ptr;
348        let mut el = el;
349        el.do_not_free_on_drop();
350        let el = el.ptr;
351        let isl_rs_result = unsafe { isl_union_pw_aff_list_set_union_pw_aff(list, index, el) };
352        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
353                                             should_free_on_drop: true };
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_aff_list_size`.
362    pub fn size(&self) -> Result<i32, LibISLError> {
363        let list = self;
364        let isl_rs_ctx = list.get_ctx();
365        let list = list.ptr;
366        let isl_rs_result = unsafe { isl_union_pw_aff_list_size(list) };
367        let err = isl_rs_ctx.last_error();
368        if err != Error::None_ {
369            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
370        }
371        Ok(isl_rs_result)
372    }
373
374    /// Wraps `isl_union_pw_aff_list_swap`.
375    pub fn swap(self, pos1: u32, pos2: u32) -> Result<UnionPwAffList, LibISLError> {
376        let list = self;
377        let isl_rs_ctx = list.get_ctx();
378        let mut list = list;
379        list.do_not_free_on_drop();
380        let list = list.ptr;
381        let isl_rs_result = unsafe { isl_union_pw_aff_list_swap(list, pos1, pos2) };
382        let isl_rs_result = UnionPwAffList { ptr: isl_rs_result,
383                                             should_free_on_drop: true };
384        let err = isl_rs_ctx.last_error();
385        if err != Error::None_ {
386            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
387        }
388        Ok(isl_rs_result)
389    }
390
391    /// Wraps `isl_union_pw_aff_list_to_str`.
392    pub fn to_str(&self) -> Result<&str, LibISLError> {
393        let list = self;
394        let isl_rs_ctx = list.get_ctx();
395        let list = list.ptr;
396        let isl_rs_result = unsafe { isl_union_pw_aff_list_to_str(list) };
397        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
398        let isl_rs_result = isl_rs_result.to_str().unwrap();
399        let err = isl_rs_ctx.last_error();
400        if err != Error::None_ {
401            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
402        }
403        Ok(isl_rs_result)
404    }
405
406    /// Does not call isl_union_pw_aff_list_free() on being dropped. (For
407    /// internal use only.)
408    pub fn do_not_free_on_drop(&mut self) {
409        self.should_free_on_drop = false;
410    }
411}
412
413impl Drop for UnionPwAffList {
414    fn drop(&mut self) {
415        if self.should_free_on_drop {
416            unsafe {
417                isl_union_pw_aff_list_free(self.ptr);
418            }
419        }
420    }
421}