File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Property object
2
+
3
+ package py
4
+
5
+ // A python Property object
6
+ type Property struct {
7
+ Fget func (self Object ) Object
8
+ Fset func (self , value Object )
9
+ Fdel func (self Object )
10
+ Doc string
11
+ }
12
+
13
+ var PropertyType = NewType ("property" , "property object" )
14
+
15
+ // Type of this object
16
+ func (o * Property ) Type () * Type {
17
+ return PropertyType
18
+ }
19
+
20
+ func (p * Property ) M__get__ (instance , owner Object ) Object {
21
+ if p .Fget == nil {
22
+ panic (ExceptionNewf (AttributeError , "can't get attribute" ))
23
+ }
24
+ return p .Fget (instance )
25
+ }
26
+
27
+ func (p * Property ) M__set__ (instance , value Object ) Object {
28
+ if p .Fset == nil {
29
+ panic (ExceptionNewf (AttributeError , "can't set attribute" ))
30
+ }
31
+ p .Fset (instance , value )
32
+ return None
33
+ }
34
+
35
+ func (p * Property ) M__delete__ (instance Object ) Object {
36
+ if p .Fdel == nil {
37
+ panic (ExceptionNewf (AttributeError , "can't delete attribute" ))
38
+ }
39
+ p .Fdel (instance )
40
+ return None
41
+ }
42
+
43
+ // Interfaces
44
+ var _ I__get__ = (* Property )(nil )
45
+ var _ I__set__ = (* Property )(nil )
46
+ var _ I__delete__ = (* Property )(nil )
You can’t perform that action at this time.
0 commit comments