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
use super::breakpoint::SBBreakpoint;
use super::target::SBTarget;
use sys;
pub struct SBBreakpointList {
pub raw: sys::SBBreakpointListRef,
}
impl SBBreakpointList {
pub fn new(target: &SBTarget) -> SBBreakpointList {
SBBreakpointList::wrap(unsafe { sys::CreateSBBreakpointList(target.raw) })
}
pub fn wrap(raw: sys::SBBreakpointListRef) -> SBBreakpointList {
SBBreakpointList { raw: raw }
}
#[allow(missing_docs)]
pub fn find_breakpoint_by_id(&self, id: i32) -> Option<SBBreakpoint> {
SBBreakpoint::maybe_wrap(unsafe {
sys::SBBreakpointListFindBreakpointByID(self.raw, id)
})
}
#[allow(missing_docs)]
pub fn append(&self, bkpt: &SBBreakpoint) {
unsafe { sys::SBBreakpointListAppend(self.raw, bkpt.raw) };
}
#[allow(missing_docs)]
pub fn append_by_id(&self, bkpt_id: i32) {
unsafe { sys::SBBreakpointListAppendByID(self.raw, bkpt_id) };
}
#[allow(missing_docs)]
pub fn append_if_unique(&self, bkpt: &SBBreakpoint) {
unsafe { sys::SBBreakpointListAppendIfUnique(self.raw, bkpt.raw) };
}
pub fn is_empty(&self) -> bool {
unsafe { sys::SBBreakpointListGetSize(self.raw) == 0 }
}
pub fn clear(&self) {
unsafe { sys::SBBreakpointListClear(self.raw) };
}
pub fn iter(&self) -> SBBreakpointListIter {
SBBreakpointListIter {
breakpoint_list: self,
idx: 0,
}
}
}
impl Drop for SBBreakpointList {
fn drop(&mut self) {
unsafe { sys::DisposeSBBreakpointList(self.raw) };
}
}
pub struct SBBreakpointListIter<'d> {
breakpoint_list: &'d SBBreakpointList,
idx: usize,
}
impl<'d> Iterator for SBBreakpointListIter<'d> {
type Item = SBBreakpoint;
fn next(&mut self) -> Option<SBBreakpoint> {
if self.idx < unsafe { sys::SBBreakpointListGetSize(self.breakpoint_list.raw) } {
let r = SBBreakpoint::wrap(unsafe {
sys::SBBreakpointListGetBreakpointAtIndex(self.breakpoint_list.raw, self.idx)
});
self.idx += 1;
Some(r)
} else {
None
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
let sz = unsafe { sys::SBBreakpointListGetSize(self.breakpoint_list.raw) };
(sz - self.idx, Some(sz))
}
}