Skip to content

Commit 475d04c

Browse files
committed
IntoPyRef to vm::function
1 parent a5b36e1 commit 475d04c

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

stdlib/src/zlib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ mod zlib {
55
use crate::common::lock::PyMutex;
66
use crate::vm::{
77
builtins::{PyBaseExceptionRef, PyBytes, PyBytesRef, PyIntRef, PyTypeRef},
8-
function::{ArgBytesLike, OptionalArg, OptionalOption},
9-
IntoPyRef, PyResult, PyValue, VirtualMachine,
8+
function::{ArgBytesLike, IntoPyRef, OptionalArg, OptionalOption},
9+
PyResult, PyValue, VirtualMachine,
1010
};
1111
use adler32::RollingAdler32 as Adler32;
1212
use crossbeam_utils::atomic::AtomicCell;

vm/src/builtins/range.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ use super::{PyInt, PyIntRef, PySlice, PyTupleRef, PyTypeRef};
22
use crate::common::hash::PyHash;
33
use crate::{
44
builtins::builtins_iter,
5-
function::{FuncArgs, OptionalArg},
5+
function::{FuncArgs, IntoPyRef, OptionalArg},
66
protocol::{PyIterReturn, PyMappingMethods, PySequenceMethods},
77
pyclass::PyClassImpl,
88
types::{
99
AsMapping, AsSequence, Comparable, Constructor, Hashable, IterNext, IterNextIterable,
1010
Iterable, PyComparisonOp, Unconstructible,
1111
},
12-
IdProtocol, IntoPyRef, PyContext, PyObject, PyObjectRef, PyRef, PyResult, PyValue,
13-
TryFromObject, TypeProtocol, VirtualMachine,
12+
IdProtocol, PyContext, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
13+
TypeProtocol, VirtualMachine,
1414
};
1515
use crossbeam_utils::atomic::AtomicCell;
1616
use num_bigint::{BigInt, Sign};

vm/src/function.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ mod number;
44

55
use crate::{
66
builtins::{PyBaseExceptionRef, PyTupleRef, PyTypeRef},
7-
PyObject, PyObjectRef, PyRef, PyResult, PyThreadingConstraint, PyValue, TryFromObject,
8-
TypeProtocol, VirtualMachine,
7+
PyObject, PyObjectPayload, PyObjectRef, PyRef, PyResult, PyThreadingConstraint, PyValue,
8+
TryFromObject, TypeProtocol, VirtualMachine,
99
};
1010
use indexmap::IndexMap;
1111
use itertools::Itertools;
@@ -28,6 +28,10 @@ pub trait IntoPyResult {
2828
fn into_pyresult(self, vm: &VirtualMachine) -> PyResult;
2929
}
3030

31+
pub trait IntoPyRef<T: PyObjectPayload> {
32+
fn into_pyref(self, vm: &VirtualMachine) -> PyRef<T>;
33+
}
34+
3135
pub trait IntoPyException {
3236
fn into_pyexception(self, vm: &VirtualMachine) -> PyBaseExceptionRef;
3337
}

vm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ pub use self::ops::{PyArithmeticValue, PyComparisonValue};
8888

8989
// pyobject
9090
pub use self::pyobject::{
91-
IdProtocol, IntoPyRef, PyAttributes, PyContext, PyLease, PyMethod, PyObjectPayload, PyRefExact,
92-
PyResult, PyStructSequence, PyThreadingConstraint, PyValue, TypeProtocol,
91+
IdProtocol, PyAttributes, PyContext, PyLease, PyMethod, PyObjectPayload, PyRefExact, PyResult,
92+
PyStructSequence, PyThreadingConstraint, PyValue, TypeProtocol,
9393
};
9494
// pyobjectrc
9595
pub use self::pyobject::{

vm/src/pyobject.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
convert::TryFromObject,
1515
dictdatatype::Dict,
1616
exceptions,
17-
function::{IntoFuncArgs, IntoPyNativeFunc, IntoPyObject, IntoPyResult},
17+
function::{IntoFuncArgs, IntoPyNativeFunc, IntoPyObject, IntoPyRef, IntoPyResult},
1818
pyclass::{PyClassImpl, StaticType},
1919
types::{PyTypeFlags, PyTypeSlots, TypeZoo},
2020
VirtualMachine,
@@ -520,10 +520,6 @@ impl<T: TypeProtocol> TypeProtocol for &'_ T {
520520
}
521521
}
522522

523-
pub trait IntoPyRef<T: PyObjectPayload> {
524-
fn into_pyref(self, vm: &VirtualMachine) -> PyRef<T>;
525-
}
526-
527523
impl<T, P> IntoPyRef<P> for T
528524
where
529525
P: PyValue + IntoPyObject + From<T>,

vm/src/stdlib/os.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,13 @@ pub(super) mod _os {
434434
PyBytesRef, PyGenericAlias, PyIntRef, PyStrRef, PyTuple, PyTupleRef, PyTypeRef,
435435
},
436436
crt_fd::{Fd, Offset},
437-
function::{ArgBytesLike, FuncArgs, IntoPyException, IntoPyObject, OptionalArg},
437+
function::{ArgBytesLike, FuncArgs, IntoPyException, IntoPyObject, IntoPyRef, OptionalArg},
438438
protocol::PyIterReturn,
439439
suppress_iph,
440440
types::{IterNext, IterNextIterable},
441441
utils::Either,
442442
vm::{ReprGuard, VirtualMachine},
443-
IntoPyRef, PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue, TryFromObject,
444-
TypeProtocol,
443+
PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue, TryFromObject, TypeProtocol,
445444
};
446445
use crossbeam_utils::atomic::AtomicCell;
447446
use itertools::Itertools;

0 commit comments

Comments
 (0)