Substantially modified the way Parenscript compilation and
[clinton/parenscript.git] / src / deprecated-interface.lisp
1 (in-package :parenscript)
2
3 (define-condition simple-style-warning (simple-condition style-warning)
4 ())
5
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)))
10
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
14 (car body))
15 (warn-deprecated ',old-name ',new-name)
16 ,@body))
17
18 ;;; DEPRECATED INTERFACE
19
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))
23
24 (defun js-equal (ps-form1 ps-form2)
25 (warn-deprecated 'js-equal)
26 (equalp ps-form1 ps-form2))
27
28 (defun-js js-compile compile-script (form)
29 (compile-script form))
30
31 (defun-js js-compile-list compile-script (form)
32 (compile-script form))
33
34 (defmacro defjsmacro (&rest args)
35 (warn-deprecated 'defjsmacro 'defpsmacro)
36 `(defpsmacro ,@args))
37
38 (defmacro js-inline (&rest body)
39 (warn-deprecated 'js-inline 'ps-inline)
40 `(js-inline* '(progn ,@body)))
41
42 (defun-js js-inline* ps-inline* (&rest body)
43 (apply #'ps-inline* body))
44
45 (defmacro with-unique-js-names (&rest args)
46 (warn-deprecated 'with-unique-js-names 'with-ps-gensyms)
47 `(with-ps-gensyms ,@args))
48
49 (defun-js gen-js-name ps-gensym (&optional (prefix "_js_"))
50 (ps-gensym prefix))
51
52 (defmacro js (&rest args)
53 (warn-deprecated 'js 'ps)
54 `(ps ,@args))
55
56 (defun-js js* ps* (&rest args)
57 (apply #'ps* args))
58
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)))
64
65 (defun-js symbol-to-js symbol-to-js-string (symbol)
66 (symbol-to-js-string symbol))