Clarified that the license is BSD 3-clause. Added SPDX identifiers
[parenscript.git] / src / deprecated-interface.lisp
blobadbaf7771f52d74b0fbc5aedb6152cd5620571e0
1 ;; SPDX-License-Identifier: BSD-3-Clause
3 (in-package #:parenscript)
4 (in-readtable :parenscript)
6 (define-condition simple-style-warning (style-warning simple-warning)
7 ())
9 (defun warn-deprecated (old-name &optional new-name)
10 (unless *suppress-deprecation*
11 (warn 'simple-style-warning
12 :format-control "~:@(~a~) is deprecated~:[.~;, use ~:@(~a~) instead~]"
13 :format-arguments (list old-name new-name new-name))))
15 (defmacro defun-js (old-name new-name args &body body)
16 `(defun ,old-name ,args
17 ,(when (and (stringp (car body)) (< 1 (length body))) ; docstring
18 (car body))
19 (warn-deprecated ',old-name ',new-name)
20 ,@body))
22 ;;; DEPRECATED INTERFACE
24 (defmacro define-script-symbol-macro (name &body body)
25 (warn-deprecated 'define-script-symbol-macro 'define-ps-symbol-macro)
26 `(define-ps-symbol-macro ,name ,@body))
28 (defun js-equal (ps-form1 ps-form2)
29 (warn-deprecated 'js-equal)
30 (equalp ps-form1 ps-form2))
32 (defun-js js-compile compile-script (form)
33 (compile-script form))
35 (defun-js js-compile-list compile-script (form)
36 (compile-script form))
38 (defmacro defjsmacro (&rest args)
39 (warn-deprecated 'defjsmacro 'defpsmacro)
40 `(defpsmacro ,@args))
42 (defmacro js-inline (&rest body)
43 (warn-deprecated 'js-inline 'ps-inline)
44 `(js-inline* '(progn ,@body)))
46 (defun-js js-inline* ps-inline* (&rest body)
47 (apply #'ps-inline* body))
49 (defmacro with-unique-js-names (&rest args)
50 (warn-deprecated 'with-unique-js-names 'with-ps-gensyms)
51 `(with-ps-gensyms ,@args))
53 (defun-js gen-js-name ps-gensym (&optional (prefix "_JS_"))
54 (ps-gensym prefix))
56 (defmacro js (&rest args)
57 (warn-deprecated 'js 'ps)
58 `(ps ,@args))
60 (defun-js js* ps* (&rest args)
61 (apply #'ps* args))
63 (defun-js compile-script ps* (ps-form &key (output-stream nil))
64 "Compiles the Parenscript form PS-FORM into Javascript.
65 If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
66 is output to the OUTPUT-STREAM stream."
67 (format output-stream "~A" (ps* ps-form)))
69 (defun-js symbol-to-js symbol-to-js-string (symbol)
70 (symbol-to-js-string symbol))
72 (defmacro defmacro/ps (name args &body body)
73 (warn-deprecated 'defmacro/ps 'defmacro+ps)
74 `(progn (defmacro ,name ,args ,@body)
75 (import-macros-from-lisp ',name)))
77 (defmacro defpsmacro-deprecated (old new)
78 `(defpsmacro ,old (&rest args)
79 (warn-deprecated ',old ',new)
80 (cons ',new args)))
82 (defpsmacro-deprecated slot-value getprop)
83 (defpsmacro-deprecated === eql)
84 (defpsmacro-deprecated == equal)
85 (defpsmacro-deprecated % rem)
86 (defpsmacro-deprecated concat-string stringify)
88 (defpsmacro !== (&rest args)
89 (warn-deprecated '!==)
90 `(not (eql ,@args)))
92 (defpsmacro != (&rest args)
93 (warn-deprecated '!=)
94 `(not (equal ,@args)))
96 (defpsmacro labeled-for (label init-forms cond-forms step-forms &rest body)
97 (warn-deprecated 'labeled-for 'label)
98 `(label ,label (for ,init-forms ,cond-forms ,step-forms ,@body)))
100 (defpsmacro do-set-timeout ((timeout) &body body)
101 (warn-deprecated 'do-set-timeout 'set-timeout)
102 `(set-timeout (lambda () ,@body) ,timeout))
104 (defun concat-string (&rest things)
105 (warn-deprecated 'concat-string 'stringify)
106 (apply #'stringify things))
108 (define-statement-operator with (expression &rest body)
109 (warn-deprecated 'with '|LET or WITH-SLOTS|)
110 `(ps-js:with ,(compile-expression expression)
111 ,(compile-statement `(progn ,@body))))
113 (defpsmacro label (&rest args)
114 (warn-deprecated 'label 'block)
115 `(block ,@args))
117 (define-ps-symbol-macro f ps-js:false)
119 (setf %compiling-reserved-forms-p% nil)