isl_rs/bindings/
space.rs

1// Automatically generated by isl_bindings_generator.
2// LICENSE: MIT
3
4use super::{
5    Aff, AffList, Context, DimType, Error, Id, IdList, LibISLError, Map, MultiAff, MultiId,
6    MultiPwAff, MultiUnionPwAff, MultiVal, PwAffList, PwMultiAff, Set, UnionPwAffList, ValList,
7};
8use libc::uintptr_t;
9use std::ffi::{CStr, CString};
10use std::os::raw::c_char;
11
12/// Wraps `isl_space`.
13pub struct Space {
14    pub ptr: uintptr_t,
15    pub should_free_on_drop: bool,
16}
17
18extern "C" {
19
20    fn isl_space_add_dims(space: uintptr_t, type_: i32, n: u32) -> uintptr_t;
21
22    fn isl_space_add_named_tuple_id_ui(space: uintptr_t, tuple_id: uintptr_t, dim: u32)
23                                       -> uintptr_t;
24
25    fn isl_space_add_param_id(space: uintptr_t, id: uintptr_t) -> uintptr_t;
26
27    fn isl_space_add_unnamed_tuple_ui(space: uintptr_t, dim: u32) -> uintptr_t;
28
29    fn isl_space_align_params(space1: uintptr_t, space2: uintptr_t) -> uintptr_t;
30
31    fn isl_space_alloc(ctx: uintptr_t, nparam: u32, n_in: u32, n_out: u32) -> uintptr_t;
32
33    fn isl_space_can_curry(space: uintptr_t) -> i32;
34
35    fn isl_space_can_range_curry(space: uintptr_t) -> i32;
36
37    fn isl_space_can_uncurry(space: uintptr_t) -> i32;
38
39    fn isl_space_can_zip(space: uintptr_t) -> i32;
40
41    fn isl_space_copy(space: uintptr_t) -> uintptr_t;
42
43    fn isl_space_curry(space: uintptr_t) -> uintptr_t;
44
45    fn isl_space_dim(space: uintptr_t, type_: i32) -> i32;
46
47    fn isl_space_domain(space: uintptr_t) -> uintptr_t;
48
49    fn isl_space_domain_factor_domain(space: uintptr_t) -> uintptr_t;
50
51    fn isl_space_domain_factor_range(space: uintptr_t) -> uintptr_t;
52
53    fn isl_space_domain_is_wrapping(space: uintptr_t) -> i32;
54
55    fn isl_space_domain_map(space: uintptr_t) -> uintptr_t;
56
57    fn isl_space_domain_map_multi_aff(space: uintptr_t) -> uintptr_t;
58
59    fn isl_space_domain_map_pw_multi_aff(space: uintptr_t) -> uintptr_t;
60
61    fn isl_space_domain_product(left: uintptr_t, right: uintptr_t) -> uintptr_t;
62
63    fn isl_space_domain_reverse(space: uintptr_t) -> uintptr_t;
64
65    fn isl_space_domain_wrapped_domain(space: uintptr_t) -> uintptr_t;
66
67    fn isl_space_domain_wrapped_range(space: uintptr_t) -> uintptr_t;
68
69    fn isl_space_drop_all_params(space: uintptr_t) -> uintptr_t;
70
71    fn isl_space_drop_dims(space: uintptr_t, type_: i32, first: u32, num: u32) -> uintptr_t;
72
73    fn isl_space_drop_inputs(space: uintptr_t, first: u32, n: u32) -> uintptr_t;
74
75    fn isl_space_drop_outputs(space: uintptr_t, first: u32, n: u32) -> uintptr_t;
76
77    fn isl_space_dump(space: uintptr_t) -> ();
78
79    fn isl_space_factor_domain(space: uintptr_t) -> uintptr_t;
80
81    fn isl_space_factor_range(space: uintptr_t) -> uintptr_t;
82
83    fn isl_space_find_dim_by_id(space: uintptr_t, type_: i32, id: uintptr_t) -> i32;
84
85    fn isl_space_find_dim_by_name(space: uintptr_t, type_: i32, name: *const c_char) -> i32;
86
87    fn isl_space_flatten_domain(space: uintptr_t) -> uintptr_t;
88
89    fn isl_space_flatten_range(space: uintptr_t) -> uintptr_t;
90
91    fn isl_space_free(space: uintptr_t) -> uintptr_t;
92
93    fn isl_space_from_domain(space: uintptr_t) -> uintptr_t;
94
95    fn isl_space_from_range(space: uintptr_t) -> uintptr_t;
96
97    fn isl_space_get_ctx(space: uintptr_t) -> uintptr_t;
98
99    fn isl_space_get_dim_id(space: uintptr_t, type_: i32, pos: u32) -> uintptr_t;
100
101    fn isl_space_get_dim_name(space: uintptr_t, type_: i32, pos: u32) -> *const c_char;
102
103    fn isl_space_get_domain_tuple_id(space: uintptr_t) -> uintptr_t;
104
105    fn isl_space_get_range_tuple_id(space: uintptr_t) -> uintptr_t;
106
107    fn isl_space_get_tuple_id(space: uintptr_t, type_: i32) -> uintptr_t;
108
109    fn isl_space_get_tuple_name(space: uintptr_t, type_: i32) -> *const c_char;
110
111    fn isl_space_has_dim_id(space: uintptr_t, type_: i32, pos: u32) -> i32;
112
113    fn isl_space_has_dim_name(space: uintptr_t, type_: i32, pos: u32) -> i32;
114
115    fn isl_space_has_domain_tuple_id(space: uintptr_t) -> i32;
116
117    fn isl_space_has_equal_params(space1: uintptr_t, space2: uintptr_t) -> i32;
118
119    fn isl_space_has_equal_tuples(space1: uintptr_t, space2: uintptr_t) -> i32;
120
121    fn isl_space_has_range_tuple_id(space: uintptr_t) -> i32;
122
123    fn isl_space_has_tuple_id(space: uintptr_t, type_: i32) -> i32;
124
125    fn isl_space_has_tuple_name(space: uintptr_t, type_: i32) -> i32;
126
127    fn isl_space_identity_multi_aff_on_domain(space: uintptr_t) -> uintptr_t;
128
129    fn isl_space_identity_multi_pw_aff_on_domain(space: uintptr_t) -> uintptr_t;
130
131    fn isl_space_identity_pw_multi_aff_on_domain(space: uintptr_t) -> uintptr_t;
132
133    fn isl_space_insert_dims(space: uintptr_t, type_: i32, pos: u32, n: u32) -> uintptr_t;
134
135    fn isl_space_is_domain(space1: uintptr_t, space2: uintptr_t) -> i32;
136
137    fn isl_space_is_equal(space1: uintptr_t, space2: uintptr_t) -> i32;
138
139    fn isl_space_is_map(space: uintptr_t) -> i32;
140
141    fn isl_space_is_params(space: uintptr_t) -> i32;
142
143    fn isl_space_is_product(space: uintptr_t) -> i32;
144
145    fn isl_space_is_range(space1: uintptr_t, space2: uintptr_t) -> i32;
146
147    fn isl_space_is_set(space: uintptr_t) -> i32;
148
149    fn isl_space_is_wrapping(space: uintptr_t) -> i32;
150
151    fn isl_space_join(left: uintptr_t, right: uintptr_t) -> uintptr_t;
152
153    fn isl_space_map_from_domain_and_range(domain: uintptr_t, range: uintptr_t) -> uintptr_t;
154
155    fn isl_space_map_from_set(space: uintptr_t) -> uintptr_t;
156
157    fn isl_space_match(space1: uintptr_t, type1: i32, space2: uintptr_t, type2: i32) -> i32;
158
159    fn isl_space_move_dims(space: uintptr_t, dst_type: i32, dst_pos: u32, src_type: i32,
160                           src_pos: u32, n: u32)
161                           -> uintptr_t;
162
163    fn isl_space_multi_aff(space: uintptr_t, list: uintptr_t) -> uintptr_t;
164
165    fn isl_space_multi_aff_on_domain_multi_val(space: uintptr_t, mv: uintptr_t) -> uintptr_t;
166
167    fn isl_space_multi_id(space: uintptr_t, list: uintptr_t) -> uintptr_t;
168
169    fn isl_space_multi_pw_aff(space: uintptr_t, list: uintptr_t) -> uintptr_t;
170
171    fn isl_space_multi_union_pw_aff(space: uintptr_t, list: uintptr_t) -> uintptr_t;
172
173    fn isl_space_multi_val(space: uintptr_t, list: uintptr_t) -> uintptr_t;
174
175    fn isl_space_param_aff_on_domain_id(space: uintptr_t, id: uintptr_t) -> uintptr_t;
176
177    fn isl_space_params(space: uintptr_t) -> uintptr_t;
178
179    fn isl_space_params_alloc(ctx: uintptr_t, nparam: u32) -> uintptr_t;
180
181    fn isl_space_product(left: uintptr_t, right: uintptr_t) -> uintptr_t;
182
183    fn isl_space_range(space: uintptr_t) -> uintptr_t;
184
185    fn isl_space_range_curry(space: uintptr_t) -> uintptr_t;
186
187    fn isl_space_range_factor_domain(space: uintptr_t) -> uintptr_t;
188
189    fn isl_space_range_factor_range(space: uintptr_t) -> uintptr_t;
190
191    fn isl_space_range_is_wrapping(space: uintptr_t) -> i32;
192
193    fn isl_space_range_map(space: uintptr_t) -> uintptr_t;
194
195    fn isl_space_range_map_multi_aff(space: uintptr_t) -> uintptr_t;
196
197    fn isl_space_range_map_pw_multi_aff(space: uintptr_t) -> uintptr_t;
198
199    fn isl_space_range_product(left: uintptr_t, right: uintptr_t) -> uintptr_t;
200
201    fn isl_space_range_reverse(space: uintptr_t) -> uintptr_t;
202
203    fn isl_space_range_wrapped_domain(space: uintptr_t) -> uintptr_t;
204
205    fn isl_space_range_wrapped_range(space: uintptr_t) -> uintptr_t;
206
207    fn isl_space_read_from_str(ctx: uintptr_t, str_: *const c_char) -> uintptr_t;
208
209    fn isl_space_reset_tuple_id(space: uintptr_t, type_: i32) -> uintptr_t;
210
211    fn isl_space_reset_user(space: uintptr_t) -> uintptr_t;
212
213    fn isl_space_reverse(space: uintptr_t) -> uintptr_t;
214
215    fn isl_space_set_alloc(ctx: uintptr_t, nparam: u32, dim: u32) -> uintptr_t;
216
217    fn isl_space_set_dim_id(space: uintptr_t, type_: i32, pos: u32, id: uintptr_t) -> uintptr_t;
218
219    fn isl_space_set_dim_name(space: uintptr_t, type_: i32, pos: u32, name: *const c_char)
220                              -> uintptr_t;
221
222    fn isl_space_set_domain_tuple_id(space: uintptr_t, id: uintptr_t) -> uintptr_t;
223
224    fn isl_space_set_from_params(space: uintptr_t) -> uintptr_t;
225
226    fn isl_space_set_range_tuple_id(space: uintptr_t, id: uintptr_t) -> uintptr_t;
227
228    fn isl_space_set_tuple_id(space: uintptr_t, type_: i32, id: uintptr_t) -> uintptr_t;
229
230    fn isl_space_set_tuple_name(space: uintptr_t, type_: i32, s: *const c_char) -> uintptr_t;
231
232    fn isl_space_to_str(space: uintptr_t) -> *const c_char;
233
234    fn isl_space_tuple_is_equal(space1: uintptr_t, type1: i32, space2: uintptr_t, type2: i32)
235                                -> i32;
236
237    fn isl_space_uncurry(space: uintptr_t) -> uintptr_t;
238
239    fn isl_space_unit(ctx: uintptr_t) -> uintptr_t;
240
241    fn isl_space_universe_map(space: uintptr_t) -> uintptr_t;
242
243    fn isl_space_universe_set(space: uintptr_t) -> uintptr_t;
244
245    fn isl_space_unwrap(space: uintptr_t) -> uintptr_t;
246
247    fn isl_space_wrap(space: uintptr_t) -> uintptr_t;
248
249    fn isl_space_wrapped_reverse(space: uintptr_t) -> uintptr_t;
250
251    fn isl_space_zero_aff_on_domain(space: uintptr_t) -> uintptr_t;
252
253    fn isl_space_zero_multi_aff(space: uintptr_t) -> uintptr_t;
254
255    fn isl_space_zero_multi_pw_aff(space: uintptr_t) -> uintptr_t;
256
257    fn isl_space_zero_multi_union_pw_aff(space: uintptr_t) -> uintptr_t;
258
259    fn isl_space_zero_multi_val(space: uintptr_t) -> uintptr_t;
260
261    fn isl_space_zip(space: uintptr_t) -> uintptr_t;
262
263}
264
265impl Space {
266    /// Wraps `isl_space_add_dims`.
267    pub fn add_dims(self, type_: DimType, n: u32) -> Result<Space, LibISLError> {
268        let space = self;
269        let isl_rs_ctx = space.get_ctx();
270        let mut space = space;
271        space.do_not_free_on_drop();
272        let space = space.ptr;
273        let type_ = type_.to_i32();
274        let isl_rs_result = unsafe { isl_space_add_dims(space, type_, n) };
275        let isl_rs_result = Space { ptr: isl_rs_result,
276                                    should_free_on_drop: true };
277        let err = isl_rs_ctx.last_error();
278        if err != Error::None_ {
279            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
280        }
281        Ok(isl_rs_result)
282    }
283
284    /// Wraps `isl_space_add_named_tuple_id_ui`.
285    pub fn add_named_tuple_id_ui(self, tuple_id: Id, dim: u32) -> Result<Space, LibISLError> {
286        let space = self;
287        let isl_rs_ctx = space.get_ctx();
288        let mut space = space;
289        space.do_not_free_on_drop();
290        let space = space.ptr;
291        let mut tuple_id = tuple_id;
292        tuple_id.do_not_free_on_drop();
293        let tuple_id = tuple_id.ptr;
294        let isl_rs_result = unsafe { isl_space_add_named_tuple_id_ui(space, tuple_id, dim) };
295        let isl_rs_result = Space { 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_space_add_param_id`.
305    pub fn add_param_id(self, id: Id) -> Result<Space, LibISLError> {
306        let space = self;
307        let isl_rs_ctx = space.get_ctx();
308        let mut space = space;
309        space.do_not_free_on_drop();
310        let space = space.ptr;
311        let mut id = id;
312        id.do_not_free_on_drop();
313        let id = id.ptr;
314        let isl_rs_result = unsafe { isl_space_add_param_id(space, id) };
315        let isl_rs_result = Space { ptr: isl_rs_result,
316                                    should_free_on_drop: true };
317        let err = isl_rs_ctx.last_error();
318        if err != Error::None_ {
319            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
320        }
321        Ok(isl_rs_result)
322    }
323
324    /// Wraps `isl_space_add_unnamed_tuple_ui`.
325    pub fn add_unnamed_tuple_ui(self, dim: u32) -> Result<Space, LibISLError> {
326        let space = self;
327        let isl_rs_ctx = space.get_ctx();
328        let mut space = space;
329        space.do_not_free_on_drop();
330        let space = space.ptr;
331        let isl_rs_result = unsafe { isl_space_add_unnamed_tuple_ui(space, dim) };
332        let isl_rs_result = Space { ptr: isl_rs_result,
333                                    should_free_on_drop: true };
334        let err = isl_rs_ctx.last_error();
335        if err != Error::None_ {
336            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
337        }
338        Ok(isl_rs_result)
339    }
340
341    /// Wraps `isl_space_align_params`.
342    pub fn align_params(self, space2: Space) -> Result<Space, LibISLError> {
343        let space1 = self;
344        let isl_rs_ctx = space1.get_ctx();
345        let mut space1 = space1;
346        space1.do_not_free_on_drop();
347        let space1 = space1.ptr;
348        let mut space2 = space2;
349        space2.do_not_free_on_drop();
350        let space2 = space2.ptr;
351        let isl_rs_result = unsafe { isl_space_align_params(space1, space2) };
352        let isl_rs_result = Space { 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_space_alloc`.
362    pub fn alloc(ctx: &Context, nparam: u32, n_in: u32, n_out: u32) -> Result<Space, LibISLError> {
363        let isl_rs_ctx = Context { ptr: ctx.ptr,
364                                   should_free_on_drop: false };
365        let ctx = ctx.ptr;
366        let isl_rs_result = unsafe { isl_space_alloc(ctx, nparam, n_in, n_out) };
367        let isl_rs_result = Space { ptr: isl_rs_result,
368                                    should_free_on_drop: true };
369        let err = isl_rs_ctx.last_error();
370        if err != Error::None_ {
371            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
372        }
373        Ok(isl_rs_result)
374    }
375
376    /// Wraps `isl_space_can_curry`.
377    pub fn can_curry(&self) -> Result<bool, LibISLError> {
378        let space = self;
379        let isl_rs_ctx = space.get_ctx();
380        let space = space.ptr;
381        let isl_rs_result = unsafe { isl_space_can_curry(space) };
382        let isl_rs_result = match isl_rs_result {
383            0 => false,
384            1 => true,
385            _ => panic!("Got isl_bool = -1"),
386        };
387        let err = isl_rs_ctx.last_error();
388        if err != Error::None_ {
389            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
390        }
391        Ok(isl_rs_result)
392    }
393
394    /// Wraps `isl_space_can_range_curry`.
395    pub fn can_range_curry(&self) -> Result<bool, LibISLError> {
396        let space = self;
397        let isl_rs_ctx = space.get_ctx();
398        let space = space.ptr;
399        let isl_rs_result = unsafe { isl_space_can_range_curry(space) };
400        let isl_rs_result = match isl_rs_result {
401            0 => false,
402            1 => true,
403            _ => panic!("Got isl_bool = -1"),
404        };
405        let err = isl_rs_ctx.last_error();
406        if err != Error::None_ {
407            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
408        }
409        Ok(isl_rs_result)
410    }
411
412    /// Wraps `isl_space_can_uncurry`.
413    pub fn can_uncurry(&self) -> Result<bool, LibISLError> {
414        let space = self;
415        let isl_rs_ctx = space.get_ctx();
416        let space = space.ptr;
417        let isl_rs_result = unsafe { isl_space_can_uncurry(space) };
418        let isl_rs_result = match isl_rs_result {
419            0 => false,
420            1 => true,
421            _ => panic!("Got isl_bool = -1"),
422        };
423        let err = isl_rs_ctx.last_error();
424        if err != Error::None_ {
425            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
426        }
427        Ok(isl_rs_result)
428    }
429
430    /// Wraps `isl_space_can_zip`.
431    pub fn can_zip(&self) -> Result<bool, LibISLError> {
432        let space = self;
433        let isl_rs_ctx = space.get_ctx();
434        let space = space.ptr;
435        let isl_rs_result = unsafe { isl_space_can_zip(space) };
436        let isl_rs_result = match isl_rs_result {
437            0 => false,
438            1 => true,
439            _ => panic!("Got isl_bool = -1"),
440        };
441        let err = isl_rs_ctx.last_error();
442        if err != Error::None_ {
443            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
444        }
445        Ok(isl_rs_result)
446    }
447
448    /// Wraps `isl_space_copy`.
449    pub fn copy(&self) -> Result<Space, LibISLError> {
450        let space = self;
451        let isl_rs_ctx = space.get_ctx();
452        let space = space.ptr;
453        let isl_rs_result = unsafe { isl_space_copy(space) };
454        let isl_rs_result = Space { ptr: isl_rs_result,
455                                    should_free_on_drop: true };
456        let err = isl_rs_ctx.last_error();
457        if err != Error::None_ {
458            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
459        }
460        Ok(isl_rs_result)
461    }
462
463    /// Wraps `isl_space_curry`.
464    pub fn curry(self) -> Result<Space, LibISLError> {
465        let space = self;
466        let isl_rs_ctx = space.get_ctx();
467        let mut space = space;
468        space.do_not_free_on_drop();
469        let space = space.ptr;
470        let isl_rs_result = unsafe { isl_space_curry(space) };
471        let isl_rs_result = Space { ptr: isl_rs_result,
472                                    should_free_on_drop: true };
473        let err = isl_rs_ctx.last_error();
474        if err != Error::None_ {
475            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
476        }
477        Ok(isl_rs_result)
478    }
479
480    /// Wraps `isl_space_dim`.
481    pub fn dim(&self, type_: DimType) -> Result<i32, LibISLError> {
482        let space = self;
483        let isl_rs_ctx = space.get_ctx();
484        let space = space.ptr;
485        let type_ = type_.to_i32();
486        let isl_rs_result = unsafe { isl_space_dim(space, type_) };
487        let err = isl_rs_ctx.last_error();
488        if err != Error::None_ {
489            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
490        }
491        Ok(isl_rs_result)
492    }
493
494    /// Wraps `isl_space_domain`.
495    pub fn domain(self) -> Result<Space, LibISLError> {
496        let space = self;
497        let isl_rs_ctx = space.get_ctx();
498        let mut space = space;
499        space.do_not_free_on_drop();
500        let space = space.ptr;
501        let isl_rs_result = unsafe { isl_space_domain(space) };
502        let isl_rs_result = Space { ptr: isl_rs_result,
503                                    should_free_on_drop: true };
504        let err = isl_rs_ctx.last_error();
505        if err != Error::None_ {
506            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
507        }
508        Ok(isl_rs_result)
509    }
510
511    /// Wraps `isl_space_domain_factor_domain`.
512    pub fn domain_factor_domain(self) -> Result<Space, LibISLError> {
513        let space = self;
514        let isl_rs_ctx = space.get_ctx();
515        let mut space = space;
516        space.do_not_free_on_drop();
517        let space = space.ptr;
518        let isl_rs_result = unsafe { isl_space_domain_factor_domain(space) };
519        let isl_rs_result = Space { ptr: isl_rs_result,
520                                    should_free_on_drop: true };
521        let err = isl_rs_ctx.last_error();
522        if err != Error::None_ {
523            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
524        }
525        Ok(isl_rs_result)
526    }
527
528    /// Wraps `isl_space_domain_factor_range`.
529    pub fn domain_factor_range(self) -> Result<Space, LibISLError> {
530        let space = self;
531        let isl_rs_ctx = space.get_ctx();
532        let mut space = space;
533        space.do_not_free_on_drop();
534        let space = space.ptr;
535        let isl_rs_result = unsafe { isl_space_domain_factor_range(space) };
536        let isl_rs_result = Space { ptr: isl_rs_result,
537                                    should_free_on_drop: true };
538        let err = isl_rs_ctx.last_error();
539        if err != Error::None_ {
540            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
541        }
542        Ok(isl_rs_result)
543    }
544
545    /// Wraps `isl_space_domain_is_wrapping`.
546    pub fn domain_is_wrapping(&self) -> Result<bool, LibISLError> {
547        let space = self;
548        let isl_rs_ctx = space.get_ctx();
549        let space = space.ptr;
550        let isl_rs_result = unsafe { isl_space_domain_is_wrapping(space) };
551        let isl_rs_result = match isl_rs_result {
552            0 => false,
553            1 => true,
554            _ => panic!("Got isl_bool = -1"),
555        };
556        let err = isl_rs_ctx.last_error();
557        if err != Error::None_ {
558            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
559        }
560        Ok(isl_rs_result)
561    }
562
563    /// Wraps `isl_space_domain_map`.
564    pub fn domain_map(self) -> Result<Space, LibISLError> {
565        let space = self;
566        let isl_rs_ctx = space.get_ctx();
567        let mut space = space;
568        space.do_not_free_on_drop();
569        let space = space.ptr;
570        let isl_rs_result = unsafe { isl_space_domain_map(space) };
571        let isl_rs_result = Space { ptr: isl_rs_result,
572                                    should_free_on_drop: true };
573        let err = isl_rs_ctx.last_error();
574        if err != Error::None_ {
575            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
576        }
577        Ok(isl_rs_result)
578    }
579
580    /// Wraps `isl_space_domain_map_multi_aff`.
581    pub fn domain_map_multi_aff(self) -> Result<MultiAff, LibISLError> {
582        let space = self;
583        let isl_rs_ctx = space.get_ctx();
584        let mut space = space;
585        space.do_not_free_on_drop();
586        let space = space.ptr;
587        let isl_rs_result = unsafe { isl_space_domain_map_multi_aff(space) };
588        let isl_rs_result = MultiAff { ptr: isl_rs_result,
589                                       should_free_on_drop: true };
590        let err = isl_rs_ctx.last_error();
591        if err != Error::None_ {
592            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
593        }
594        Ok(isl_rs_result)
595    }
596
597    /// Wraps `isl_space_domain_map_pw_multi_aff`.
598    pub fn domain_map_pw_multi_aff(self) -> Result<PwMultiAff, LibISLError> {
599        let space = self;
600        let isl_rs_ctx = space.get_ctx();
601        let mut space = space;
602        space.do_not_free_on_drop();
603        let space = space.ptr;
604        let isl_rs_result = unsafe { isl_space_domain_map_pw_multi_aff(space) };
605        let isl_rs_result = PwMultiAff { ptr: isl_rs_result,
606                                         should_free_on_drop: true };
607        let err = isl_rs_ctx.last_error();
608        if err != Error::None_ {
609            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
610        }
611        Ok(isl_rs_result)
612    }
613
614    /// Wraps `isl_space_domain_product`.
615    pub fn domain_product(self, right: Space) -> Result<Space, LibISLError> {
616        let left = self;
617        let isl_rs_ctx = left.get_ctx();
618        let mut left = left;
619        left.do_not_free_on_drop();
620        let left = left.ptr;
621        let mut right = right;
622        right.do_not_free_on_drop();
623        let right = right.ptr;
624        let isl_rs_result = unsafe { isl_space_domain_product(left, right) };
625        let isl_rs_result = Space { ptr: isl_rs_result,
626                                    should_free_on_drop: true };
627        let err = isl_rs_ctx.last_error();
628        if err != Error::None_ {
629            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
630        }
631        Ok(isl_rs_result)
632    }
633
634    /// Wraps `isl_space_domain_reverse`.
635    pub fn domain_reverse(self) -> Result<Space, LibISLError> {
636        let space = self;
637        let isl_rs_ctx = space.get_ctx();
638        let mut space = space;
639        space.do_not_free_on_drop();
640        let space = space.ptr;
641        let isl_rs_result = unsafe { isl_space_domain_reverse(space) };
642        let isl_rs_result = Space { ptr: isl_rs_result,
643                                    should_free_on_drop: true };
644        let err = isl_rs_ctx.last_error();
645        if err != Error::None_ {
646            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
647        }
648        Ok(isl_rs_result)
649    }
650
651    /// Wraps `isl_space_domain_wrapped_domain`.
652    pub fn domain_wrapped_domain(self) -> Result<Space, LibISLError> {
653        let space = self;
654        let isl_rs_ctx = space.get_ctx();
655        let mut space = space;
656        space.do_not_free_on_drop();
657        let space = space.ptr;
658        let isl_rs_result = unsafe { isl_space_domain_wrapped_domain(space) };
659        let isl_rs_result = Space { ptr: isl_rs_result,
660                                    should_free_on_drop: true };
661        let err = isl_rs_ctx.last_error();
662        if err != Error::None_ {
663            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
664        }
665        Ok(isl_rs_result)
666    }
667
668    /// Wraps `isl_space_domain_wrapped_range`.
669    pub fn domain_wrapped_range(self) -> Result<Space, LibISLError> {
670        let space = self;
671        let isl_rs_ctx = space.get_ctx();
672        let mut space = space;
673        space.do_not_free_on_drop();
674        let space = space.ptr;
675        let isl_rs_result = unsafe { isl_space_domain_wrapped_range(space) };
676        let isl_rs_result = Space { ptr: isl_rs_result,
677                                    should_free_on_drop: true };
678        let err = isl_rs_ctx.last_error();
679        if err != Error::None_ {
680            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
681        }
682        Ok(isl_rs_result)
683    }
684
685    /// Wraps `isl_space_drop_all_params`.
686    pub fn drop_all_params(self) -> Result<Space, LibISLError> {
687        let space = self;
688        let isl_rs_ctx = space.get_ctx();
689        let mut space = space;
690        space.do_not_free_on_drop();
691        let space = space.ptr;
692        let isl_rs_result = unsafe { isl_space_drop_all_params(space) };
693        let isl_rs_result = Space { ptr: isl_rs_result,
694                                    should_free_on_drop: true };
695        let err = isl_rs_ctx.last_error();
696        if err != Error::None_ {
697            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
698        }
699        Ok(isl_rs_result)
700    }
701
702    /// Wraps `isl_space_drop_dims`.
703    pub fn drop_dims(self, type_: DimType, first: u32, num: u32) -> Result<Space, LibISLError> {
704        let space = self;
705        let isl_rs_ctx = space.get_ctx();
706        let mut space = space;
707        space.do_not_free_on_drop();
708        let space = space.ptr;
709        let type_ = type_.to_i32();
710        let isl_rs_result = unsafe { isl_space_drop_dims(space, type_, first, num) };
711        let isl_rs_result = Space { ptr: isl_rs_result,
712                                    should_free_on_drop: true };
713        let err = isl_rs_ctx.last_error();
714        if err != Error::None_ {
715            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
716        }
717        Ok(isl_rs_result)
718    }
719
720    /// Wraps `isl_space_drop_inputs`.
721    pub fn drop_inputs(self, first: u32, n: u32) -> Result<Space, LibISLError> {
722        let space = self;
723        let isl_rs_ctx = space.get_ctx();
724        let mut space = space;
725        space.do_not_free_on_drop();
726        let space = space.ptr;
727        let isl_rs_result = unsafe { isl_space_drop_inputs(space, first, n) };
728        let isl_rs_result = Space { ptr: isl_rs_result,
729                                    should_free_on_drop: true };
730        let err = isl_rs_ctx.last_error();
731        if err != Error::None_ {
732            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
733        }
734        Ok(isl_rs_result)
735    }
736
737    /// Wraps `isl_space_drop_outputs`.
738    pub fn drop_outputs(self, first: u32, n: u32) -> Result<Space, LibISLError> {
739        let space = self;
740        let isl_rs_ctx = space.get_ctx();
741        let mut space = space;
742        space.do_not_free_on_drop();
743        let space = space.ptr;
744        let isl_rs_result = unsafe { isl_space_drop_outputs(space, first, n) };
745        let isl_rs_result = Space { ptr: isl_rs_result,
746                                    should_free_on_drop: true };
747        let err = isl_rs_ctx.last_error();
748        if err != Error::None_ {
749            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
750        }
751        Ok(isl_rs_result)
752    }
753
754    /// Wraps `isl_space_dump`.
755    pub fn dump(&self) -> Result<(), LibISLError> {
756        let space = self;
757        let isl_rs_ctx = space.get_ctx();
758        let space = space.ptr;
759        let isl_rs_result = unsafe { isl_space_dump(space) };
760        let err = isl_rs_ctx.last_error();
761        if err != Error::None_ {
762            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
763        }
764        Ok(isl_rs_result)
765    }
766
767    /// Wraps `isl_space_factor_domain`.
768    pub fn factor_domain(self) -> Result<Space, LibISLError> {
769        let space = self;
770        let isl_rs_ctx = space.get_ctx();
771        let mut space = space;
772        space.do_not_free_on_drop();
773        let space = space.ptr;
774        let isl_rs_result = unsafe { isl_space_factor_domain(space) };
775        let isl_rs_result = Space { ptr: isl_rs_result,
776                                    should_free_on_drop: true };
777        let err = isl_rs_ctx.last_error();
778        if err != Error::None_ {
779            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
780        }
781        Ok(isl_rs_result)
782    }
783
784    /// Wraps `isl_space_factor_range`.
785    pub fn factor_range(self) -> Result<Space, LibISLError> {
786        let space = self;
787        let isl_rs_ctx = space.get_ctx();
788        let mut space = space;
789        space.do_not_free_on_drop();
790        let space = space.ptr;
791        let isl_rs_result = unsafe { isl_space_factor_range(space) };
792        let isl_rs_result = Space { ptr: isl_rs_result,
793                                    should_free_on_drop: true };
794        let err = isl_rs_ctx.last_error();
795        if err != Error::None_ {
796            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
797        }
798        Ok(isl_rs_result)
799    }
800
801    /// Wraps `isl_space_find_dim_by_id`.
802    pub fn find_dim_by_id(&self, type_: DimType, id: &Id) -> Result<i32, LibISLError> {
803        let space = self;
804        let isl_rs_ctx = space.get_ctx();
805        let space = space.ptr;
806        let type_ = type_.to_i32();
807        let id = id.ptr;
808        let isl_rs_result = unsafe { isl_space_find_dim_by_id(space, type_, id) };
809        let err = isl_rs_ctx.last_error();
810        if err != Error::None_ {
811            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
812        }
813        Ok(isl_rs_result)
814    }
815
816    /// Wraps `isl_space_find_dim_by_name`.
817    pub fn find_dim_by_name(&self, type_: DimType, name: &str) -> Result<i32, LibISLError> {
818        let space = self;
819        let isl_rs_ctx = space.get_ctx();
820        let space = space.ptr;
821        let type_ = type_.to_i32();
822        let name = CString::new(name).unwrap();
823        let name = name.as_ptr();
824        let isl_rs_result = unsafe { isl_space_find_dim_by_name(space, type_, name) };
825        let err = isl_rs_ctx.last_error();
826        if err != Error::None_ {
827            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
828        }
829        Ok(isl_rs_result)
830    }
831
832    /// Wraps `isl_space_flatten_domain`.
833    pub fn flatten_domain(self) -> Result<Space, LibISLError> {
834        let space = self;
835        let isl_rs_ctx = space.get_ctx();
836        let mut space = space;
837        space.do_not_free_on_drop();
838        let space = space.ptr;
839        let isl_rs_result = unsafe { isl_space_flatten_domain(space) };
840        let isl_rs_result = Space { ptr: isl_rs_result,
841                                    should_free_on_drop: true };
842        let err = isl_rs_ctx.last_error();
843        if err != Error::None_ {
844            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
845        }
846        Ok(isl_rs_result)
847    }
848
849    /// Wraps `isl_space_flatten_range`.
850    pub fn flatten_range(self) -> Result<Space, LibISLError> {
851        let space = self;
852        let isl_rs_ctx = space.get_ctx();
853        let mut space = space;
854        space.do_not_free_on_drop();
855        let space = space.ptr;
856        let isl_rs_result = unsafe { isl_space_flatten_range(space) };
857        let isl_rs_result = Space { ptr: isl_rs_result,
858                                    should_free_on_drop: true };
859        let err = isl_rs_ctx.last_error();
860        if err != Error::None_ {
861            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
862        }
863        Ok(isl_rs_result)
864    }
865
866    /// Wraps `isl_space_free`.
867    pub fn free(self) -> Result<Space, LibISLError> {
868        let space = self;
869        let isl_rs_ctx = space.get_ctx();
870        let mut space = space;
871        space.do_not_free_on_drop();
872        let space = space.ptr;
873        let isl_rs_result = unsafe { isl_space_free(space) };
874        let isl_rs_result = Space { ptr: isl_rs_result,
875                                    should_free_on_drop: true };
876        let err = isl_rs_ctx.last_error();
877        if err != Error::None_ {
878            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
879        }
880        Ok(isl_rs_result)
881    }
882
883    /// Wraps `isl_space_from_domain`.
884    pub fn from_domain(self) -> Result<Space, LibISLError> {
885        let space = self;
886        let isl_rs_ctx = space.get_ctx();
887        let mut space = space;
888        space.do_not_free_on_drop();
889        let space = space.ptr;
890        let isl_rs_result = unsafe { isl_space_from_domain(space) };
891        let isl_rs_result = Space { ptr: isl_rs_result,
892                                    should_free_on_drop: true };
893        let err = isl_rs_ctx.last_error();
894        if err != Error::None_ {
895            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
896        }
897        Ok(isl_rs_result)
898    }
899
900    /// Wraps `isl_space_from_range`.
901    pub fn from_range(self) -> Result<Space, LibISLError> {
902        let space = self;
903        let isl_rs_ctx = space.get_ctx();
904        let mut space = space;
905        space.do_not_free_on_drop();
906        let space = space.ptr;
907        let isl_rs_result = unsafe { isl_space_from_range(space) };
908        let isl_rs_result = Space { ptr: isl_rs_result,
909                                    should_free_on_drop: true };
910        let err = isl_rs_ctx.last_error();
911        if err != Error::None_ {
912            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
913        }
914        Ok(isl_rs_result)
915    }
916
917    /// Wraps `isl_space_get_ctx`.
918    pub fn get_ctx(&self) -> Context {
919        let space = self;
920        let space = space.ptr;
921        let isl_rs_result = unsafe { isl_space_get_ctx(space) };
922        let isl_rs_result = Context { ptr: isl_rs_result,
923                                      should_free_on_drop: false };
924        isl_rs_result
925    }
926
927    /// Wraps `isl_space_get_dim_id`.
928    pub fn get_dim_id(&self, type_: DimType, pos: u32) -> Result<Id, LibISLError> {
929        let space = self;
930        let isl_rs_ctx = space.get_ctx();
931        let space = space.ptr;
932        let type_ = type_.to_i32();
933        let isl_rs_result = unsafe { isl_space_get_dim_id(space, type_, pos) };
934        let isl_rs_result = Id { ptr: isl_rs_result,
935                                 should_free_on_drop: true };
936        let err = isl_rs_ctx.last_error();
937        if err != Error::None_ {
938            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
939        }
940        Ok(isl_rs_result)
941    }
942
943    /// Wraps `isl_space_get_dim_name`.
944    pub fn get_dim_name(&self, type_: DimType, pos: u32) -> Result<&str, LibISLError> {
945        let space = self;
946        let isl_rs_ctx = space.get_ctx();
947        let space = space.ptr;
948        let type_ = type_.to_i32();
949        let isl_rs_result = unsafe { isl_space_get_dim_name(space, type_, pos) };
950        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
951        let isl_rs_result = isl_rs_result.to_str().unwrap();
952        let err = isl_rs_ctx.last_error();
953        if err != Error::None_ {
954            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
955        }
956        Ok(isl_rs_result)
957    }
958
959    /// Wraps `isl_space_get_domain_tuple_id`.
960    pub fn get_domain_tuple_id(&self) -> Result<Id, LibISLError> {
961        let space = self;
962        let isl_rs_ctx = space.get_ctx();
963        let space = space.ptr;
964        let isl_rs_result = unsafe { isl_space_get_domain_tuple_id(space) };
965        let isl_rs_result = Id { ptr: isl_rs_result,
966                                 should_free_on_drop: true };
967        let err = isl_rs_ctx.last_error();
968        if err != Error::None_ {
969            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
970        }
971        Ok(isl_rs_result)
972    }
973
974    /// Wraps `isl_space_get_range_tuple_id`.
975    pub fn get_range_tuple_id(&self) -> Result<Id, LibISLError> {
976        let space = self;
977        let isl_rs_ctx = space.get_ctx();
978        let space = space.ptr;
979        let isl_rs_result = unsafe { isl_space_get_range_tuple_id(space) };
980        let isl_rs_result = Id { ptr: isl_rs_result,
981                                 should_free_on_drop: true };
982        let err = isl_rs_ctx.last_error();
983        if err != Error::None_ {
984            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
985        }
986        Ok(isl_rs_result)
987    }
988
989    /// Wraps `isl_space_get_tuple_id`.
990    pub fn get_tuple_id(&self, type_: DimType) -> Result<Id, LibISLError> {
991        let space = self;
992        let isl_rs_ctx = space.get_ctx();
993        let space = space.ptr;
994        let type_ = type_.to_i32();
995        let isl_rs_result = unsafe { isl_space_get_tuple_id(space, type_) };
996        let isl_rs_result = Id { ptr: isl_rs_result,
997                                 should_free_on_drop: true };
998        let err = isl_rs_ctx.last_error();
999        if err != Error::None_ {
1000            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1001        }
1002        Ok(isl_rs_result)
1003    }
1004
1005    /// Wraps `isl_space_get_tuple_name`.
1006    pub fn get_tuple_name(&self, type_: DimType) -> Result<&str, LibISLError> {
1007        let space = self;
1008        let isl_rs_ctx = space.get_ctx();
1009        let space = space.ptr;
1010        let type_ = type_.to_i32();
1011        let isl_rs_result = unsafe { isl_space_get_tuple_name(space, type_) };
1012        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
1013        let isl_rs_result = isl_rs_result.to_str().unwrap();
1014        let err = isl_rs_ctx.last_error();
1015        if err != Error::None_ {
1016            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1017        }
1018        Ok(isl_rs_result)
1019    }
1020
1021    /// Wraps `isl_space_has_dim_id`.
1022    pub fn has_dim_id(&self, type_: DimType, pos: u32) -> Result<bool, LibISLError> {
1023        let space = self;
1024        let isl_rs_ctx = space.get_ctx();
1025        let space = space.ptr;
1026        let type_ = type_.to_i32();
1027        let isl_rs_result = unsafe { isl_space_has_dim_id(space, type_, pos) };
1028        let isl_rs_result = match isl_rs_result {
1029            0 => false,
1030            1 => true,
1031            _ => panic!("Got isl_bool = -1"),
1032        };
1033        let err = isl_rs_ctx.last_error();
1034        if err != Error::None_ {
1035            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1036        }
1037        Ok(isl_rs_result)
1038    }
1039
1040    /// Wraps `isl_space_has_dim_name`.
1041    pub fn has_dim_name(&self, type_: DimType, pos: u32) -> Result<bool, LibISLError> {
1042        let space = self;
1043        let isl_rs_ctx = space.get_ctx();
1044        let space = space.ptr;
1045        let type_ = type_.to_i32();
1046        let isl_rs_result = unsafe { isl_space_has_dim_name(space, type_, pos) };
1047        let isl_rs_result = match isl_rs_result {
1048            0 => false,
1049            1 => true,
1050            _ => panic!("Got isl_bool = -1"),
1051        };
1052        let err = isl_rs_ctx.last_error();
1053        if err != Error::None_ {
1054            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1055        }
1056        Ok(isl_rs_result)
1057    }
1058
1059    /// Wraps `isl_space_has_domain_tuple_id`.
1060    pub fn has_domain_tuple_id(&self) -> Result<bool, LibISLError> {
1061        let space = self;
1062        let isl_rs_ctx = space.get_ctx();
1063        let space = space.ptr;
1064        let isl_rs_result = unsafe { isl_space_has_domain_tuple_id(space) };
1065        let isl_rs_result = match isl_rs_result {
1066            0 => false,
1067            1 => true,
1068            _ => panic!("Got isl_bool = -1"),
1069        };
1070        let err = isl_rs_ctx.last_error();
1071        if err != Error::None_ {
1072            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1073        }
1074        Ok(isl_rs_result)
1075    }
1076
1077    /// Wraps `isl_space_has_equal_params`.
1078    pub fn has_equal_params(&self, space2: &Space) -> Result<bool, LibISLError> {
1079        let space1 = self;
1080        let isl_rs_ctx = space1.get_ctx();
1081        let space1 = space1.ptr;
1082        let space2 = space2.ptr;
1083        let isl_rs_result = unsafe { isl_space_has_equal_params(space1, space2) };
1084        let isl_rs_result = match isl_rs_result {
1085            0 => false,
1086            1 => true,
1087            _ => panic!("Got isl_bool = -1"),
1088        };
1089        let err = isl_rs_ctx.last_error();
1090        if err != Error::None_ {
1091            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1092        }
1093        Ok(isl_rs_result)
1094    }
1095
1096    /// Wraps `isl_space_has_equal_tuples`.
1097    pub fn has_equal_tuples(&self, space2: &Space) -> Result<bool, LibISLError> {
1098        let space1 = self;
1099        let isl_rs_ctx = space1.get_ctx();
1100        let space1 = space1.ptr;
1101        let space2 = space2.ptr;
1102        let isl_rs_result = unsafe { isl_space_has_equal_tuples(space1, space2) };
1103        let isl_rs_result = match isl_rs_result {
1104            0 => false,
1105            1 => true,
1106            _ => panic!("Got isl_bool = -1"),
1107        };
1108        let err = isl_rs_ctx.last_error();
1109        if err != Error::None_ {
1110            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1111        }
1112        Ok(isl_rs_result)
1113    }
1114
1115    /// Wraps `isl_space_has_range_tuple_id`.
1116    pub fn has_range_tuple_id(&self) -> Result<bool, LibISLError> {
1117        let space = self;
1118        let isl_rs_ctx = space.get_ctx();
1119        let space = space.ptr;
1120        let isl_rs_result = unsafe { isl_space_has_range_tuple_id(space) };
1121        let isl_rs_result = match isl_rs_result {
1122            0 => false,
1123            1 => true,
1124            _ => panic!("Got isl_bool = -1"),
1125        };
1126        let err = isl_rs_ctx.last_error();
1127        if err != Error::None_ {
1128            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1129        }
1130        Ok(isl_rs_result)
1131    }
1132
1133    /// Wraps `isl_space_has_tuple_id`.
1134    pub fn has_tuple_id(&self, type_: DimType) -> Result<bool, LibISLError> {
1135        let space = self;
1136        let isl_rs_ctx = space.get_ctx();
1137        let space = space.ptr;
1138        let type_ = type_.to_i32();
1139        let isl_rs_result = unsafe { isl_space_has_tuple_id(space, type_) };
1140        let isl_rs_result = match isl_rs_result {
1141            0 => false,
1142            1 => true,
1143            _ => panic!("Got isl_bool = -1"),
1144        };
1145        let err = isl_rs_ctx.last_error();
1146        if err != Error::None_ {
1147            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1148        }
1149        Ok(isl_rs_result)
1150    }
1151
1152    /// Wraps `isl_space_has_tuple_name`.
1153    pub fn has_tuple_name(&self, type_: DimType) -> Result<bool, LibISLError> {
1154        let space = self;
1155        let isl_rs_ctx = space.get_ctx();
1156        let space = space.ptr;
1157        let type_ = type_.to_i32();
1158        let isl_rs_result = unsafe { isl_space_has_tuple_name(space, type_) };
1159        let isl_rs_result = match isl_rs_result {
1160            0 => false,
1161            1 => true,
1162            _ => panic!("Got isl_bool = -1"),
1163        };
1164        let err = isl_rs_ctx.last_error();
1165        if err != Error::None_ {
1166            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1167        }
1168        Ok(isl_rs_result)
1169    }
1170
1171    /// Wraps `isl_space_identity_multi_aff_on_domain`.
1172    pub fn identity_multi_aff_on_domain(self) -> Result<MultiAff, LibISLError> {
1173        let space = self;
1174        let isl_rs_ctx = space.get_ctx();
1175        let mut space = space;
1176        space.do_not_free_on_drop();
1177        let space = space.ptr;
1178        let isl_rs_result = unsafe { isl_space_identity_multi_aff_on_domain(space) };
1179        let isl_rs_result = MultiAff { ptr: isl_rs_result,
1180                                       should_free_on_drop: true };
1181        let err = isl_rs_ctx.last_error();
1182        if err != Error::None_ {
1183            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1184        }
1185        Ok(isl_rs_result)
1186    }
1187
1188    /// Wraps `isl_space_identity_multi_pw_aff_on_domain`.
1189    pub fn identity_multi_pw_aff_on_domain(self) -> Result<MultiPwAff, LibISLError> {
1190        let space = self;
1191        let isl_rs_ctx = space.get_ctx();
1192        let mut space = space;
1193        space.do_not_free_on_drop();
1194        let space = space.ptr;
1195        let isl_rs_result = unsafe { isl_space_identity_multi_pw_aff_on_domain(space) };
1196        let isl_rs_result = MultiPwAff { ptr: isl_rs_result,
1197                                         should_free_on_drop: true };
1198        let err = isl_rs_ctx.last_error();
1199        if err != Error::None_ {
1200            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1201        }
1202        Ok(isl_rs_result)
1203    }
1204
1205    /// Wraps `isl_space_identity_pw_multi_aff_on_domain`.
1206    pub fn identity_pw_multi_aff_on_domain(self) -> Result<PwMultiAff, LibISLError> {
1207        let space = self;
1208        let isl_rs_ctx = space.get_ctx();
1209        let mut space = space;
1210        space.do_not_free_on_drop();
1211        let space = space.ptr;
1212        let isl_rs_result = unsafe { isl_space_identity_pw_multi_aff_on_domain(space) };
1213        let isl_rs_result = PwMultiAff { ptr: isl_rs_result,
1214                                         should_free_on_drop: true };
1215        let err = isl_rs_ctx.last_error();
1216        if err != Error::None_ {
1217            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1218        }
1219        Ok(isl_rs_result)
1220    }
1221
1222    /// Wraps `isl_space_insert_dims`.
1223    pub fn insert_dims(self, type_: DimType, pos: u32, n: u32) -> Result<Space, LibISLError> {
1224        let space = self;
1225        let isl_rs_ctx = space.get_ctx();
1226        let mut space = space;
1227        space.do_not_free_on_drop();
1228        let space = space.ptr;
1229        let type_ = type_.to_i32();
1230        let isl_rs_result = unsafe { isl_space_insert_dims(space, type_, pos, n) };
1231        let isl_rs_result = Space { ptr: isl_rs_result,
1232                                    should_free_on_drop: true };
1233        let err = isl_rs_ctx.last_error();
1234        if err != Error::None_ {
1235            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1236        }
1237        Ok(isl_rs_result)
1238    }
1239
1240    /// Wraps `isl_space_is_domain`.
1241    pub fn is_domain(&self, space2: &Space) -> Result<bool, LibISLError> {
1242        let space1 = self;
1243        let isl_rs_ctx = space1.get_ctx();
1244        let space1 = space1.ptr;
1245        let space2 = space2.ptr;
1246        let isl_rs_result = unsafe { isl_space_is_domain(space1, space2) };
1247        let isl_rs_result = match isl_rs_result {
1248            0 => false,
1249            1 => true,
1250            _ => panic!("Got isl_bool = -1"),
1251        };
1252        let err = isl_rs_ctx.last_error();
1253        if err != Error::None_ {
1254            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1255        }
1256        Ok(isl_rs_result)
1257    }
1258
1259    /// Wraps `isl_space_is_equal`.
1260    pub fn is_equal(&self, space2: &Space) -> Result<bool, LibISLError> {
1261        let space1 = self;
1262        let isl_rs_ctx = space1.get_ctx();
1263        let space1 = space1.ptr;
1264        let space2 = space2.ptr;
1265        let isl_rs_result = unsafe { isl_space_is_equal(space1, space2) };
1266        let isl_rs_result = match isl_rs_result {
1267            0 => false,
1268            1 => true,
1269            _ => panic!("Got isl_bool = -1"),
1270        };
1271        let err = isl_rs_ctx.last_error();
1272        if err != Error::None_ {
1273            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1274        }
1275        Ok(isl_rs_result)
1276    }
1277
1278    /// Wraps `isl_space_is_map`.
1279    pub fn is_map(&self) -> Result<bool, LibISLError> {
1280        let space = self;
1281        let isl_rs_ctx = space.get_ctx();
1282        let space = space.ptr;
1283        let isl_rs_result = unsafe { isl_space_is_map(space) };
1284        let isl_rs_result = match isl_rs_result {
1285            0 => false,
1286            1 => true,
1287            _ => panic!("Got isl_bool = -1"),
1288        };
1289        let err = isl_rs_ctx.last_error();
1290        if err != Error::None_ {
1291            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1292        }
1293        Ok(isl_rs_result)
1294    }
1295
1296    /// Wraps `isl_space_is_params`.
1297    pub fn is_params(&self) -> Result<bool, LibISLError> {
1298        let space = self;
1299        let isl_rs_ctx = space.get_ctx();
1300        let space = space.ptr;
1301        let isl_rs_result = unsafe { isl_space_is_params(space) };
1302        let isl_rs_result = match isl_rs_result {
1303            0 => false,
1304            1 => true,
1305            _ => panic!("Got isl_bool = -1"),
1306        };
1307        let err = isl_rs_ctx.last_error();
1308        if err != Error::None_ {
1309            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1310        }
1311        Ok(isl_rs_result)
1312    }
1313
1314    /// Wraps `isl_space_is_product`.
1315    pub fn is_product(&self) -> Result<bool, LibISLError> {
1316        let space = self;
1317        let isl_rs_ctx = space.get_ctx();
1318        let space = space.ptr;
1319        let isl_rs_result = unsafe { isl_space_is_product(space) };
1320        let isl_rs_result = match isl_rs_result {
1321            0 => false,
1322            1 => true,
1323            _ => panic!("Got isl_bool = -1"),
1324        };
1325        let err = isl_rs_ctx.last_error();
1326        if err != Error::None_ {
1327            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1328        }
1329        Ok(isl_rs_result)
1330    }
1331
1332    /// Wraps `isl_space_is_range`.
1333    pub fn is_range(&self, space2: &Space) -> Result<bool, LibISLError> {
1334        let space1 = self;
1335        let isl_rs_ctx = space1.get_ctx();
1336        let space1 = space1.ptr;
1337        let space2 = space2.ptr;
1338        let isl_rs_result = unsafe { isl_space_is_range(space1, space2) };
1339        let isl_rs_result = match isl_rs_result {
1340            0 => false,
1341            1 => true,
1342            _ => panic!("Got isl_bool = -1"),
1343        };
1344        let err = isl_rs_ctx.last_error();
1345        if err != Error::None_ {
1346            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1347        }
1348        Ok(isl_rs_result)
1349    }
1350
1351    /// Wraps `isl_space_is_set`.
1352    pub fn is_set(&self) -> Result<bool, LibISLError> {
1353        let space = self;
1354        let isl_rs_ctx = space.get_ctx();
1355        let space = space.ptr;
1356        let isl_rs_result = unsafe { isl_space_is_set(space) };
1357        let isl_rs_result = match isl_rs_result {
1358            0 => false,
1359            1 => true,
1360            _ => panic!("Got isl_bool = -1"),
1361        };
1362        let err = isl_rs_ctx.last_error();
1363        if err != Error::None_ {
1364            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1365        }
1366        Ok(isl_rs_result)
1367    }
1368
1369    /// Wraps `isl_space_is_wrapping`.
1370    pub fn is_wrapping(&self) -> Result<bool, LibISLError> {
1371        let space = self;
1372        let isl_rs_ctx = space.get_ctx();
1373        let space = space.ptr;
1374        let isl_rs_result = unsafe { isl_space_is_wrapping(space) };
1375        let isl_rs_result = match isl_rs_result {
1376            0 => false,
1377            1 => true,
1378            _ => panic!("Got isl_bool = -1"),
1379        };
1380        let err = isl_rs_ctx.last_error();
1381        if err != Error::None_ {
1382            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1383        }
1384        Ok(isl_rs_result)
1385    }
1386
1387    /// Wraps `isl_space_join`.
1388    pub fn join(self, right: Space) -> Result<Space, LibISLError> {
1389        let left = self;
1390        let isl_rs_ctx = left.get_ctx();
1391        let mut left = left;
1392        left.do_not_free_on_drop();
1393        let left = left.ptr;
1394        let mut right = right;
1395        right.do_not_free_on_drop();
1396        let right = right.ptr;
1397        let isl_rs_result = unsafe { isl_space_join(left, right) };
1398        let isl_rs_result = Space { ptr: isl_rs_result,
1399                                    should_free_on_drop: true };
1400        let err = isl_rs_ctx.last_error();
1401        if err != Error::None_ {
1402            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1403        }
1404        Ok(isl_rs_result)
1405    }
1406
1407    /// Wraps `isl_space_map_from_domain_and_range`.
1408    pub fn map_from_domain_and_range(self, range: Space) -> Result<Space, LibISLError> {
1409        let domain = self;
1410        let isl_rs_ctx = domain.get_ctx();
1411        let mut domain = domain;
1412        domain.do_not_free_on_drop();
1413        let domain = domain.ptr;
1414        let mut range = range;
1415        range.do_not_free_on_drop();
1416        let range = range.ptr;
1417        let isl_rs_result = unsafe { isl_space_map_from_domain_and_range(domain, range) };
1418        let isl_rs_result = Space { ptr: isl_rs_result,
1419                                    should_free_on_drop: true };
1420        let err = isl_rs_ctx.last_error();
1421        if err != Error::None_ {
1422            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1423        }
1424        Ok(isl_rs_result)
1425    }
1426
1427    /// Wraps `isl_space_map_from_set`.
1428    pub fn map_from_set(self) -> Result<Space, LibISLError> {
1429        let space = self;
1430        let isl_rs_ctx = space.get_ctx();
1431        let mut space = space;
1432        space.do_not_free_on_drop();
1433        let space = space.ptr;
1434        let isl_rs_result = unsafe { isl_space_map_from_set(space) };
1435        let isl_rs_result = Space { ptr: isl_rs_result,
1436                                    should_free_on_drop: true };
1437        let err = isl_rs_ctx.last_error();
1438        if err != Error::None_ {
1439            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1440        }
1441        Ok(isl_rs_result)
1442    }
1443
1444    /// Wraps `isl_space_match`.
1445    pub fn match_(&self, type1: DimType, space2: &Space, type2: DimType)
1446                  -> Result<bool, LibISLError> {
1447        let space1 = self;
1448        let isl_rs_ctx = space1.get_ctx();
1449        let space1 = space1.ptr;
1450        let type1 = type1.to_i32();
1451        let space2 = space2.ptr;
1452        let type2 = type2.to_i32();
1453        let isl_rs_result = unsafe { isl_space_match(space1, type1, space2, type2) };
1454        let isl_rs_result = match isl_rs_result {
1455            0 => false,
1456            1 => true,
1457            _ => panic!("Got isl_bool = -1"),
1458        };
1459        let err = isl_rs_ctx.last_error();
1460        if err != Error::None_ {
1461            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1462        }
1463        Ok(isl_rs_result)
1464    }
1465
1466    /// Wraps `isl_space_move_dims`.
1467    pub fn move_dims(self, dst_type: DimType, dst_pos: u32, src_type: DimType, src_pos: u32,
1468                     n: u32)
1469                     -> Result<Space, LibISLError> {
1470        let space = self;
1471        let isl_rs_ctx = space.get_ctx();
1472        let mut space = space;
1473        space.do_not_free_on_drop();
1474        let space = space.ptr;
1475        let dst_type = dst_type.to_i32();
1476        let src_type = src_type.to_i32();
1477        let isl_rs_result =
1478            unsafe { isl_space_move_dims(space, dst_type, dst_pos, src_type, src_pos, n) };
1479        let isl_rs_result = Space { ptr: isl_rs_result,
1480                                    should_free_on_drop: true };
1481        let err = isl_rs_ctx.last_error();
1482        if err != Error::None_ {
1483            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1484        }
1485        Ok(isl_rs_result)
1486    }
1487
1488    /// Wraps `isl_space_multi_aff`.
1489    pub fn multi_aff(self, list: AffList) -> Result<MultiAff, LibISLError> {
1490        let space = self;
1491        let isl_rs_ctx = space.get_ctx();
1492        let mut space = space;
1493        space.do_not_free_on_drop();
1494        let space = space.ptr;
1495        let mut list = list;
1496        list.do_not_free_on_drop();
1497        let list = list.ptr;
1498        let isl_rs_result = unsafe { isl_space_multi_aff(space, list) };
1499        let isl_rs_result = MultiAff { ptr: isl_rs_result,
1500                                       should_free_on_drop: true };
1501        let err = isl_rs_ctx.last_error();
1502        if err != Error::None_ {
1503            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1504        }
1505        Ok(isl_rs_result)
1506    }
1507
1508    /// Wraps `isl_space_multi_aff_on_domain_multi_val`.
1509    pub fn multi_aff_on_domain_multi_val(self, mv: MultiVal) -> Result<MultiAff, LibISLError> {
1510        let space = self;
1511        let isl_rs_ctx = space.get_ctx();
1512        let mut space = space;
1513        space.do_not_free_on_drop();
1514        let space = space.ptr;
1515        let mut mv = mv;
1516        mv.do_not_free_on_drop();
1517        let mv = mv.ptr;
1518        let isl_rs_result = unsafe { isl_space_multi_aff_on_domain_multi_val(space, mv) };
1519        let isl_rs_result = MultiAff { ptr: isl_rs_result,
1520                                       should_free_on_drop: true };
1521        let err = isl_rs_ctx.last_error();
1522        if err != Error::None_ {
1523            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1524        }
1525        Ok(isl_rs_result)
1526    }
1527
1528    /// Wraps `isl_space_multi_id`.
1529    pub fn multi_id(self, list: IdList) -> Result<MultiId, LibISLError> {
1530        let space = self;
1531        let isl_rs_ctx = space.get_ctx();
1532        let mut space = space;
1533        space.do_not_free_on_drop();
1534        let space = space.ptr;
1535        let mut list = list;
1536        list.do_not_free_on_drop();
1537        let list = list.ptr;
1538        let isl_rs_result = unsafe { isl_space_multi_id(space, list) };
1539        let isl_rs_result = MultiId { ptr: isl_rs_result,
1540                                      should_free_on_drop: true };
1541        let err = isl_rs_ctx.last_error();
1542        if err != Error::None_ {
1543            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1544        }
1545        Ok(isl_rs_result)
1546    }
1547
1548    /// Wraps `isl_space_multi_pw_aff`.
1549    pub fn multi_pw_aff(self, list: PwAffList) -> Result<MultiPwAff, LibISLError> {
1550        let space = self;
1551        let isl_rs_ctx = space.get_ctx();
1552        let mut space = space;
1553        space.do_not_free_on_drop();
1554        let space = space.ptr;
1555        let mut list = list;
1556        list.do_not_free_on_drop();
1557        let list = list.ptr;
1558        let isl_rs_result = unsafe { isl_space_multi_pw_aff(space, list) };
1559        let isl_rs_result = MultiPwAff { ptr: isl_rs_result,
1560                                         should_free_on_drop: true };
1561        let err = isl_rs_ctx.last_error();
1562        if err != Error::None_ {
1563            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1564        }
1565        Ok(isl_rs_result)
1566    }
1567
1568    /// Wraps `isl_space_multi_union_pw_aff`.
1569    pub fn multi_union_pw_aff(self, list: UnionPwAffList) -> Result<MultiUnionPwAff, LibISLError> {
1570        let space = self;
1571        let isl_rs_ctx = space.get_ctx();
1572        let mut space = space;
1573        space.do_not_free_on_drop();
1574        let space = space.ptr;
1575        let mut list = list;
1576        list.do_not_free_on_drop();
1577        let list = list.ptr;
1578        let isl_rs_result = unsafe { isl_space_multi_union_pw_aff(space, list) };
1579        let isl_rs_result = MultiUnionPwAff { ptr: isl_rs_result,
1580                                              should_free_on_drop: true };
1581        let err = isl_rs_ctx.last_error();
1582        if err != Error::None_ {
1583            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1584        }
1585        Ok(isl_rs_result)
1586    }
1587
1588    /// Wraps `isl_space_multi_val`.
1589    pub fn multi_val(self, list: ValList) -> Result<MultiVal, LibISLError> {
1590        let space = self;
1591        let isl_rs_ctx = space.get_ctx();
1592        let mut space = space;
1593        space.do_not_free_on_drop();
1594        let space = space.ptr;
1595        let mut list = list;
1596        list.do_not_free_on_drop();
1597        let list = list.ptr;
1598        let isl_rs_result = unsafe { isl_space_multi_val(space, list) };
1599        let isl_rs_result = MultiVal { ptr: isl_rs_result,
1600                                       should_free_on_drop: true };
1601        let err = isl_rs_ctx.last_error();
1602        if err != Error::None_ {
1603            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1604        }
1605        Ok(isl_rs_result)
1606    }
1607
1608    /// Wraps `isl_space_param_aff_on_domain_id`.
1609    pub fn param_aff_on_domain_id(self, id: Id) -> Result<Aff, LibISLError> {
1610        let space = self;
1611        let isl_rs_ctx = space.get_ctx();
1612        let mut space = space;
1613        space.do_not_free_on_drop();
1614        let space = space.ptr;
1615        let mut id = id;
1616        id.do_not_free_on_drop();
1617        let id = id.ptr;
1618        let isl_rs_result = unsafe { isl_space_param_aff_on_domain_id(space, id) };
1619        let isl_rs_result = Aff { ptr: isl_rs_result,
1620                                  should_free_on_drop: true };
1621        let err = isl_rs_ctx.last_error();
1622        if err != Error::None_ {
1623            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1624        }
1625        Ok(isl_rs_result)
1626    }
1627
1628    /// Wraps `isl_space_params`.
1629    pub fn params(self) -> Result<Space, LibISLError> {
1630        let space = self;
1631        let isl_rs_ctx = space.get_ctx();
1632        let mut space = space;
1633        space.do_not_free_on_drop();
1634        let space = space.ptr;
1635        let isl_rs_result = unsafe { isl_space_params(space) };
1636        let isl_rs_result = Space { ptr: isl_rs_result,
1637                                    should_free_on_drop: true };
1638        let err = isl_rs_ctx.last_error();
1639        if err != Error::None_ {
1640            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1641        }
1642        Ok(isl_rs_result)
1643    }
1644
1645    /// Wraps `isl_space_params_alloc`.
1646    pub fn params_alloc(ctx: &Context, nparam: u32) -> Result<Space, LibISLError> {
1647        let isl_rs_ctx = Context { ptr: ctx.ptr,
1648                                   should_free_on_drop: false };
1649        let ctx = ctx.ptr;
1650        let isl_rs_result = unsafe { isl_space_params_alloc(ctx, nparam) };
1651        let isl_rs_result = Space { ptr: isl_rs_result,
1652                                    should_free_on_drop: true };
1653        let err = isl_rs_ctx.last_error();
1654        if err != Error::None_ {
1655            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1656        }
1657        Ok(isl_rs_result)
1658    }
1659
1660    /// Wraps `isl_space_product`.
1661    pub fn product(self, right: Space) -> Result<Space, LibISLError> {
1662        let left = self;
1663        let isl_rs_ctx = left.get_ctx();
1664        let mut left = left;
1665        left.do_not_free_on_drop();
1666        let left = left.ptr;
1667        let mut right = right;
1668        right.do_not_free_on_drop();
1669        let right = right.ptr;
1670        let isl_rs_result = unsafe { isl_space_product(left, right) };
1671        let isl_rs_result = Space { ptr: isl_rs_result,
1672                                    should_free_on_drop: true };
1673        let err = isl_rs_ctx.last_error();
1674        if err != Error::None_ {
1675            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1676        }
1677        Ok(isl_rs_result)
1678    }
1679
1680    /// Wraps `isl_space_range`.
1681    pub fn range(self) -> Result<Space, LibISLError> {
1682        let space = self;
1683        let isl_rs_ctx = space.get_ctx();
1684        let mut space = space;
1685        space.do_not_free_on_drop();
1686        let space = space.ptr;
1687        let isl_rs_result = unsafe { isl_space_range(space) };
1688        let isl_rs_result = Space { ptr: isl_rs_result,
1689                                    should_free_on_drop: true };
1690        let err = isl_rs_ctx.last_error();
1691        if err != Error::None_ {
1692            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1693        }
1694        Ok(isl_rs_result)
1695    }
1696
1697    /// Wraps `isl_space_range_curry`.
1698    pub fn range_curry(self) -> Result<Space, LibISLError> {
1699        let space = self;
1700        let isl_rs_ctx = space.get_ctx();
1701        let mut space = space;
1702        space.do_not_free_on_drop();
1703        let space = space.ptr;
1704        let isl_rs_result = unsafe { isl_space_range_curry(space) };
1705        let isl_rs_result = Space { ptr: isl_rs_result,
1706                                    should_free_on_drop: true };
1707        let err = isl_rs_ctx.last_error();
1708        if err != Error::None_ {
1709            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1710        }
1711        Ok(isl_rs_result)
1712    }
1713
1714    /// Wraps `isl_space_range_factor_domain`.
1715    pub fn range_factor_domain(self) -> Result<Space, LibISLError> {
1716        let space = self;
1717        let isl_rs_ctx = space.get_ctx();
1718        let mut space = space;
1719        space.do_not_free_on_drop();
1720        let space = space.ptr;
1721        let isl_rs_result = unsafe { isl_space_range_factor_domain(space) };
1722        let isl_rs_result = Space { ptr: isl_rs_result,
1723                                    should_free_on_drop: true };
1724        let err = isl_rs_ctx.last_error();
1725        if err != Error::None_ {
1726            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1727        }
1728        Ok(isl_rs_result)
1729    }
1730
1731    /// Wraps `isl_space_range_factor_range`.
1732    pub fn range_factor_range(self) -> Result<Space, LibISLError> {
1733        let space = self;
1734        let isl_rs_ctx = space.get_ctx();
1735        let mut space = space;
1736        space.do_not_free_on_drop();
1737        let space = space.ptr;
1738        let isl_rs_result = unsafe { isl_space_range_factor_range(space) };
1739        let isl_rs_result = Space { ptr: isl_rs_result,
1740                                    should_free_on_drop: true };
1741        let err = isl_rs_ctx.last_error();
1742        if err != Error::None_ {
1743            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1744        }
1745        Ok(isl_rs_result)
1746    }
1747
1748    /// Wraps `isl_space_range_is_wrapping`.
1749    pub fn range_is_wrapping(&self) -> Result<bool, LibISLError> {
1750        let space = self;
1751        let isl_rs_ctx = space.get_ctx();
1752        let space = space.ptr;
1753        let isl_rs_result = unsafe { isl_space_range_is_wrapping(space) };
1754        let isl_rs_result = match isl_rs_result {
1755            0 => false,
1756            1 => true,
1757            _ => panic!("Got isl_bool = -1"),
1758        };
1759        let err = isl_rs_ctx.last_error();
1760        if err != Error::None_ {
1761            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1762        }
1763        Ok(isl_rs_result)
1764    }
1765
1766    /// Wraps `isl_space_range_map`.
1767    pub fn range_map(self) -> Result<Space, LibISLError> {
1768        let space = self;
1769        let isl_rs_ctx = space.get_ctx();
1770        let mut space = space;
1771        space.do_not_free_on_drop();
1772        let space = space.ptr;
1773        let isl_rs_result = unsafe { isl_space_range_map(space) };
1774        let isl_rs_result = Space { ptr: isl_rs_result,
1775                                    should_free_on_drop: true };
1776        let err = isl_rs_ctx.last_error();
1777        if err != Error::None_ {
1778            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1779        }
1780        Ok(isl_rs_result)
1781    }
1782
1783    /// Wraps `isl_space_range_map_multi_aff`.
1784    pub fn range_map_multi_aff(self) -> Result<MultiAff, LibISLError> {
1785        let space = self;
1786        let isl_rs_ctx = space.get_ctx();
1787        let mut space = space;
1788        space.do_not_free_on_drop();
1789        let space = space.ptr;
1790        let isl_rs_result = unsafe { isl_space_range_map_multi_aff(space) };
1791        let isl_rs_result = MultiAff { ptr: isl_rs_result,
1792                                       should_free_on_drop: true };
1793        let err = isl_rs_ctx.last_error();
1794        if err != Error::None_ {
1795            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1796        }
1797        Ok(isl_rs_result)
1798    }
1799
1800    /// Wraps `isl_space_range_map_pw_multi_aff`.
1801    pub fn range_map_pw_multi_aff(self) -> Result<PwMultiAff, LibISLError> {
1802        let space = self;
1803        let isl_rs_ctx = space.get_ctx();
1804        let mut space = space;
1805        space.do_not_free_on_drop();
1806        let space = space.ptr;
1807        let isl_rs_result = unsafe { isl_space_range_map_pw_multi_aff(space) };
1808        let isl_rs_result = PwMultiAff { ptr: isl_rs_result,
1809                                         should_free_on_drop: true };
1810        let err = isl_rs_ctx.last_error();
1811        if err != Error::None_ {
1812            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1813        }
1814        Ok(isl_rs_result)
1815    }
1816
1817    /// Wraps `isl_space_range_product`.
1818    pub fn range_product(self, right: Space) -> Result<Space, LibISLError> {
1819        let left = self;
1820        let isl_rs_ctx = left.get_ctx();
1821        let mut left = left;
1822        left.do_not_free_on_drop();
1823        let left = left.ptr;
1824        let mut right = right;
1825        right.do_not_free_on_drop();
1826        let right = right.ptr;
1827        let isl_rs_result = unsafe { isl_space_range_product(left, right) };
1828        let isl_rs_result = Space { ptr: isl_rs_result,
1829                                    should_free_on_drop: true };
1830        let err = isl_rs_ctx.last_error();
1831        if err != Error::None_ {
1832            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1833        }
1834        Ok(isl_rs_result)
1835    }
1836
1837    /// Wraps `isl_space_range_reverse`.
1838    pub fn range_reverse(self) -> Result<Space, LibISLError> {
1839        let space = self;
1840        let isl_rs_ctx = space.get_ctx();
1841        let mut space = space;
1842        space.do_not_free_on_drop();
1843        let space = space.ptr;
1844        let isl_rs_result = unsafe { isl_space_range_reverse(space) };
1845        let isl_rs_result = Space { ptr: isl_rs_result,
1846                                    should_free_on_drop: true };
1847        let err = isl_rs_ctx.last_error();
1848        if err != Error::None_ {
1849            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1850        }
1851        Ok(isl_rs_result)
1852    }
1853
1854    /// Wraps `isl_space_range_wrapped_domain`.
1855    pub fn range_wrapped_domain(self) -> Result<Space, LibISLError> {
1856        let space = self;
1857        let isl_rs_ctx = space.get_ctx();
1858        let mut space = space;
1859        space.do_not_free_on_drop();
1860        let space = space.ptr;
1861        let isl_rs_result = unsafe { isl_space_range_wrapped_domain(space) };
1862        let isl_rs_result = Space { ptr: isl_rs_result,
1863                                    should_free_on_drop: true };
1864        let err = isl_rs_ctx.last_error();
1865        if err != Error::None_ {
1866            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1867        }
1868        Ok(isl_rs_result)
1869    }
1870
1871    /// Wraps `isl_space_range_wrapped_range`.
1872    pub fn range_wrapped_range(self) -> Result<Space, LibISLError> {
1873        let space = self;
1874        let isl_rs_ctx = space.get_ctx();
1875        let mut space = space;
1876        space.do_not_free_on_drop();
1877        let space = space.ptr;
1878        let isl_rs_result = unsafe { isl_space_range_wrapped_range(space) };
1879        let isl_rs_result = Space { ptr: isl_rs_result,
1880                                    should_free_on_drop: true };
1881        let err = isl_rs_ctx.last_error();
1882        if err != Error::None_ {
1883            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1884        }
1885        Ok(isl_rs_result)
1886    }
1887
1888    /// Wraps `isl_space_read_from_str`.
1889    pub fn read_from_str(ctx: &Context, str_: &str) -> Result<Space, LibISLError> {
1890        let isl_rs_ctx = Context { ptr: ctx.ptr,
1891                                   should_free_on_drop: false };
1892        let ctx = ctx.ptr;
1893        let str_ = CString::new(str_).unwrap();
1894        let str_ = str_.as_ptr();
1895        let isl_rs_result = unsafe { isl_space_read_from_str(ctx, str_) };
1896        let isl_rs_result = Space { ptr: isl_rs_result,
1897                                    should_free_on_drop: true };
1898        let err = isl_rs_ctx.last_error();
1899        if err != Error::None_ {
1900            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1901        }
1902        Ok(isl_rs_result)
1903    }
1904
1905    /// Wraps `isl_space_reset_tuple_id`.
1906    pub fn reset_tuple_id(self, type_: DimType) -> Result<Space, LibISLError> {
1907        let space = self;
1908        let isl_rs_ctx = space.get_ctx();
1909        let mut space = space;
1910        space.do_not_free_on_drop();
1911        let space = space.ptr;
1912        let type_ = type_.to_i32();
1913        let isl_rs_result = unsafe { isl_space_reset_tuple_id(space, type_) };
1914        let isl_rs_result = Space { ptr: isl_rs_result,
1915                                    should_free_on_drop: true };
1916        let err = isl_rs_ctx.last_error();
1917        if err != Error::None_ {
1918            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1919        }
1920        Ok(isl_rs_result)
1921    }
1922
1923    /// Wraps `isl_space_reset_user`.
1924    pub fn reset_user(self) -> Result<Space, LibISLError> {
1925        let space = self;
1926        let isl_rs_ctx = space.get_ctx();
1927        let mut space = space;
1928        space.do_not_free_on_drop();
1929        let space = space.ptr;
1930        let isl_rs_result = unsafe { isl_space_reset_user(space) };
1931        let isl_rs_result = Space { ptr: isl_rs_result,
1932                                    should_free_on_drop: true };
1933        let err = isl_rs_ctx.last_error();
1934        if err != Error::None_ {
1935            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1936        }
1937        Ok(isl_rs_result)
1938    }
1939
1940    /// Wraps `isl_space_reverse`.
1941    pub fn reverse(self) -> Result<Space, LibISLError> {
1942        let space = self;
1943        let isl_rs_ctx = space.get_ctx();
1944        let mut space = space;
1945        space.do_not_free_on_drop();
1946        let space = space.ptr;
1947        let isl_rs_result = unsafe { isl_space_reverse(space) };
1948        let isl_rs_result = Space { ptr: isl_rs_result,
1949                                    should_free_on_drop: true };
1950        let err = isl_rs_ctx.last_error();
1951        if err != Error::None_ {
1952            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1953        }
1954        Ok(isl_rs_result)
1955    }
1956
1957    /// Wraps `isl_space_set_alloc`.
1958    pub fn set_alloc(ctx: &Context, nparam: u32, dim: u32) -> Result<Space, LibISLError> {
1959        let isl_rs_ctx = Context { ptr: ctx.ptr,
1960                                   should_free_on_drop: false };
1961        let ctx = ctx.ptr;
1962        let isl_rs_result = unsafe { isl_space_set_alloc(ctx, nparam, dim) };
1963        let isl_rs_result = Space { ptr: isl_rs_result,
1964                                    should_free_on_drop: true };
1965        let err = isl_rs_ctx.last_error();
1966        if err != Error::None_ {
1967            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1968        }
1969        Ok(isl_rs_result)
1970    }
1971
1972    /// Wraps `isl_space_set_dim_id`.
1973    pub fn set_dim_id(self, type_: DimType, pos: u32, id: Id) -> Result<Space, LibISLError> {
1974        let space = self;
1975        let isl_rs_ctx = space.get_ctx();
1976        let mut space = space;
1977        space.do_not_free_on_drop();
1978        let space = space.ptr;
1979        let type_ = type_.to_i32();
1980        let mut id = id;
1981        id.do_not_free_on_drop();
1982        let id = id.ptr;
1983        let isl_rs_result = unsafe { isl_space_set_dim_id(space, type_, pos, id) };
1984        let isl_rs_result = Space { ptr: isl_rs_result,
1985                                    should_free_on_drop: true };
1986        let err = isl_rs_ctx.last_error();
1987        if err != Error::None_ {
1988            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
1989        }
1990        Ok(isl_rs_result)
1991    }
1992
1993    /// Wraps `isl_space_set_dim_name`.
1994    pub fn set_dim_name(self, type_: DimType, pos: u32, name: &str) -> Result<Space, LibISLError> {
1995        let space = self;
1996        let isl_rs_ctx = space.get_ctx();
1997        let mut space = space;
1998        space.do_not_free_on_drop();
1999        let space = space.ptr;
2000        let type_ = type_.to_i32();
2001        let name = CString::new(name).unwrap();
2002        let name = name.as_ptr();
2003        let isl_rs_result = unsafe { isl_space_set_dim_name(space, type_, pos, name) };
2004        let isl_rs_result = Space { ptr: isl_rs_result,
2005                                    should_free_on_drop: true };
2006        let err = isl_rs_ctx.last_error();
2007        if err != Error::None_ {
2008            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2009        }
2010        Ok(isl_rs_result)
2011    }
2012
2013    /// Wraps `isl_space_set_domain_tuple_id`.
2014    pub fn set_domain_tuple_id(self, id: Id) -> Result<Space, LibISLError> {
2015        let space = self;
2016        let isl_rs_ctx = space.get_ctx();
2017        let mut space = space;
2018        space.do_not_free_on_drop();
2019        let space = space.ptr;
2020        let mut id = id;
2021        id.do_not_free_on_drop();
2022        let id = id.ptr;
2023        let isl_rs_result = unsafe { isl_space_set_domain_tuple_id(space, id) };
2024        let isl_rs_result = Space { ptr: isl_rs_result,
2025                                    should_free_on_drop: true };
2026        let err = isl_rs_ctx.last_error();
2027        if err != Error::None_ {
2028            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2029        }
2030        Ok(isl_rs_result)
2031    }
2032
2033    /// Wraps `isl_space_set_from_params`.
2034    pub fn set_from_params(self) -> Result<Space, LibISLError> {
2035        let space = self;
2036        let isl_rs_ctx = space.get_ctx();
2037        let mut space = space;
2038        space.do_not_free_on_drop();
2039        let space = space.ptr;
2040        let isl_rs_result = unsafe { isl_space_set_from_params(space) };
2041        let isl_rs_result = Space { ptr: isl_rs_result,
2042                                    should_free_on_drop: true };
2043        let err = isl_rs_ctx.last_error();
2044        if err != Error::None_ {
2045            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2046        }
2047        Ok(isl_rs_result)
2048    }
2049
2050    /// Wraps `isl_space_set_range_tuple_id`.
2051    pub fn set_range_tuple_id(self, id: Id) -> Result<Space, LibISLError> {
2052        let space = self;
2053        let isl_rs_ctx = space.get_ctx();
2054        let mut space = space;
2055        space.do_not_free_on_drop();
2056        let space = space.ptr;
2057        let mut id = id;
2058        id.do_not_free_on_drop();
2059        let id = id.ptr;
2060        let isl_rs_result = unsafe { isl_space_set_range_tuple_id(space, id) };
2061        let isl_rs_result = Space { ptr: isl_rs_result,
2062                                    should_free_on_drop: true };
2063        let err = isl_rs_ctx.last_error();
2064        if err != Error::None_ {
2065            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2066        }
2067        Ok(isl_rs_result)
2068    }
2069
2070    /// Wraps `isl_space_set_tuple_id`.
2071    pub fn set_tuple_id(self, type_: DimType, id: Id) -> Result<Space, LibISLError> {
2072        let space = self;
2073        let isl_rs_ctx = space.get_ctx();
2074        let mut space = space;
2075        space.do_not_free_on_drop();
2076        let space = space.ptr;
2077        let type_ = type_.to_i32();
2078        let mut id = id;
2079        id.do_not_free_on_drop();
2080        let id = id.ptr;
2081        let isl_rs_result = unsafe { isl_space_set_tuple_id(space, type_, id) };
2082        let isl_rs_result = Space { ptr: isl_rs_result,
2083                                    should_free_on_drop: true };
2084        let err = isl_rs_ctx.last_error();
2085        if err != Error::None_ {
2086            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2087        }
2088        Ok(isl_rs_result)
2089    }
2090
2091    /// Wraps `isl_space_set_tuple_name`.
2092    pub fn set_tuple_name(self, type_: DimType, s: &str) -> Result<Space, LibISLError> {
2093        let space = self;
2094        let isl_rs_ctx = space.get_ctx();
2095        let mut space = space;
2096        space.do_not_free_on_drop();
2097        let space = space.ptr;
2098        let type_ = type_.to_i32();
2099        let s = CString::new(s).unwrap();
2100        let s = s.as_ptr();
2101        let isl_rs_result = unsafe { isl_space_set_tuple_name(space, type_, s) };
2102        let isl_rs_result = Space { ptr: isl_rs_result,
2103                                    should_free_on_drop: true };
2104        let err = isl_rs_ctx.last_error();
2105        if err != Error::None_ {
2106            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2107        }
2108        Ok(isl_rs_result)
2109    }
2110
2111    /// Wraps `isl_space_to_str`.
2112    pub fn to_str(&self) -> Result<&str, LibISLError> {
2113        let space = self;
2114        let isl_rs_ctx = space.get_ctx();
2115        let space = space.ptr;
2116        let isl_rs_result = unsafe { isl_space_to_str(space) };
2117        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
2118        let isl_rs_result = isl_rs_result.to_str().unwrap();
2119        let err = isl_rs_ctx.last_error();
2120        if err != Error::None_ {
2121            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2122        }
2123        Ok(isl_rs_result)
2124    }
2125
2126    /// Wraps `isl_space_tuple_is_equal`.
2127    pub fn tuple_is_equal(&self, type1: DimType, space2: &Space, type2: DimType)
2128                          -> Result<bool, LibISLError> {
2129        let space1 = self;
2130        let isl_rs_ctx = space1.get_ctx();
2131        let space1 = space1.ptr;
2132        let type1 = type1.to_i32();
2133        let space2 = space2.ptr;
2134        let type2 = type2.to_i32();
2135        let isl_rs_result = unsafe { isl_space_tuple_is_equal(space1, type1, space2, type2) };
2136        let isl_rs_result = match isl_rs_result {
2137            0 => false,
2138            1 => true,
2139            _ => panic!("Got isl_bool = -1"),
2140        };
2141        let err = isl_rs_ctx.last_error();
2142        if err != Error::None_ {
2143            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2144        }
2145        Ok(isl_rs_result)
2146    }
2147
2148    /// Wraps `isl_space_uncurry`.
2149    pub fn uncurry(self) -> Result<Space, LibISLError> {
2150        let space = self;
2151        let isl_rs_ctx = space.get_ctx();
2152        let mut space = space;
2153        space.do_not_free_on_drop();
2154        let space = space.ptr;
2155        let isl_rs_result = unsafe { isl_space_uncurry(space) };
2156        let isl_rs_result = Space { ptr: isl_rs_result,
2157                                    should_free_on_drop: true };
2158        let err = isl_rs_ctx.last_error();
2159        if err != Error::None_ {
2160            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2161        }
2162        Ok(isl_rs_result)
2163    }
2164
2165    /// Wraps `isl_space_unit`.
2166    pub fn unit(ctx: &Context) -> Result<Space, LibISLError> {
2167        let isl_rs_ctx = Context { ptr: ctx.ptr,
2168                                   should_free_on_drop: false };
2169        let ctx = ctx.ptr;
2170        let isl_rs_result = unsafe { isl_space_unit(ctx) };
2171        let isl_rs_result = Space { ptr: isl_rs_result,
2172                                    should_free_on_drop: true };
2173        let err = isl_rs_ctx.last_error();
2174        if err != Error::None_ {
2175            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2176        }
2177        Ok(isl_rs_result)
2178    }
2179
2180    /// Wraps `isl_space_universe_map`.
2181    pub fn universe_map(self) -> Result<Map, LibISLError> {
2182        let space = self;
2183        let isl_rs_ctx = space.get_ctx();
2184        let mut space = space;
2185        space.do_not_free_on_drop();
2186        let space = space.ptr;
2187        let isl_rs_result = unsafe { isl_space_universe_map(space) };
2188        let isl_rs_result = Map { ptr: isl_rs_result,
2189                                  should_free_on_drop: true };
2190        let err = isl_rs_ctx.last_error();
2191        if err != Error::None_ {
2192            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2193        }
2194        Ok(isl_rs_result)
2195    }
2196
2197    /// Wraps `isl_space_universe_set`.
2198    pub fn universe_set(self) -> Result<Set, LibISLError> {
2199        let space = self;
2200        let isl_rs_ctx = space.get_ctx();
2201        let mut space = space;
2202        space.do_not_free_on_drop();
2203        let space = space.ptr;
2204        let isl_rs_result = unsafe { isl_space_universe_set(space) };
2205        let isl_rs_result = Set { ptr: isl_rs_result,
2206                                  should_free_on_drop: true };
2207        let err = isl_rs_ctx.last_error();
2208        if err != Error::None_ {
2209            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2210        }
2211        Ok(isl_rs_result)
2212    }
2213
2214    /// Wraps `isl_space_unwrap`.
2215    pub fn unwrap(self) -> Result<Space, LibISLError> {
2216        let space = self;
2217        let isl_rs_ctx = space.get_ctx();
2218        let mut space = space;
2219        space.do_not_free_on_drop();
2220        let space = space.ptr;
2221        let isl_rs_result = unsafe { isl_space_unwrap(space) };
2222        let isl_rs_result = Space { ptr: isl_rs_result,
2223                                    should_free_on_drop: true };
2224        let err = isl_rs_ctx.last_error();
2225        if err != Error::None_ {
2226            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2227        }
2228        Ok(isl_rs_result)
2229    }
2230
2231    /// Wraps `isl_space_wrap`.
2232    pub fn wrap(self) -> Result<Space, LibISLError> {
2233        let space = self;
2234        let isl_rs_ctx = space.get_ctx();
2235        let mut space = space;
2236        space.do_not_free_on_drop();
2237        let space = space.ptr;
2238        let isl_rs_result = unsafe { isl_space_wrap(space) };
2239        let isl_rs_result = Space { ptr: isl_rs_result,
2240                                    should_free_on_drop: true };
2241        let err = isl_rs_ctx.last_error();
2242        if err != Error::None_ {
2243            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2244        }
2245        Ok(isl_rs_result)
2246    }
2247
2248    /// Wraps `isl_space_wrapped_reverse`.
2249    pub fn wrapped_reverse(self) -> Result<Space, LibISLError> {
2250        let space = self;
2251        let isl_rs_ctx = space.get_ctx();
2252        let mut space = space;
2253        space.do_not_free_on_drop();
2254        let space = space.ptr;
2255        let isl_rs_result = unsafe { isl_space_wrapped_reverse(space) };
2256        let isl_rs_result = Space { ptr: isl_rs_result,
2257                                    should_free_on_drop: true };
2258        let err = isl_rs_ctx.last_error();
2259        if err != Error::None_ {
2260            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2261        }
2262        Ok(isl_rs_result)
2263    }
2264
2265    /// Wraps `isl_space_zero_aff_on_domain`.
2266    pub fn zero_aff_on_domain(self) -> Result<Aff, LibISLError> {
2267        let space = self;
2268        let isl_rs_ctx = space.get_ctx();
2269        let mut space = space;
2270        space.do_not_free_on_drop();
2271        let space = space.ptr;
2272        let isl_rs_result = unsafe { isl_space_zero_aff_on_domain(space) };
2273        let isl_rs_result = Aff { ptr: isl_rs_result,
2274                                  should_free_on_drop: true };
2275        let err = isl_rs_ctx.last_error();
2276        if err != Error::None_ {
2277            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2278        }
2279        Ok(isl_rs_result)
2280    }
2281
2282    /// Wraps `isl_space_zero_multi_aff`.
2283    pub fn zero_multi_aff(self) -> Result<MultiAff, LibISLError> {
2284        let space = self;
2285        let isl_rs_ctx = space.get_ctx();
2286        let mut space = space;
2287        space.do_not_free_on_drop();
2288        let space = space.ptr;
2289        let isl_rs_result = unsafe { isl_space_zero_multi_aff(space) };
2290        let isl_rs_result = MultiAff { ptr: isl_rs_result,
2291                                       should_free_on_drop: true };
2292        let err = isl_rs_ctx.last_error();
2293        if err != Error::None_ {
2294            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2295        }
2296        Ok(isl_rs_result)
2297    }
2298
2299    /// Wraps `isl_space_zero_multi_pw_aff`.
2300    pub fn zero_multi_pw_aff(self) -> Result<MultiPwAff, LibISLError> {
2301        let space = self;
2302        let isl_rs_ctx = space.get_ctx();
2303        let mut space = space;
2304        space.do_not_free_on_drop();
2305        let space = space.ptr;
2306        let isl_rs_result = unsafe { isl_space_zero_multi_pw_aff(space) };
2307        let isl_rs_result = MultiPwAff { ptr: isl_rs_result,
2308                                         should_free_on_drop: true };
2309        let err = isl_rs_ctx.last_error();
2310        if err != Error::None_ {
2311            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2312        }
2313        Ok(isl_rs_result)
2314    }
2315
2316    /// Wraps `isl_space_zero_multi_union_pw_aff`.
2317    pub fn zero_multi_union_pw_aff(self) -> Result<MultiUnionPwAff, LibISLError> {
2318        let space = self;
2319        let isl_rs_ctx = space.get_ctx();
2320        let mut space = space;
2321        space.do_not_free_on_drop();
2322        let space = space.ptr;
2323        let isl_rs_result = unsafe { isl_space_zero_multi_union_pw_aff(space) };
2324        let isl_rs_result = MultiUnionPwAff { ptr: isl_rs_result,
2325                                              should_free_on_drop: true };
2326        let err = isl_rs_ctx.last_error();
2327        if err != Error::None_ {
2328            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2329        }
2330        Ok(isl_rs_result)
2331    }
2332
2333    /// Wraps `isl_space_zero_multi_val`.
2334    pub fn zero_multi_val(self) -> Result<MultiVal, LibISLError> {
2335        let space = self;
2336        let isl_rs_ctx = space.get_ctx();
2337        let mut space = space;
2338        space.do_not_free_on_drop();
2339        let space = space.ptr;
2340        let isl_rs_result = unsafe { isl_space_zero_multi_val(space) };
2341        let isl_rs_result = MultiVal { ptr: isl_rs_result,
2342                                       should_free_on_drop: true };
2343        let err = isl_rs_ctx.last_error();
2344        if err != Error::None_ {
2345            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2346        }
2347        Ok(isl_rs_result)
2348    }
2349
2350    /// Wraps `isl_space_zip`.
2351    pub fn zip(self) -> Result<Space, LibISLError> {
2352        let space = self;
2353        let isl_rs_ctx = space.get_ctx();
2354        let mut space = space;
2355        space.do_not_free_on_drop();
2356        let space = space.ptr;
2357        let isl_rs_result = unsafe { isl_space_zip(space) };
2358        let isl_rs_result = Space { ptr: isl_rs_result,
2359                                    should_free_on_drop: true };
2360        let err = isl_rs_ctx.last_error();
2361        if err != Error::None_ {
2362            return Err(LibISLError::new(err, isl_rs_ctx.last_error_msg()));
2363        }
2364        Ok(isl_rs_result)
2365    }
2366
2367    /// Does not call isl_space_free() on being dropped. (For internal use
2368    /// only.)
2369    pub fn do_not_free_on_drop(&mut self) {
2370        self.should_free_on_drop = false;
2371    }
2372}
2373
2374impl Drop for Space {
2375    fn drop(&mut self) {
2376        if self.should_free_on_drop {
2377            unsafe {
2378                isl_space_free(self.ptr);
2379            }
2380        }
2381    }
2382}