1 (in-package :parenscript
)
3 (define-condition simple-style-warning
(simple-condition style-warning
)
6 (defun warn-deprecated (old-name &optional new-name
)
7 (warn 'simple-style-warning
8 :format-control
"~:@(~a~) is deprecated~:[.~;, use ~:@(~a~) instead~]"
9 :format-arguments
(list old-name new-name new-name
)))
11 (defmacro defun-js
(old-name new-name args
&body body
)
12 `(defun ,old-name
,args
13 ,(when (and (stringp (car body
)) (< 1 (length body
))) ; docstring
15 (warn-deprecated ',old-name
',new-name
)
18 ;;; DEPRECATED INTERFACE
20 (defmacro define-script-symbol-macro
(name &body body
)
21 (warn-deprecated 'define-script-symbol-macro
'define-ps-symbol-macro
)
22 `(define-ps-symbol-macro ,name
,@body
))
24 (defun js-equal (ps-form1 ps-form2
)
25 (warn-deprecated 'js-equal
)
26 (equalp ps-form1 ps-form2
))
28 (defun-js js-compile compile-script
(form)
29 (compile-script form
))
31 (defun-js js-compile-list compile-script
(form)
32 (compile-script form
))
34 (defmacro defjsmacro
(&rest args
)
35 (warn-deprecated 'defjsmacro
'defpsmacro
)
38 (defmacro js-inline
(&rest body
)
39 (warn-deprecated 'js-inline
'ps-inline
)
40 `(js-inline* '(progn ,@body
)))
42 (defun-js js-inline
* ps-inline
* (&rest body
)
43 (apply #'ps-inline
* body
))
45 (defmacro with-unique-js-names
(&rest args
)
46 (warn-deprecated 'with-unique-js-names
'with-ps-gensyms
)
47 `(with-ps-gensyms ,@args
))
49 (defun-js gen-js-name ps-gensym
(&optional
(prefix "_js_"))
52 (defmacro js
(&rest args
)
53 (warn-deprecated 'js
'ps
)
56 (defun-js js
* ps
* (&rest args
)
59 (defun-js compile-script ps
* (ps-form &key
(output-stream nil
))
60 "Compiles the Parenscript form PS-FORM into Javascript.
61 If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
62 is output to the OUTPUT-STREAM stream."
63 (format output-stream
"~A" (ps* ps-form
)))
65 (defun-js symbol-to-js symbol-to-js-string
(symbol)
66 (symbol-to-js-string symbol
))
68 (defmacro defmacro
/ps
(name args
&body body
)
69 (warn-deprecated 'defmacro
/ps
'defmacro
+ps
)
70 `(progn (defmacro ,name
,args
,@body
)
71 (import-macros-from-lisp ',name
)))
73 (defmacro defpsmacro-deprecated
(old new
)
74 `(defpsmacro ,old
(&rest args
)
75 (warn-deprecated ',old
',new
)
78 (defpsmacro-deprecated slot-value getprop
)
79 (defpsmacro-deprecated === eql
)
80 (defpsmacro-deprecated == equal
)
81 (defpsmacro-deprecated % rem
)
83 (defpsmacro !== (&rest args
)
84 (warn-deprecated '!==)
87 (defpsmacro != (&rest args
)
89 `(not (equal ,@args
)))
91 (defpsmacro labeled-for
(label init-forms cond-forms step-forms
&rest body
)
92 (warn-deprecated 'labeled-for
'label
)
93 `(label ,label
(for ,init-forms
,cond-forms
,step-forms
,@body
)))
95 (defpsmacro do-set-timeout
((timeout) &body body
)
96 (warn-deprecated 'do-set-timeout
'set-timeout
)
97 `(set-timeout (lambda () ,@body
) ,timeout
))