Remove types module

This commit is contained in:
Seo Sanghyeon
2019-05-13 11:41:46 +09:00
parent b01d7564b8
commit 29fff5ab4d
2 changed files with 0 additions and 41 deletions

View File

@@ -14,7 +14,6 @@ mod string;
mod thread;
mod time_module;
mod tokenize;
mod types;
mod weakref;
use std::collections::HashMap;
@@ -49,7 +48,6 @@ pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
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

View File

@@ -1,39 +0,0 @@
/*
* Dynamic type creation and names for built in types.
*/
use crate::function::OptionalArg;
use crate::obj::objdict::PyDict;
use crate::obj::objstr::PyStringRef;
use crate::obj::objtype;
use crate::obj::objtype::PyClassRef;
use crate::pyobject::{PyIterable, PyObjectRef, PyResult, PyValue, TryFromObject};
use crate::VirtualMachine;
fn types_new_class(
name: PyStringRef,
bases: OptionalArg<PyIterable<PyClassRef>>,
vm: &VirtualMachine,
) -> PyResult<PyClassRef> {
// TODO kwds and exec_body parameter
let bases = match bases {
OptionalArg::Present(bases) => bases,
OptionalArg::Missing => PyIterable::try_from_object(vm, vm.ctx.new_tuple(vec![]))?,
};
let dict = PyDict::default().into_ref(vm);
objtype::type_new_class(vm, vm.ctx.type_type(), name, bases, dict)
}
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
let ctx = &vm.ctx;
py_module!(vm, "types", {
"new_class" => ctx.new_rustfunc(types_new_class),
"FunctionType" => ctx.function_type(),
"MethodType" => ctx.bound_method_type(),
"LambdaType" => ctx.function_type(),
"CodeType" => ctx.code_type(),
"FrameType" => ctx.frame_type()
})
}