isl_rs/bindings/
local_space.rs

1// Automatically generated by isl_bindings_generator.
2// LICENSE: MIT
3
4use super::{Aff, BasicMap, Context, DimType, Error, Id, LibISLError, Space};
5use libc::uintptr_t;
6use std::ffi::{CStr, CString};
7use std::os::raw::c_char;
8
9/// Wraps `isl_local_space`.
10pub struct LocalSpace {
11    pub ptr: uintptr_t,
12    pub should_free_on_drop: bool,
13}
14
15extern "C" {
16
17    fn isl_local_space_add_dims(ls: uintptr_t, type_: i32, n: u32) -> uintptr_t;
18
19    fn isl_local_space_copy(ls: uintptr_t) -> uintptr_t;
20
21    fn isl_local_space_dim(ls: uintptr_t, type_: i32) -> i32;
22
23    fn isl_local_space_domain(ls: uintptr_t) -> uintptr_t;
24
25    fn isl_local_space_drop_dims(ls: uintptr_t, type_: i32, first: u32, n: u32) -> uintptr_t;
26
27    fn isl_local_space_dump(ls: uintptr_t) -> ();
28
29    fn isl_local_space_find_dim_by_name(ls: uintptr_t, type_: i32, name: *const c_char) -> i32;
30
31    fn isl_local_space_flatten_domain(ls: uintptr_t) -> uintptr_t;
32
33    fn isl_local_space_flatten_range(ls: uintptr_t) -> uintptr_t;
34
35    fn isl_local_space_free(ls: uintptr_t) -> uintptr_t;
36
37    fn isl_local_space_from_domain(ls: uintptr_t) -> uintptr_t;
38
39    fn isl_local_space_from_space(space: uintptr_t) -> uintptr_t;
40
41    fn isl_local_space_get_ctx(ls: uintptr_t) -> uintptr_t;
42
43    fn isl_local_space_get_dim_id(ls: uintptr_t, type_: i32, pos: u32) -> uintptr_t;
44
45    fn isl_local_space_get_dim_name(ls: uintptr_t, type_: i32, pos: u32) -> *const c_char;
46
47    fn isl_local_space_get_div(ls: uintptr_t, pos: i32) -> uintptr_t;
48
49    fn isl_local_space_get_space(ls: uintptr_t) -> uintptr_t;
50
51    fn isl_local_space_has_dim_id(ls: uintptr_t, type_: i32, pos: u32) -> i32;
52
53    fn isl_local_space_has_dim_name(ls: uintptr_t, type_: i32, pos: u32) -> i32;
54
55    fn isl_local_space_insert_dims(ls: uintptr_t, type_: i32, first: u32, n: u32) -> uintptr_t;
56
57    fn isl_local_space_intersect(ls1: uintptr_t, ls2: uintptr_t) -> uintptr_t;
58
59    fn isl_local_space_is_equal(ls1: uintptr_t, ls2: uintptr_t) -> i32;
60
61    fn isl_local_space_is_params(ls: uintptr_t) -> i32;
62
63    fn isl_local_space_is_set(ls: uintptr_t) -> i32;
64
65    fn isl_local_space_lifting(ls: uintptr_t) -> uintptr_t;
66
67    fn isl_local_space_range(ls: uintptr_t) -> uintptr_t;
68
69    fn isl_local_space_set_dim_id(ls: uintptr_t, type_: i32, pos: u32, id: uintptr_t) -> uintptr_t;
70
71    fn isl_local_space_set_dim_name(ls: uintptr_t, type_: i32, pos: u32, s: *const c_char)
72                                    -> uintptr_t;
73
74    fn isl_local_space_set_from_params(ls: uintptr_t) -> uintptr_t;
75
76    fn isl_local_space_set_tuple_id(ls: uintptr_t, type_: i32, id: uintptr_t) -> uintptr_t;
77
78    fn isl_local_space_wrap(ls: uintptr_t) -> uintptr_t;
79
80}
81
82impl LocalSpace {
83    /// Wraps `isl_local_space_add_dims`.
84    pub fn add_dims(self, type_: DimType, n: u32) -> Result<LocalSpace, LibISLError> {
85        let ls = self;
86        let isl_rs_ctx = ls.get_ctx();
87        let mut ls = ls;
88        ls.do_not_free_on_drop();
89        let ls = ls.ptr;
90        let type_ = type_.to_i32();
91        let isl_rs_result = unsafe { isl_local_space_add_dims(ls, type_, n) };
92        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
93                                         should_free_on_drop: true };
94        let err = isl_rs_ctx.last_error();
95        if err != Error::None_ {
96            let err_msg = isl_rs_ctx.last_error_msg();
97            isl_rs_ctx.reset_error();
98            return Err(LibISLError::new(err, err_msg));
99        }
100        Ok(isl_rs_result)
101    }
102
103    /// Wraps `isl_local_space_copy`.
104    pub fn copy(&self) -> Result<LocalSpace, LibISLError> {
105        let ls = self;
106        let isl_rs_ctx = ls.get_ctx();
107        let ls = ls.ptr;
108        let isl_rs_result = unsafe { isl_local_space_copy(ls) };
109        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
110                                         should_free_on_drop: true };
111        let err = isl_rs_ctx.last_error();
112        if err != Error::None_ {
113            let err_msg = isl_rs_ctx.last_error_msg();
114            isl_rs_ctx.reset_error();
115            return Err(LibISLError::new(err, err_msg));
116        }
117        Ok(isl_rs_result)
118    }
119
120    /// Wraps `isl_local_space_dim`.
121    pub fn dim(&self, type_: DimType) -> Result<i32, LibISLError> {
122        let ls = self;
123        let isl_rs_ctx = ls.get_ctx();
124        let ls = ls.ptr;
125        let type_ = type_.to_i32();
126        let isl_rs_result = unsafe { isl_local_space_dim(ls, type_) };
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    /// Wraps `isl_local_space_domain`.
137    pub fn domain(self) -> Result<LocalSpace, LibISLError> {
138        let ls = self;
139        let isl_rs_ctx = ls.get_ctx();
140        let mut ls = ls;
141        ls.do_not_free_on_drop();
142        let ls = ls.ptr;
143        let isl_rs_result = unsafe { isl_local_space_domain(ls) };
144        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
145                                         should_free_on_drop: true };
146        let err = isl_rs_ctx.last_error();
147        if err != Error::None_ {
148            let err_msg = isl_rs_ctx.last_error_msg();
149            isl_rs_ctx.reset_error();
150            return Err(LibISLError::new(err, err_msg));
151        }
152        Ok(isl_rs_result)
153    }
154
155    /// Wraps `isl_local_space_drop_dims`.
156    pub fn drop_dims(self, type_: DimType, first: u32, n: u32) -> Result<LocalSpace, LibISLError> {
157        let ls = self;
158        let isl_rs_ctx = ls.get_ctx();
159        let mut ls = ls;
160        ls.do_not_free_on_drop();
161        let ls = ls.ptr;
162        let type_ = type_.to_i32();
163        let isl_rs_result = unsafe { isl_local_space_drop_dims(ls, type_, first, n) };
164        let isl_rs_result = LocalSpace { 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    /// Wraps `isl_local_space_dump`.
176    pub fn dump(&self) -> Result<(), LibISLError> {
177        let ls = self;
178        let isl_rs_ctx = ls.get_ctx();
179        let ls = ls.ptr;
180        let isl_rs_result = unsafe { isl_local_space_dump(ls) };
181        let err = isl_rs_ctx.last_error();
182        if err != Error::None_ {
183            let err_msg = isl_rs_ctx.last_error_msg();
184            isl_rs_ctx.reset_error();
185            return Err(LibISLError::new(err, err_msg));
186        }
187        Ok(isl_rs_result)
188    }
189
190    /// Wraps `isl_local_space_find_dim_by_name`.
191    pub fn find_dim_by_name(&self, type_: DimType, name: &str) -> Result<i32, LibISLError> {
192        let ls = self;
193        let isl_rs_ctx = ls.get_ctx();
194        let ls = ls.ptr;
195        let type_ = type_.to_i32();
196        let name = CString::new(name).unwrap();
197        let name = name.as_ptr();
198        let isl_rs_result = unsafe { isl_local_space_find_dim_by_name(ls, type_, name) };
199        let err = isl_rs_ctx.last_error();
200        if err != Error::None_ {
201            let err_msg = isl_rs_ctx.last_error_msg();
202            isl_rs_ctx.reset_error();
203            return Err(LibISLError::new(err, err_msg));
204        }
205        Ok(isl_rs_result)
206    }
207
208    /// Wraps `isl_local_space_flatten_domain`.
209    pub fn flatten_domain(self) -> Result<LocalSpace, LibISLError> {
210        let ls = self;
211        let isl_rs_ctx = ls.get_ctx();
212        let mut ls = ls;
213        ls.do_not_free_on_drop();
214        let ls = ls.ptr;
215        let isl_rs_result = unsafe { isl_local_space_flatten_domain(ls) };
216        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
217                                         should_free_on_drop: true };
218        let err = isl_rs_ctx.last_error();
219        if err != Error::None_ {
220            let err_msg = isl_rs_ctx.last_error_msg();
221            isl_rs_ctx.reset_error();
222            return Err(LibISLError::new(err, err_msg));
223        }
224        Ok(isl_rs_result)
225    }
226
227    /// Wraps `isl_local_space_flatten_range`.
228    pub fn flatten_range(self) -> Result<LocalSpace, LibISLError> {
229        let ls = self;
230        let isl_rs_ctx = ls.get_ctx();
231        let mut ls = ls;
232        ls.do_not_free_on_drop();
233        let ls = ls.ptr;
234        let isl_rs_result = unsafe { isl_local_space_flatten_range(ls) };
235        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
236                                         should_free_on_drop: true };
237        let err = isl_rs_ctx.last_error();
238        if err != Error::None_ {
239            let err_msg = isl_rs_ctx.last_error_msg();
240            isl_rs_ctx.reset_error();
241            return Err(LibISLError::new(err, err_msg));
242        }
243        Ok(isl_rs_result)
244    }
245
246    /// Wraps `isl_local_space_free`.
247    pub fn free(self) -> Result<LocalSpace, LibISLError> {
248        let ls = self;
249        let isl_rs_ctx = ls.get_ctx();
250        let mut ls = ls;
251        ls.do_not_free_on_drop();
252        let ls = ls.ptr;
253        let isl_rs_result = unsafe { isl_local_space_free(ls) };
254        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
255                                         should_free_on_drop: true };
256        let err = isl_rs_ctx.last_error();
257        if err != Error::None_ {
258            let err_msg = isl_rs_ctx.last_error_msg();
259            isl_rs_ctx.reset_error();
260            return Err(LibISLError::new(err, err_msg));
261        }
262        Ok(isl_rs_result)
263    }
264
265    /// Wraps `isl_local_space_from_domain`.
266    pub fn from_domain(self) -> Result<LocalSpace, LibISLError> {
267        let ls = self;
268        let isl_rs_ctx = ls.get_ctx();
269        let mut ls = ls;
270        ls.do_not_free_on_drop();
271        let ls = ls.ptr;
272        let isl_rs_result = unsafe { isl_local_space_from_domain(ls) };
273        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
274                                         should_free_on_drop: true };
275        let err = isl_rs_ctx.last_error();
276        if err != Error::None_ {
277            let err_msg = isl_rs_ctx.last_error_msg();
278            isl_rs_ctx.reset_error();
279            return Err(LibISLError::new(err, err_msg));
280        }
281        Ok(isl_rs_result)
282    }
283
284    /// Wraps `isl_local_space_from_space`.
285    pub fn from_space(space: Space) -> Result<LocalSpace, LibISLError> {
286        let isl_rs_ctx = space.get_ctx();
287        let mut space = space;
288        space.do_not_free_on_drop();
289        let space = space.ptr;
290        let isl_rs_result = unsafe { isl_local_space_from_space(space) };
291        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
292                                         should_free_on_drop: true };
293        let err = isl_rs_ctx.last_error();
294        if err != Error::None_ {
295            let err_msg = isl_rs_ctx.last_error_msg();
296            isl_rs_ctx.reset_error();
297            return Err(LibISLError::new(err, err_msg));
298        }
299        Ok(isl_rs_result)
300    }
301
302    /// Wraps `isl_local_space_get_ctx`.
303    pub fn get_ctx(&self) -> Context {
304        let ls = self;
305        let ls = ls.ptr;
306        let isl_rs_result = unsafe { isl_local_space_get_ctx(ls) };
307        let isl_rs_result = Context { ptr: isl_rs_result,
308                                      should_free_on_drop: false };
309        isl_rs_result
310    }
311
312    /// Wraps `isl_local_space_get_dim_id`.
313    pub fn get_dim_id(&self, type_: DimType, pos: u32) -> Result<Id, LibISLError> {
314        let ls = self;
315        let isl_rs_ctx = ls.get_ctx();
316        let ls = ls.ptr;
317        let type_ = type_.to_i32();
318        let isl_rs_result = unsafe { isl_local_space_get_dim_id(ls, type_, pos) };
319        let isl_rs_result = Id { ptr: isl_rs_result,
320                                 should_free_on_drop: true };
321        let err = isl_rs_ctx.last_error();
322        if err != Error::None_ {
323            let err_msg = isl_rs_ctx.last_error_msg();
324            isl_rs_ctx.reset_error();
325            return Err(LibISLError::new(err, err_msg));
326        }
327        Ok(isl_rs_result)
328    }
329
330    /// Wraps `isl_local_space_get_dim_name`.
331    pub fn get_dim_name(&self, type_: DimType, pos: u32) -> Result<&str, LibISLError> {
332        let ls = self;
333        let isl_rs_ctx = ls.get_ctx();
334        let ls = ls.ptr;
335        let type_ = type_.to_i32();
336        let isl_rs_result = unsafe { isl_local_space_get_dim_name(ls, type_, pos) };
337        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
338        let isl_rs_result = isl_rs_result.to_str().unwrap();
339        let err = isl_rs_ctx.last_error();
340        if err != Error::None_ {
341            let err_msg = isl_rs_ctx.last_error_msg();
342            isl_rs_ctx.reset_error();
343            return Err(LibISLError::new(err, err_msg));
344        }
345        Ok(isl_rs_result)
346    }
347
348    /// Wraps `isl_local_space_get_div`.
349    pub fn get_div(&self, pos: i32) -> Result<Aff, LibISLError> {
350        let ls = self;
351        let isl_rs_ctx = ls.get_ctx();
352        let ls = ls.ptr;
353        let isl_rs_result = unsafe { isl_local_space_get_div(ls, pos) };
354        let isl_rs_result = Aff { ptr: isl_rs_result,
355                                  should_free_on_drop: true };
356        let err = isl_rs_ctx.last_error();
357        if err != Error::None_ {
358            let err_msg = isl_rs_ctx.last_error_msg();
359            isl_rs_ctx.reset_error();
360            return Err(LibISLError::new(err, err_msg));
361        }
362        Ok(isl_rs_result)
363    }
364
365    /// Wraps `isl_local_space_get_space`.
366    pub fn get_space(&self) -> Result<Space, LibISLError> {
367        let ls = self;
368        let isl_rs_ctx = ls.get_ctx();
369        let ls = ls.ptr;
370        let isl_rs_result = unsafe { isl_local_space_get_space(ls) };
371        let isl_rs_result = Space { ptr: isl_rs_result,
372                                    should_free_on_drop: true };
373        let err = isl_rs_ctx.last_error();
374        if err != Error::None_ {
375            let err_msg = isl_rs_ctx.last_error_msg();
376            isl_rs_ctx.reset_error();
377            return Err(LibISLError::new(err, err_msg));
378        }
379        Ok(isl_rs_result)
380    }
381
382    /// Wraps `isl_local_space_has_dim_id`.
383    pub fn has_dim_id(&self, type_: DimType, pos: u32) -> Result<bool, LibISLError> {
384        let ls = self;
385        let isl_rs_ctx = ls.get_ctx();
386        let ls = ls.ptr;
387        let type_ = type_.to_i32();
388        let isl_rs_result = unsafe { isl_local_space_has_dim_id(ls, type_, pos) };
389        let isl_rs_result = match isl_rs_result {
390            0 => false,
391            1 => true,
392            _ => {
393                return Err(LibISLError::new(Error::Unknown, "Got isl_bool = -1"));
394            }
395        };
396        let err = isl_rs_ctx.last_error();
397        if err != Error::None_ {
398            let err_msg = isl_rs_ctx.last_error_msg();
399            isl_rs_ctx.reset_error();
400            return Err(LibISLError::new(err, err_msg));
401        }
402        Ok(isl_rs_result)
403    }
404
405    /// Wraps `isl_local_space_has_dim_name`.
406    pub fn has_dim_name(&self, type_: DimType, pos: u32) -> Result<bool, LibISLError> {
407        let ls = self;
408        let isl_rs_ctx = ls.get_ctx();
409        let ls = ls.ptr;
410        let type_ = type_.to_i32();
411        let isl_rs_result = unsafe { isl_local_space_has_dim_name(ls, type_, pos) };
412        let isl_rs_result = match isl_rs_result {
413            0 => false,
414            1 => true,
415            _ => {
416                return Err(LibISLError::new(Error::Unknown, "Got isl_bool = -1"));
417            }
418        };
419        let err = isl_rs_ctx.last_error();
420        if err != Error::None_ {
421            let err_msg = isl_rs_ctx.last_error_msg();
422            isl_rs_ctx.reset_error();
423            return Err(LibISLError::new(err, err_msg));
424        }
425        Ok(isl_rs_result)
426    }
427
428    /// Wraps `isl_local_space_insert_dims`.
429    pub fn insert_dims(self, type_: DimType, first: u32, n: u32)
430                       -> Result<LocalSpace, LibISLError> {
431        let ls = self;
432        let isl_rs_ctx = ls.get_ctx();
433        let mut ls = ls;
434        ls.do_not_free_on_drop();
435        let ls = ls.ptr;
436        let type_ = type_.to_i32();
437        let isl_rs_result = unsafe { isl_local_space_insert_dims(ls, type_, first, n) };
438        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
439                                         should_free_on_drop: true };
440        let err = isl_rs_ctx.last_error();
441        if err != Error::None_ {
442            let err_msg = isl_rs_ctx.last_error_msg();
443            isl_rs_ctx.reset_error();
444            return Err(LibISLError::new(err, err_msg));
445        }
446        Ok(isl_rs_result)
447    }
448
449    /// Wraps `isl_local_space_intersect`.
450    pub fn intersect(self, ls2: LocalSpace) -> Result<LocalSpace, LibISLError> {
451        let ls1 = self;
452        let isl_rs_ctx = ls1.get_ctx();
453        let mut ls1 = ls1;
454        ls1.do_not_free_on_drop();
455        let ls1 = ls1.ptr;
456        let mut ls2 = ls2;
457        ls2.do_not_free_on_drop();
458        let ls2 = ls2.ptr;
459        let isl_rs_result = unsafe { isl_local_space_intersect(ls1, ls2) };
460        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
461                                         should_free_on_drop: true };
462        let err = isl_rs_ctx.last_error();
463        if err != Error::None_ {
464            let err_msg = isl_rs_ctx.last_error_msg();
465            isl_rs_ctx.reset_error();
466            return Err(LibISLError::new(err, err_msg));
467        }
468        Ok(isl_rs_result)
469    }
470
471    /// Wraps `isl_local_space_is_equal`.
472    pub fn is_equal(&self, ls2: &LocalSpace) -> Result<bool, LibISLError> {
473        let ls1 = self;
474        let isl_rs_ctx = ls1.get_ctx();
475        let ls1 = ls1.ptr;
476        let ls2 = ls2.ptr;
477        let isl_rs_result = unsafe { isl_local_space_is_equal(ls1, ls2) };
478        let isl_rs_result = match isl_rs_result {
479            0 => false,
480            1 => true,
481            _ => {
482                return Err(LibISLError::new(Error::Unknown, "Got isl_bool = -1"));
483            }
484        };
485        let err = isl_rs_ctx.last_error();
486        if err != Error::None_ {
487            let err_msg = isl_rs_ctx.last_error_msg();
488            isl_rs_ctx.reset_error();
489            return Err(LibISLError::new(err, err_msg));
490        }
491        Ok(isl_rs_result)
492    }
493
494    /// Wraps `isl_local_space_is_params`.
495    pub fn is_params(&self) -> Result<bool, LibISLError> {
496        let ls = self;
497        let isl_rs_ctx = ls.get_ctx();
498        let ls = ls.ptr;
499        let isl_rs_result = unsafe { isl_local_space_is_params(ls) };
500        let isl_rs_result = match isl_rs_result {
501            0 => false,
502            1 => true,
503            _ => {
504                return Err(LibISLError::new(Error::Unknown, "Got isl_bool = -1"));
505            }
506        };
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    /// Wraps `isl_local_space_is_set`.
517    pub fn is_set(&self) -> Result<bool, LibISLError> {
518        let ls = self;
519        let isl_rs_ctx = ls.get_ctx();
520        let ls = ls.ptr;
521        let isl_rs_result = unsafe { isl_local_space_is_set(ls) };
522        let isl_rs_result = match isl_rs_result {
523            0 => false,
524            1 => true,
525            _ => {
526                return Err(LibISLError::new(Error::Unknown, "Got isl_bool = -1"));
527            }
528        };
529        let err = isl_rs_ctx.last_error();
530        if err != Error::None_ {
531            let err_msg = isl_rs_ctx.last_error_msg();
532            isl_rs_ctx.reset_error();
533            return Err(LibISLError::new(err, err_msg));
534        }
535        Ok(isl_rs_result)
536    }
537
538    /// Wraps `isl_local_space_lifting`.
539    pub fn lifting(self) -> Result<BasicMap, LibISLError> {
540        let ls = self;
541        let isl_rs_ctx = ls.get_ctx();
542        let mut ls = ls;
543        ls.do_not_free_on_drop();
544        let ls = ls.ptr;
545        let isl_rs_result = unsafe { isl_local_space_lifting(ls) };
546        let isl_rs_result = BasicMap { 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    /// Wraps `isl_local_space_range`.
558    pub fn range(self) -> Result<LocalSpace, LibISLError> {
559        let ls = self;
560        let isl_rs_ctx = ls.get_ctx();
561        let mut ls = ls;
562        ls.do_not_free_on_drop();
563        let ls = ls.ptr;
564        let isl_rs_result = unsafe { isl_local_space_range(ls) };
565        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
566                                         should_free_on_drop: true };
567        let err = isl_rs_ctx.last_error();
568        if err != Error::None_ {
569            let err_msg = isl_rs_ctx.last_error_msg();
570            isl_rs_ctx.reset_error();
571            return Err(LibISLError::new(err, err_msg));
572        }
573        Ok(isl_rs_result)
574    }
575
576    /// Wraps `isl_local_space_set_dim_id`.
577    pub fn set_dim_id(self, type_: DimType, pos: u32, id: Id) -> Result<LocalSpace, LibISLError> {
578        let ls = self;
579        let isl_rs_ctx = ls.get_ctx();
580        let mut ls = ls;
581        ls.do_not_free_on_drop();
582        let ls = ls.ptr;
583        let type_ = type_.to_i32();
584        let mut id = id;
585        id.do_not_free_on_drop();
586        let id = id.ptr;
587        let isl_rs_result = unsafe { isl_local_space_set_dim_id(ls, type_, pos, id) };
588        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
589                                         should_free_on_drop: true };
590        let err = isl_rs_ctx.last_error();
591        if err != Error::None_ {
592            let err_msg = isl_rs_ctx.last_error_msg();
593            isl_rs_ctx.reset_error();
594            return Err(LibISLError::new(err, err_msg));
595        }
596        Ok(isl_rs_result)
597    }
598
599    /// Wraps `isl_local_space_set_dim_name`.
600    pub fn set_dim_name(self, type_: DimType, pos: u32, s: &str)
601                        -> Result<LocalSpace, LibISLError> {
602        let ls = self;
603        let isl_rs_ctx = ls.get_ctx();
604        let mut ls = ls;
605        ls.do_not_free_on_drop();
606        let ls = ls.ptr;
607        let type_ = type_.to_i32();
608        let s = CString::new(s).unwrap();
609        let s = s.as_ptr();
610        let isl_rs_result = unsafe { isl_local_space_set_dim_name(ls, type_, pos, s) };
611        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
612                                         should_free_on_drop: true };
613        let err = isl_rs_ctx.last_error();
614        if err != Error::None_ {
615            let err_msg = isl_rs_ctx.last_error_msg();
616            isl_rs_ctx.reset_error();
617            return Err(LibISLError::new(err, err_msg));
618        }
619        Ok(isl_rs_result)
620    }
621
622    /// Wraps `isl_local_space_set_from_params`.
623    pub fn set_from_params(self) -> Result<LocalSpace, LibISLError> {
624        let ls = self;
625        let isl_rs_ctx = ls.get_ctx();
626        let mut ls = ls;
627        ls.do_not_free_on_drop();
628        let ls = ls.ptr;
629        let isl_rs_result = unsafe { isl_local_space_set_from_params(ls) };
630        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
631                                         should_free_on_drop: true };
632        let err = isl_rs_ctx.last_error();
633        if err != Error::None_ {
634            let err_msg = isl_rs_ctx.last_error_msg();
635            isl_rs_ctx.reset_error();
636            return Err(LibISLError::new(err, err_msg));
637        }
638        Ok(isl_rs_result)
639    }
640
641    /// Wraps `isl_local_space_set_tuple_id`.
642    pub fn set_tuple_id(self, type_: DimType, id: Id) -> Result<LocalSpace, LibISLError> {
643        let ls = self;
644        let isl_rs_ctx = ls.get_ctx();
645        let mut ls = ls;
646        ls.do_not_free_on_drop();
647        let ls = ls.ptr;
648        let type_ = type_.to_i32();
649        let mut id = id;
650        id.do_not_free_on_drop();
651        let id = id.ptr;
652        let isl_rs_result = unsafe { isl_local_space_set_tuple_id(ls, type_, id) };
653        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
654                                         should_free_on_drop: true };
655        let err = isl_rs_ctx.last_error();
656        if err != Error::None_ {
657            let err_msg = isl_rs_ctx.last_error_msg();
658            isl_rs_ctx.reset_error();
659            return Err(LibISLError::new(err, err_msg));
660        }
661        Ok(isl_rs_result)
662    }
663
664    /// Wraps `isl_local_space_wrap`.
665    pub fn wrap(self) -> Result<LocalSpace, LibISLError> {
666        let ls = self;
667        let isl_rs_ctx = ls.get_ctx();
668        let mut ls = ls;
669        ls.do_not_free_on_drop();
670        let ls = ls.ptr;
671        let isl_rs_result = unsafe { isl_local_space_wrap(ls) };
672        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
673                                         should_free_on_drop: true };
674        let err = isl_rs_ctx.last_error();
675        if err != Error::None_ {
676            let err_msg = isl_rs_ctx.last_error_msg();
677            isl_rs_ctx.reset_error();
678            return Err(LibISLError::new(err, err_msg));
679        }
680        Ok(isl_rs_result)
681    }
682
683    /// Does not call isl_local_space_free() on being dropped. (For internal use
684    /// only.)
685    pub fn do_not_free_on_drop(&mut self) {
686        self.should_free_on_drop = false;
687    }
688}
689
690impl Drop for LocalSpace {
691    fn drop(&mut self) {
692        if self.should_free_on_drop {
693            unsafe {
694                isl_local_space_free(self.ptr);
695            }
696        }
697    }
698}