Introduced the "funcall" macro (which really doesn't do anything - only CL needs...
[clinton/parenscript.git] / src / deprecated-interface.lisp
dissimilarity index 92%
index 7eee9cf..dc1f2f6 100644 (file)
@@ -1,81 +1,66 @@
-(in-package :parenscript)
-
-(defun warn-deprecated (old-name new-name)
-  (warn (format nil "~:@(~a~) is deprecated. Use ~:@(~a~) instead." old-name new-name)))
-
-;;; DEPRECATED INTERFACE ;;;
-
-(defun js-equal (a b)
-  (warn-deprecated 'js-equal 'script-equal)
-  (script-equal a b))
-
-(defun js-compile (form)
-  (warn-deprecated 'js-compile 'compile-script)
-  (compile-script form :output-spec :javascript))
-
-(defun js-compile-list (form)
-  (warn-deprecated 'js-compile-list 'compile-script)
-  (compile-script form :output-spec :javascript))
-
-(defun js-gensym (&rest args)
-  (warn-deprecated 'js-gensym 'script-gensym)
-  (apply #'script-gensym args))
-
-(defmacro defjsmacro (&rest args)
-  (warn-deprecated 'defjsmacro 'defscriptmacro)
-  `(defscriptmacro ,@args))
-
-(defmacro js (&body body)
-  (warn-deprecated 'js 'script)
-  `(script ,@body))
-
-(defmacro js* (&body body)
-  (warn-deprecated 'js* 'ps*)
-  `(script* ,@body))
-
-(defun js-to-string (expr)
-  "Given an AST node, compiles it to a Javascript string."
-  (warn "JS-TO-STRING is deprecated.")
-  (string-join
-   (ps-js::js-to-statement-strings (compile-script-form expr) 0)
-   (string #\Newline)))
-
-(defun js-to-line (expr)
-  "Given an AST node, compiles it to a Javascript string."
-  (warn "JS-TO-LINE is deprecated.")
-  (string-join
-   (ps-js::js-to-statement-strings (compile-script-form expr) 0) " "))
-
-(defmacro js-file (&rest body)
-  (warn "JS-FILE is deprecated.")
-  `(html
-    (:princ
-     (js ,@body))))
-
-(defmacro js-script (&rest body)
-  (warn "JS-SCRIPT is deprecated.")
-  `((:script :type "text/javascript")
-    (:princ (format nil "~%// <![CDATA[~%"))
-    (:princ (js ,@body))
-    (:princ (format nil "~%// ]]>~%"))))
-
-(defmacro js-inline (&rest body)
-  (warn "JS-INLINE is deprecated.")
-  `(js-inline* '(progn ,@body)))
-
-(defmacro js-inline* (&rest body)
-  (warn "JS-INLINE* is deprecated.")
-  `(concatenate 'string "javascript:"
-    (string-join (js-to-statement-strings (compile-script-form (list 'progn ,@body)) 0) " ")))
-
-(defmacro with-unique-js-names (&rest args)
-  (warn-deprecated 'with-unique-js-names 'with-unique-ps-names)
-  `(with-unique-ps-names ,@args))
-
-(defmacro gen-js-name (&rest args)
-  (warn-deprecated 'gen-js-name 'gen-ps-name)
-  `(gen-ps-name ,@args))
-
-(defmacro gen-js-name-string (&rest args)
-  (warn-deprecated 'gen-js-name-string 'gen-script-name-string)
-  `(gen-script-name-string ,@args))
+(in-package :parenscript)
+
+(define-condition simple-style-warning (simple-condition style-warning)
+  ())
+
+(defun warn-deprecated (old-name &optional new-name)
+  (warn 'simple-style-warning
+        :format-control "~:@(~a~) is deprecated~:[.~;, use ~:@(~a~) instead~]"
+        :format-arguments (list old-name new-name new-name)))
+
+(defmacro defun-js (old-name new-name args &body body)
+  `(defun ,old-name ,args
+    ,(when (and (stringp (car body)) (< 1 (length body))) ; docstring
+           (car body))
+    (warn-deprecated ',old-name ',new-name)
+    ,@body))
+
+;;; DEPRECATED INTERFACE
+
+(defmacro define-script-symbol-macro (name &body body)
+  (warn-deprecated 'define-script-symbol-macro 'define-ps-symbol-macro)
+  `(define-ps-symbol-macro ,name ,@body))
+
+(defun js-equal (ps-form1 ps-form2)
+  (warn-deprecated 'js-equal)
+  (equalp ps-form1 ps-form2))
+
+(defun-js js-compile compile-script (form)
+  (compile-script form))
+
+(defun-js js-compile-list compile-script (form)
+  (compile-script form))
+
+(defmacro defjsmacro (&rest args)
+  (warn-deprecated 'defjsmacro 'defpsmacro)
+  `(defpsmacro ,@args))
+
+(defmacro js-inline (&rest body)
+  (warn-deprecated 'js-inline 'ps-inline)
+  `(js-inline* '(progn ,@body)))
+
+(defun-js js-inline* ps-inline* (&rest body)
+  (apply #'ps-inline* body))
+
+(defmacro with-unique-js-names (&rest args)
+  (warn-deprecated 'with-unique-js-names 'with-ps-gensyms)
+  `(with-ps-gensyms ,@args))
+
+(defun-js gen-js-name ps-gensym (&optional (prefix "_js_"))
+  (ps-gensym prefix))
+
+(defmacro js (&rest args)
+  (warn-deprecated 'js 'ps)
+  `(ps ,@args))
+
+(defun-js js* ps* (&rest args)
+  (apply #'ps* args))
+
+(defun-js compile-script ps1* (ps-form &key (output-stream nil))
+  "Compiles the Parenscript form PS-FORM into Javascript.
+If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
+is output to the OUTPUT-STREAM stream."
+  (format output-stream "~A" (ps1* ps-form)))
+
+(defun-js symbol-to-js symbol-to-js-string (symbol)
+  (symbol-to-js-string symbol))