| 1 |
#!/usr/bin/env ikarus --r6rs-script |
| 2 |
|
| 3 |
(import (ikarus) (objc)) |
| 4 |
|
| 5 |
(define-framework Cocoa) |
| 6 |
;(load-shared-object "IKFoo.dylib") |
| 7 |
|
| 8 |
(define who (car (command-line))) |
| 9 |
|
| 10 |
(define (println x) (printf "~a\n" x)) |
| 11 |
|
| 12 |
(define (print-classes) |
| 13 |
(for-each println |
| 14 |
(list-sort string<? |
| 15 |
(map class-name (get-class-list))))) |
| 16 |
|
| 17 |
(define (parents x) |
| 18 |
(let ([p (class-parent x)]) |
| 19 |
(if p (cons p (parents p)) '()))) |
| 20 |
|
| 21 |
(define (ivar-info x) |
| 22 |
`(ivar name: ,(ivar-name x) |
| 23 |
type: ,(ivar-type x) |
| 24 |
offset: ,(ivar-offset x))) |
| 25 |
|
| 26 |
(define (print-class-methods x) |
| 27 |
(define (public? x) |
| 28 |
(and (> (string-length x) 0) |
| 29 |
(not (char=? (string-ref x 0) #\_)))) |
| 30 |
(let ([x (or (get-class x) (error who "cannot find class" x))]) |
| 31 |
(printf "instance size = ~s\n" (class-instance-size x)) |
| 32 |
(printf "parents = ~s\n" |
| 33 |
(map (lambda (x) |
| 34 |
(cons (class-name x) |
| 35 |
(class-instance-size x))) |
| 36 |
(parents x))) |
| 37 |
(printf "ivars=~s\n" (map ivar-info (class-ivars x))) |
| 38 |
#; |
| 39 |
(for-each println |
| 40 |
(list-sort string<? |
| 41 |
(filter public? |
| 42 |
(map method-name (class-methods x))))))) |
| 43 |
|
| 44 |
(apply |
| 45 |
(case-lambda |
| 46 |
[() (print-classes)] |
| 47 |
[(x) (print-class-methods x)] |
| 48 |
[args |
| 49 |
(error who "supply either 0 or 1 arguments")]) |
| 50 |
(cdr (command-line))) |
| 51 |
|