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
use crate::*;
pub unsafe trait RuntimeType: Abi + Clone {
type DefaultType;
const SIGNATURE: crate::ConstBuffer;
}
macro_rules! primitive_runtime_types {
($(($t:ty, $s:literal)),+) => {
$(
unsafe impl RuntimeType for $t {
type DefaultType = Self;
const SIGNATURE: crate::ConstBuffer = crate::ConstBuffer::from_slice($s);
}
unsafe impl Abi for $t {
type Abi = Self;
}
)*
};
}
primitive_runtime_types! {
(bool, b"b1"),
(i8, b"i1"),
(u8, b"u1"),
(i16, b"i2"),
(u16, b"u2"),
(i32, b"i4"),
(u32, b"u4"),
(i64, b"i8"),
(u64, b"u8"),
(f32, b"f4"),
(f64, b"f8")
}
unsafe impl Abi for isize {
type Abi = Self;
}
unsafe impl Abi for usize {
type Abi = Self;
}