mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
as_mapping uses ptr
This commit is contained in:
@@ -29,7 +29,7 @@ impl PyMapping<PyObjectRef> {
|
||||
pub fn check(obj: &PyObjectRef, vm: &VirtualMachine) -> bool {
|
||||
obj.class()
|
||||
.mro_find_map(|x| x.slots.as_mapping.load())
|
||||
.map(|f| f(obj, vm).subscript.is_some())
|
||||
.map(|f| obj.with_ptr(|obj| f(obj, vm)).subscript.is_some())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ impl PyMapping<PyObjectRef> {
|
||||
let obj_cls = self.0.class();
|
||||
for cls in obj_cls.iter_mro() {
|
||||
if let Some(f) = cls.slots.as_mapping.load() {
|
||||
return f(&self.0, vm);
|
||||
return self.0.with_ptr(|zelf| f(zelf, vm));
|
||||
}
|
||||
}
|
||||
PyMappingMethods::default()
|
||||
|
||||
@@ -128,7 +128,7 @@ impl Default for PyTypeFlags {
|
||||
}
|
||||
|
||||
pub(crate) type GenericMethod = fn(PyObjectPtr, FuncArgs, &VirtualMachine) -> PyResult;
|
||||
pub(crate) type AsMappingFunc = fn(&PyObjectRef, &VirtualMachine) -> PyMappingMethods;
|
||||
pub(crate) type AsMappingFunc = fn(PyObjectPtr, &VirtualMachine) -> PyMappingMethods;
|
||||
pub(crate) type HashFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult<PyHash>;
|
||||
// CallFunc = GenericMethod
|
||||
pub(crate) type GetattroFunc = fn(PyObjectRef, PyStrRef, &VirtualMachine) -> PyResult;
|
||||
@@ -150,7 +150,7 @@ pub(crate) type DescrSetFunc =
|
||||
pub(crate) type NewFunc = fn(PyTypeRef, FuncArgs, &VirtualMachine) -> PyResult;
|
||||
pub(crate) type DelFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult<()>;
|
||||
|
||||
fn as_mapping_wrapper(zelf: &PyObjectRef, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
fn as_mapping_wrapper(zelf: PyObjectPtr, _vm: &VirtualMachine) -> PyMappingMethods {
|
||||
macro_rules! then_some_closure {
|
||||
($cond:expr, $closure:expr) => {
|
||||
if $cond {
|
||||
@@ -768,7 +768,7 @@ pub trait AsBuffer: PyValue {
|
||||
pub trait AsMapping: PyValue {
|
||||
#[inline]
|
||||
#[pyslot]
|
||||
fn slot_as_mapping(zelf: &PyObjectRef, vm: &VirtualMachine) -> PyMappingMethods {
|
||||
fn slot_as_mapping(zelf: PyObjectPtr, vm: &VirtualMachine) -> PyMappingMethods {
|
||||
let zelf = unsafe { zelf.downcast_unchecked_ref::<Self>() };
|
||||
Self::as_mapping(zelf, vm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user