PyObjectRef -> &PyObj, &PyRef<T> -> &Py<T>

This commit is contained in:
Noa
2021-10-18 16:01:17 -05:00
committed by Jeong YunWon
parent e5a1c3b137
commit 8dd18d97be
85 changed files with 3350 additions and 1716 deletions

View File

@@ -2,7 +2,7 @@ use crate::{
builtins::{PyStr, PyStrRef},
common::borrow::{BorrowedValue, BorrowedValueMut},
protocol::PyBuffer,
PyObjectRef, PyResult, TryFromBorrowedObject, TryFromObject, VirtualMachine,
PyObj, PyObjectRef, PyResult, TryFromBorrowedObject, TryFromObject, VirtualMachine,
};
// Python/getargs.c
@@ -11,7 +11,7 @@ use crate::{
#[derive(Debug)]
pub struct ArgBytesLike(PyBuffer);
impl PyObjectRef {
impl PyObj {
pub fn try_bytes_like<R>(
&self,
vm: &VirtualMachine,
@@ -70,7 +70,7 @@ impl From<ArgBytesLike> for PyBuffer {
}
impl TryFromBorrowedObject for ArgBytesLike {
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<Self> {
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObj) -> PyResult<Self> {
let buffer = PyBuffer::try_from_borrowed_object(vm, obj)?;
if buffer.options.contiguous {
Ok(Self(buffer))
@@ -112,7 +112,7 @@ impl From<ArgMemoryBuffer> for PyBuffer {
}
impl TryFromBorrowedObject for ArgMemoryBuffer {
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<Self> {
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObj) -> PyResult<Self> {
let buffer = PyBuffer::try_from_borrowed_object(vm, obj)?;
if !buffer.options.contiguous {
Err(vm.new_type_error("non-contiguous buffer is not a bytes-like object".to_owned()))