Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(), {}),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/dis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
34 changes: 17 additions & 17 deletions vm/src/stdlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
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
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/pystruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/time_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/weakref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
2 changes: 1 addition & 1 deletion vm/src/sysmodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions wasm/lib/src/browser_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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));
}