Skip to content

Commit f0dd29d

Browse files
authored
Merge pull request #3127 from youknowone/static-type
derive(PyValue) not to depend on local context
2 parents 6e908de + 0d09bc7 commit f0dd29d

25 files changed

+34
-40
lines changed

derive/src/pyvalue.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ pub(crate) fn impl_pyvalue(input: DeriveInput) -> std::result::Result<TokenStrea
88

99
let ret = quote! {
1010
impl ::rustpython_vm::PyValue for #ty {
11-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
11+
fn class(_vm: &::rustpython_vm::VirtualMachine) -> &rustpython_vm::builtins::PyTypeRef {
12+
use ::rustpython_vm::StaticType;
1213
Self::static_type()
1314
}
1415
}

vm/src/stdlib/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod array {
2121
sliceable::{saturate_index, PySliceableSequence, PySliceableSequenceMut, SequenceIndex},
2222
slots::{AsBuffer, Comparable, Iterable, PyComparisonOp, PyIter, SlotConstructor},
2323
IdProtocol, IntoPyObject, IntoPyResult, PyComparisonValue, PyObjectRef, PyRef, PyResult,
24-
PyValue, StaticType, TryFromObject, TypeProtocol, VirtualMachine,
24+
PyValue, TryFromObject, TypeProtocol, VirtualMachine,
2525
};
2626
use crossbeam_utils::atomic::AtomicCell;
2727
use itertools::Itertools;

vm/src/stdlib/collections.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ mod _collections {
1414
Comparable, Hashable, Iterable, PyComparisonOp, PyIter, SlotConstructor, Unhashable,
1515
},
1616
vm::ReprGuard,
17-
PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TypeProtocol,
18-
VirtualMachine,
17+
PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol, VirtualMachine,
1918
};
2019
use crossbeam_utils::atomic::AtomicCell;
2120
use itertools::Itertools;

vm/src/stdlib/csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::common::lock::PyMutex;
22
use crate::{
3-
builtins::{PyStr, PyStrRef, PyTypeRef},
3+
builtins::{PyStr, PyStrRef},
44
function::{ArgIterable, ArgumentError, FromArgs, FuncArgs},
55
iterator,
66
slots::PyIter,
77
types::create_simple_type,
8-
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
8+
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
99
VirtualMachine,
1010
};
1111
use itertools::{self, Itertools};

vm/src/stdlib/hashlib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod hashlib {
66
use crate::{
77
builtins::{PyBytes, PyBytesRef, PyStrRef, PyTypeRef},
88
function::{FuncArgs, OptionalArg},
9-
PyResult, PyValue, StaticType, VirtualMachine,
9+
PyResult, PyValue, VirtualMachine,
1010
};
1111
use blake2::{Blake2b, Blake2s};
1212
use digest::DynDigest;

vm/src/stdlib/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3682,7 +3682,7 @@ mod fileio {
36823682
use crate::function::{FuncArgs, OptionalArg};
36833683
use crate::stdlib::os;
36843684
use crate::vm::VirtualMachine;
3685-
use crate::{PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol};
3685+
use crate::{PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol};
36863686
use crossbeam_utils::atomic::AtomicCell;
36873687
use std::io::{Read, Write};
36883688

vm/src/stdlib/itertools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ mod decl {
1111
function::{ArgCallable, FuncArgs, OptionalArg, OptionalOption, PosArgs},
1212
iterator::{call_next, get_iter, get_next_object},
1313
slots::{PyIter, SlotConstructor},
14-
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, PyWeakRef, StaticType,
15-
TypeProtocol, VirtualMachine,
14+
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, PyWeakRef, TypeProtocol,
15+
VirtualMachine,
1616
};
1717
use crossbeam_utils::atomic::AtomicCell;
1818
use num_bigint::BigInt;

vm/src/stdlib/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod _json {
1010
function::{FuncArgs, OptionalArg},
1111
iterator,
1212
slots::{Callable, SlotConstructor},
13-
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject,
13+
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
1414
VirtualMachine,
1515
};
1616
use num_bigint::BigInt;

vm/src/stdlib/operator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ mod _operator {
2222
},
2323
utils::Either,
2424
vm::ReprGuard,
25-
IdProtocol, ItemProtocol, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryIntoRef,
26-
TypeProtocol, VirtualMachine,
25+
IdProtocol, ItemProtocol, PyObjectRef, PyRef, PyResult, PyValue, TryIntoRef, TypeProtocol,
26+
VirtualMachine,
2727
};
2828

2929
/// Same as a < b.

vm/src/stdlib/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ pub(super) mod _os {
378378
suppress_iph,
379379
utils::Either,
380380
vm::{ReprGuard, VirtualMachine},
381-
IntoPyObject, PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue, StaticType,
381+
IntoPyObject, PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue,
382382
TryFromBorrowedObject, TryFromObject, TypeProtocol,
383383
};
384384
use crossbeam_utils::atomic::AtomicCell;

vm/src/stdlib/posix.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ pub mod module {
3939
_os, fs_metadata,
4040
},
4141
utils::{Either, ToCString},
42-
IntoPyObject, ItemProtocol, PyObjectRef, PyResult, PyValue, StaticType, TryFromObject,
43-
VirtualMachine,
42+
IntoPyObject, ItemProtocol, PyObjectRef, PyResult, PyValue, TryFromObject, VirtualMachine,
4443
};
4544
use bitflags::bitflags;
4645
use nix::fcntl;

vm/src/stdlib/pyexpat.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ mod _pyexpat {
3434
use crate::builtins::{PyStr, PyStrRef, PyTypeRef};
3535
use crate::byteslike::ArgBytesLike;
3636
use crate::function::{IntoFuncArgs, OptionalArg};
37-
use crate::pyobject::StaticType;
3837
use crate::{
3938
ItemProtocol, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
4039
VirtualMachine,

vm/src/stdlib/pystruct.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub(crate) mod _struct {
2222
function::PosArgs,
2323
slots::{PyIter, SlotConstructor},
2424
utils::Either,
25-
IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject,
26-
VirtualMachine,
25+
IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine,
2726
};
2827
use crossbeam_utils::atomic::AtomicCell;
2928
use half::f16;

vm/src/stdlib/random.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod _random {
99
builtins::{PyIntRef, PyTypeRef},
1010
function::OptionalOption,
1111
slots::SlotConstructor,
12-
PyObjectRef, PyResult, PyValue, StaticType, VirtualMachine,
12+
PyObjectRef, PyResult, PyValue, VirtualMachine,
1313
};
1414
use num_bigint::{BigInt, Sign};
1515
use num_traits::{Signed, Zero};

vm/src/stdlib/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ mod decl {
252252
#[cfg(unix)]
253253
pub(super) mod poll {
254254
use super::*;
255-
use crate::builtins::{PyFloat, PyTypeRef};
255+
use crate::builtins::PyFloat;
256256
use crate::common::lock::PyMutex;
257257
use crate::function::OptionalArg;
258258
use crate::stdlib::io::Fildes;
259-
use crate::{IntoPyObject, PyValue, StaticType, TypeProtocol};
259+
use crate::{IntoPyObject, PyValue, TypeProtocol};
260260
use libc::pollfd;
261261
use num_traits::ToPrimitive;
262262
use std::time;

vm/src/stdlib/socket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::{
55
exceptions::{IntoPyException, PyBaseExceptionRef},
66
function::{FuncArgs, OptionalArg, OptionalOption},
77
utils::{Either, ToCString},
8-
IntoPyObject, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
9-
TryFromBorrowedObject, TryFromObject, TypeProtocol, VirtualMachine,
8+
IntoPyObject, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromBorrowedObject,
9+
TryFromObject, TypeProtocol, VirtualMachine,
1010
};
1111
use crossbeam_utils::atomic::AtomicCell;
1212
use gethostname::gethostname;

vm/src/stdlib/sre.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ mod _sre {
66
buffer::PyBuffer,
77
builtins::{
88
PyCallableIterator, PyDictRef, PyInt, PyList, PyListRef, PyStr, PyStrRef, PyTupleRef,
9-
PyTypeRef,
109
},
1110
common::hash::PyHash,
1211
function::{ArgCallable, OptionalArg, PosArgs},
1312
slots::{Comparable, Hashable},
1413
IntoPyObject, ItemProtocol, PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue,
15-
StaticType, TryFromBorrowedObject, TryFromObject, VirtualMachine,
14+
TryFromBorrowedObject, TryFromObject, VirtualMachine,
1615
};
1716
use core::str;
1817
use crossbeam_utils::atomic::AtomicCell;

vm/src/stdlib/ssl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use crate::{
88
slots::SlotConstructor,
99
stdlib::os::PyPathLike,
1010
utils::{Either, ToCString},
11-
IntoPyObject, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
12-
VirtualMachine,
11+
IntoPyObject, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, VirtualMachine,
1312
};
1413
use crossbeam_utils::atomic::AtomicCell;
1514
use foreign_types_shared::{ForeignType, ForeignTypeRef};

vm/src/stdlib/symtable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ pub(crate) use decl::make_module;
33
#[pymodule(name = "symtable")]
44
mod decl {
55
use crate::{
6-
builtins::{PyStrRef, PyTypeRef},
6+
builtins::PyStrRef,
77
compile::{self, Symbol, SymbolScope, SymbolTable, SymbolTableType},
8-
PyRef, PyResult, PyValue, StaticType, VirtualMachine,
8+
PyRef, PyResult, PyValue, VirtualMachine,
99
};
1010
use std::fmt;
1111

vm/src/stdlib/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::{
77
py_io,
88
slots::{SlotGetattro, SlotSetattro},
99
utils::Either,
10-
IdProtocol, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
11-
TypeProtocol, VirtualMachine,
10+
IdProtocol, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
11+
VirtualMachine,
1212
};
1313
use parking_lot::{
1414
lock_api::{RawMutex as RawMutexT, RawMutexTimed, RawReentrantMutex},

vm/src/stdlib/unicodedata.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
*/
44

55
use crate::{
6-
builtins::{PyStrRef, PyTypeRef},
7-
function::OptionalArg,
8-
PyClassImpl, PyObject, PyObjectRef, PyResult, PyValue, StaticType, VirtualMachine,
6+
builtins::PyStrRef, function::OptionalArg, PyClassImpl, PyObject, PyObjectRef, PyResult,
7+
PyValue, VirtualMachine,
98
};
109
use itertools::Itertools;
1110
use unic_char_property::EnumeratedCharProperty;

vm/src/stdlib/winreg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
44
use crate::{
55
builtins::{PyStrRef, PyTypeRef},
66
exceptions::IntoPyException,
7-
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, VirtualMachine,
7+
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine,
88
};
99
use std::convert::TryInto;
1010
use std::ffi::OsStr;

vm/src/stdlib/zlib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod decl {
99
exceptions::PyBaseExceptionRef,
1010
function::OptionalArg,
1111
types::create_simple_type,
12-
IntoPyRef, PyResult, PyValue, StaticType, VirtualMachine,
12+
IntoPyRef, PyResult, PyValue, VirtualMachine,
1313
};
1414
use adler32::RollingAdler32 as Adler32;
1515
use crc32fast::Hasher as Crc32;

wasm/lib/src/browser_module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use wasm_bindgen::prelude::*;
33
use wasm_bindgen::JsCast;
44
use wasm_bindgen_futures::JsFuture;
55

6-
use rustpython_vm::builtins::{PyDictRef, PyStrRef, PyTypeRef};
6+
use rustpython_vm::builtins::{PyDictRef, PyStrRef};
77
use rustpython_vm::function::{ArgCallable, OptionalArg};
88
use rustpython_vm::import::import_file;
99
use rustpython_vm::{
10-
IntoPyObject, PyClassImpl, PyObject, PyObjectRef, PyResult, PyValue, StaticType, VirtualMachine,
10+
IntoPyObject, PyClassImpl, PyObject, PyObjectRef, PyResult, PyValue, VirtualMachine,
1111
};
1212

1313
use crate::{convert, js_module::PyPromise, vm_class::weak_vm, wasm_builtins::window};

wasm/lib/src/js_module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustpython_vm::types::create_simple_type;
1414
use rustpython_vm::VirtualMachine;
1515
use rustpython_vm::{
1616
function::ArgCallable, IntoPyObject, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue,
17-
StaticType, TryFromObject,
17+
TryFromObject,
1818
};
1919

2020
#[wasm_bindgen(inline_js = "

0 commit comments

Comments
 (0)