@@ -9,7 +9,7 @@ use crate::pyobject::{
9
9
IdProtocol , PyClassImpl , PyContext , PyObject , PyObjectRef , PyRef , PyResult , PyValue ,
10
10
TypeProtocol ,
11
11
} ;
12
- use crate :: slots:: PyBuiltinDescriptor ;
12
+ use crate :: slots:: SlotDescriptor ;
13
13
use crate :: vm:: VirtualMachine ;
14
14
15
15
// Read-only property, doesn't have __set__ or __delete__
@@ -27,13 +27,14 @@ impl PyValue for PyReadOnlyProperty {
27
27
28
28
pub type PyReadOnlyPropertyRef = PyRef < PyReadOnlyProperty > ;
29
29
30
- impl PyBuiltinDescriptor for PyReadOnlyProperty {
31
- fn get (
32
- zelf : PyRef < Self > ,
33
- obj : PyObjectRef ,
34
- cls : OptionalArg < PyObjectRef > ,
30
+ impl SlotDescriptor for PyReadOnlyProperty {
31
+ fn descr_get (
35
32
vm : & VirtualMachine ,
33
+ zelf : PyObjectRef ,
34
+ obj : Option < PyObjectRef > ,
35
+ cls : OptionalArg < PyObjectRef > ,
36
36
) -> PyResult {
37
+ let ( zelf, obj) = Self :: _unwrap ( zelf, obj, vm) ?;
37
38
if vm. is_none ( & obj) {
38
39
if Self :: _cls_is ( & cls, & vm. ctx . types . type_type ) {
39
40
vm. invoke ( & zelf. getter , cls. unwrap ( ) )
@@ -46,7 +47,7 @@ impl PyBuiltinDescriptor for PyReadOnlyProperty {
46
47
}
47
48
}
48
49
49
- #[ pyimpl( with( PyBuiltinDescriptor ) ) ]
50
+ #[ pyimpl( with( SlotDescriptor ) ) ]
50
51
impl PyReadOnlyProperty { }
51
52
52
53
/// Property attribute.
@@ -110,13 +111,14 @@ struct PropertyArgs {
110
111
doc : Option < PyObjectRef > ,
111
112
}
112
113
113
- impl PyBuiltinDescriptor for PyProperty {
114
- fn get (
115
- zelf : PyRef < Self > ,
116
- obj : PyObjectRef ,
117
- _cls : OptionalArg < PyObjectRef > ,
114
+ impl SlotDescriptor for PyProperty {
115
+ fn descr_get (
118
116
vm : & VirtualMachine ,
117
+ zelf : PyObjectRef ,
118
+ obj : Option < PyObjectRef > ,
119
+ _cls : OptionalArg < PyObjectRef > ,
119
120
) -> PyResult {
121
+ let ( zelf, obj) = Self :: _unwrap ( zelf, obj, vm) ?;
120
122
if let Some ( getter) = zelf. getter . as_ref ( ) {
121
123
if obj. is ( vm. ctx . none . as_object ( ) ) {
122
124
Ok ( zelf. into_object ( ) )
@@ -129,7 +131,7 @@ impl PyBuiltinDescriptor for PyProperty {
129
131
}
130
132
}
131
133
132
- #[ pyimpl( with( PyBuiltinDescriptor ) , flags( BASETYPE ) ) ]
134
+ #[ pyimpl( with( SlotDescriptor ) , flags( BASETYPE ) ) ]
133
135
impl PyProperty {
134
136
#[ pyslot]
135
137
fn tp_new ( cls : PyClassRef , args : PropertyArgs , vm : & VirtualMachine ) -> PyResult < PyPropertyRef > {
0 commit comments