Skip to content

Commit c5ce44e

Browse files
committed
remove slots.as_number replaced with slots.number
1 parent 75e11da commit c5ce44e

File tree

4 files changed

+81
-90
lines changed

4 files changed

+81
-90
lines changed

derive-impl/src/pyclass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ where
703703
let tokens = {
704704
const NON_ATOMIC_SLOTS: &[&str] = &["as_buffer"];
705705
const POINTER_SLOTS: &[&str] = &["as_sequence", "as_mapping"];
706+
const STATIC_GEN_SLOTS: &[&str] = &["as_number"];
706707

707708
if NON_ATOMIC_SLOTS.contains(&slot_name.as_str()) {
708709
quote_spanned! { span =>
@@ -712,10 +713,9 @@ where
712713
quote_spanned! { span =>
713714
slots.#slot_ident.store(Some(PointerSlot::from(Self::#ident())));
714715
}
715-
} else if "as_number" == slot_name.as_str() {
716+
} else if STATIC_GEN_SLOTS.contains(&slot_name.as_str()) {
716717
quote_spanned! { span =>
717-
slots.#slot_ident = Self::#ident();
718-
slots.number = Self::#ident().into();
718+
slots.#slot_ident = Self::#ident().into();
719719
}
720720
} else {
721721
quote_spanned! { span =>

vm/src/protocol/number.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'a> PyNumber<'a> {
424424

425425
// PyNumber_Check
426426
pub fn check(obj: &PyObject) -> bool {
427-
let methods = &obj.class().slots.number;
427+
let methods = &obj.class().slots.as_number;
428428
methods.int.load().is_some()
429429
|| methods.index.load().is_some()
430430
|| methods.float.load().is_some()
@@ -435,12 +435,12 @@ impl<'a> PyNumber<'a> {
435435
impl PyNumber<'_> {
436436
// PyIndex_Check
437437
pub fn is_index(self) -> bool {
438-
self.class().slots.number.index.load().is_some()
438+
self.class().slots.as_number.index.load().is_some()
439439
}
440440

441441
#[inline]
442442
pub fn int(self, vm: &VirtualMachine) -> Option<PyResult<PyIntRef>> {
443-
self.class().slots.number.int.load().map(|f| {
443+
self.class().slots.as_number.int.load().map(|f| {
444444
let ret = f(self, vm)?;
445445
let value = if !ret.class().is(PyInt::class(&vm.ctx)) {
446446
warnings::warn(
@@ -464,7 +464,7 @@ impl PyNumber<'_> {
464464

465465
#[inline]
466466
pub fn index(self, vm: &VirtualMachine) -> Option<PyResult<PyIntRef>> {
467-
self.class().slots.number.index.load().map(|f| {
467+
self.class().slots.as_number.index.load().map(|f| {
468468
let ret = f(self, vm)?;
469469
let value = if !ret.class().is(PyInt::class(&vm.ctx)) {
470470
warnings::warn(
@@ -488,7 +488,7 @@ impl PyNumber<'_> {
488488

489489
#[inline]
490490
pub fn float(self, vm: &VirtualMachine) -> Option<PyResult<PyRef<PyFloat>>> {
491-
self.class().slots.number.float.load().map(|f| {
491+
self.class().slots.as_number.float.load().map(|f| {
492492
let ret = f(self, vm)?;
493493
let value = if !ret.class().is(PyFloat::class(&vm.ctx)) {
494494
warnings::warn(

0 commit comments

Comments
 (0)