(define-module (language python dir) #:use-module (language python list) #:use-module (language python for) #:use-module (language python dict) #:use-module (language python string) #:use-module (language python number) #:use-module (oop goops) #:use-module (ice-9 vlist) #:use-module (oop pf-objects) #:export (dir)) (define-syntax-rule (aif it p x y) (let ((it p)) (if it x y))) (define-method (dir) (pylist)) (define (get-from-class c f) (let lp ((c c)) (hash-for-each f (slot-ref c 'h)) (let lpp ((pl (ref c '__parents__))) (if (pair? pl) (begin (lp (car pl)) (lpp (cdr pl))))))) (define (get-from-class-f c f) (let lp ((c c)) (vhash-fold f 0 (slot-ref c 'h)) (let lpp ((pl (ref c '__parents__))) (if (pair? pl) (begin (lp (car pl)) (lpp (cdr pl))))))) (define-method (dir (o
))
(if (not (pyclass? o))
(aif it (ref o '__dir__)
(it)
(aif it (ref o '__dict__)
(let ((l (pylist)))
(for ((k v : it)) ()
(pylist-append! l k))
(pylist-sort! l)
l)
(let* ((h (make-hash-table))
(c (ref o '__class__))
(l '())
(f (lambda (k v) (set! l (cons k l)))))
(hash-for-each f (slot-ref o 'h))
(get-from-class c f)
(hash-for-each (lambda (k v) (pylist-append! l k)) h)
(to-pylist (map symbol->string (sort l <))))))
(let* ((h (make-hash-table))
(c o)
(l '())
(f (lambda (k v) (hash-set! h k #t))))
(get-from-class c f)
(hash-for-each (lambda (k v) (set! l (cons k l))) h)
(to-pylist (map symbol->string (sort l <))))))
(define-method (dir (o )
(let* ((l2 (next-method))
(l (+ l1 l2)))
(pylist-sort! l)
l)
l1)))
(define-method (dir (o )
(let* ((l2 (next-method))
(l (+ l1 l2)))
(pylist-sort! l)
l)
l1)))
(define-method (dir (o )
(let* ((l2 (next-method))
(l (+ l1 l2)))
(pylist-sort! l)
l)
l1)))
(define-method (dir (o )
(let* ((l2 (next-method))
(l (+ l1 l2)))
(pylist-sort! l)
l)
l1)))
(define-method (dir (o )
(let* ((l2 (next-method))
(l (+ l1 l2)))
(pylist-sort! l)
l)
l1)))
(define-method (dir (o )
(let* ((l2 (next-method))
(l (+ l1 l2)))
(pylist-sort! l)
l)
l1)))
(define-method (dir (o