summaryrefslogtreecommitdiff
path: root/modules/language/python/dir.scm
diff options
context:
space:
mode:
Diffstat (limited to 'modules/language/python/dir.scm')
-rw-r--r--modules/language/python/dir.scm42
1 files changed, 25 insertions, 17 deletions
diff --git a/modules/language/python/dir.scm b/modules/language/python/dir.scm
index ecd85cf..2f23e35 100644
--- a/modules/language/python/dir.scm
+++ b/modules/language/python/dir.scm
@@ -13,8 +13,8 @@
(define-method (dir) (pylist))
(define (get-from-class c f)
- (let lp ((c c))
- (hash-for-each f c)
+ (let lp ((c c))
+ (hash-for-each f (slot-ref c 'h))
(let lpp ((pl (ref c '__parents__)))
(if (pair? pl)
(begin
@@ -23,7 +23,7 @@
(define (get-from-class-f c f)
(let lp ((c c))
- (vhash-fold f 0 c)
+ (vhash-fold f 0 (slot-ref c 'h))
(let lpp ((pl (ref c '__parents__)))
(if (pair? pl)
(begin
@@ -31,49 +31,49 @@
(lpp (cdr pl)))))))
(define-method (dir (o <p>))
- (if (pyclass? 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 (pylist))
- (f (lambda (k v) (pylist-append! h k #t))))
- (hash-for-each f o)
+ (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)
- (pylist-sort! l)
- l)))
+ (to-pylist (map symbol->string (sort l <))))))
(let* ((h (make-hash-table))
(c o)
(l '())
- (f (lambda (k v) (pylist-append! h k #t))))
+ (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 <pf>))
- (if (pyclass? 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 (pylist))
- (f (lambda (k v s) (pylist-append! h k #t))))
- (vhash-fold f 0 o)
+ (l '())
+ (f (lambda (k v s) (set! l (cons k l)))))
+ (vhash-fold f 0 (slot-ref o 'h))
(get-from-class-f c f)
(hash-for-each (lambda (k v) (pylist-append! l k)) h)
- (pylist-sort! l)
- l)))
+ (to-pylist (map symbol->string (sort l <))))))
(let* ((h (make-hash-table))
(c o)
(l '())
@@ -82,7 +82,15 @@
(hash-for-each (lambda (k v) (set! l (cons k l))) h)
(to-pylist (map symbol->string (sort l <))))))
-(define-method (dir (o <py-list> )) (pylist-listing))
+(define-method (dir (o <py-list> ))
+ (let ((l1 (pylist-listing)))
+ (if (is-a? o <p>)
+ (let* ((l2 (next-method))
+ (l (+ l1 l2)))
+ (pylist-sort! l)
+ l))))
+
+
(define-method (dir (o <hashtable> )) pyhash-listing)
(define-method (dir (o <py-hashtable>)) pyhash-listing)
(define-method (dir (o <string> )) string-listing)