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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use std::ffi::CString;
use super::value::SBValue;
use super::lldb_user_id_t;
use sys;
#[derive(Debug)]
pub struct SBValueList {
pub raw: sys::SBValueListRef,
}
impl SBValueList {
pub fn wrap(raw: sys::SBValueListRef) -> SBValueList {
SBValueList { raw: raw }
}
pub fn maybe_wrap(raw: sys::SBValueListRef) -> Option<SBValueList> {
if unsafe { sys::SBValueListIsValid(raw) != 0 } {
Some(SBValueList { raw: raw })
} else {
None
}
}
pub fn is_valid(&self) -> bool {
unsafe { sys::SBValueListIsValid(self.raw) != 0 }
}
#[allow(missing_docs)]
pub fn append(&self, value: &SBValue) {
unsafe { sys::SBValueListAppend(self.raw, value.raw) };
}
#[allow(missing_docs)]
pub fn append_list(&self, values: &SBValueList) {
unsafe { sys::SBValueListAppend2(self.raw, values.raw) };
}
pub fn is_empty(&self) -> bool {
unsafe { sys::SBValueListGetSize(self.raw) == 0 }
}
pub fn clear(&self) {
unsafe { sys::SBValueListClear(self.raw) };
}
#[allow(missing_docs)]
pub fn find_value_by_uid(&self, uid: lldb_user_id_t) -> Option<SBValue> {
SBValue::maybe_wrap(unsafe {
sys::SBValueListFindValueObjectByUID(self.raw, uid)
})
}
#[allow(missing_docs)]
pub fn get_first_value_by_name(&self, name: &str) -> Option<SBValue> {
let name = CString::new(name).unwrap();
SBValue::maybe_wrap(unsafe {
sys::SBValueListGetFirstValueByName(self.raw, name.as_ptr())
})
}
pub fn iter(&self) -> SBValueListIter {
SBValueListIter {
value_list: self,
idx: 0,
}
}
}
impl Drop for SBValueList {
fn drop(&mut self) {
unsafe { sys::DisposeSBValueList(self.raw) };
}
}
pub struct SBValueListIter<'d> {
value_list: &'d SBValueList,
idx: usize,
}
impl<'d> Iterator for SBValueListIter<'d> {
type Item = SBValue;
fn next(&mut self) -> Option<SBValue> {
if self.idx < unsafe { sys::SBValueListGetSize(self.value_list.raw) as usize } {
let r = SBValue::wrap(unsafe {
sys::SBValueListGetValueAtIndex(self.value_list.raw, self.idx as u32)
});
self.idx += 1;
Some(r)
} else {
None
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
let sz = unsafe { sys::SBValueListGetSize(self.value_list.raw) } as usize;
(sz - self.idx, Some(sz))
}
}