[Added :eval-forms-p to compile-parenscript-file attila.lendvai@gmail.com**20060707151231] { hunk ./src/compile-js.lisp 3 -(defun compile-parenscript-file-to-string (source-file &key (log-stream nil) (comment nil)) - "Compile a parenscript file to a javascript string. (in-package ...) forms -behave as expected and all other forms are evaluated. If the result of the -evaluation is not nil tehn it's compiled with js:js* and written to the output." +(defun compile-parenscript-file-to-string (source-file &key + (log-stream nil) + (comment nil) + (eval-forms-p nil)) + "Compile SOURCE-FILE (a parenscript file) to a javascript string. (in-package ...) forms +behave as expected and all other forms are evaluated according to the value of +EVAL-FORMS-P. If the result of the evaluation is not nil then it's compiled with +js:js* and written to the output." hunk ./src/compile-js.lisp 18 - (let ((saved-package *package*)) - (unwind-protect - (loop for form = (read-form) - while form do - (if (or (not (listp form)) - (not (eq (car form) 'cl:in-package))) - (progn - (log-message "Processing form:~%~S~%" form) - (when comment - (princ "/*" output) - (print form output) - (terpri output) - (princ "*/" output) - (terpri output)) - (setf form (eval form)) - (log-message "After evaluation:~%~S~%" form) - (when form - (let ((compiled (js:js* form))) - (log-message "Compiled into:~%~A~%~%" compiled) - (write-string compiled output) - (terpri output) - (terpri output)))) - (when (and (listp form) - (eq (car form) 'cl:in-package)) - (log-message "Setting package to: ~S~%" (cadr form)) - (setf *package* (find-package (cadr form)))))) - (setf *package* saved-package))))))) + (let ((*package* *package*)) + (loop for form = (read-form) + while form do + (if (or (not (listp form)) + (not (eq (car form) 'cl:in-package))) + (progn + (log-message "Processing form:~%~S~%" form) + (when comment + (princ "/*" output) + (print form output) + (terpri output) + (princ "*/" output) + (terpri output)) + (when eval-forms-p + (setf form (eval form))) + (log-message "After evaluation:~%~S~%" form) + (when form + (let ((compiled (js:js* form))) + (log-message "Compiled into:~%~A~%~%" compiled) + (write-string compiled output) + (terpri output) + (terpri output)))) + (when (and (listp form) + (eq (car form) 'cl:in-package)) + (log-message "Setting package to: ~S~%" (cadr form)) + (setf *package* (find-package (cadr form))))))))))) hunk ./src/compile-js.lisp 45 -(defun compile-parenscript-file (source-file &key destination-file (log-stream nil) (comment nil)) - "Compile a parenscript file to a javascript file with +(defun compile-parenscript-file (source-file &rest args &key destination-file &allow-other-keys) + "Compile SOURCE-FILE (a parenscript file) to a javascript file with hunk ./src/compile-js.lisp 48 -then it will be named the same as the SOURCE-FILE but with js extension." +then it will be named the same as SOURCE-FILE but with js extension." + (setf args (copy-list args)) + (remf args :destination-file) hunk ./src/compile-js.lisp 55 - (write-string (compile-parenscript-file-to-string source-file :log-stream log-stream :comment comment) output))) + (write-string (apply #'compile-parenscript-file-to-string source-file args) output))) }