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
macro_rules! impl_raw_accessors(
($(($t:ty, $raw:ty)),+) => (
$(
impl $t {
#[inline]
pub unsafe fn raw(&self) -> $raw { self.raw }
}
)+
)
);
macro_rules! impl_raw_constructor(
($(($t:ty, $te:ident ($($r:ident:$rt:ty),+))),+) => (
$(
impl $t {
#[inline]
pub unsafe fn from_ll($($r:$rt),+) -> $t {
$te { $($r: $r),+ }
}
}
)+
)
);
macro_rules! u32_to_int(
($value:expr) => (
if $value >= 1<<31 { Err(format!("`{}` is out of bounds.", stringify!($value))) }
else { Ok($value as ::libc::c_int) }
)
);
macro_rules! usize_to_int(
($value:expr) => (
if $value >= 1<<31 { Err(format!("`{}` is out of bounds.", stringify!($value))) }
else { Ok($value as ::libc::c_int) }
)
);
macro_rules! int_to_u32(
($value:expr) => (
if $value < 0 { Err(format!("`{}` is out of bounds.", stringify!($value))) }
else { Ok($value as u32) }
)
);