tp_cmp -> tp_richcompare

this was the last typeslot with mismatching name
This commit is contained in:
Jeong YunWon
2021-08-12 03:25:59 +09:00
parent 03a9d6058b
commit 1a57ef03aa
4 changed files with 8 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ impl PyBaseObject {
}
#[pyslot]
fn tp_cmp(
fn tp_richcompare(
zelf: &PyObjectRef,
other: &PyObjectRef,
op: PyComparisonOp,
@@ -67,7 +67,7 @@ impl PyBaseObject {
PyComparisonOp::Ne => {
let cmp = zelf
.class()
.mro_find_map(|cls| cls.slots.cmp.load())
.mro_find_map(|cls| cls.slots.richcompare.load())
.unwrap();
let value = match cmp(zelf, other, PyComparisonOp::Eq, vm)? {
Either::A(obj) => PyArithmaticValue::from_object(vm, obj)

View File

@@ -193,11 +193,11 @@ impl PyType {
update_slot!(del, func);
}
"__eq__" | "__ne__" | "__le__" | "__lt__" | "__ge__" | "__gt__" => {
let func: slots::CmpFunc = |zelf, other, op, vm| {
let func: slots::RichCompareFunc = |zelf, other, op, vm| {
vm.call_special_method(zelf.clone(), op.method_name(), (other.clone(),))
.map(Either::A)
} as _;
update_slot!(cmp, func);
update_slot!(richcompare, func);
}
"__getattribute__" => {
let func: slots::GetattroFunc =

View File

@@ -52,7 +52,7 @@ pub(crate) type DescrGetFunc =
pub(crate) type DescrSetFunc =
fn(PyObjectRef, PyObjectRef, Option<PyObjectRef>, &VirtualMachine) -> PyResult<()>;
pub(crate) type HashFunc = fn(&PyObjectRef, &VirtualMachine) -> PyResult<PyHash>;
pub(crate) type CmpFunc = fn(
pub(crate) type RichCompareFunc = fn(
&PyObjectRef,
&PyObjectRef,
PyComparisonOp,
@@ -89,7 +89,7 @@ pub struct PyTypeSlots {
// Assigned meaning in release 2.1
// rich comparisons
pub cmp: AtomicCell<Option<CmpFunc>>,
pub richcompare: AtomicCell<Option<RichCompareFunc>>,
// Iterators
pub iter: AtomicCell<Option<IterFunc>>,
@@ -268,7 +268,7 @@ where
#[pyimpl]
pub trait Comparable: PyValue {
#[pyslot]
fn tp_cmp(
fn tp_richcompare(
zelf: &PyObjectRef,
other: &PyObjectRef,
op: PyComparisonOp,

View File

@@ -1654,7 +1654,7 @@ impl VirtualMachine {
let call_cmp = |obj: &PyObjectRef, other, op| {
let cmp = obj
.class()
.mro_find_map(|cls| cls.slots.cmp.load())
.mro_find_map(|cls| cls.slots.richcompare.load())
.unwrap();
Ok(match cmp(obj, other, op, self)? {
Either::A(obj) => PyArithmaticValue::from_object(self, obj).map(Either::A),