mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Remove special Type type. Type is just a class.
This commit is contained in:
1 parent
aa1207adcf
commit
339189aff4
2 files changed
+9
-6
No files matched your search
+9
-4
@@ -1,5 +1,4 @@
|
||||
// use std::rc::Rc;
|
||||
// use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/*
|
||||
* The magical type type
|
||||
@@ -9,8 +8,14 @@ use super::pyobject::{PyObject, PyObjectKind, PyObjectRef};
|
||||
|
||||
pub fn create_type() -> PyObjectRef {
|
||||
let typ = PyObject::default().into_ref();
|
||||
(*typ.borrow_mut()).kind = PyObjectKind::Type;
|
||||
let dict = PyObject::new(
|
||||
PyObjectKind::Dict {
|
||||
elements: HashMap::new(),
|
||||
}, typ.clone());
|
||||
(*typ.borrow_mut()).kind = PyObjectKind::Class {
|
||||
name: String::from("type"),
|
||||
dict: dict,
|
||||
};
|
||||
(*typ.borrow_mut()).typ = Some(typ.clone());
|
||||
// typ.borrow_mut().dict.insert("__str__".to_string(), PyObject::new(PyObjectKind::RustFunction { function: str }));
|
||||
typ
|
||||
}
|
||||
@@ -347,7 +347,6 @@ pub enum PyObjectKind {
|
||||
RustFunction {
|
||||
function: RustPyFunc,
|
||||
},
|
||||
Type
|
||||
}
|
||||
|
||||
impl fmt::Debug for PyObjectKind {
|
||||
@@ -371,7 +370,6 @@ impl fmt::Debug for PyObjectKind {
|
||||
&PyObjectKind::Class { name: _, dict: _ } => write!(f, "class"),
|
||||
&PyObjectKind::Instance { dict: _ } => write!(f, "instance"),
|
||||
&PyObjectKind::RustFunction { function: _ } => write!(f, "rust function"),
|
||||
&PyObjectKind::Type => write!(f, "type"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user