forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
60 lines (53 loc) · 1.97 KB
/
mod.rs
File metadata and controls
60 lines (53 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
mod ast;
mod dis;
pub(crate) mod json;
mod keyword;
mod math;
mod platform;
mod pystruct;
mod random;
mod re;
pub mod socket;
mod string;
mod thread;
mod time_module;
mod tokenize;
mod types;
mod weakref;
use std::collections::HashMap;
use crate::vm::VirtualMachine;
#[cfg(not(target_arch = "wasm32"))]
pub mod io;
#[cfg(not(target_arch = "wasm32"))]
mod os;
use crate::pyobject::PyObjectRef;
pub type StdlibInitFunc = Box<dyn Fn(&VirtualMachine) -> PyObjectRef>;
pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
let mut modules = HashMap::new();
modules.insert(
"ast".to_string(),
Box::new(ast::make_module) as StdlibInitFunc,
);
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("_thread".to_string(), Box::new(thread::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::make_module));
modules.insert("_os".to_string(), Box::new(os::make_module));
modules.insert("socket".to_string(), Box::new(socket::make_module));
}
modules
}