forked from Rust-related/RustPython
Merge pull request #3127 from youknowone/static-type
derive(PyValue) not to depend on local context
This commit is contained in:
@@ -8,7 +8,8 @@ pub(crate) fn impl_pyvalue(input: DeriveInput) -> std::result::Result<TokenStrea
|
||||
|
||||
let ret = quote! {
|
||||
impl ::rustpython_vm::PyValue for #ty {
|
||||
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
|
||||
fn class(_vm: &::rustpython_vm::VirtualMachine) -> &rustpython_vm::builtins::PyTypeRef {
|
||||
use ::rustpython_vm::StaticType;
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ mod array {
|
||||
sliceable::{saturate_index, PySliceableSequence, PySliceableSequenceMut, SequenceIndex},
|
||||
slots::{AsBuffer, Comparable, Iterable, PyComparisonOp, PyIter, SlotConstructor},
|
||||
IdProtocol, IntoPyObject, IntoPyResult, PyComparisonValue, PyObjectRef, PyRef, PyResult,
|
||||
PyValue, StaticType, TryFromObject, TypeProtocol, VirtualMachine,
|
||||
PyValue, TryFromObject, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use itertools::Itertools;
|
||||
|
||||
@@ -14,8 +14,7 @@ mod _collections {
|
||||
Comparable, Hashable, Iterable, PyComparisonOp, PyIter, SlotConstructor, Unhashable,
|
||||
},
|
||||
vm::ReprGuard,
|
||||
PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TypeProtocol,
|
||||
VirtualMachine,
|
||||
PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use itertools::Itertools;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::common::lock::PyMutex;
|
||||
use crate::{
|
||||
builtins::{PyStr, PyStrRef, PyTypeRef},
|
||||
builtins::{PyStr, PyStrRef},
|
||||
function::{ArgIterable, ArgumentError, FromArgs, FuncArgs},
|
||||
iterator,
|
||||
slots::PyIter,
|
||||
types::create_simple_type,
|
||||
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol,
|
||||
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
|
||||
VirtualMachine,
|
||||
};
|
||||
use itertools::{self, Itertools};
|
||||
|
||||
@@ -6,7 +6,7 @@ mod hashlib {
|
||||
use crate::{
|
||||
builtins::{PyBytes, PyBytesRef, PyStrRef, PyTypeRef},
|
||||
function::{FuncArgs, OptionalArg},
|
||||
PyResult, PyValue, StaticType, VirtualMachine,
|
||||
PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
use blake2::{Blake2b, Blake2s};
|
||||
use digest::DynDigest;
|
||||
|
||||
@@ -3682,7 +3682,7 @@ mod fileio {
|
||||
use crate::function::{FuncArgs, OptionalArg};
|
||||
use crate::stdlib::os;
|
||||
use crate::vm::VirtualMachine;
|
||||
use crate::{PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, TypeProtocol};
|
||||
use crate::{PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ mod decl {
|
||||
function::{ArgCallable, FuncArgs, OptionalArg, OptionalOption, PosArgs},
|
||||
iterator::{call_next, get_iter, get_next_object},
|
||||
slots::{PyIter, SlotConstructor},
|
||||
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, PyWeakRef, StaticType,
|
||||
TypeProtocol, VirtualMachine,
|
||||
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, PyWeakRef, TypeProtocol,
|
||||
VirtualMachine,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use num_bigint::BigInt;
|
||||
|
||||
@@ -10,7 +10,7 @@ mod _json {
|
||||
function::{FuncArgs, OptionalArg},
|
||||
iterator,
|
||||
slots::{Callable, SlotConstructor},
|
||||
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject,
|
||||
IdProtocol, IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
VirtualMachine,
|
||||
};
|
||||
use num_bigint::BigInt;
|
||||
|
||||
@@ -22,8 +22,8 @@ mod _operator {
|
||||
},
|
||||
utils::Either,
|
||||
vm::ReprGuard,
|
||||
IdProtocol, ItemProtocol, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryIntoRef,
|
||||
TypeProtocol, VirtualMachine,
|
||||
IdProtocol, ItemProtocol, PyObjectRef, PyRef, PyResult, PyValue, TryIntoRef, TypeProtocol,
|
||||
VirtualMachine,
|
||||
};
|
||||
|
||||
/// Same as a < b.
|
||||
|
||||
@@ -378,7 +378,7 @@ pub(super) mod _os {
|
||||
suppress_iph,
|
||||
utils::Either,
|
||||
vm::{ReprGuard, VirtualMachine},
|
||||
IntoPyObject, PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue, StaticType,
|
||||
IntoPyObject, PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue,
|
||||
TryFromBorrowedObject, TryFromObject, TypeProtocol,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
@@ -39,8 +39,7 @@ pub mod module {
|
||||
_os, fs_metadata,
|
||||
},
|
||||
utils::{Either, ToCString},
|
||||
IntoPyObject, ItemProtocol, PyObjectRef, PyResult, PyValue, StaticType, TryFromObject,
|
||||
VirtualMachine,
|
||||
IntoPyObject, ItemProtocol, PyObjectRef, PyResult, PyValue, TryFromObject, VirtualMachine,
|
||||
};
|
||||
use bitflags::bitflags;
|
||||
use nix::fcntl;
|
||||
|
||||
@@ -34,7 +34,6 @@ mod _pyexpat {
|
||||
use crate::builtins::{PyStr, PyStrRef, PyTypeRef};
|
||||
use crate::byteslike::ArgBytesLike;
|
||||
use crate::function::{IntoFuncArgs, OptionalArg};
|
||||
use crate::pyobject::StaticType;
|
||||
use crate::{
|
||||
ItemProtocol, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
VirtualMachine,
|
||||
|
||||
@@ -22,8 +22,7 @@ pub(crate) mod _struct {
|
||||
function::PosArgs,
|
||||
slots::{PyIter, SlotConstructor},
|
||||
utils::Either,
|
||||
IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject,
|
||||
VirtualMachine,
|
||||
IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use half::f16;
|
||||
|
||||
@@ -9,7 +9,7 @@ mod _random {
|
||||
builtins::{PyIntRef, PyTypeRef},
|
||||
function::OptionalOption,
|
||||
slots::SlotConstructor,
|
||||
PyObjectRef, PyResult, PyValue, StaticType, VirtualMachine,
|
||||
PyObjectRef, PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
use num_bigint::{BigInt, Sign};
|
||||
use num_traits::{Signed, Zero};
|
||||
|
||||
@@ -252,11 +252,11 @@ mod decl {
|
||||
#[cfg(unix)]
|
||||
pub(super) mod poll {
|
||||
use super::*;
|
||||
use crate::builtins::{PyFloat, PyTypeRef};
|
||||
use crate::builtins::PyFloat;
|
||||
use crate::common::lock::PyMutex;
|
||||
use crate::function::OptionalArg;
|
||||
use crate::stdlib::io::Fildes;
|
||||
use crate::{IntoPyObject, PyValue, StaticType, TypeProtocol};
|
||||
use crate::{IntoPyObject, PyValue, TypeProtocol};
|
||||
use libc::pollfd;
|
||||
use num_traits::ToPrimitive;
|
||||
use std::time;
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::{
|
||||
exceptions::{IntoPyException, PyBaseExceptionRef},
|
||||
function::{FuncArgs, OptionalArg, OptionalOption},
|
||||
utils::{Either, ToCString},
|
||||
IntoPyObject, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
TryFromBorrowedObject, TryFromObject, TypeProtocol, VirtualMachine,
|
||||
IntoPyObject, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromBorrowedObject,
|
||||
TryFromObject, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use gethostname::gethostname;
|
||||
|
||||
@@ -6,13 +6,12 @@ mod _sre {
|
||||
buffer::PyBuffer,
|
||||
builtins::{
|
||||
PyCallableIterator, PyDictRef, PyInt, PyList, PyListRef, PyStr, PyStrRef, PyTupleRef,
|
||||
PyTypeRef,
|
||||
},
|
||||
common::hash::PyHash,
|
||||
function::{ArgCallable, OptionalArg, PosArgs},
|
||||
slots::{Comparable, Hashable},
|
||||
IntoPyObject, ItemProtocol, PyComparisonValue, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
StaticType, TryFromBorrowedObject, TryFromObject, VirtualMachine,
|
||||
TryFromBorrowedObject, TryFromObject, VirtualMachine,
|
||||
};
|
||||
use core::str;
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
@@ -8,8 +8,7 @@ use crate::{
|
||||
slots::SlotConstructor,
|
||||
stdlib::os::PyPathLike,
|
||||
utils::{Either, ToCString},
|
||||
IntoPyObject, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
VirtualMachine,
|
||||
IntoPyObject, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use foreign_types_shared::{ForeignType, ForeignTypeRef};
|
||||
|
||||
@@ -3,9 +3,9 @@ pub(crate) use decl::make_module;
|
||||
#[pymodule(name = "symtable")]
|
||||
mod decl {
|
||||
use crate::{
|
||||
builtins::{PyStrRef, PyTypeRef},
|
||||
builtins::PyStrRef,
|
||||
compile::{self, Symbol, SymbolScope, SymbolTable, SymbolTableType},
|
||||
PyRef, PyResult, PyValue, StaticType, VirtualMachine,
|
||||
PyRef, PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
use std::fmt;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ use crate::{
|
||||
py_io,
|
||||
slots::{SlotGetattro, SlotSetattro},
|
||||
utils::Either,
|
||||
IdProtocol, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType,
|
||||
TypeProtocol, VirtualMachine,
|
||||
IdProtocol, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
|
||||
VirtualMachine,
|
||||
};
|
||||
use parking_lot::{
|
||||
lock_api::{RawMutex as RawMutexT, RawMutexTimed, RawReentrantMutex},
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
builtins::{PyStrRef, PyTypeRef},
|
||||
function::OptionalArg,
|
||||
PyClassImpl, PyObject, PyObjectRef, PyResult, PyValue, StaticType, VirtualMachine,
|
||||
builtins::PyStrRef, function::OptionalArg, PyClassImpl, PyObject, PyObjectRef, PyResult,
|
||||
PyValue, VirtualMachine,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use unic_char_property::EnumeratedCharProperty;
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
|
||||
use crate::{
|
||||
builtins::{PyStrRef, PyTypeRef},
|
||||
exceptions::IntoPyException,
|
||||
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject, VirtualMachine,
|
||||
PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine,
|
||||
};
|
||||
use std::convert::TryInto;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
@@ -9,7 +9,7 @@ mod decl {
|
||||
exceptions::PyBaseExceptionRef,
|
||||
function::OptionalArg,
|
||||
types::create_simple_type,
|
||||
IntoPyRef, PyResult, PyValue, StaticType, VirtualMachine,
|
||||
IntoPyRef, PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
use adler32::RollingAdler32 as Adler32;
|
||||
use crc32fast::Hasher as Crc32;
|
||||
|
||||
@@ -3,11 +3,11 @@ use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
|
||||
use rustpython_vm::builtins::{PyDictRef, PyStrRef, PyTypeRef};
|
||||
use rustpython_vm::builtins::{PyDictRef, PyStrRef};
|
||||
use rustpython_vm::function::{ArgCallable, OptionalArg};
|
||||
use rustpython_vm::import::import_file;
|
||||
use rustpython_vm::{
|
||||
IntoPyObject, PyClassImpl, PyObject, PyObjectRef, PyResult, PyValue, StaticType, VirtualMachine,
|
||||
IntoPyObject, PyClassImpl, PyObject, PyObjectRef, PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
|
||||
use crate::{convert, js_module::PyPromise, vm_class::weak_vm, wasm_builtins::window};
|
||||
|
||||
@@ -14,7 +14,7 @@ use rustpython_vm::types::create_simple_type;
|
||||
use rustpython_vm::VirtualMachine;
|
||||
use rustpython_vm::{
|
||||
function::ArgCallable, IntoPyObject, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue,
|
||||
StaticType, TryFromObject,
|
||||
TryFromObject,
|
||||
};
|
||||
|
||||
#[wasm_bindgen(inline_js = "
|
||||
|
||||
Reference in New Issue
Block a user