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            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
97        }
98        Ok(isl_rs_result)
99    }
100
101    /// Wraps `isl_local_space_copy`.
102    pub fn copy(&self) -> Result<LocalSpace, LibISLError> {
103        let ls = self;
104        let isl_rs_ctx = ls.get_ctx();
105        let ls = ls.ptr;
106        let isl_rs_result = unsafe { isl_local_space_copy(ls) };
107        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
108                                         should_free_on_drop: true };
109        let err = isl_rs_ctx.last_error();
110        if err != Error::None_ {
111            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
112        }
113        Ok(isl_rs_result)
114    }
115
116    /// Wraps `isl_local_space_dim`.
117    pub fn dim(&self, type_: DimType) -> Result<i32, LibISLError> {
118        let ls = self;
119        let isl_rs_ctx = ls.get_ctx();
120        let ls = ls.ptr;
121        let type_ = type_.to_i32();
122        let isl_rs_result = unsafe { isl_local_space_dim(ls, type_) };
123        let err = isl_rs_ctx.last_error();
124        if err != Error::None_ {
125            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
126        }
127        Ok(isl_rs_result)
128    }
129
130    /// Wraps `isl_local_space_domain`.
131    pub fn domain(self) -> Result<LocalSpace, LibISLError> {
132        let ls = self;
133        let isl_rs_ctx = ls.get_ctx();
134        let mut ls = ls;
135        ls.do_not_free_on_drop();
136        let ls = ls.ptr;
137        let isl_rs_result = unsafe { isl_local_space_domain(ls) };
138        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
139                                         should_free_on_drop: true };
140        let err = isl_rs_ctx.last_error();
141        if err != Error::None_ {
142            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
143        }
144        Ok(isl_rs_result)
145    }
146
147    /// Wraps `isl_local_space_drop_dims`.
148    pub fn drop_dims(self, type_: DimType, first: u32, n: u32) -> Result<LocalSpace, LibISLError> {
149        let ls = self;
150        let isl_rs_ctx = ls.get_ctx();
151        let mut ls = ls;
152        ls.do_not_free_on_drop();
153        let ls = ls.ptr;
154        let type_ = type_.to_i32();
155        let isl_rs_result = unsafe { isl_local_space_drop_dims(ls, type_, first, n) };
156        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
157                                         should_free_on_drop: true };
158        let err = isl_rs_ctx.last_error();
159        if err != Error::None_ {
160            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
161        }
162        Ok(isl_rs_result)
163    }
164
165    /// Wraps `isl_local_space_dump`.
166    pub fn dump(&self) -> Result<(), LibISLError> {
167        let ls = self;
168        let isl_rs_ctx = ls.get_ctx();
169        let ls = ls.ptr;
170        let isl_rs_result = unsafe { isl_local_space_dump(ls) };
171        let err = isl_rs_ctx.last_error();
172        if err != Error::None_ {
173            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
174        }
175        Ok(isl_rs_result)
176    }
177
178    /// Wraps `isl_local_space_find_dim_by_name`.
179    pub fn find_dim_by_name(&self, type_: DimType, name: &str) -> Result<i32, LibISLError> {
180        let ls = self;
181        let isl_rs_ctx = ls.get_ctx();
182        let ls = ls.ptr;
183        let type_ = type_.to_i32();
184        let name = CString::new(name).unwrap();
185        let name = name.as_ptr();
186        let isl_rs_result = unsafe { isl_local_space_find_dim_by_name(ls, type_, name) };
187        let err = isl_rs_ctx.last_error();
188        if err != Error::None_ {
189            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
190        }
191        Ok(isl_rs_result)
192    }
193
194    /// Wraps `isl_local_space_flatten_domain`.
195    pub fn flatten_domain(self) -> Result<LocalSpace, LibISLError> {
196        let ls = self;
197        let isl_rs_ctx = ls.get_ctx();
198        let mut ls = ls;
199        ls.do_not_free_on_drop();
200        let ls = ls.ptr;
201        let isl_rs_result = unsafe { isl_local_space_flatten_domain(ls) };
202        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
203                                         should_free_on_drop: true };
204        let err = isl_rs_ctx.last_error();
205        if err != Error::None_ {
206            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
207        }
208        Ok(isl_rs_result)
209    }
210
211    /// Wraps `isl_local_space_flatten_range`.
212    pub fn flatten_range(self) -> Result<LocalSpace, LibISLError> {
213        let ls = self;
214        let isl_rs_ctx = ls.get_ctx();
215        let mut ls = ls;
216        ls.do_not_free_on_drop();
217        let ls = ls.ptr;
218        let isl_rs_result = unsafe { isl_local_space_flatten_range(ls) };
219        let isl_rs_result = LocalSpace { 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_local_space_free`.
229    pub fn free(self) -> Result<LocalSpace, LibISLError> {
230        let ls = self;
231        let isl_rs_ctx = ls.get_ctx();
232        let mut ls = ls;
233        ls.do_not_free_on_drop();
234        let ls = ls.ptr;
235        let isl_rs_result = unsafe { isl_local_space_free(ls) };
236        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
237                                         should_free_on_drop: true };
238        let err = isl_rs_ctx.last_error();
239        if err != Error::None_ {
240            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
241        }
242        Ok(isl_rs_result)
243    }
244
245    /// Wraps `isl_local_space_from_domain`.
246    pub fn from_domain(self) -> Result<LocalSpace, LibISLError> {
247        let ls = self;
248        let isl_rs_ctx = ls.get_ctx();
249        let mut ls = ls;
250        ls.do_not_free_on_drop();
251        let ls = ls.ptr;
252        let isl_rs_result = unsafe { isl_local_space_from_domain(ls) };
253        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
254                                         should_free_on_drop: true };
255        let err = isl_rs_ctx.last_error();
256        if err != Error::None_ {
257            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
258        }
259        Ok(isl_rs_result)
260    }
261
262    /// Wraps `isl_local_space_from_space`.
263    pub fn from_space(space: Space) -> Result<LocalSpace, LibISLError> {
264        let isl_rs_ctx = space.get_ctx();
265        let mut space = space;
266        space.do_not_free_on_drop();
267        let space = space.ptr;
268        let isl_rs_result = unsafe { isl_local_space_from_space(space) };
269        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
270                                         should_free_on_drop: true };
271        let err = isl_rs_ctx.last_error();
272        if err != Error::None_ {
273            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
274        }
275        Ok(isl_rs_result)
276    }
277
278    /// Wraps `isl_local_space_get_ctx`.
279    pub fn get_ctx(&self) -> Context {
280        let ls = self;
281        let ls = ls.ptr;
282        let isl_rs_result = unsafe { isl_local_space_get_ctx(ls) };
283        let isl_rs_result = Context { ptr: isl_rs_result,
284                                      should_free_on_drop: false };
285        isl_rs_result
286    }
287
288    /// Wraps `isl_local_space_get_dim_id`.
289    pub fn get_dim_id(&self, type_: DimType, pos: u32) -> Result<Id, LibISLError> {
290        let ls = self;
291        let isl_rs_ctx = ls.get_ctx();
292        let ls = ls.ptr;
293        let type_ = type_.to_i32();
294        let isl_rs_result = unsafe { isl_local_space_get_dim_id(ls, type_, pos) };
295        let isl_rs_result = Id { ptr: isl_rs_result,
296                                 should_free_on_drop: true };
297        let err = isl_rs_ctx.last_error();
298        if err != Error::None_ {
299            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
300        }
301        Ok(isl_rs_result)
302    }
303
304    /// Wraps `isl_local_space_get_dim_name`.
305    pub fn get_dim_name(&self, type_: DimType, pos: u32) -> Result<&str, LibISLError> {
306        let ls = self;
307        let isl_rs_ctx = ls.get_ctx();
308        let ls = ls.ptr;
309        let type_ = type_.to_i32();
310        let isl_rs_result = unsafe { isl_local_space_get_dim_name(ls, type_, pos) };
311        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
312        let isl_rs_result = isl_rs_result.to_str().unwrap();
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_local_space_get_div`.
321    pub fn get_div(&self, pos: i32) -> Result<Aff, LibISLError> {
322        let ls = self;
323        let isl_rs_ctx = ls.get_ctx();
324        let ls = ls.ptr;
325        let isl_rs_result = unsafe { isl_local_space_get_div(ls, pos) };
326        let isl_rs_result = Aff { ptr: isl_rs_result,
327                                  should_free_on_drop: true };
328        let err = isl_rs_ctx.last_error();
329        if err != Error::None_ {
330            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
331        }
332        Ok(isl_rs_result)
333    }
334
335    /// Wraps `isl_local_space_get_space`.
336    pub fn get_space(&self) -> Result<Space, LibISLError> {
337        let ls = self;
338        let isl_rs_ctx = ls.get_ctx();
339        let ls = ls.ptr;
340        let isl_rs_result = unsafe { isl_local_space_get_space(ls) };
341        let isl_rs_result = Space { ptr: isl_rs_result,
342                                    should_free_on_drop: true };
343        let err = isl_rs_ctx.last_error();
344        if err != Error::None_ {
345            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
346        }
347        Ok(isl_rs_result)
348    }
349
350    /// Wraps `isl_local_space_has_dim_id`.
351    pub fn has_dim_id(&self, type_: DimType, pos: u32) -> Result<bool, LibISLError> {
352        let ls = self;
353        let isl_rs_ctx = ls.get_ctx();
354        let ls = ls.ptr;
355        let type_ = type_.to_i32();
356        let isl_rs_result = unsafe { isl_local_space_has_dim_id(ls, type_, pos) };
357        let isl_rs_result = match isl_rs_result {
358            0 => false,
359            1 => true,
360            _ => panic!("Got isl_bool = -1"),
361        };
362        let err = isl_rs_ctx.last_error();
363        if err != Error::None_ {
364            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
365        }
366        Ok(isl_rs_result)
367    }
368
369    /// Wraps `isl_local_space_has_dim_name`.
370    pub fn has_dim_name(&self, type_: DimType, pos: u32) -> Result<bool, LibISLError> {
371        let ls = self;
372        let isl_rs_ctx = ls.get_ctx();
373        let ls = ls.ptr;
374        let type_ = type_.to_i32();
375        let isl_rs_result = unsafe { isl_local_space_has_dim_name(ls, type_, pos) };
376        let isl_rs_result = match isl_rs_result {
377            0 => false,
378            1 => true,
379            _ => panic!("Got isl_bool = -1"),
380        };
381        let err = isl_rs_ctx.last_error();
382        if err != Error::None_ {
383            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
384        }
385        Ok(isl_rs_result)
386    }
387
388    /// Wraps `isl_local_space_insert_dims`.
389    pub fn insert_dims(self, type_: DimType, first: u32, n: u32)
390                       -> Result<LocalSpace, LibISLError> {
391        let ls = self;
392        let isl_rs_ctx = ls.get_ctx();
393        let mut ls = ls;
394        ls.do_not_free_on_drop();
395        let ls = ls.ptr;
396        let type_ = type_.to_i32();
397        let isl_rs_result = unsafe { isl_local_space_insert_dims(ls, type_, first, n) };
398        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
399                                         should_free_on_drop: true };
400        let err = isl_rs_ctx.last_error();
401        if err != Error::None_ {
402            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
403        }
404        Ok(isl_rs_result)
405    }
406
407    /// Wraps `isl_local_space_intersect`.
408    pub fn intersect(self, ls2: LocalSpace) -> Result<LocalSpace, LibISLError> {
409        let ls1 = self;
410        let isl_rs_ctx = ls1.get_ctx();
411        let mut ls1 = ls1;
412        ls1.do_not_free_on_drop();
413        let ls1 = ls1.ptr;
414        let mut ls2 = ls2;
415        ls2.do_not_free_on_drop();
416        let ls2 = ls2.ptr;
417        let isl_rs_result = unsafe { isl_local_space_intersect(ls1, ls2) };
418        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
419                                         should_free_on_drop: true };
420        let err = isl_rs_ctx.last_error();
421        if err != Error::None_ {
422            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
423        }
424        Ok(isl_rs_result)
425    }
426
427    /// Wraps `isl_local_space_is_equal`.
428    pub fn is_equal(&self, ls2: &LocalSpace) -> Result<bool, LibISLError> {
429        let ls1 = self;
430        let isl_rs_ctx = ls1.get_ctx();
431        let ls1 = ls1.ptr;
432        let ls2 = ls2.ptr;
433        let isl_rs_result = unsafe { isl_local_space_is_equal(ls1, ls2) };
434        let isl_rs_result = match isl_rs_result {
435            0 => false,
436            1 => true,
437            _ => panic!("Got isl_bool = -1"),
438        };
439        let err = isl_rs_ctx.last_error();
440        if err != Error::None_ {
441            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
442        }
443        Ok(isl_rs_result)
444    }
445
446    /// Wraps `isl_local_space_is_params`.
447    pub fn is_params(&self) -> Result<bool, LibISLError> {
448        let ls = self;
449        let isl_rs_ctx = ls.get_ctx();
450        let ls = ls.ptr;
451        let isl_rs_result = unsafe { isl_local_space_is_params(ls) };
452        let isl_rs_result = match isl_rs_result {
453            0 => false,
454            1 => true,
455            _ => panic!("Got isl_bool = -1"),
456        };
457        let err = isl_rs_ctx.last_error();
458        if err != Error::None_ {
459            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
460        }
461        Ok(isl_rs_result)
462    }
463
464    /// Wraps `isl_local_space_is_set`.
465    pub fn is_set(&self) -> Result<bool, LibISLError> {
466        let ls = self;
467        let isl_rs_ctx = ls.get_ctx();
468        let ls = ls.ptr;
469        let isl_rs_result = unsafe { isl_local_space_is_set(ls) };
470        let isl_rs_result = match isl_rs_result {
471            0 => false,
472            1 => true,
473            _ => panic!("Got isl_bool = -1"),
474        };
475        let err = isl_rs_ctx.last_error();
476        if err != Error::None_ {
477            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
478        }
479        Ok(isl_rs_result)
480    }
481
482    /// Wraps `isl_local_space_lifting`.
483    pub fn lifting(self) -> Result<BasicMap, LibISLError> {
484        let ls = self;
485        let isl_rs_ctx = ls.get_ctx();
486        let mut ls = ls;
487        ls.do_not_free_on_drop();
488        let ls = ls.ptr;
489        let isl_rs_result = unsafe { isl_local_space_lifting(ls) };
490        let isl_rs_result = BasicMap { ptr: isl_rs_result,
491                                       should_free_on_drop: true };
492        let err = isl_rs_ctx.last_error();
493        if err != Error::None_ {
494            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
495        }
496        Ok(isl_rs_result)
497    }
498
499    /// Wraps `isl_local_space_range`.
500    pub fn range(self) -> Result<LocalSpace, LibISLError> {
501        let ls = self;
502        let isl_rs_ctx = ls.get_ctx();
503        let mut ls = ls;
504        ls.do_not_free_on_drop();
505        let ls = ls.ptr;
506        let isl_rs_result = unsafe { isl_local_space_range(ls) };
507        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
508                                         should_free_on_drop: true };
509        let err = isl_rs_ctx.last_error();
510        if err != Error::None_ {
511            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
512        }
513        Ok(isl_rs_result)
514    }
515
516    /// Wraps `isl_local_space_set_dim_id`.
517    pub fn set_dim_id(self, type_: DimType, pos: u32, id: Id) -> Result<LocalSpace, LibISLError> {
518        let ls = self;
519        let isl_rs_ctx = ls.get_ctx();
520        let mut ls = ls;
521        ls.do_not_free_on_drop();
522        let ls = ls.ptr;
523        let type_ = type_.to_i32();
524        let mut id = id;
525        id.do_not_free_on_drop();
526        let id = id.ptr;
527        let isl_rs_result = unsafe { isl_local_space_set_dim_id(ls, type_, pos, id) };
528        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
529                                         should_free_on_drop: true };
530        let err = isl_rs_ctx.last_error();
531        if err != Error::None_ {
532            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
533        }
534        Ok(isl_rs_result)
535    }
536
537    /// Wraps `isl_local_space_set_dim_name`.
538    pub fn set_dim_name(self, type_: DimType, pos: u32, s: &str)
539                        -> Result<LocalSpace, 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 type_ = type_.to_i32();
546        let s = CString::new(s).unwrap();
547        let s = s.as_ptr();
548        let isl_rs_result = unsafe { isl_local_space_set_dim_name(ls, type_, pos, s) };
549        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
550                                         should_free_on_drop: true };
551        let err = isl_rs_ctx.last_error();
552        if err != Error::None_ {
553            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
554        }
555        Ok(isl_rs_result)
556    }
557
558    /// Wraps `isl_local_space_set_from_params`.
559    pub fn set_from_params(self) -> Result<LocalSpace, LibISLError> {
560        let ls = self;
561        let isl_rs_ctx = ls.get_ctx();
562        let mut ls = ls;
563        ls.do_not_free_on_drop();
564        let ls = ls.ptr;
565        let isl_rs_result = unsafe { isl_local_space_set_from_params(ls) };
566        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
567                                         should_free_on_drop: true };
568        let err = isl_rs_ctx.last_error();
569        if err != Error::None_ {
570            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
571        }
572        Ok(isl_rs_result)
573    }
574
575    /// Wraps `isl_local_space_set_tuple_id`.
576    pub fn set_tuple_id(self, type_: DimType, id: Id) -> Result<LocalSpace, LibISLError> {
577        let ls = self;
578        let isl_rs_ctx = ls.get_ctx();
579        let mut ls = ls;
580        ls.do_not_free_on_drop();
581        let ls = ls.ptr;
582        let type_ = type_.to_i32();
583        let mut id = id;
584        id.do_not_free_on_drop();
585        let id = id.ptr;
586        let isl_rs_result = unsafe { isl_local_space_set_tuple_id(ls, type_, id) };
587        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
588                                         should_free_on_drop: true };
589        let err = isl_rs_ctx.last_error();
590        if err != Error::None_ {
591            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
592        }
593        Ok(isl_rs_result)
594    }
595
596    /// Wraps `isl_local_space_wrap`.
597    pub fn wrap(self) -> Result<LocalSpace, LibISLError> {
598        let ls = self;
599        let isl_rs_ctx = ls.get_ctx();
600        let mut ls = ls;
601        ls.do_not_free_on_drop();
602        let ls = ls.ptr;
603        let isl_rs_result = unsafe { isl_local_space_wrap(ls) };
604        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
605                                         should_free_on_drop: true };
606        let err = isl_rs_ctx.last_error();
607        if err != Error::None_ {
608            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
609        }
610        Ok(isl_rs_result)
611    }
612
613    /// Does not call isl_local_space_free() on being dropped. (For internal use
614    /// only.)
615    pub fn do_not_free_on_drop(&mut self) {
616        self.should_free_on_drop = false;
617    }
618}
619
620impl Drop for LocalSpace {
621    fn drop(&mut self) {
622        if self.should_free_on_drop {
623            unsafe {
624                isl_local_space_free(self.ptr);
625            }
626        }
627    }
628}