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
use crate::bindings::Context;
use libc::uintptr_t;
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
pub struct Id {
pub ptr: uintptr_t,
}
extern "C" {
fn isl_id_get_ctx(id: uintptr_t) -> uintptr_t;
fn isl_id_get_hash(id: uintptr_t) -> u32;
fn isl_id_copy(id: uintptr_t) -> uintptr_t;
fn isl_id_free(id: uintptr_t) -> uintptr_t;
fn isl_id_get_name(id: uintptr_t) -> *const c_char;
fn isl_id_read_from_str(ctx: uintptr_t, str_: *const c_char) -> uintptr_t;
fn isl_id_to_str(id: uintptr_t) -> *const c_char;
fn isl_id_dump(id: uintptr_t);
}
impl Id {
pub fn get_ctx(&self) -> Context {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_get_ctx(id) };
let isl_rs_result = Context { ptr: isl_rs_result };
isl_rs_result
}
pub fn get_hash(&self) -> u32 {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_get_hash(id) };
isl_rs_result
}
pub fn copy(&self) -> Id {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_copy(id) };
let isl_rs_result = Id { ptr: isl_rs_result };
isl_rs_result
}
pub fn free(self) -> Id {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_free(id) };
let isl_rs_result = Id { ptr: isl_rs_result };
isl_rs_result
}
pub fn get_name(&self) -> &str {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_get_name(id) };
let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
let isl_rs_result = isl_rs_result.to_str().unwrap();
isl_rs_result
}
pub fn read_from_str(ctx: &Context, str_: &str) -> Id {
let ctx = ctx.ptr;
let str_ = CString::new(str_).unwrap();
let str_ = str_.as_ptr();
let isl_rs_result = unsafe { isl_id_read_from_str(ctx, str_) };
let isl_rs_result = Id { ptr: isl_rs_result };
isl_rs_result
}
pub fn to_str(&self) -> &str {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_to_str(id) };
let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
let isl_rs_result = isl_rs_result.to_str().unwrap();
isl_rs_result
}
pub fn dump(&self) {
let id = self;
let id = id.ptr;
let isl_rs_result = unsafe { isl_id_dump(id) };
isl_rs_result
}
}
impl Drop for Id {
fn drop(&mut self) {
unsafe {
isl_id_free(self.ptr);
}
}
}