1 ;; Tracing macro courtesy of William Halliburton
2 ;; <whalliburton@gmail.com>, logs to Firebug console
4 ;; On a happier note here is a macro I wrote to enable
5 ;; tracing-ala-cl. Works with firebug. You'll need to (defvar
6 ;; *trace-level*). I don't do indentation but that would be an easy
9 (defpsmacro console
(&rest rest
)
10 `(console.log
,@rest
))
12 (defpsmacro defun-trace
(name args
&rest body
)
13 (let* ((sname (ps::symbol-to-js name
))
14 (tname (ps-gensym name
))
15 (arg-names (loop for arg in args
16 unless
(eq arg
'&optional
)
17 collect
(if (consp arg
) (car arg
) arg
)))
19 (loop for arg in arg-names
20 nconc
(list (ps::symbol-to-js arg
) arg
))))
22 (defun ,name
,arg-names
23 (console *trace-level
* ,sname
":" ,@argpairs
)
25 (let* ((rtn (,tname
,@arg-names
)))
27 (console *trace-level
* ,sname
"returned" rtn
)