Ignore:
Timestamp:
02/04/09 21:58:25 (14 years ago)
Author:
astalla
Message:

Perfectioned ABCL auto-configuration when using JSR-223; added option to
compile scripts using temp files (default) or using the run-time
compiler; added example of usage of ABCL with JSR-223.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp

    r11618 r11623  
    9696
    9797(defun compile-script (code-string)
    98   (eval
    99    `(compile
    100      nil
    101      (lambda ()
    102        ,@(let ((*package* (find-package :abcl-script-user)))
    103         (read-from-string (concatenate 'string "(" code-string ")")))))))
    104 
     98  (if *compile-using-temp-files*
     99      (let* ((tmp-file (jstatic (jmethod "java.io.File" "createTempFile" "java.lang.String" "java.lang.String")
     100        nil "abcl-src-file-" ".lisp"))
     101       (tmp-file-path (jcall (jmethod "java.io.File" "getAbsolutePath") tmp-file)))
     102  (jcall (jmethod "java.io.File" "deleteOnExit") tmp-file) ;to be really-really-really sure...
     103  (unwind-protect
     104       (progn
     105         (with-open-file (stream tmp-file-path :direction :output :if-exists :overwrite)
     106     (prin1 code-string stream)
     107     (finish-output stream))
     108         (let ((compiled-file (compile-file tmp-file-path)))
     109     (jcall (jmethod "java.io.File" "deleteOnExit")
     110      (jnew (jconstructor "java.io.File" "java.lang.String")
     111            (namestring compiled-file)))
     112     (lambda () (load compiled-file))))
     113    (delete-file tmp-file-path)))
     114      (eval
     115       `(compile
     116   nil
     117   (lambda ()
     118     ,@(let ((*package* (find-package :abcl-script-user)))
     119      (read-from-string (concatenate 'string "(" code-string ")"))))))))
    105120
    106121;;Java interface implementation
Note: See TracChangeset for help on using the changeset viewer.