Show More
@@ -31,10 +31,10 b' mod conversion;' | |||||
31 | pub mod ref_sharing; |
|
31 | pub mod ref_sharing; | |
32 | pub mod dagops; |
|
32 | pub mod dagops; | |
33 | pub mod dirstate; |
|
33 | pub mod dirstate; | |
34 | pub mod parsers; |
|
|||
35 | pub mod discovery; |
|
34 | pub mod discovery; | |
36 | pub mod exceptions; |
|
35 | pub mod exceptions; | |
37 | pub mod filepatterns; |
|
36 | pub mod filepatterns; | |
|
37 | pub mod parsers; | |||
38 |
|
38 | |||
39 | py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| { |
|
39 | py_module_initializer!(rustext, initrustext, PyInit_rustext, |py, m| { | |
40 | m.add( |
|
40 | m.add( |
@@ -36,9 +36,7 b' pub struct Index {' | |||||
36 |
|
36 | |||
37 | impl Index { |
|
37 | impl Index { | |
38 | pub fn new(index: IndexPtr) -> Self { |
|
38 | pub fn new(index: IndexPtr) -> Self { | |
39 | Index { |
|
39 | Index { index: index } | |
40 | index: index, |
|
|||
41 | } |
|
|||
42 | } |
|
40 | } | |
43 | } |
|
41 | } | |
44 |
|
42 | |||
@@ -46,8 +44,13 b' impl Graph for Index {' | |||||
46 | /// wrap a call to the C extern parents function |
|
44 | /// wrap a call to the C extern parents function | |
47 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { |
|
45 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { | |
48 | let mut res: [c_int; 2] = [0; 2]; |
|
46 | let mut res: [c_int; 2] = [0; 2]; | |
49 | let code = |
|
47 | let code = unsafe { | |
50 | unsafe { HgRevlogIndex_GetParents(self.index, rev, &mut res as *mut [c_int; 2]) }; |
|
48 | HgRevlogIndex_GetParents( | |
|
49 | self.index, | |||
|
50 | rev, | |||
|
51 | &mut res as *mut [c_int; 2], | |||
|
52 | ) | |||
|
53 | }; | |||
51 | match code { |
|
54 | match code { | |
52 | 0 => Ok(res), |
|
55 | 0 => Ok(res), | |
53 | _ => Err(GraphError::ParentOutOfRange(rev)), |
|
56 | _ => Err(GraphError::ParentOutOfRange(rev)), | |
@@ -98,22 +101,26 b' unsafe fn raw_init<G: Graph>(' | |||||
98 |
|
101 | |||
99 | let slice = slice::from_raw_parts(initrevs, initrevslen); |
|
102 | let slice = slice::from_raw_parts(initrevs, initrevslen); | |
100 |
|
103 | |||
101 |
Box::into_raw(Box::new( |
|
104 | Box::into_raw(Box::new( | |
102 | graph, |
|
105 | match AncestorsIterator::new( | |
103 | slice.into_iter().map(|&r| r as Revision), |
|
106 | graph, | |
104 |
|
|
107 | slice.into_iter().map(|&r| r as Revision), | |
105 | inclb, |
|
108 | stoprev as Revision, | |
106 | ) { |
|
109 | inclb, | |
107 |
|
|
110 | ) { | |
108 |
|
|
111 | Ok(it) => it, | |
109 | return null_mut(); |
|
112 | Err(_) => { | |
110 | } |
|
113 | return null_mut(); | |
111 | })) |
|
114 | } | |
|
115 | }, | |||
|
116 | )) | |||
112 | } |
|
117 | } | |
113 |
|
118 | |||
114 | /// Deallocator to be called from C code |
|
119 | /// Deallocator to be called from C code | |
115 | #[no_mangle] |
|
120 | #[no_mangle] | |
116 |
pub extern "C" fn rustlazyancestors_drop( |
|
121 | pub extern "C" fn rustlazyancestors_drop( | |
|
122 | raw_iter: *mut AncestorsIterator<Index>, | |||
|
123 | ) { | |||
117 | raw_drop(raw_iter); |
|
124 | raw_drop(raw_iter); | |
118 | } |
|
125 | } | |
119 |
|
126 | |||
@@ -131,7 +138,9 b' fn raw_drop<G: Graph>(raw_iter: *mut Anc' | |||||
131 | /// it will be up to the C wrapper to convert that back into a Python end of |
|
138 | /// it will be up to the C wrapper to convert that back into a Python end of | |
132 | /// iteration |
|
139 | /// iteration | |
133 | #[no_mangle] |
|
140 | #[no_mangle] | |
134 |
pub extern "C" fn rustlazyancestors_next( |
|
141 | pub extern "C" fn rustlazyancestors_next( | |
|
142 | raw: *mut AncestorsIterator<Index>, | |||
|
143 | ) -> c_long { | |||
135 | raw_next(raw) |
|
144 | raw_next(raw) | |
136 | } |
|
145 | } | |
137 |
|
146 | |||
@@ -227,7 +236,9 b' mod tests {' | |||||
227 | let mut initrevs: Vec<c_long> = vec![11, 13]; |
|
236 | let mut initrevs: Vec<c_long> = vec![11, 13]; | |
228 | let initrevs_len = initrevs.len(); |
|
237 | let initrevs_len = initrevs.len(); | |
229 | let initrevs_ptr = initrevs.as_mut_ptr() as usize; |
|
238 | let initrevs_ptr = initrevs.as_mut_ptr() as usize; | |
230 |
let handler = thread::spawn(move || |
|
239 | let handler = thread::spawn(move || { | |
|
240 | stub_raw_init(initrevs_len, initrevs_ptr, 0, 1) | |||
|
241 | }); | |||
231 | let raw = handler.join().unwrap() as *mut AncestorsIterator<Stub>; |
|
242 | let raw = handler.join().unwrap() as *mut AncestorsIterator<Stub>; | |
232 |
|
243 | |||
233 | assert_eq!(raw_next(raw), 13); |
|
244 | assert_eq!(raw_next(raw), 13); |
General Comments 0
You need to be logged in to leave comments.
Login now