itertools
[software/python-on-guile.git] / modules / language / python / property.scm
1 (define-module (language python property)
2 #:use-module (oop pf-objects)
3 #:use-module (oop goops)
4 #:use-module (language python def)
5 #:use-module (language python exceptions)
6 #:use-module (language python persist)
7 #:export (property))
8
9 (cpit <property> (o (lambda (o get set del)
10 (slot-set! o 'get get)
11 (slot-set! o 'set set)
12 (slot-set! o 'del del))
13 (list
14 (slot-ref o 'get)
15 (slot-ref o 'set)
16 (slot-ref o 'del))))
17
18 (define-python-class property (<property>)
19 (define __init__
20 (lam (o (= getx None) (= setx None) (= delx None))
21 (slot-set! o 'get getx)
22 (slot-set! o 'set setx)
23 (slot-set! o 'del delx)
24 o))
25
26 (define setter
27 (lambda (self f)
28 (slot-set! self 'set f)
29 self))
30
31 (define getter
32 (lambda (self f)
33 (slot-set! self 'get f)
34 self))
35
36 (define deleter
37 (lambda (self f)
38 (slot-set! self 'del f)
39 self))
40
41 (define fget (lambda (self) (slot-ref self 'get)))
42 (define fset (lambda (self) (slot-ref self 'set)))
43 (define fdel (lambda (self) (slot-ref self 'del))))
44