author | Yuya Nishihara <yuya@tcha.org> |
Sun, 15 Sep 2019 16:50:48 +0900 | |
changeset 43178 | 1b2200bd06b6 |
parent 43177 | 5cb8867c9e2b |
child 43179 | 7d6758f2d50c |
permissions | -rw-r--r-- |
42762
b3518b0baa47
rust-dirstate: create dirstate submodule in hg-cpython
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
1 |
// dirs_multiset.rs |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
2 |
// |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
3 |
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net> |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
4 |
// |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
5 |
// This software may be used and distributed according to the terms of the |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
6 |
// GNU General Public License version 2 or any later version. |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
7 |
|
42762
b3518b0baa47
rust-dirstate: create dirstate submodule in hg-cpython
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
8 |
//! Bindings for the `hg::dirstate::dirs_multiset` file provided by the |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
9 |
//! `hg-core` package. |
42762
b3518b0baa47
rust-dirstate: create dirstate submodule in hg-cpython
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
10 |
|
b3518b0baa47
rust-dirstate: create dirstate submodule in hg-cpython
Raphaël Gomès <rgomes@octobus.net>
parents:
42609
diff
changeset
|
11 |
use std::cell::RefCell; |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
12 |
use std::convert::TryInto; |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
13 |
|
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
14 |
use cpython::{ |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
15 |
exc, ObjectProtocol, PyBytes, PyClone, PyDict, PyErr, PyObject, PyResult, |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
16 |
Python, |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
17 |
}; |
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
18 |
|
43177
5cb8867c9e2b
rust-cpython: move $leaked struct out of macro
Yuya Nishihara <yuya@tcha.org>
parents:
43173
diff
changeset
|
19 |
use crate::dirstate::extract_dirstate; |
5cb8867c9e2b
rust-cpython: move $leaked struct out of macro
Yuya Nishihara <yuya@tcha.org>
parents:
43173
diff
changeset
|
20 |
use crate::ref_sharing::{PyLeakedRef, PySharedRefCell}; |
42893
706104dcb2c8
rust-cpython: replace dyn Iterator<..> of sequence with concrete type
Yuya Nishihara <yuya@tcha.org>
parents:
42857
diff
changeset
|
21 |
use hg::{ |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
22 |
utils::hg_path::{HgPath, HgPathBuf}, |
42893
706104dcb2c8
rust-cpython: replace dyn Iterator<..> of sequence with concrete type
Yuya Nishihara <yuya@tcha.org>
parents:
42857
diff
changeset
|
23 |
DirsMultiset, DirsMultisetIter, DirstateMapError, DirstateParseError, |
706104dcb2c8
rust-cpython: replace dyn Iterator<..> of sequence with concrete type
Yuya Nishihara <yuya@tcha.org>
parents:
42857
diff
changeset
|
24 |
EntryState, |
706104dcb2c8
rust-cpython: replace dyn Iterator<..> of sequence with concrete type
Yuya Nishihara <yuya@tcha.org>
parents:
42857
diff
changeset
|
25 |
}; |
42330
e240bec26626
rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff
changeset
|
26 |
|
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
27 |
py_class!(pub class Dirs |py| { |
42855
8db8fa1de2ef
rust-cpython: introduce restricted variant of RefCell
Yuya Nishihara <yuya@tcha.org>
parents:
42818
diff
changeset
|
28 |
data inner: PySharedRefCell<DirsMultiset>; |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
29 |
|
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
30 |
// `map` is either a `dict` or a flat iterator (usually a `set`, sometimes |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
31 |
// a `list`) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
32 |
def __new__( |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
33 |
_cls, |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
34 |
map: PyObject, |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
35 |
skip: Option<PyObject> = None |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
36 |
) -> PyResult<Self> { |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
37 |
let mut skip_state: Option<EntryState> = None; |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
38 |
if let Some(skip) = skip { |
42765
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
39 |
skip_state = Some( |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
40 |
skip.extract::<PyBytes>(py)?.data(py)[0] |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
41 |
.try_into() |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
42 |
.map_err(|e: DirstateParseError| { |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
43 |
PyErr::new::<exc::ValueError, _>(py, e.to_string()) |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
44 |
})?, |
7ceded4419a3
rust-dirstate: use EntryState enum instead of literals
Raphaël Gomès <rgomes@octobus.net>
parents:
42764
diff
changeset
|
45 |
); |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
46 |
} |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42762
diff
changeset
|
47 |
let inner = if let Ok(map) = map.cast_as::<PyDict>(py) { |
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42762
diff
changeset
|
48 |
let dirstate = extract_dirstate(py, &map)?; |
42818
2e1f74cc3350
rust-dirstate: split DirsMultiset constructor per input type
Yuya Nishihara <yuya@tcha.org>
parents:
42768
diff
changeset
|
49 |
DirsMultiset::from_dirstate(&dirstate, skip_state) |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
50 |
} else { |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
51 |
let map: Result<Vec<HgPathBuf>, PyErr> = map |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
52 |
.iter(py)? |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
53 |
.map(|o| { |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
54 |
Ok(HgPathBuf::from_bytes( |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
55 |
o?.extract::<PyBytes>(py)?.data(py), |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
56 |
)) |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
57 |
}) |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
58 |
.collect(); |
42818
2e1f74cc3350
rust-dirstate: split DirsMultiset constructor per input type
Yuya Nishihara <yuya@tcha.org>
parents:
42768
diff
changeset
|
59 |
DirsMultiset::from_manifest(&map?) |
42764
7cae6bc29ff9
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop
Raphaël Gomès <rgomes@octobus.net>
parents:
42762
diff
changeset
|
60 |
}; |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
61 |
|
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
62 |
Self::create_instance( |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
63 |
py, |
42855
8db8fa1de2ef
rust-cpython: introduce restricted variant of RefCell
Yuya Nishihara <yuya@tcha.org>
parents:
42818
diff
changeset
|
64 |
PySharedRefCell::new(inner), |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
65 |
) |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
66 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
67 |
|
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
68 |
def addpath(&self, path: PyObject) -> PyResult<PyObject> { |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
69 |
self.borrow_mut(py)?.add_path( |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
70 |
HgPath::new(path.extract::<PyBytes>(py)?.data(py)), |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
71 |
); |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
72 |
Ok(py.None()) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
73 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
74 |
|
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
75 |
def delpath(&self, path: PyObject) -> PyResult<PyObject> { |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
76 |
self.borrow_mut(py)?.delete_path( |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
77 |
HgPath::new(path.extract::<PyBytes>(py)?.data(py)), |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
78 |
) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
79 |
.and(Ok(py.None())) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
80 |
.or_else(|e| { |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
81 |
match e { |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
82 |
DirstateMapError::PathNotFound(_p) => { |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
83 |
Err(PyErr::new::<exc::ValueError, _>( |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
84 |
py, |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
85 |
"expected a value, found none".to_string(), |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
86 |
)) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
87 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
88 |
DirstateMapError::EmptyPath => { |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
89 |
Ok(py.None()) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
90 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
91 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
92 |
}) |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
93 |
} |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
94 |
def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> { |
42857
64e28b891796
rust-cpython: mark unsafe functions as such
Yuya Nishihara <yuya@tcha.org>
parents:
42856
diff
changeset
|
95 |
let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; |
42897
5ccc08d02280
rust-cpython: leverage py_shared_iterator::from_inner() where appropriate
Yuya Nishihara <yuya@tcha.org>
parents:
42895
diff
changeset
|
96 |
DirsMultisetKeysIterator::from_inner( |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
97 |
py, |
42897
5ccc08d02280
rust-cpython: leverage py_shared_iterator::from_inner() where appropriate
Yuya Nishihara <yuya@tcha.org>
parents:
42895
diff
changeset
|
98 |
leak_handle, |
5ccc08d02280
rust-cpython: leverage py_shared_iterator::from_inner() where appropriate
Yuya Nishihara <yuya@tcha.org>
parents:
42895
diff
changeset
|
99 |
leaked_ref.iter(), |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
100 |
) |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
101 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
102 |
|
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
103 |
def __contains__(&self, item: PyObject) -> PyResult<bool> { |
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
104 |
Ok(self.inner(py).borrow().contains(HgPath::new( |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
105 |
item.extract::<PyBytes>(py)?.data(py).as_ref(), |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
106 |
))) |
42544
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
107 |
} |
ce94f9622acd
rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents:
42427
diff
changeset
|
108 |
}); |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
109 |
|
43178
1b2200bd06b6
rust-cpython: add safe wrapper representing shared data borrowed from PyObject
Yuya Nishihara <yuya@tcha.org>
parents:
43177
diff
changeset
|
110 |
py_shared_ref!(Dirs, DirsMultiset, inner, inner_shared); |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
111 |
|
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
112 |
impl Dirs { |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
113 |
pub fn from_inner(py: Python, d: DirsMultiset) -> PyResult<Self> { |
43173
070a38737334
rust-cpython: move py_shared_state to PySharedRefCell object
Yuya Nishihara <yuya@tcha.org>
parents:
42960
diff
changeset
|
114 |
Self::create_instance(py, PySharedRefCell::new(d)) |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
115 |
} |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
116 |
|
42960
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
117 |
fn translate_key( |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
118 |
py: Python, |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
119 |
res: &HgPathBuf, |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
120 |
) -> PyResult<Option<PyBytes>> { |
7a01778bc7b7
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf
Raphaël Gomès <rgomes@octobus.net>
parents:
42897
diff
changeset
|
121 |
Ok(Some(PyBytes::new(py, res.as_ref()))) |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
122 |
} |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
123 |
} |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
124 |
|
42895
ea91a126c803
rust-cpython: rename py_shared_iterator_impl to py_shared_iterator
Yuya Nishihara <yuya@tcha.org>
parents:
42893
diff
changeset
|
125 |
py_shared_iterator!( |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
126 |
DirsMultisetKeysIterator, |
43177
5cb8867c9e2b
rust-cpython: move $leaked struct out of macro
Yuya Nishihara <yuya@tcha.org>
parents:
43173
diff
changeset
|
127 |
PyLeakedRef, |
42893
706104dcb2c8
rust-cpython: replace dyn Iterator<..> of sequence with concrete type
Yuya Nishihara <yuya@tcha.org>
parents:
42857
diff
changeset
|
128 |
DirsMultisetIter<'static>, |
42768
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
129 |
Dirs::translate_key, |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
130 |
Option<PyBytes> |
30320c7bf79f
rust-cpython: add macro for sharing references
Raphaël Gomès <rgomes@octobus.net>
parents:
42766
diff
changeset
|
131 |
); |