PageRenderTime 35ms CodeModel.GetById 27ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/chicken/swigclosprefix.scm

#
Lisp | 31 lines | 28 code | 3 blank | 0 comment | 0 complexity | 87804676500ec821b92eb1967476d310 MD5 | raw file
 1(declare (hide swig-initialize))
 2
 3(define (swig-initialize obj initargs create)
 4     (slot-set! obj 'swig-this
 5        (if (memq 'swig-this initargs)
 6            (cadr initargs)
 7            (let ((ret (apply create initargs)))
 8              (if (instance? ret)
 9                (slot-ref ret 'swig-this)
10                ret)))))
11
12(define-class <swig-metaclass-$module> (<class>) (void))
13
14(define-method (compute-getter-and-setter (class <swig-metaclass-$module>) slot allocator)
15  (if (not (memq ':swig-virtual slot))
16    (call-next-method)
17    (let ((getter (let search-get ((lst slot))
18                    (if (null? lst)
19                      #f
20                      (if (eq? (car lst) ':swig-get)
21                        (cadr lst)
22                        (search-get (cdr lst))))))
23          (setter (let search-set ((lst slot))
24                    (if (null? lst)
25                      #f
26                      (if (eq? (car lst) ':swig-set)
27                        (cadr lst)
28                        (search-set (cdr lst)))))))
29      (values
30        (lambda (o) (getter (slot-ref o 'swig-this)))
31	(lambda (o new) (setter (slot-ref o 'swig-this) new) new)))))