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
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_union(&self) -> bool {
        self.pointers == 0 && self.kind.has_union()
    }

    pub fn has_pack(&self) -> bool {
        self.pointers == 0 && self.kind.has_pack()
    }

    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()
    }
}