mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Remove Box from PyObject
This commit is contained in:
@@ -35,12 +35,6 @@ impl PyValue for PyClass {
|
||||
}
|
||||
}
|
||||
|
||||
impl IdProtocol for PyClassRef {
|
||||
fn get_id(&self) -> usize {
|
||||
self.as_object().get_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeProtocol for PyClassRef {
|
||||
fn type_ref(&self) -> &PyObjectRef {
|
||||
&self.as_object().type_ref()
|
||||
@@ -300,10 +294,7 @@ fn take_next_base(mut bases: Vec<Vec<PyClassRef>>) -> Option<(PyClassRef, Vec<Ve
|
||||
|
||||
for base in &bases {
|
||||
let head = base[0].clone();
|
||||
if !(&bases)
|
||||
.iter()
|
||||
.any(|x| x[1..].iter().any(|x| x.get_id() == head.get_id()))
|
||||
{
|
||||
if !(&bases).iter().any(|x| x[1..].iter().any(|x| x.is(&head))) {
|
||||
next = Some(head);
|
||||
break;
|
||||
}
|
||||
@@ -311,7 +302,7 @@ fn take_next_base(mut bases: Vec<Vec<PyClassRef>>) -> Option<(PyClassRef, Vec<Ve
|
||||
|
||||
if let Some(head) = next {
|
||||
for item in &mut bases {
|
||||
if item[0].get_id() == head.get_id() {
|
||||
if item[0].is(&head) {
|
||||
item.remove(0);
|
||||
}
|
||||
}
|
||||
@@ -347,10 +338,10 @@ pub fn new(
|
||||
let mros = bases.into_iter().map(|x| _mro(&x)).collect();
|
||||
let mro = linearise_mro(mros).unwrap();
|
||||
Ok(PyObject {
|
||||
payload: Box::new(PyClass {
|
||||
payload: PyClass {
|
||||
name: String::from(name),
|
||||
mro,
|
||||
}),
|
||||
},
|
||||
dict: Some(RefCell::new(dict)),
|
||||
typ,
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use crate::obj::objtype::PyClassRef;
|
||||
use crate::pyobject::PyValue;
|
||||
use crate::pyobject::{PyContext, PyObject, PyObjectRef, PyRef, PyResult};
|
||||
use crate::pyobject::{PyContext, PyObject, PyObjectPayload, PyObjectRef, PyRef, PyResult};
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
use std::rc::{Rc, Weak};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PyWeak {
|
||||
referent: Weak<PyObject>,
|
||||
referent: Weak<PyObject<dyn PyObjectPayload>>,
|
||||
}
|
||||
|
||||
impl PyWeak {
|
||||
|
||||
Reference in New Issue
Block a user