@@ -84,14 +84,14 @@ impl PyObjVTable {
84
84
/// payload can be a rust float or rust int in case of float and int objects.
85
85
#[ repr( C ) ]
86
86
struct PyInner < T > {
87
- refcount : RefCount ,
87
+ ref_count : RefCount ,
88
88
// TODO: move typeid into vtable once TypeId::of is const
89
89
typeid : TypeId ,
90
90
vtable : & ' static PyObjVTable ,
91
91
92
92
typ : PyRwLock < PyTypeRef > , // __class__ member
93
93
dict : Option < InstanceDict > ,
94
- weaklist : WeakRefList ,
94
+ weak_list : WeakRefList ,
95
95
96
96
payload : T ,
97
97
}
@@ -160,7 +160,7 @@ impl WeakRefList {
160
160
if is_generic {
161
161
if let Some ( generic_weakref) = inner. generic_weakref {
162
162
let generic_weakref = unsafe { generic_weakref. as_ref ( ) } ;
163
- if generic_weakref. 0 . refcount . get ( ) != 0 {
163
+ if generic_weakref. 0 . ref_count . get ( ) != 0 {
164
164
return PyObjectWeak {
165
165
weak : generic_weakref. to_owned ( ) ,
166
166
} ;
@@ -171,7 +171,7 @@ impl WeakRefList {
171
171
pointers : Pointers :: new ( ) ,
172
172
parent : inner_ptr,
173
173
callback : UnsafeCell :: new ( callback) ,
174
- hash : Radium :: new ( - 1 ) ,
174
+ hash : Radium :: new ( crate :: common :: hash :: SENTINEL ) ,
175
175
} ;
176
176
let weak = PyRef :: new_ref ( obj, cls, dict) ;
177
177
// SAFETY: we don't actually own the PyObjectWeaks inside `list`, and every time we take
@@ -266,7 +266,7 @@ impl WeakRefList {
266
266
267
267
impl WeakListInner {
268
268
fn iter ( & self ) -> impl Iterator < Item = & PyObjectView < PyWeak > > {
269
- self . list . iter ( ) . filter ( |wr| wr. 0 . refcount . get ( ) > 0 )
269
+ self . list . iter ( ) . filter ( |wr| wr. 0 . ref_count . get ( ) > 0 )
270
270
}
271
271
}
272
272
@@ -317,7 +317,7 @@ impl PyWeak {
317
317
let guard = unsafe { self . parent . as_ref ( ) . lock ( ) } ;
318
318
let obj_ptr = guard. obj ?;
319
319
unsafe {
320
- if !obj_ptr. as_ref ( ) . 0 . refcount . safe_inc ( ) {
320
+ if !obj_ptr. as_ref ( ) . 0 . ref_count . safe_inc ( ) {
321
321
return None ;
322
322
}
323
323
Some ( PyObjectRef :: from_raw ( obj_ptr. as_ptr ( ) ) )
@@ -399,12 +399,12 @@ impl InstanceDict {
399
399
impl < T : PyObjectPayload > PyInner < T > {
400
400
fn new ( payload : T , typ : PyTypeRef , dict : Option < PyDictRef > ) -> Box < Self > {
401
401
Box :: new ( PyInner {
402
- refcount : RefCount :: new ( ) ,
402
+ ref_count : RefCount :: new ( ) ,
403
403
typeid : TypeId :: of :: < T > ( ) ,
404
404
vtable : PyObjVTable :: of :: < T > ( ) ,
405
405
typ : PyRwLock :: new ( typ) ,
406
406
dict : dict. map ( InstanceDict :: new) ,
407
- weaklist : WeakRefList :: new ( ) ,
407
+ weak_list : WeakRefList :: new ( ) ,
408
408
payload,
409
409
} )
410
410
}
@@ -455,7 +455,7 @@ impl ToOwned for PyObject {
455
455
456
456
#[ inline( always) ]
457
457
fn to_owned ( & self ) -> Self :: Owned {
458
- self . 0 . refcount . inc ( ) ;
458
+ self . 0 . ref_count . inc ( ) ;
459
459
PyObjectRef {
460
460
ptr : NonNull :: from ( self ) ,
461
461
}
@@ -554,7 +554,7 @@ impl PyObjectRef {
554
554
impl PyObject {
555
555
#[ inline]
556
556
fn weak_ref_list ( & self ) -> Option < & WeakRefList > {
557
- Some ( & self . 0 . weaklist )
557
+ Some ( & self . 0 . weak_list )
558
558
}
559
559
560
560
pub ( crate ) fn downgrade_with_weakref_typ_opt (
@@ -684,7 +684,7 @@ impl PyObject {
684
684
685
685
#[ inline]
686
686
pub fn strong_count ( & self ) -> usize {
687
- self . 0 . refcount . get ( )
687
+ self . 0 . ref_count . get ( )
688
688
}
689
689
690
690
#[ inline]
@@ -702,14 +702,14 @@ impl PyObject {
702
702
// CPython-compatible drop implementation
703
703
if let Some ( slot_del) = self . class ( ) . mro_find_map ( |cls| cls. slots . del . load ( ) ) {
704
704
let ret = crate :: vm:: thread:: with_vm ( self , |vm| {
705
- self . 0 . refcount . inc ( ) ;
705
+ self . 0 . ref_count . inc ( ) ;
706
706
if let Err ( e) = slot_del ( self , vm) {
707
707
print_del_error ( e, self , vm) ;
708
708
}
709
- self . 0 . refcount . dec ( )
709
+ self . 0 . ref_count . dec ( )
710
710
} ) ;
711
711
match ret {
712
- // the decref right above set refcount back to 0
712
+ // the decref right above set ref_count back to 0
713
713
Some ( true ) => { }
714
714
// we've been resurrected by __del__
715
715
Some ( false ) => return Err ( ( ) ) ,
@@ -725,7 +725,7 @@ impl PyObject {
725
725
Ok ( ( ) )
726
726
}
727
727
728
- /// Can only be called when refcount has dropped to zero. `ptr` must be valid
728
+ /// Can only be called when ref_count has dropped to zero. `ptr` must be valid
729
729
#[ inline( never) ]
730
730
#[ cold]
731
731
unsafe fn drop_slow ( ptr : NonNull < PyObject > ) {
@@ -797,7 +797,7 @@ impl PyObjectWeak {
797
797
798
798
impl Drop for PyObjectRef {
799
799
fn drop ( & mut self ) {
800
- if self . 0 . refcount . dec ( ) {
800
+ if self . 0 . ref_count . dec ( ) {
801
801
unsafe { PyObject :: drop_slow ( self . ptr ) }
802
802
}
803
803
}
@@ -863,7 +863,7 @@ impl<T: PyObjectPayload> ToOwned for PyObjectView<T> {
863
863
864
864
#[ inline( always) ]
865
865
fn to_owned ( & self ) -> Self :: Owned {
866
- self . 0 . refcount . inc ( ) ;
866
+ self . 0 . ref_count . inc ( ) ;
867
867
PyRef {
868
868
ptr : NonNull :: from ( self ) ,
869
869
}
@@ -923,7 +923,7 @@ impl<T: PyObjectPayload> fmt::Debug for PyRef<T> {
923
923
impl < T : PyObjectPayload > Drop for PyRef < T > {
924
924
#[ inline]
925
925
fn drop ( & mut self ) {
926
- if self . 0 . refcount . dec ( ) {
926
+ if self . 0 . ref_count . dec ( ) {
927
927
unsafe { PyObject :: drop_slow ( self . ptr . cast :: < PyObject > ( ) ) }
928
928
}
929
929
}
@@ -1078,22 +1078,22 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef, PyTypeRef) {
1078
1078
} ;
1079
1079
let type_type_ptr = Box :: into_raw ( Box :: new ( partially_init ! (
1080
1080
PyInner :: <PyType > {
1081
- refcount : RefCount :: new( ) ,
1081
+ ref_count : RefCount :: new( ) ,
1082
1082
typeid: TypeId :: of:: <PyType >( ) ,
1083
1083
vtable: PyObjVTable :: of:: <PyType >( ) ,
1084
1084
dict: None ,
1085
- weaklist : WeakRefList :: new( ) ,
1085
+ weak_list : WeakRefList :: new( ) ,
1086
1086
payload: type_payload,
1087
1087
} ,
1088
1088
Uninit { typ }
1089
1089
) ) ) ;
1090
1090
let object_type_ptr = Box :: into_raw ( Box :: new ( partially_init ! (
1091
1091
PyInner :: <PyType > {
1092
- refcount : RefCount :: new( ) ,
1092
+ ref_count : RefCount :: new( ) ,
1093
1093
typeid: TypeId :: of:: <PyType >( ) ,
1094
1094
vtable: PyObjVTable :: of:: <PyType >( ) ,
1095
1095
dict: None ,
1096
- weaklist : WeakRefList :: new( ) ,
1096
+ weak_list : WeakRefList :: new( ) ,
1097
1097
payload: object_payload,
1098
1098
} ,
1099
1099
Uninit { typ } ,
@@ -1105,12 +1105,12 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef, PyTypeRef) {
1105
1105
type_type_ptr as * mut MaybeUninit < PyInner < PyType > > as * mut PyInner < PyType > ;
1106
1106
1107
1107
unsafe {
1108
- ( * type_type_ptr) . refcount . inc ( ) ;
1108
+ ( * type_type_ptr) . ref_count . inc ( ) ;
1109
1109
ptr:: write (
1110
1110
& mut ( * object_type_ptr) . typ as * mut PyRwLock < PyTypeRef > as * mut UninitRef < PyType > ,
1111
1111
PyRwLock :: new ( NonNull :: new_unchecked ( type_type_ptr) ) ,
1112
1112
) ;
1113
- ( * type_type_ptr) . refcount . inc ( ) ;
1113
+ ( * type_type_ptr) . ref_count . inc ( ) ;
1114
1114
ptr:: write (
1115
1115
& mut ( * type_type_ptr) . typ as * mut PyRwLock < PyTypeRef > as * mut UninitRef < PyType > ,
1116
1116
PyRwLock :: new ( NonNull :: new_unchecked ( type_type_ptr) ) ,
0 commit comments