Skip to content

Commit 8cdde91

Browse files
committed
Rename slot traits to drop Slot prefix
1 parent b99cb2f commit 8cdde91

52 files changed

Lines changed: 335 additions & 338 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

stdlib/src/array.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ mod array {
2525
},
2626
sliceable::{PySliceableSequence, PySliceableSequenceMut, SaturatedSlice, SequenceIndex},
2727
types::{
28-
AsBuffer, AsMapping, Comparable, Iterable, IteratorIterable, PyComparisonOp,
29-
SlotConstructor, SlotIterator,
28+
AsBuffer, AsMapping, Comparable, Constructor, IterNext, IterNextIterable, Iterable,
29+
PyComparisonOp,
3030
},
3131
IdProtocol, PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
3232
TypeProtocol, VirtualMachine,
@@ -638,7 +638,7 @@ mod array {
638638
init: OptionalArg<PyObjectRef>,
639639
}
640640

641-
impl SlotConstructor for PyArray {
641+
impl Constructor for PyArray {
642642
type Args = ArrayNewArgs;
643643

644644
fn py_new(
@@ -698,7 +698,7 @@ mod array {
698698

699699
#[pyimpl(
700700
flags(BASETYPE),
701-
with(Comparable, AsBuffer, AsMapping, Iterable, SlotConstructor)
701+
with(Comparable, AsBuffer, AsMapping, Iterable, Constructor)
702702
)]
703703
impl PyArray {
704704
fn read(&self) -> PyRwLockReadGuard<'_, ArrayContentType> {
@@ -1317,11 +1317,11 @@ mod array {
13171317
array: PyArrayRef,
13181318
}
13191319

1320-
#[pyimpl(with(SlotIterator))]
1320+
#[pyimpl(with(IterNext))]
13211321
impl PyArrayIter {}
13221322

1323-
impl IteratorIterable for PyArrayIter {}
1324-
impl SlotIterator for PyArrayIter {
1323+
impl IterNextIterable for PyArrayIter {}
1324+
impl IterNext for PyArrayIter {
13251325
fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
13261326
let pos = zelf.position.fetch_add(1);
13271327
let r = if let Some(item) = zelf.array.read().getitem_by_idx(pos, vm)? {

stdlib/src/csv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod _csv {
1515
function::{ArgIterable, ArgumentError, FromArgs, FuncArgs},
1616
match_class,
1717
protocol::{PyIter, PyIterReturn},
18-
types::{IteratorIterable, SlotIterator},
18+
types::{IterNext, IterNextIterable},
1919
PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol, VirtualMachine,
2020
};
2121
use itertools::{self, Itertools};
@@ -168,10 +168,10 @@ mod _csv {
168168
}
169169
}
170170

171-
#[pyimpl(with(SlotIterator))]
171+
#[pyimpl(with(IterNext))]
172172
impl Reader {}
173-
impl IteratorIterable for Reader {}
174-
impl SlotIterator for Reader {
173+
impl IterNextIterable for Reader {}
174+
impl IterNext for Reader {
175175
fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
176176
let string = match zelf.iter.next(vm)? {
177177
PyIterReturn::Return(obj) => obj,

stdlib/src/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod _json {
88
builtins::{PyBaseExceptionRef, PyStrRef, PyTypeRef},
99
function::{FuncArgs, IntoPyObject, IntoPyResult, OptionalArg},
1010
protocol::PyIterReturn,
11-
types::{Callable, SlotConstructor},
11+
types::{Callable, Constructor},
1212
IdProtocol, PyObjectRef, PyRef, PyResult, PyValue, VirtualMachine,
1313
};
1414
use num_bigint::BigInt;
@@ -27,7 +27,7 @@ mod _json {
2727
ctx: PyObjectRef,
2828
}
2929

30-
impl SlotConstructor for JsonScanner {
30+
impl Constructor for JsonScanner {
3131
type Args = PyObjectRef;
3232

3333
fn py_new(cls: PyTypeRef, ctx: Self::Args, vm: &VirtualMachine) -> PyResult {
@@ -63,7 +63,7 @@ mod _json {
6363
}
6464
}
6565

66-
#[pyimpl(with(Callable, SlotConstructor))]
66+
#[pyimpl(with(Callable, Constructor))]
6767
impl JsonScanner {
6868
fn parse(
6969
&self,

stdlib/src/random.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod _random {
88
use crate::vm::{
99
builtins::{PyIntRef, PyTypeRef},
1010
function::OptionalOption,
11-
types::SlotConstructor,
11+
types::Constructor,
1212
PyObjectRef, PyResult, PyValue, VirtualMachine,
1313
};
1414
use num_bigint::{BigInt, Sign};
@@ -61,7 +61,7 @@ mod _random {
6161
rng: PyMutex<PyRng>,
6262
}
6363

64-
impl SlotConstructor for PyRandom {
64+
impl Constructor for PyRandom {
6565
type Args = OptionalOption<PyObjectRef>;
6666

6767
fn py_new(
@@ -77,7 +77,7 @@ mod _random {
7777
}
7878
}
7979

80-
#[pyimpl(flags(BASETYPE), with(SlotConstructor))]
80+
#[pyimpl(flags(BASETYPE), with(Constructor))]
8181
impl PyRandom {
8282
#[pymethod]
8383
fn random(&self) -> f64 {

stdlib/src/ssl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mod _ssl {
3737
IntoPyObject, OptionalArg,
3838
},
3939
stdlib::os::PyPathLike,
40-
types::SlotConstructor,
40+
types::Constructor,
4141
utils::{Either, ToCString},
4242
ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, VirtualMachine,
4343
},
@@ -461,7 +461,7 @@ mod _ssl {
461461
unsafe { ssl::SslContextRef::from_ptr(x.as_ptr()) }
462462
}
463463

464-
impl SlotConstructor for PySslContext {
464+
impl Constructor for PySslContext {
465465
type Args = i32;
466466

467467
fn py_new(cls: PyTypeRef, proto_version: Self::Args, vm: &VirtualMachine) -> PyResult {
@@ -522,7 +522,7 @@ mod _ssl {
522522
}
523523
}
524524

525-
#[pyimpl(flags(BASETYPE), with(SlotConstructor))]
525+
#[pyimpl(flags(BASETYPE), with(Constructor))]
526526
impl PySslContext {
527527
fn builder(&self) -> PyRwLockWriteGuard<'_, SslContextBuilder> {
528528
self.ctx.write()

vm/src/builtins/asyncgenerator.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
frame::FrameRef,
66
function::OptionalArg,
77
protocol::PyIterReturn,
8-
types::{IteratorIterable, SlotIterator},
8+
types::{IterNext, IterNextIterable},
99
IdProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
1010
VirtualMachine,
1111
};
@@ -183,7 +183,7 @@ impl PyValue for PyAsyncGenASend {
183183
}
184184
}
185185

186-
#[pyimpl(with(SlotIterator))]
186+
#[pyimpl(with(IterNext))]
187187
impl PyAsyncGenASend {
188188
#[pymethod(name = "__await__")]
189189
fn r#await(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyRef<Self> {
@@ -256,8 +256,8 @@ impl PyAsyncGenASend {
256256
}
257257
}
258258

259-
impl IteratorIterable for PyAsyncGenASend {}
260-
impl SlotIterator for PyAsyncGenASend {
259+
impl IterNextIterable for PyAsyncGenASend {}
260+
impl IterNext for PyAsyncGenASend {
261261
fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
262262
PyIterReturn::from_pyresult(zelf.send(vm.ctx.none(), vm), vm)
263263
}
@@ -278,7 +278,7 @@ impl PyValue for PyAsyncGenAThrow {
278278
}
279279
}
280280

281-
#[pyimpl(with(SlotIterator))]
281+
#[pyimpl(with(IterNext))]
282282
impl PyAsyncGenAThrow {
283283
#[pymethod(name = "__await__")]
284284
fn r#await(zelf: PyRef<Self>, _vm: &VirtualMachine) -> PyRef<Self> {
@@ -402,8 +402,8 @@ impl PyAsyncGenAThrow {
402402
}
403403
}
404404

405-
impl IteratorIterable for PyAsyncGenAThrow {}
406-
impl SlotIterator for PyAsyncGenAThrow {
405+
impl IterNextIterable for PyAsyncGenAThrow {}
406+
impl IterNext for PyAsyncGenAThrow {
407407
fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
408408
PyIterReturn::from_pyresult(zelf.send(vm.ctx.none(), vm), vm)
409409
}

vm/src/builtins/builtinfunc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{pytype, PyClassMethod, PyStr, PyStrRef, PyTypeRef};
22
use crate::{
33
builtins::PyBoundMethod,
44
function::{FuncArgs, IntoPyNativeFunc, PyNativeFunc},
5-
types::{Callable, SlotDescriptor},
5+
types::{Callable, GetDescriptor},
66
PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol, VirtualMachine,
77
};
88
use std::fmt;
@@ -167,7 +167,7 @@ impl fmt::Debug for PyBuiltinMethod {
167167
}
168168
}
169169

170-
impl SlotDescriptor for PyBuiltinMethod {
170+
impl GetDescriptor for PyBuiltinMethod {
171171
fn descr_get(
172172
zelf: PyObjectRef,
173173
obj: Option<PyObjectRef>,
@@ -207,7 +207,7 @@ impl PyBuiltinMethod {
207207
}
208208
}
209209

210-
#[pyimpl(with(SlotDescriptor, Callable), flags(METHOD_DESCR))]
210+
#[pyimpl(with(GetDescriptor, Callable), flags(METHOD_DESCR))]
211211
impl PyBuiltinMethod {
212212
#[pyproperty(magic)]
213213
fn name(&self) -> PyStrRef {

vm/src/builtins/bytearray.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use crate::{
2323
},
2424
sliceable::{PySliceableSequence, PySliceableSequenceMut, SequenceIndex},
2525
types::{
26-
AsBuffer, AsMapping, Callable, Comparable, Hashable, Iterable, IteratorIterable,
27-
PyComparisonOp, SlotConstructor, SlotIterator, Unconstructible, Unhashable,
26+
AsBuffer, AsMapping, Callable, Comparable, Constructor, Hashable, IterNext,
27+
IterNextIterable, Iterable, PyComparisonOp, Unconstructible, Unhashable,
2828
},
2929
utils::Either,
3030
IdProtocol, PyClassDef, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef,
@@ -816,7 +816,7 @@ impl PyValue for PyByteArrayIterator {
816816
}
817817
}
818818

819-
#[pyimpl(with(SlotConstructor, SlotIterator))]
819+
#[pyimpl(with(Constructor, IterNext))]
820820
impl PyByteArrayIterator {
821821
#[pymethod(magic)]
822822
fn length_hint(&self) -> usize {
@@ -838,8 +838,8 @@ impl PyByteArrayIterator {
838838
}
839839
impl Unconstructible for PyByteArrayIterator {}
840840

841-
impl IteratorIterable for PyByteArrayIterator {}
842-
impl SlotIterator for PyByteArrayIterator {
841+
impl IterNextIterable for PyByteArrayIterator {}
842+
impl IterNext for PyByteArrayIterator {
843843
fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
844844
zelf.internal.lock().next(|bytearray, pos| {
845845
let buf = bytearray.borrow_buf();

vm/src/builtins/bytes.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::{
1111
},
1212
protocol::{BufferInternal, BufferOptions, PyBuffer, PyIterReturn, PyMappingMethods},
1313
types::{
14-
AsBuffer, AsMapping, Callable, Comparable, Hashable, Iterable, IteratorIterable,
15-
PyComparisonOp, SlotConstructor, SlotIterator, Unconstructible,
14+
AsBuffer, AsMapping, Callable, Comparable, Constructor, Hashable, IterNext,
15+
IterNextIterable, Iterable, PyComparisonOp, Unconstructible,
1616
},
1717
utils::Either,
1818
IdProtocol, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
@@ -93,7 +93,7 @@ pub(crate) fn init(context: &PyContext) {
9393
PyBytesIterator::extend_class(context, &context.types.bytes_iterator_type);
9494
}
9595

96-
impl SlotConstructor for PyBytes {
96+
impl Constructor for PyBytes {
9797
type Args = ByteInnerNewOptions;
9898

9999
fn py_new(cls: PyTypeRef, options: Self::Args, vm: &VirtualMachine) -> PyResult {
@@ -109,7 +109,7 @@ impl PyBytes {
109109

110110
#[pyimpl(
111111
flags(BASETYPE),
112-
with(AsMapping, Hashable, Comparable, AsBuffer, Iterable, SlotConstructor)
112+
with(AsMapping, Hashable, Comparable, AsBuffer, Iterable, Constructor)
113113
)]
114114
impl PyBytes {
115115
#[pymethod(magic)]
@@ -649,7 +649,7 @@ impl PyValue for PyBytesIterator {
649649
}
650650
}
651651

652-
#[pyimpl(with(SlotConstructor, SlotIterator))]
652+
#[pyimpl(with(Constructor, IterNext))]
653653
impl PyBytesIterator {
654654
#[pymethod(magic)]
655655
fn length_hint(&self) -> usize {
@@ -672,8 +672,8 @@ impl PyBytesIterator {
672672
}
673673
impl Unconstructible for PyBytesIterator {}
674674

675-
impl IteratorIterable for PyBytesIterator {}
676-
impl SlotIterator for PyBytesIterator {
675+
impl IterNextIterable for PyBytesIterator {}
676+
impl IterNext for PyBytesIterator {
677677
fn next(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
678678
zelf.internal.lock().next(|bytes, pos| {
679679
Ok(match bytes.as_bytes().get(pos) {

vm/src/builtins/classmethod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::PyTypeRef;
22
use crate::{
33
builtins::PyBoundMethod,
4-
types::{SlotConstructor, SlotDescriptor},
4+
types::{Constructor, GetDescriptor},
55
PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol, VirtualMachine,
66
};
77

@@ -43,7 +43,7 @@ impl PyValue for PyClassMethod {
4343
}
4444
}
4545

46-
impl SlotDescriptor for PyClassMethod {
46+
impl GetDescriptor for PyClassMethod {
4747
fn descr_get(
4848
zelf: PyObjectRef,
4949
obj: Option<PyObjectRef>,
@@ -56,7 +56,7 @@ impl SlotDescriptor for PyClassMethod {
5656
}
5757
}
5858

59-
impl SlotConstructor for PyClassMethod {
59+
impl Constructor for PyClassMethod {
6060
type Args = PyObjectRef;
6161

6262
fn py_new(cls: PyTypeRef, callable: Self::Args, vm: &VirtualMachine) -> PyResult {
@@ -70,7 +70,7 @@ impl PyClassMethod {
7070
}
7171
}
7272

73-
#[pyimpl(with(SlotDescriptor, SlotConstructor), flags(BASETYPE, HAS_DICT))]
73+
#[pyimpl(with(GetDescriptor, Constructor), flags(BASETYPE, HAS_DICT))]
7474
impl PyClassMethod {
7575
#[pyproperty(magic)]
7676
fn func(&self) -> PyObjectRef {

0 commit comments

Comments
 (0)