/
signature.rs
56 lines (46 loc) · 1.27 KB
/
signature.rs
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
use super::*;
#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, Default)]
pub struct Signature {
pub kind: ElementType,
pub pointers: usize,
pub by_ref: bool,
pub is_const: bool,
pub is_array: bool,
}
impl Signature {
pub fn is_blittable(&self) -> bool {
self.pointers > 0 || self.kind.is_blittable()
}
pub fn is_udt(&self) -> bool {
self.pointers == 0 && self.kind.is_udt()
}
pub fn has_explicit(&self) -> bool {
self.pointers == 0 && self.kind.has_explicit()
}
pub fn is_packed(&self) -> bool {
if self.pointers > 0 {
return false;
}
match &self.kind {
ElementType::TypeDef(def) => def.is_packed(),
ElementType::Array((signature, _)) => signature.is_packed(),
_ => false,
}
}
pub fn is_callback(&self) -> bool {
self.pointers == 0 && self.kind.is_callback()
}
pub fn is_callback_array(&self) -> bool {
self.pointers == 0 && self.kind.is_callback_array()
}
pub fn size(&self) -> usize {
if self.pointers > 0 {
1
} else {
self.kind.size()
}
}
pub fn is_primitive(&self) -> bool {
self.pointers > 0 || self.kind.is_primitive()
}
}