diff --git a/vm/src/stdlib/ast.rs b/vm/src/stdlib/ast.rs index d3bdd3656b..3875157b8d 100644 --- a/vm/src/stdlib/ast.rs +++ b/vm/src/stdlib/ast.rs @@ -621,7 +621,7 @@ fn ast_parse(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Ok(ast_node) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "ast", { "parse" => ctx.new_rustfunc(ast_parse), "Module" => py_class!(ctx, "_ast.Module", ctx.object(), {}), diff --git a/vm/src/stdlib/dis.rs b/vm/src/stdlib/dis.rs index d726b71106..96d727a3f0 100644 --- a/vm/src/stdlib/dis.rs +++ b/vm/src/stdlib/dis.rs @@ -22,7 +22,7 @@ fn dis_disassemble(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Ok(vm.get_none()) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "dis", { "dis" => ctx.new_rustfunc(dis_dis), "disassemble" => ctx.new_rustfunc(dis_disassemble) diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 9d5600498a..02171df344 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -365,7 +365,7 @@ pub fn io_open(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { } } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { //IOBase the abstract base class of the IO Module let io_base = py_class!(ctx, "IOBase", ctx.object(), { "__enter__" => ctx.new_rustfunc(io_base_cm_enter), diff --git a/vm/src/stdlib/json.rs b/vm/src/stdlib/json.rs index 0d0bc23dc5..a23028773f 100644 --- a/vm/src/stdlib/json.rs +++ b/vm/src/stdlib/json.rs @@ -228,7 +228,7 @@ fn json_loads(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { }) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { // TODO: Make this a proper type with a constructor let json_decode_error = create_type( "JSONDecodeError", diff --git a/vm/src/stdlib/keyword.rs b/vm/src/stdlib/keyword.rs index 85d6fa49e6..362d68ece3 100644 --- a/vm/src/stdlib/keyword.rs +++ b/vm/src/stdlib/keyword.rs @@ -17,7 +17,7 @@ fn keyword_iskeyword(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Ok(value) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let keyword_kwlist = ctx.new_list( lexer::get_keywords() .keys() diff --git a/vm/src/stdlib/math.rs b/vm/src/stdlib/math.rs index 8caa59e6de..19e5899a2a 100644 --- a/vm/src/stdlib/math.rs +++ b/vm/src/stdlib/math.rs @@ -171,7 +171,7 @@ fn math_lgamma(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { } } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "math", { // Number theory functions: "fabs" => ctx.new_rustfunc(math_fabs), diff --git a/vm/src/stdlib/mod.rs b/vm/src/stdlib/mod.rs index 2a22093751..c3bb543f52 100644 --- a/vm/src/stdlib/mod.rs +++ b/vm/src/stdlib/mod.rs @@ -28,28 +28,28 @@ pub fn get_module_inits() -> HashMap { let mut modules = HashMap::new(); modules.insert( "ast".to_string(), - Box::new(ast::mk_module) as StdlibInitFunc, + Box::new(ast::make_module) as StdlibInitFunc, ); - modules.insert("dis".to_string(), Box::new(dis::mk_module)); - modules.insert("json".to_string(), Box::new(json::mk_module)); - modules.insert("keyword".to_string(), Box::new(keyword::mk_module)); - modules.insert("math".to_string(), Box::new(math::mk_module)); - modules.insert("platform".to_string(), Box::new(platform::mk_module)); - modules.insert("re".to_string(), Box::new(re::mk_module)); - modules.insert("random".to_string(), Box::new(random::mk_module)); - modules.insert("string".to_string(), Box::new(string::mk_module)); - modules.insert("struct".to_string(), Box::new(pystruct::mk_module)); - modules.insert("time".to_string(), Box::new(time_module::mk_module)); - modules.insert("tokenize".to_string(), Box::new(tokenize::mk_module)); - modules.insert("types".to_string(), Box::new(types::mk_module)); - modules.insert("_weakref".to_string(), Box::new(weakref::mk_module)); + modules.insert("dis".to_string(), Box::new(dis::make_module)); + modules.insert("json".to_string(), Box::new(json::make_module)); + modules.insert("keyword".to_string(), Box::new(keyword::make_module)); + modules.insert("math".to_string(), Box::new(math::make_module)); + modules.insert("platform".to_string(), Box::new(platform::make_module)); + modules.insert("re".to_string(), Box::new(re::make_module)); + modules.insert("random".to_string(), Box::new(random::make_module)); + modules.insert("string".to_string(), Box::new(string::make_module)); + modules.insert("struct".to_string(), Box::new(pystruct::make_module)); + modules.insert("time".to_string(), Box::new(time_module::make_module)); + modules.insert("tokenize".to_string(), Box::new(tokenize::make_module)); + modules.insert("types".to_string(), Box::new(types::make_module)); + modules.insert("_weakref".to_string(), Box::new(weakref::make_module)); // disable some modules on WASM #[cfg(not(target_arch = "wasm32"))] { - modules.insert("io".to_string(), Box::new(io::mk_module)); - modules.insert("os".to_string(), Box::new(os::mk_module)); - modules.insert("socket".to_string(), Box::new(socket::mk_module)); + modules.insert("io".to_string(), Box::new(io::make_module)); + modules.insert("os".to_string(), Box::new(os::make_module)); + modules.insert("socket".to_string(), Box::new(socket::make_module)); } modules diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 5379fefc4d..7745ca2053 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -118,7 +118,7 @@ fn os_error(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Err(vm.new_os_error(msg)) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let py_mod = py_module!(ctx, "os", { "open" => ctx.new_rustfunc(os_open), "close" => ctx.new_rustfunc(os_close), diff --git a/vm/src/stdlib/platform.rs b/vm/src/stdlib/platform.rs index e1681a4dd5..dd0bc79bcb 100644 --- a/vm/src/stdlib/platform.rs +++ b/vm/src/stdlib/platform.rs @@ -3,7 +3,7 @@ extern crate rustc_version_runtime; use crate::pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult}; use crate::VirtualMachine; -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "platform", { "python_compiler" => ctx.new_rustfunc(platform_python_compiler), "python_implementation" => ctx.new_rustfunc(platform_python_implementation), diff --git a/vm/src/stdlib/pystruct.rs b/vm/src/stdlib/pystruct.rs index c96bba736e..8052492b2b 100644 --- a/vm/src/stdlib/pystruct.rs +++ b/vm/src/stdlib/pystruct.rs @@ -296,7 +296,7 @@ fn struct_unpack(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Ok(vm.ctx.new_tuple(items)) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "struct", { "pack" => ctx.new_rustfunc(struct_pack), "unpack" => ctx.new_rustfunc(struct_unpack) diff --git a/vm/src/stdlib/random.rs b/vm/src/stdlib/random.rs index 85cd52a587..31b0162837 100644 --- a/vm/src/stdlib/random.rs +++ b/vm/src/stdlib/random.rs @@ -7,7 +7,7 @@ use crate::pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol use crate::stdlib::random::rand::distributions::{Distribution, Normal}; use crate::VirtualMachine; -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "random", { "guass" => ctx.new_rustfunc(random_gauss), "normalvariate" => ctx.new_rustfunc(random_normalvariate), diff --git a/vm/src/stdlib/re.rs b/vm/src/stdlib/re.rs index 0828a13d14..3a3aee3430 100644 --- a/vm/src/stdlib/re.rs +++ b/vm/src/stdlib/re.rs @@ -17,7 +17,7 @@ use crate::pyobject::{ use crate::VirtualMachine; /// Create the python `re` module with all its members. -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let match_type = py_class!(ctx, "Match", ctx.object(), { "start" => ctx.new_rustfunc(match_start), "end" => ctx.new_rustfunc(match_end) diff --git a/vm/src/stdlib/socket.rs b/vm/src/stdlib/socket.rs index d6e6283af9..0ebc28f744 100644 --- a/vm/src/stdlib/socket.rs +++ b/vm/src/stdlib/socket.rs @@ -420,7 +420,7 @@ fn get_addr_tuple(vm: &mut VirtualMachine, addr: SocketAddr) -> PyResult { Ok(vm.ctx.new_tuple(vec![ip, port])) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let socket = py_class!(ctx, "socket", ctx.object(), { "__new__" => ctx.new_rustfunc(socket_new), "connect" => ctx.new_rustfunc(socket_connect), diff --git a/vm/src/stdlib/string.rs b/vm/src/stdlib/string.rs index 5b3f2a7282..157dae035f 100644 --- a/vm/src/stdlib/string.rs +++ b/vm/src/stdlib/string.rs @@ -5,7 +5,7 @@ use crate::pyobject::{PyContext, PyObjectRef}; -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let ascii_lowercase = "abcdefghijklmnopqrstuvwxyz".to_string(); let ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".to_string(); let ascii_letters = format!("{}{}", ascii_lowercase, ascii_uppercase); diff --git a/vm/src/stdlib/time_module.rs b/vm/src/stdlib/time_module.rs index b9a360ce81..05c9b640c9 100644 --- a/vm/src/stdlib/time_module.rs +++ b/vm/src/stdlib/time_module.rs @@ -30,7 +30,7 @@ fn time_time(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Ok(value) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "time", { "sleep" => ctx.new_rustfunc(time_sleep), "time" => ctx.new_rustfunc(time_time) diff --git a/vm/src/stdlib/tokenize.rs b/vm/src/stdlib/tokenize.rs index 8207e9efc5..1da20655df 100644 --- a/vm/src/stdlib/tokenize.rs +++ b/vm/src/stdlib/tokenize.rs @@ -25,7 +25,7 @@ fn tokenize_tokenize(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { // TODO: create main function when called with -m -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "tokenize", { "tokenize" => ctx.new_rustfunc(tokenize_tokenize) }) diff --git a/vm/src/stdlib/types.rs b/vm/src/stdlib/types.rs index 959b141f55..d875cbb95d 100644 --- a/vm/src/stdlib/types.rs +++ b/vm/src/stdlib/types.rs @@ -30,7 +30,7 @@ fn types_new_class(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { objtype::new(vm.ctx.type_type(), &name, bases, PyAttributes::new()) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "types", { "new_class" => ctx.new_rustfunc(types_new_class), "FunctionType" => ctx.function_type(), diff --git a/vm/src/stdlib/weakref.rs b/vm/src/stdlib/weakref.rs index b32caa61d1..5616c3ddfe 100644 --- a/vm/src/stdlib/weakref.rs +++ b/vm/src/stdlib/weakref.rs @@ -7,7 +7,7 @@ use super::super::pyobject::{PyContext, PyObjectRef}; -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { py_module!(ctx, "_weakref", { "ref" => ctx.weakref_type() }) diff --git a/vm/src/sysmodule.rs b/vm/src/sysmodule.rs index d794792b8f..cc82792ced 100644 --- a/vm/src/sysmodule.rs +++ b/vm/src/sysmodule.rs @@ -54,7 +54,7 @@ fn sys_getsizeof(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { Ok(vm.ctx.new_int(size)) } -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let path_list = match env::var_os("PYTHONPATH") { Some(paths) => env::split_paths(&paths) .map(|path| { diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 0f95bf66c6..80a393cd58 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -57,7 +57,7 @@ impl VirtualMachine { // Hard-core modules: let builtins = builtins::make_module(&ctx); - let sysmod = sysmodule::mk_module(&ctx); + let sysmod = sysmodule::make_module(&ctx); // Add builtins as builtins module: let modules = sysmod.get_attr("modules").unwrap(); diff --git a/wasm/lib/src/browser_module.rs b/wasm/lib/src/browser_module.rs index d8014ae520..ad151bc534 100644 --- a/wasm/lib/src/browser_module.rs +++ b/wasm/lib/src/browser_module.rs @@ -310,7 +310,7 @@ fn browser_prompt(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult { const BROWSER_NAME: &str = "browser"; -pub fn mk_module(ctx: &PyContext) -> PyObjectRef { +pub fn make_module(ctx: &PyContext) -> PyObjectRef { let promise = py_class!(ctx, "Promise", ctx.object(), { "then" => ctx.new_rustfunc(promise_then), "catch" => ctx.new_rustfunc(promise_catch) @@ -329,5 +329,5 @@ pub fn mk_module(ctx: &PyContext) -> PyObjectRef { pub fn setup_browser_module(vm: &mut VirtualMachine) { vm.stdlib_inits - .insert(BROWSER_NAME.to_string(), Box::new(mk_module)); + .insert(BROWSER_NAME.to_string(), Box::new(make_module)); }