forked from Rust-related/RustPython
move vm/src/{byteslike.rs -> function/byteslike.rs}
This commit is contained in:
@@ -14,8 +14,7 @@ use crate::{
|
||||
ByteInnerNewOptions, ByteInnerPaddingOptions, ByteInnerSplitOptions,
|
||||
ByteInnerTranslateOptions, DecodeArgs, PyBytesInner,
|
||||
},
|
||||
byteslike::ArgBytesLike,
|
||||
function::{ArgIterable, FuncArgs, OptionalArg, OptionalOption},
|
||||
function::{ArgBytesLike, ArgIterable, FuncArgs, OptionalArg, OptionalOption},
|
||||
protocol::{BufferInternal, BufferOptions, PyBuffer, ResizeGuard},
|
||||
sliceable::{PySliceableSequence, PySliceableSequenceMut, SequenceIndex},
|
||||
slots::{
|
||||
|
||||
@@ -5,9 +5,8 @@ use crate::{
|
||||
bytes_decode, ByteInnerFindOptions, ByteInnerNewOptions, ByteInnerPaddingOptions,
|
||||
ByteInnerSplitOptions, ByteInnerTranslateOptions, DecodeArgs, PyBytesInner,
|
||||
},
|
||||
byteslike::ArgBytesLike,
|
||||
common::hash::PyHash,
|
||||
function::{ArgIterable, OptionalArg, OptionalOption},
|
||||
function::{ArgBytesLike, ArgIterable, OptionalArg, OptionalOption},
|
||||
protocol::{BufferInternal, BufferOptions, PyBuffer},
|
||||
slots::{
|
||||
AsBuffer, Callable, Comparable, Hashable, Iterable, IteratorIterable, PyComparisonOp,
|
||||
|
||||
@@ -20,10 +20,10 @@ mod decl {
|
||||
#[cfg(feature = "rustpython-compiler")]
|
||||
use crate::compile;
|
||||
use crate::{
|
||||
byteslike::ArgBytesLike,
|
||||
common::{hash::PyHash, str::to_ascii},
|
||||
function::{
|
||||
ArgCallable, ArgIterable, FuncArgs, KwArgs, OptionalArg, OptionalOption, PosArgs,
|
||||
ArgBytesLike, ArgCallable, ArgIterable, FuncArgs, KwArgs, OptionalArg, OptionalOption,
|
||||
PosArgs,
|
||||
},
|
||||
iterator, py_io,
|
||||
readline::{Readline, ReadlineResult},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
mod argument;
|
||||
mod byteslike;
|
||||
|
||||
use self::OptionalArg::*;
|
||||
use crate::builtins::pytype::PyTypeRef;
|
||||
@@ -16,6 +17,7 @@ use std::marker::PhantomData;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
pub use argument::{ArgCallable, ArgIterable, PyIterator};
|
||||
pub use byteslike::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike};
|
||||
|
||||
pub trait IntoFuncArgs: Sized {
|
||||
fn into_args(self, vm: &VirtualMachine) -> FuncArgs;
|
||||
|
||||
@@ -45,7 +45,6 @@ pub(crate) mod macros;
|
||||
mod anystr;
|
||||
pub mod builtins;
|
||||
mod bytesinner;
|
||||
pub mod byteslike;
|
||||
pub mod cformat;
|
||||
mod codecs;
|
||||
mod coroutine;
|
||||
|
||||
@@ -15,8 +15,7 @@ mod array {
|
||||
IntoPyFloat, PyByteArray, PyBytes, PyBytesRef, PyIntRef, PyList, PyListRef, PySliceRef,
|
||||
PyStr, PyStrRef, PyTypeRef,
|
||||
},
|
||||
byteslike::ArgBytesLike,
|
||||
function::{ArgIterable, OptionalArg},
|
||||
function::{ArgBytesLike, ArgIterable, OptionalArg},
|
||||
protocol::{BufferInternal, BufferOptions, PyBuffer, ResizeGuard},
|
||||
sliceable::{saturate_index, PySliceableSequence, PySliceableSequenceMut, SequenceIndex},
|
||||
slots::{
|
||||
|
||||
@@ -4,8 +4,7 @@ pub(crate) use decl::make_module;
|
||||
mod decl {
|
||||
use crate::{
|
||||
builtins::{PyByteArray, PyBytes, PyStr, PyTypeRef},
|
||||
byteslike::ArgBytesLike,
|
||||
function::OptionalArg,
|
||||
function::{ArgBytesLike, OptionalArg},
|
||||
PyObjectRef, PyRef, PyResult, TryFromObject, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use crc::{crc32, Hasher32};
|
||||
|
||||
@@ -5,10 +5,9 @@ mod _codecs {
|
||||
use crate::common::encodings;
|
||||
use crate::{
|
||||
builtins::{PyBytes, PyBytesRef, PyStr, PyStrRef, PyTuple},
|
||||
byteslike::ArgBytesLike,
|
||||
codecs,
|
||||
exceptions::PyBaseExceptionRef,
|
||||
function::FuncArgs,
|
||||
function::{ArgBytesLike, FuncArgs},
|
||||
IdProtocol, PyObjectRef, PyResult, TryFromBorrowedObject, VirtualMachine,
|
||||
};
|
||||
use std::ops::Range;
|
||||
|
||||
@@ -4,8 +4,7 @@ pub(crate) use fcntl::make_module;
|
||||
mod fcntl {
|
||||
use crate::{
|
||||
builtins::int,
|
||||
byteslike::{ArgMemoryBuffer, ArgStrOrBytesLike},
|
||||
function::OptionalArg,
|
||||
function::{ArgMemoryBuffer, ArgStrOrBytesLike, OptionalArg},
|
||||
stdlib::{io, os},
|
||||
utils::Either,
|
||||
PyResult, VirtualMachine,
|
||||
|
||||
@@ -80,8 +80,8 @@ mod _io {
|
||||
builtins::{
|
||||
PyByteArray, PyBytes, PyBytesRef, PyMemoryView, PyStr, PyStrRef, PyType, PyTypeRef,
|
||||
},
|
||||
byteslike::{ArgBytesLike, ArgMemoryBuffer},
|
||||
exceptions::{self, PyBaseExceptionRef},
|
||||
function::{ArgBytesLike, ArgMemoryBuffer},
|
||||
function::{ArgIterable, FuncArgs, OptionalArg, OptionalOption},
|
||||
protocol::{BufferInternal, BufferOptions, PyBuffer, ResizeGuard},
|
||||
slots::{Iterable, PyIter, SlotConstructor},
|
||||
@@ -3682,10 +3682,10 @@ mod fileio {
|
||||
use super::_io::*;
|
||||
use crate::{
|
||||
builtins::{PyStr, PyStrRef, PyTypeRef},
|
||||
byteslike::{ArgBytesLike, ArgMemoryBuffer},
|
||||
crt_fd::Fd,
|
||||
exceptions::IntoPyException,
|
||||
function::OptionalOption,
|
||||
function::{ArgBytesLike, ArgMemoryBuffer},
|
||||
function::{FuncArgs, OptionalArg},
|
||||
stdlib::os,
|
||||
PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol, VirtualMachine,
|
||||
|
||||
@@ -5,7 +5,7 @@ mod decl {
|
||||
use crate::{
|
||||
builtins::{PyBytes, PyCode},
|
||||
bytecode,
|
||||
byteslike::ArgBytesLike,
|
||||
function::ArgBytesLike,
|
||||
PyObjectRef, PyRef, PyResult, TryFromObject, VirtualMachine,
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ pub(crate) use _multiprocessing::make_module;
|
||||
#[cfg(windows)]
|
||||
#[pymodule]
|
||||
mod _multiprocessing {
|
||||
use crate::{byteslike::ArgBytesLike, stdlib::os, PyResult, VirtualMachine};
|
||||
use crate::{function::ArgBytesLike, stdlib::os, PyResult, VirtualMachine};
|
||||
use winapi::um::winsock2::{self, SOCKET};
|
||||
|
||||
#[pyfunction]
|
||||
|
||||
@@ -12,8 +12,7 @@ mod _operator {
|
||||
use crate::common::cmp;
|
||||
use crate::{
|
||||
builtins::{PyInt, PyIntRef, PyStrRef, PyTypeRef},
|
||||
byteslike::ArgBytesLike,
|
||||
function::{FuncArgs, KwArgs, OptionalArg},
|
||||
function::{ArgBytesLike, FuncArgs, KwArgs, OptionalArg},
|
||||
iterator,
|
||||
slots::{
|
||||
Callable,
|
||||
|
||||
@@ -370,10 +370,9 @@ pub(super) mod _os {
|
||||
use crate::common::lock::{OnceCell, PyRwLock};
|
||||
use crate::{
|
||||
builtins::{PyBytesRef, PyStrRef, PyTuple, PyTupleRef, PyTypeRef},
|
||||
byteslike::ArgBytesLike,
|
||||
crt_fd::{Fd, Offset},
|
||||
exceptions::IntoPyException,
|
||||
function::{FuncArgs, OptionalArg},
|
||||
function::{ArgBytesLike, FuncArgs, OptionalArg},
|
||||
slots::{IteratorIterable, PyIter},
|
||||
suppress_iph,
|
||||
utils::Either,
|
||||
|
||||
@@ -1729,10 +1729,10 @@ pub mod module {
|
||||
fn _extract_vec_bytes(
|
||||
x: OptionalArg,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<Option<Vec<crate::byteslike::ArgBytesLike>>> {
|
||||
) -> PyResult<Option<Vec<crate::function::ArgBytesLike>>> {
|
||||
let inner = match x.into_option() {
|
||||
Some(v) => {
|
||||
let v = vm.extract_elements::<crate::byteslike::ArgBytesLike>(&v)?;
|
||||
let v = vm.extract_elements::<crate::function::ArgBytesLike>(&v)?;
|
||||
if v.is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
||||
@@ -33,7 +33,7 @@ macro_rules! create_property {
|
||||
mod _pyexpat {
|
||||
use crate::{
|
||||
builtins::{PyStr, PyStrRef, PyTypeRef},
|
||||
byteslike::ArgBytesLike,
|
||||
function::ArgBytesLike,
|
||||
function::{IntoFuncArgs, OptionalArg},
|
||||
ItemProtocol, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
VirtualMachine,
|
||||
|
||||
@@ -16,10 +16,9 @@ pub(crate) mod _struct {
|
||||
bytes::PyBytesRef, float, pybool::IntoPyBool, pystr::PyStr, pystr::PyStrRef,
|
||||
pytype::PyTypeRef, tuple::PyTupleRef,
|
||||
},
|
||||
byteslike::{ArgBytesLike, ArgMemoryBuffer},
|
||||
common::str::wchar_t,
|
||||
exceptions::PyBaseExceptionRef,
|
||||
function::PosArgs,
|
||||
function::{ArgBytesLike, ArgMemoryBuffer, PosArgs},
|
||||
slots::{IteratorIterable, PyIter, SlotConstructor},
|
||||
utils::Either,
|
||||
IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, VirtualMachine,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::common::lock::{PyMappedRwLockReadGuard, PyRwLock, PyRwLockReadGuard};
|
||||
use crate::{
|
||||
builtins::{PyStrRef, PyTupleRef, PyTypeRef},
|
||||
byteslike::{ArgBytesLike, ArgMemoryBuffer},
|
||||
exceptions::{IntoPyException, PyBaseExceptionRef},
|
||||
function::{FuncArgs, OptionalArg, OptionalOption},
|
||||
function::{ArgBytesLike, ArgMemoryBuffer, FuncArgs, OptionalArg, OptionalOption},
|
||||
utils::{Either, ToCString},
|
||||
IntoPyObject, PyClassImpl, PyObjectRef, PyResult, PyValue, TryFromBorrowedObject,
|
||||
TryFromObject, TypeProtocol, VirtualMachine,
|
||||
@@ -302,7 +301,7 @@ impl PySocket {
|
||||
#[cfg(unix)]
|
||||
c::AF_UNIX => {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let buf = crate::byteslike::ArgStrOrBytesLike::try_from_object(vm, addr)?;
|
||||
let buf = crate::function::ArgStrOrBytesLike::try_from_object(vm, addr)?;
|
||||
let path = &*buf.borrow_bytes();
|
||||
if cfg!(any(target_os = "linux", target_os = "android")) && path.first() == Some(&0)
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::common::{
|
||||
};
|
||||
use crate::{
|
||||
builtins::{PyStrRef, PyType, PyTypeRef, PyWeak},
|
||||
byteslike::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike},
|
||||
exceptions::{self, IntoPyException, PyBaseException, PyBaseExceptionRef},
|
||||
function::{ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike},
|
||||
function::{ArgCallable, OptionalArg},
|
||||
slots::SlotConstructor,
|
||||
stdlib::os::PyPathLike,
|
||||
|
||||
@@ -5,9 +5,8 @@ mod decl {
|
||||
use crate::common::lock::PyMutex;
|
||||
use crate::{
|
||||
builtins::{PyBytes, PyBytesRef, PyIntRef, PyTypeRef},
|
||||
byteslike::ArgBytesLike,
|
||||
exceptions::PyBaseExceptionRef,
|
||||
function::OptionalArg,
|
||||
function::{ArgBytesLike, OptionalArg},
|
||||
types::create_simple_type,
|
||||
IntoPyRef, PyResult, PyValue, VirtualMachine,
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@ use js_sys::{Array, ArrayBuffer, Object, Promise, Reflect, SyntaxError, Uint8Arr
|
||||
use wasm_bindgen::{closure::Closure, prelude::*, JsCast};
|
||||
|
||||
use rustpython_parser::error::ParseErrorType;
|
||||
use rustpython_vm::byteslike::ArgBytesLike;
|
||||
use rustpython_vm::compile::{CompileError, CompileErrorType};
|
||||
use rustpython_vm::exceptions::PyBaseExceptionRef;
|
||||
use rustpython_vm::function::ArgBytesLike;
|
||||
use rustpython_vm::function::FuncArgs;
|
||||
use rustpython_vm::VirtualMachine;
|
||||
use rustpython_vm::{exceptions, py_serde};
|
||||
|
||||
Reference in New Issue
Block a user