forked from Rust-related/RustPython
as_buffer uses ptr
This commit is contained in:
@@ -108,7 +108,7 @@ impl TryFromBorrowedObject for PyBuffer {
|
||||
let obj_cls = obj.class();
|
||||
for cls in obj_cls.iter_mro() {
|
||||
if let Some(f) = cls.slots.as_buffer.as_ref() {
|
||||
return f(obj, vm);
|
||||
return obj.with_ptr(|obj| f(obj, vm));
|
||||
}
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
|
||||
@@ -134,7 +134,7 @@ pub(crate) type HashFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult<PyHash>;
|
||||
pub(crate) type GetattroFunc = fn(PyObjectRef, PyStrRef, &VirtualMachine) -> PyResult;
|
||||
pub(crate) type SetattroFunc =
|
||||
fn(&PyObjectRef, PyStrRef, Option<PyObjectRef>, &VirtualMachine) -> PyResult<()>;
|
||||
pub(crate) type AsBufferFunc = fn(&PyObjectRef, &VirtualMachine) -> PyResult<PyBuffer>;
|
||||
pub(crate) type AsBufferFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult<PyBuffer>;
|
||||
pub(crate) type RichCompareFunc = fn(
|
||||
PyObjectPtr,
|
||||
PyObjectPtr,
|
||||
@@ -754,7 +754,7 @@ pub trait AsBuffer: PyValue {
|
||||
// TODO: `flags` parameter
|
||||
#[inline]
|
||||
#[pyslot]
|
||||
fn slot_as_buffer(zelf: &PyObjectRef, vm: &VirtualMachine) -> PyResult<PyBuffer> {
|
||||
fn slot_as_buffer(zelf: PyObjectPtr, vm: &VirtualMachine) -> PyResult<PyBuffer> {
|
||||
let zelf = zelf
|
||||
.downcast_ref()
|
||||
.ok_or_else(|| vm.new_type_error("unexpected payload for as_buffer".to_owned()))?;
|
||||
|
||||
Reference in New Issue
Block a user