1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Automatically generated by isl_bindings_generator.
// LICENSE: MIT

use crate::bindings::{Context, DimType, Space, Val};
use libc::uintptr_t;
use std::ffi::{CStr, CString};
use std::os::raw::c_char;

/// Wraps `isl_point`.
pub struct Point {
    pub ptr: uintptr_t,
}

extern "C" {

    fn isl_point_get_ctx(pnt: uintptr_t) -> uintptr_t;

    fn isl_point_get_space(pnt: uintptr_t) -> uintptr_t;

    fn isl_point_zero(space: uintptr_t) -> uintptr_t;

    fn isl_point_copy(pnt: uintptr_t) -> uintptr_t;

    fn isl_point_free(pnt: uintptr_t) -> uintptr_t;

    fn isl_point_get_coordinate_val(pnt: uintptr_t, type_: DimType, pos: i32) -> uintptr_t;

    fn isl_point_set_coordinate_val(pnt: uintptr_t, type_: DimType, pos: i32, v: uintptr_t)
                                    -> uintptr_t;

    fn isl_point_add_ui(pnt: uintptr_t, type_: DimType, pos: i32, val: u32) -> uintptr_t;

    fn isl_point_sub_ui(pnt: uintptr_t, type_: DimType, pos: i32, val: u32) -> uintptr_t;

    fn isl_point_void(space: uintptr_t) -> uintptr_t;

    fn isl_point_is_void(pnt: uintptr_t) -> i32;

    fn isl_point_to_str(pnt: uintptr_t) -> *const c_char;

    fn isl_point_dump(pnt: uintptr_t);

}

impl Point {
    /// Wraps `isl_point_get_ctx`.
    pub fn get_ctx(&self) -> Context {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_get_ctx(pnt) };
        let isl_rs_result = Context { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_get_space`.
    pub fn get_space(&self) -> Space {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_get_space(pnt) };
        let isl_rs_result = Space { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_zero`.
    pub fn zero(space: Space) -> Point {
        let space = space.ptr;
        let isl_rs_result = unsafe { isl_point_zero(space) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_copy`.
    pub fn copy(&self) -> Point {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_copy(pnt) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_free`.
    pub fn free(self) -> Point {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_free(pnt) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_get_coordinate_val`.
    pub fn get_coordinate_val(&self, type_: DimType, pos: i32) -> Val {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_get_coordinate_val(pnt, type_, pos) };
        let isl_rs_result = Val { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_set_coordinate_val`.
    pub fn set_coordinate_val(self, type_: DimType, pos: i32, v: Val) -> Point {
        let pnt = self;
        let pnt = pnt.ptr;
        let v = v.ptr;
        let isl_rs_result = unsafe { isl_point_set_coordinate_val(pnt, type_, pos, v) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_add_ui`.
    pub fn add_ui(self, type_: DimType, pos: i32, val: u32) -> Point {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_add_ui(pnt, type_, pos, val) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_sub_ui`.
    pub fn sub_ui(self, type_: DimType, pos: i32, val: u32) -> Point {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_sub_ui(pnt, type_, pos, val) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_void`.
    pub fn void(space: Space) -> Point {
        let space = space.ptr;
        let isl_rs_result = unsafe { isl_point_void(space) };
        let isl_rs_result = Point { ptr: isl_rs_result };
        isl_rs_result
    }

    /// Wraps `isl_point_is_void`.
    pub fn is_void(&self) -> bool {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_is_void(pnt) };
        let isl_rs_result = match isl_rs_result {
            0 => false,
            1 => true,
            _ => panic!("Got isl_bool = -1"),
        };
        isl_rs_result
    }

    /// Wraps `isl_point_to_str`.
    pub fn to_str(&self) -> &str {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_to_str(pnt) };
        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
        let isl_rs_result = isl_rs_result.to_str().unwrap();
        isl_rs_result
    }

    /// Wraps `isl_point_dump`.
    pub fn dump(&self) {
        let pnt = self;
        let pnt = pnt.ptr;
        let isl_rs_result = unsafe { isl_point_dump(pnt) };
        isl_rs_result
    }
}

impl Drop for Point {
    fn drop(&mut self) {
        unsafe {
            isl_point_free(self.ptr);
        }
    }
}