1use super::{Context, Error, LibISLError, PwAff, Set};
5use libc::uintptr_t;
6use std::ffi::{CStr, CString};
7use std::os::raw::c_char;
8
9pub struct PwAffList {
11 pub ptr: uintptr_t,
12 pub should_free_on_drop: bool,
13}
14
15extern "C" {
16
17 fn isl_pw_aff_list_add(list: uintptr_t, el: uintptr_t) -> uintptr_t;
18
19 fn isl_pw_aff_list_alloc(ctx: uintptr_t, n: i32) -> uintptr_t;
20
21 fn isl_pw_aff_list_clear(list: uintptr_t) -> uintptr_t;
22
23 fn isl_pw_aff_list_concat(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
24
25 fn isl_pw_aff_list_copy(list: uintptr_t) -> uintptr_t;
26
27 fn isl_pw_aff_list_drop(list: uintptr_t, first: u32, n: u32) -> uintptr_t;
28
29 fn isl_pw_aff_list_dump(list: uintptr_t) -> ();
30
31 fn isl_pw_aff_list_eq_set(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
32
33 fn isl_pw_aff_list_free(list: uintptr_t) -> uintptr_t;
34
35 fn isl_pw_aff_list_from_pw_aff(el: uintptr_t) -> uintptr_t;
36
37 fn isl_pw_aff_list_ge_set(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
38
39 fn isl_pw_aff_list_get_at(list: uintptr_t, index: i32) -> uintptr_t;
40
41 fn isl_pw_aff_list_get_ctx(list: uintptr_t) -> uintptr_t;
42
43 fn isl_pw_aff_list_get_pw_aff(list: uintptr_t, index: i32) -> uintptr_t;
44
45 fn isl_pw_aff_list_gt_set(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
46
47 fn isl_pw_aff_list_insert(list: uintptr_t, pos: u32, el: uintptr_t) -> uintptr_t;
48
49 fn isl_pw_aff_list_le_set(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
50
51 fn isl_pw_aff_list_lt_set(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
52
53 fn isl_pw_aff_list_max(list: uintptr_t) -> uintptr_t;
54
55 fn isl_pw_aff_list_min(list: uintptr_t) -> uintptr_t;
56
57 fn isl_pw_aff_list_n_pw_aff(list: uintptr_t) -> i32;
58
59 fn isl_pw_aff_list_ne_set(list1: uintptr_t, list2: uintptr_t) -> uintptr_t;
60
61 fn isl_pw_aff_list_read_from_str(ctx: uintptr_t, str_: *const c_char) -> uintptr_t;
62
63 fn isl_pw_aff_list_reverse(list: uintptr_t) -> uintptr_t;
64
65 fn isl_pw_aff_list_set_at(list: uintptr_t, index: i32, el: uintptr_t) -> uintptr_t;
66
67 fn isl_pw_aff_list_set_pw_aff(list: uintptr_t, index: i32, el: uintptr_t) -> uintptr_t;
68
69 fn isl_pw_aff_list_size(list: uintptr_t) -> i32;
70
71 fn isl_pw_aff_list_swap(list: uintptr_t, pos1: u32, pos2: u32) -> uintptr_t;
72
73 fn isl_pw_aff_list_to_str(list: uintptr_t) -> *const c_char;
74
75}
76
77impl PwAffList {
78 pub fn add(self, el: PwAff) -> Result<PwAffList, LibISLError> {
80 let list = self;
81 let isl_rs_ctx = list.get_ctx();
82 let mut list = list;
83 list.do_not_free_on_drop();
84 let list = list.ptr;
85 let mut el = el;
86 el.do_not_free_on_drop();
87 let el = el.ptr;
88 let isl_rs_result = unsafe { isl_pw_aff_list_add(list, el) };
89 let isl_rs_result = PwAffList { ptr: isl_rs_result,
90 should_free_on_drop: true };
91 let err = isl_rs_ctx.last_error();
92 if err != Error::None_ {
93 let err_msg = isl_rs_ctx.last_error_msg();
94 isl_rs_ctx.reset_error();
95 return Err(LibISLError::new(err, err_msg));
96 }
97 Ok(isl_rs_result)
98 }
99
100 pub fn alloc(ctx: &Context, n: i32) -> Result<PwAffList, LibISLError> {
102 let isl_rs_ctx = Context { ptr: ctx.ptr,
103 should_free_on_drop: false };
104 let ctx = ctx.ptr;
105 let isl_rs_result = unsafe { isl_pw_aff_list_alloc(ctx, n) };
106 let isl_rs_result = PwAffList { ptr: isl_rs_result,
107 should_free_on_drop: true };
108 let err = isl_rs_ctx.last_error();
109 if err != Error::None_ {
110 let err_msg = isl_rs_ctx.last_error_msg();
111 isl_rs_ctx.reset_error();
112 return Err(LibISLError::new(err, err_msg));
113 }
114 Ok(isl_rs_result)
115 }
116
117 pub fn clear(self) -> Result<PwAffList, LibISLError> {
119 let list = self;
120 let isl_rs_ctx = list.get_ctx();
121 let mut list = list;
122 list.do_not_free_on_drop();
123 let list = list.ptr;
124 let isl_rs_result = unsafe { isl_pw_aff_list_clear(list) };
125 let isl_rs_result = PwAffList { ptr: isl_rs_result,
126 should_free_on_drop: true };
127 let err = isl_rs_ctx.last_error();
128 if err != Error::None_ {
129 let err_msg = isl_rs_ctx.last_error_msg();
130 isl_rs_ctx.reset_error();
131 return Err(LibISLError::new(err, err_msg));
132 }
133 Ok(isl_rs_result)
134 }
135
136 pub fn concat(self, list2: PwAffList) -> Result<PwAffList, LibISLError> {
138 let list1 = self;
139 let isl_rs_ctx = list1.get_ctx();
140 let mut list1 = list1;
141 list1.do_not_free_on_drop();
142 let list1 = list1.ptr;
143 let mut list2 = list2;
144 list2.do_not_free_on_drop();
145 let list2 = list2.ptr;
146 let isl_rs_result = unsafe { isl_pw_aff_list_concat(list1, list2) };
147 let isl_rs_result = PwAffList { ptr: isl_rs_result,
148 should_free_on_drop: true };
149 let err = isl_rs_ctx.last_error();
150 if err != Error::None_ {
151 let err_msg = isl_rs_ctx.last_error_msg();
152 isl_rs_ctx.reset_error();
153 return Err(LibISLError::new(err, err_msg));
154 }
155 Ok(isl_rs_result)
156 }
157
158 pub fn copy(&self) -> Result<PwAffList, LibISLError> {
160 let list = self;
161 let isl_rs_ctx = list.get_ctx();
162 let list = list.ptr;
163 let isl_rs_result = unsafe { isl_pw_aff_list_copy(list) };
164 let isl_rs_result = PwAffList { ptr: isl_rs_result,
165 should_free_on_drop: true };
166 let err = isl_rs_ctx.last_error();
167 if err != Error::None_ {
168 let err_msg = isl_rs_ctx.last_error_msg();
169 isl_rs_ctx.reset_error();
170 return Err(LibISLError::new(err, err_msg));
171 }
172 Ok(isl_rs_result)
173 }
174
175 pub fn drop(self, first: u32, n: u32) -> Result<PwAffList, LibISLError> {
177 let list = self;
178 let isl_rs_ctx = list.get_ctx();
179 let mut list = list;
180 list.do_not_free_on_drop();
181 let list = list.ptr;
182 let isl_rs_result = unsafe { isl_pw_aff_list_drop(list, first, n) };
183 let isl_rs_result = PwAffList { ptr: isl_rs_result,
184 should_free_on_drop: true };
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 pub fn dump(&self) -> Result<(), LibISLError> {
196 let list = self;
197 let isl_rs_ctx = list.get_ctx();
198 let list = list.ptr;
199 let isl_rs_result = unsafe { isl_pw_aff_list_dump(list) };
200 let err = isl_rs_ctx.last_error();
201 if err != Error::None_ {
202 let err_msg = isl_rs_ctx.last_error_msg();
203 isl_rs_ctx.reset_error();
204 return Err(LibISLError::new(err, err_msg));
205 }
206 Ok(isl_rs_result)
207 }
208
209 pub fn eq_set(self, list2: PwAffList) -> Result<Set, LibISLError> {
211 let list1 = self;
212 let isl_rs_ctx = list1.get_ctx();
213 let mut list1 = list1;
214 list1.do_not_free_on_drop();
215 let list1 = list1.ptr;
216 let mut list2 = list2;
217 list2.do_not_free_on_drop();
218 let list2 = list2.ptr;
219 let isl_rs_result = unsafe { isl_pw_aff_list_eq_set(list1, list2) };
220 let isl_rs_result = Set { 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 pub fn free(self) -> Result<PwAffList, LibISLError> {
233 let list = self;
234 let isl_rs_ctx = list.get_ctx();
235 let mut list = list;
236 list.do_not_free_on_drop();
237 let list = list.ptr;
238 let isl_rs_result = unsafe { isl_pw_aff_list_free(list) };
239 let isl_rs_result = PwAffList { ptr: isl_rs_result,
240 should_free_on_drop: true };
241 let err = isl_rs_ctx.last_error();
242 if err != Error::None_ {
243 let err_msg = isl_rs_ctx.last_error_msg();
244 isl_rs_ctx.reset_error();
245 return Err(LibISLError::new(err, err_msg));
246 }
247 Ok(isl_rs_result)
248 }
249
250 pub fn from_pw_aff(el: PwAff) -> Result<PwAffList, LibISLError> {
252 let isl_rs_ctx = el.get_ctx();
253 let mut el = el;
254 el.do_not_free_on_drop();
255 let el = el.ptr;
256 let isl_rs_result = unsafe { isl_pw_aff_list_from_pw_aff(el) };
257 let isl_rs_result = PwAffList { ptr: isl_rs_result,
258 should_free_on_drop: true };
259 let err = isl_rs_ctx.last_error();
260 if err != Error::None_ {
261 let err_msg = isl_rs_ctx.last_error_msg();
262 isl_rs_ctx.reset_error();
263 return Err(LibISLError::new(err, err_msg));
264 }
265 Ok(isl_rs_result)
266 }
267
268 pub fn ge_set(self, list2: PwAffList) -> Result<Set, LibISLError> {
270 let list1 = self;
271 let isl_rs_ctx = list1.get_ctx();
272 let mut list1 = list1;
273 list1.do_not_free_on_drop();
274 let list1 = list1.ptr;
275 let mut list2 = list2;
276 list2.do_not_free_on_drop();
277 let list2 = list2.ptr;
278 let isl_rs_result = unsafe { isl_pw_aff_list_ge_set(list1, list2) };
279 let isl_rs_result = Set { ptr: isl_rs_result,
280 should_free_on_drop: true };
281 let err = isl_rs_ctx.last_error();
282 if err != Error::None_ {
283 let err_msg = isl_rs_ctx.last_error_msg();
284 isl_rs_ctx.reset_error();
285 return Err(LibISLError::new(err, err_msg));
286 }
287 Ok(isl_rs_result)
288 }
289
290 pub fn get_at(&self, index: i32) -> Result<PwAff, LibISLError> {
292 let list = self;
293 let isl_rs_ctx = list.get_ctx();
294 let list = list.ptr;
295 let isl_rs_result = unsafe { isl_pw_aff_list_get_at(list, index) };
296 let isl_rs_result = PwAff { ptr: isl_rs_result,
297 should_free_on_drop: true };
298 let err = isl_rs_ctx.last_error();
299 if err != Error::None_ {
300 let err_msg = isl_rs_ctx.last_error_msg();
301 isl_rs_ctx.reset_error();
302 return Err(LibISLError::new(err, err_msg));
303 }
304 Ok(isl_rs_result)
305 }
306
307 pub fn get_ctx(&self) -> Context {
309 let list = self;
310 let list = list.ptr;
311 let isl_rs_result = unsafe { isl_pw_aff_list_get_ctx(list) };
312 let isl_rs_result = Context { ptr: isl_rs_result,
313 should_free_on_drop: false };
314 isl_rs_result
315 }
316
317 pub fn get_pw_aff(&self, index: i32) -> Result<PwAff, LibISLError> {
319 let list = self;
320 let isl_rs_ctx = list.get_ctx();
321 let list = list.ptr;
322 let isl_rs_result = unsafe { isl_pw_aff_list_get_pw_aff(list, index) };
323 let isl_rs_result = PwAff { ptr: isl_rs_result,
324 should_free_on_drop: true };
325 let err = isl_rs_ctx.last_error();
326 if err != Error::None_ {
327 let err_msg = isl_rs_ctx.last_error_msg();
328 isl_rs_ctx.reset_error();
329 return Err(LibISLError::new(err, err_msg));
330 }
331 Ok(isl_rs_result)
332 }
333
334 pub fn gt_set(self, list2: PwAffList) -> Result<Set, LibISLError> {
336 let list1 = self;
337 let isl_rs_ctx = list1.get_ctx();
338 let mut list1 = list1;
339 list1.do_not_free_on_drop();
340 let list1 = list1.ptr;
341 let mut list2 = list2;
342 list2.do_not_free_on_drop();
343 let list2 = list2.ptr;
344 let isl_rs_result = unsafe { isl_pw_aff_list_gt_set(list1, list2) };
345 let isl_rs_result = Set { ptr: isl_rs_result,
346 should_free_on_drop: true };
347 let err = isl_rs_ctx.last_error();
348 if err != Error::None_ {
349 let err_msg = isl_rs_ctx.last_error_msg();
350 isl_rs_ctx.reset_error();
351 return Err(LibISLError::new(err, err_msg));
352 }
353 Ok(isl_rs_result)
354 }
355
356 pub fn insert(self, pos: u32, el: PwAff) -> Result<PwAffList, LibISLError> {
358 let list = self;
359 let isl_rs_ctx = list.get_ctx();
360 let mut list = list;
361 list.do_not_free_on_drop();
362 let list = list.ptr;
363 let mut el = el;
364 el.do_not_free_on_drop();
365 let el = el.ptr;
366 let isl_rs_result = unsafe { isl_pw_aff_list_insert(list, pos, el) };
367 let isl_rs_result = PwAffList { ptr: isl_rs_result,
368 should_free_on_drop: true };
369 let err = isl_rs_ctx.last_error();
370 if err != Error::None_ {
371 let err_msg = isl_rs_ctx.last_error_msg();
372 isl_rs_ctx.reset_error();
373 return Err(LibISLError::new(err, err_msg));
374 }
375 Ok(isl_rs_result)
376 }
377
378 pub fn le_set(self, list2: PwAffList) -> Result<Set, LibISLError> {
380 let list1 = self;
381 let isl_rs_ctx = list1.get_ctx();
382 let mut list1 = list1;
383 list1.do_not_free_on_drop();
384 let list1 = list1.ptr;
385 let mut list2 = list2;
386 list2.do_not_free_on_drop();
387 let list2 = list2.ptr;
388 let isl_rs_result = unsafe { isl_pw_aff_list_le_set(list1, list2) };
389 let isl_rs_result = Set { ptr: isl_rs_result,
390 should_free_on_drop: true };
391 let err = isl_rs_ctx.last_error();
392 if err != Error::None_ {
393 let err_msg = isl_rs_ctx.last_error_msg();
394 isl_rs_ctx.reset_error();
395 return Err(LibISLError::new(err, err_msg));
396 }
397 Ok(isl_rs_result)
398 }
399
400 pub fn lt_set(self, list2: PwAffList) -> Result<Set, LibISLError> {
402 let list1 = self;
403 let isl_rs_ctx = list1.get_ctx();
404 let mut list1 = list1;
405 list1.do_not_free_on_drop();
406 let list1 = list1.ptr;
407 let mut list2 = list2;
408 list2.do_not_free_on_drop();
409 let list2 = list2.ptr;
410 let isl_rs_result = unsafe { isl_pw_aff_list_lt_set(list1, list2) };
411 let isl_rs_result = Set { ptr: isl_rs_result,
412 should_free_on_drop: true };
413 let err = isl_rs_ctx.last_error();
414 if err != Error::None_ {
415 let err_msg = isl_rs_ctx.last_error_msg();
416 isl_rs_ctx.reset_error();
417 return Err(LibISLError::new(err, err_msg));
418 }
419 Ok(isl_rs_result)
420 }
421
422 pub fn max(self) -> Result<PwAff, LibISLError> {
424 let list = self;
425 let isl_rs_ctx = list.get_ctx();
426 let mut list = list;
427 list.do_not_free_on_drop();
428 let list = list.ptr;
429 let isl_rs_result = unsafe { isl_pw_aff_list_max(list) };
430 let isl_rs_result = PwAff { ptr: isl_rs_result,
431 should_free_on_drop: true };
432 let err = isl_rs_ctx.last_error();
433 if err != Error::None_ {
434 let err_msg = isl_rs_ctx.last_error_msg();
435 isl_rs_ctx.reset_error();
436 return Err(LibISLError::new(err, err_msg));
437 }
438 Ok(isl_rs_result)
439 }
440
441 pub fn min(self) -> Result<PwAff, LibISLError> {
443 let list = self;
444 let isl_rs_ctx = list.get_ctx();
445 let mut list = list;
446 list.do_not_free_on_drop();
447 let list = list.ptr;
448 let isl_rs_result = unsafe { isl_pw_aff_list_min(list) };
449 let isl_rs_result = PwAff { ptr: isl_rs_result,
450 should_free_on_drop: true };
451 let err = isl_rs_ctx.last_error();
452 if err != Error::None_ {
453 let err_msg = isl_rs_ctx.last_error_msg();
454 isl_rs_ctx.reset_error();
455 return Err(LibISLError::new(err, err_msg));
456 }
457 Ok(isl_rs_result)
458 }
459
460 pub fn n_pw_aff(&self) -> Result<i32, LibISLError> {
462 let list = self;
463 let isl_rs_ctx = list.get_ctx();
464 let list = list.ptr;
465 let isl_rs_result = unsafe { isl_pw_aff_list_n_pw_aff(list) };
466 let err = isl_rs_ctx.last_error();
467 if err != Error::None_ {
468 let err_msg = isl_rs_ctx.last_error_msg();
469 isl_rs_ctx.reset_error();
470 return Err(LibISLError::new(err, err_msg));
471 }
472 Ok(isl_rs_result)
473 }
474
475 pub fn ne_set(self, list2: PwAffList) -> Result<Set, LibISLError> {
477 let list1 = self;
478 let isl_rs_ctx = list1.get_ctx();
479 let mut list1 = list1;
480 list1.do_not_free_on_drop();
481 let list1 = list1.ptr;
482 let mut list2 = list2;
483 list2.do_not_free_on_drop();
484 let list2 = list2.ptr;
485 let isl_rs_result = unsafe { isl_pw_aff_list_ne_set(list1, list2) };
486 let isl_rs_result = Set { ptr: isl_rs_result,
487 should_free_on_drop: true };
488 let err = isl_rs_ctx.last_error();
489 if err != Error::None_ {
490 let err_msg = isl_rs_ctx.last_error_msg();
491 isl_rs_ctx.reset_error();
492 return Err(LibISLError::new(err, err_msg));
493 }
494 Ok(isl_rs_result)
495 }
496
497 pub fn read_from_str(ctx: &Context, str_: &str) -> Result<PwAffList, LibISLError> {
499 let isl_rs_ctx = Context { ptr: ctx.ptr,
500 should_free_on_drop: false };
501 let ctx = ctx.ptr;
502 let str_ = CString::new(str_).unwrap();
503 let str_ = str_.as_ptr();
504 let isl_rs_result = unsafe { isl_pw_aff_list_read_from_str(ctx, str_) };
505 let isl_rs_result = PwAffList { ptr: isl_rs_result,
506 should_free_on_drop: true };
507 let err = isl_rs_ctx.last_error();
508 if err != Error::None_ {
509 let err_msg = isl_rs_ctx.last_error_msg();
510 isl_rs_ctx.reset_error();
511 return Err(LibISLError::new(err, err_msg));
512 }
513 Ok(isl_rs_result)
514 }
515
516 pub fn reverse(self) -> Result<PwAffList, LibISLError> {
518 let list = self;
519 let isl_rs_ctx = list.get_ctx();
520 let mut list = list;
521 list.do_not_free_on_drop();
522 let list = list.ptr;
523 let isl_rs_result = unsafe { isl_pw_aff_list_reverse(list) };
524 let isl_rs_result = PwAffList { ptr: isl_rs_result,
525 should_free_on_drop: true };
526 let err = isl_rs_ctx.last_error();
527 if err != Error::None_ {
528 let err_msg = isl_rs_ctx.last_error_msg();
529 isl_rs_ctx.reset_error();
530 return Err(LibISLError::new(err, err_msg));
531 }
532 Ok(isl_rs_result)
533 }
534
535 pub fn set_at(self, index: i32, el: PwAff) -> Result<PwAffList, LibISLError> {
537 let list = self;
538 let isl_rs_ctx = list.get_ctx();
539 let mut list = list;
540 list.do_not_free_on_drop();
541 let list = list.ptr;
542 let mut el = el;
543 el.do_not_free_on_drop();
544 let el = el.ptr;
545 let isl_rs_result = unsafe { isl_pw_aff_list_set_at(list, index, el) };
546 let isl_rs_result = PwAffList { ptr: isl_rs_result,
547 should_free_on_drop: true };
548 let err = isl_rs_ctx.last_error();
549 if err != Error::None_ {
550 let err_msg = isl_rs_ctx.last_error_msg();
551 isl_rs_ctx.reset_error();
552 return Err(LibISLError::new(err, err_msg));
553 }
554 Ok(isl_rs_result)
555 }
556
557 pub fn set_pw_aff(self, index: i32, el: PwAff) -> Result<PwAffList, LibISLError> {
559 let list = self;
560 let isl_rs_ctx = list.get_ctx();
561 let mut list = list;
562 list.do_not_free_on_drop();
563 let list = list.ptr;
564 let mut el = el;
565 el.do_not_free_on_drop();
566 let el = el.ptr;
567 let isl_rs_result = unsafe { isl_pw_aff_list_set_pw_aff(list, index, el) };
568 let isl_rs_result = PwAffList { ptr: isl_rs_result,
569 should_free_on_drop: true };
570 let err = isl_rs_ctx.last_error();
571 if err != Error::None_ {
572 let err_msg = isl_rs_ctx.last_error_msg();
573 isl_rs_ctx.reset_error();
574 return Err(LibISLError::new(err, err_msg));
575 }
576 Ok(isl_rs_result)
577 }
578
579 pub fn size(&self) -> Result<i32, LibISLError> {
581 let list = self;
582 let isl_rs_ctx = list.get_ctx();
583 let list = list.ptr;
584 let isl_rs_result = unsafe { isl_pw_aff_list_size(list) };
585 let err = isl_rs_ctx.last_error();
586 if err != Error::None_ {
587 let err_msg = isl_rs_ctx.last_error_msg();
588 isl_rs_ctx.reset_error();
589 return Err(LibISLError::new(err, err_msg));
590 }
591 Ok(isl_rs_result)
592 }
593
594 pub fn swap(self, pos1: u32, pos2: u32) -> Result<PwAffList, LibISLError> {
596 let list = self;
597 let isl_rs_ctx = list.get_ctx();
598 let mut list = list;
599 list.do_not_free_on_drop();
600 let list = list.ptr;
601 let isl_rs_result = unsafe { isl_pw_aff_list_swap(list, pos1, pos2) };
602 let isl_rs_result = PwAffList { ptr: isl_rs_result,
603 should_free_on_drop: true };
604 let err = isl_rs_ctx.last_error();
605 if err != Error::None_ {
606 let err_msg = isl_rs_ctx.last_error_msg();
607 isl_rs_ctx.reset_error();
608 return Err(LibISLError::new(err, err_msg));
609 }
610 Ok(isl_rs_result)
611 }
612
613 pub fn to_str(&self) -> Result<&str, LibISLError> {
615 let list = self;
616 let isl_rs_ctx = list.get_ctx();
617 let list = list.ptr;
618 let isl_rs_result = unsafe { isl_pw_aff_list_to_str(list) };
619 let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
620 let isl_rs_result = isl_rs_result.to_str().unwrap();
621 let err = isl_rs_ctx.last_error();
622 if err != Error::None_ {
623 let err_msg = isl_rs_ctx.last_error_msg();
624 isl_rs_ctx.reset_error();
625 return Err(LibISLError::new(err, err_msg));
626 }
627 Ok(isl_rs_result)
628 }
629
630 pub fn do_not_free_on_drop(&mut self) {
633 self.should_free_on_drop = false;
634 }
635}
636
637impl Drop for PwAffList {
638 fn drop(&mut self) {
639 if self.should_free_on_drop {
640 unsafe {
641 isl_pw_aff_list_free(self.ptr);
642 }
643 }
644 }
645}