diff --git a/benches/microbenchmarks.rs b/benches/microbenchmarks.rs index eaf125a01..0b3996f3c 100644 --- a/benches/microbenchmarks.rs +++ b/benches/microbenchmarks.rs @@ -3,7 +3,7 @@ use criterion::{ Criterion, Throughput, }; use rustpython_compiler::Mode; -use rustpython_vm::{common::ascii, InitParameter, Interpreter, PyResult, PySettings}; +use rustpython_vm::{common::ascii, InitParameter, Interpreter, PyResult, Settings}; use std::{ ffi, fs, io, path::{Path, PathBuf}, @@ -109,7 +109,7 @@ fn cpy_run_code( } fn bench_rustpy_code(group: &mut BenchmarkGroup, bench: &MicroBenchmark) { - let mut settings = PySettings::default(); + let mut settings = Settings::default(); settings.path_list.push("Lib/".to_string()); settings.dont_write_bytecode = true; settings.no_user_site = true; diff --git a/src/lib.rs b/src/lib.rs index bc08a47e9..28cba7903 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ use rustpython_vm::{ compile, match_class, scope::Scope, stdlib::{atexit, sys}, - AsObject, InitParameter, Interpreter, PyObjectRef, PyResult, PySettings, TryFromObject, + AsObject, InitParameter, Interpreter, PyObjectRef, PyResult, Settings, TryFromObject, VirtualMachine, }; use std::{env, path::Path, process, str::FromStr}; @@ -308,8 +308,8 @@ fn add_stdlib(vm: &mut VirtualMachine) { /// Create settings by examining command line arguments and environment /// variables. -fn create_settings(matches: &ArgMatches) -> PySettings { - let mut settings = PySettings::default(); +fn create_settings(matches: &ArgMatches) -> Settings { + let mut settings = Settings::default(); settings.isolated = matches.is_present("isolate"); settings.ignore_environment = matches.is_present("ignore-environment"); settings.interactive = !matches.is_present("c") @@ -320,7 +320,7 @@ fn create_settings(matches: &ArgMatches) -> PySettings { let ignore_environment = settings.ignore_environment || settings.isolated; - // when rustpython-vm/pylib is enabled, PySettings::default().path_list has pylib::LIB_PATH + // when rustpython-vm/pylib is enabled, Settings::default().path_list has pylib::LIB_PATH let maybe_pylib = settings.path_list.pop(); // add the current directory to sys.path @@ -699,7 +699,7 @@ mod tests { use super::*; fn interpreter() -> Interpreter { - Interpreter::new_with_init(PySettings::default(), |vm| { + Interpreter::new_with_init(Settings::default(), |vm| { add_stdlib(vm); InitParameter::External }) diff --git a/vm/src/lib.rs b/vm/src/lib.rs index e5df719a3..4d39a4b7f 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -90,7 +90,7 @@ pub use self::pyobject::{AsObject, PyMethod, PyPayload, PyRefExact, PyResult}; // pyobjectrc items pub use self::pyobject::{Py, PyObject, PyObjectRef, PyRef, PyWeakRef}; pub use self::types::PyStructSequence; -pub use self::vm::{InitParameter, Interpreter, PyContext, PySettings, VirtualMachine}; +pub use self::vm::{InitParameter, Interpreter, PyContext, Settings, VirtualMachine}; pub use rustpython_bytecode as bytecode; pub use rustpython_common as common; diff --git a/vm/src/stdlib/sys.rs b/vm/src/stdlib/sys.rs index cafd1dc74..0204af2be 100644 --- a/vm/src/stdlib/sys.rs +++ b/vm/src/stdlib/sys.rs @@ -15,7 +15,7 @@ mod sys { stdlib::builtins, types::PyStructSequence, version, - vm::{PySettings, VirtualMachine}, + vm::{Settings, VirtualMachine}, PyObjectRef, PyRef, PyRefExact, PyResult, }; use num_traits::ToPrimitive; @@ -550,7 +550,7 @@ mod sys { #[pyimpl(with(PyStructSequence))] impl Flags { - fn from_settings(settings: &PySettings) -> Self { + fn from_settings(settings: &Settings) -> Self { Self { debug: settings.debug as u8, inspect: settings.inspect as u8, diff --git a/vm/src/vm/interpreter.rs b/vm/src/vm/interpreter.rs index 6713b792e..313c34cef 100644 --- a/vm/src/vm/interpreter.rs +++ b/vm/src/vm/interpreter.rs @@ -1,4 +1,4 @@ -use super::{setting::PySettings, thread, InitParameter, VirtualMachine}; +use super::{setting::Settings, thread, InitParameter, VirtualMachine}; /// The general interface for the VM /// @@ -21,11 +21,11 @@ pub struct Interpreter { } impl Interpreter { - pub fn new(settings: PySettings, init: InitParameter) -> Self { + pub fn new(settings: Settings, init: InitParameter) -> Self { Self::new_with_init(settings, |_| init) } - pub fn new_with_init(settings: PySettings, init: F) -> Self + pub fn new_with_init(settings: Settings, init: F) -> Self where F: FnOnce(&mut VirtualMachine) -> InitParameter, { @@ -56,7 +56,7 @@ impl Interpreter { impl Default for Interpreter { fn default() -> Self { - Self::new(PySettings::default(), InitParameter::External) + Self::new(Settings::default(), InitParameter::External) } } diff --git a/vm/src/vm/mod.rs b/vm/src/vm/mod.rs index 28353e374..a6e4cb298 100644 --- a/vm/src/vm/mod.rs +++ b/vm/src/vm/mod.rs @@ -42,7 +42,7 @@ use std::{ pub use context::PyContext; pub use interpreter::Interpreter; -pub use setting::PySettings; +pub use setting::Settings; // Objects are live when they are on stack, or referenced by a name (for now) @@ -77,7 +77,7 @@ struct ExceptionStack { } pub struct PyGlobalState { - pub settings: PySettings, + pub settings: Settings, pub module_inits: stdlib::StdlibMap, pub frozen: HashMap, pub stacksize: AtomicCell, @@ -95,7 +95,7 @@ pub enum InitParameter { impl VirtualMachine { /// Create a new `VirtualMachine` structure. - fn new(settings: PySettings) -> VirtualMachine { + fn new(settings: Settings) -> VirtualMachine { flame_guard!("new VirtualMachine"); let ctx = PyContext::default(); diff --git a/vm/src/vm/setting.rs b/vm/src/vm/setting.rs index f7638035b..f6d273373 100644 --- a/vm/src/vm/setting.rs +++ b/vm/src/vm/setting.rs @@ -1,6 +1,6 @@ /// Struct containing all kind of settings for the python vm. #[non_exhaustive] -pub struct PySettings { +pub struct Settings { /// -d command line switch pub debug: bool, @@ -61,9 +61,9 @@ pub struct PySettings { } /// Sensible default settings. -impl Default for PySettings { +impl Default for Settings { fn default() -> Self { - PySettings { + Settings { debug: false, inspect: false, interactive: false, diff --git a/wasm/lib/src/vm_class.rs b/wasm/lib/src/vm_class.rs index 969ac06ca..9c01882fd 100644 --- a/wasm/lib/src/vm_class.rs +++ b/wasm/lib/src/vm_class.rs @@ -8,8 +8,7 @@ use rustpython_vm::{ builtins::PyWeak, compile::{self, Mode}, scope::Scope, - InitParameter, Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, PySettings, - VirtualMachine, + InitParameter, Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, Settings, VirtualMachine, }; use std::{ cell::RefCell, @@ -42,7 +41,7 @@ fn init_window_module(vm: &VirtualMachine) -> PyObjectRef { impl StoredVirtualMachine { fn new(id: String, inject_browser_module: bool) -> StoredVirtualMachine { let mut scope = None; - let interp = Interpreter::new_with_init(PySettings::default(), |vm| { + let interp = Interpreter::new_with_init(Settings::default(), |vm| { vm.wasm_id = Some(id); js_module::setup_js_module(vm);