- Timestamp:
- 05/07/09 22:01:52 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp
r11623 r11839 58 58 ,java-bindings ,(car jbinding) ,(car binding)))) 59 59 60 (defmacro with-script-context ((global-bindings engine-bindings stdin stdout script-context) 61 body) 60 (defmacro eval-in-script-context ((global-bindings engine-bindings stdin stdout script-context) 61 body) 62 "Sets up an environment in which to evaluate a piece of code coming from Java through the JSR-223 methods." 62 63 (let ((actual-global-bindings (gensym)) 63 64 (actual-engine-bindings (gensym))) … … 65 66 (*standard-input* ,stdin) 66 67 (*standard-output* ,stdout) 68 (*debugger-hook* (if *use-throwing-debugger* 69 #'sys::%debugger-hook-function 70 *debugger-hook*)) 67 71 (,actual-global-bindings (generate-bindings ,global-bindings)) 68 72 (,actual-engine-bindings (generate-bindings ,engine-bindings))) 69 (eval `(let ((*standard-input* ,,stdin) 70 (*standard-output* ,,stdout) 71 (*package* (find-package :abcl-script-user))) 72 (let (,@,actual-global-bindings) 73 (eval `(let (,@,actual-global-bindings) 73 74 (let (,@,actual-engine-bindings) 74 75 (prog1 … … 82 83 ,engine-bindings 83 84 ,actual-engine-bindings 84 (jcall +get-bindings+ ,script-context +engine-scope+))))))))) )85 (jcall +get-bindings+ ,script-context +engine-scope+))))))))) 85 86 86 87 (defun eval-script (global-bindings engine-bindings stdin stdout 87 88 code-string script-context) 88 ( with-script-context (global-bindings engine-bindings stdin stdout script-context)89 (eval-in-script-context (global-bindings engine-bindings stdin stdout script-context) 89 90 (read-from-string 90 91 (concatenate 'string "(" code-string ")")))) … … 92 93 (defun eval-compiled-script (global-bindings engine-bindings stdin stdout 93 94 function script-context) 94 ( with-script-context (global-bindings engine-bindings stdin stdout script-context)95 (eval-in-script-context (global-bindings engine-bindings stdin stdout script-context) 95 96 `((funcall ,function)))) 96 97 … … 103 104 (unwind-protect 104 105 (progn 105 (with-open-file (stream tmp-file-path :direction :output :if-exists :overwrite) 106 (prin1 code-string stream) 106 (with-open-file (stream tmp-file-path :direction :output) 107 (princ "(in-package :abcl-script-user)" stream) 108 (princ code-string stream) 107 109 (finish-output stream)) 108 110 (let ((compiled-file (compile-file tmp-file-path))) … … 110 112 (jnew (jconstructor "java.io.File" "java.lang.String") 111 113 (namestring compiled-file))) 112 (lambda () (load compiled-file)))) 114 (lambda () 115 (let ((*package* (find-package :abcl-script-user))) 116 (load compiled-file :verbose t :print t))))) 113 117 (delete-file tmp-file-path))) 114 118 (eval … … 117 121 (lambda () 118 122 ,@(let ((*package* (find-package :abcl-script-user))) 119 (read-from-string (concatenate 'string "(" code-string ")")))))))) 123 (read-from-string 124 (concatenate 'string "(" code-string " cl:t)")))))))) ;return T in conformity of what LOAD does. 120 125 121 ;;Java interface implementation 126 ;;Java interface implementation - TODO 122 127 123 128 (defvar *interface-implementation-map* (make-hash-table :test #'equal)) … … 126 131 (gethash interface *interface-implementation-map*)) 127 132 128 (defun register-java-interface-implementation (interface impl) 129 (setf (gethash interface *interface-implementation-map*) impl)) 133 (defun register-java-interface-implementation (interface implementation &optional lisp-this) 134 (setf (gethash interface *interface-implementation-map*) 135 (jmake-proxy interface implementation lisp-this))) 130 136 131 137 (defun remove-java-interface-implementation (interface) 132 138 (remhash interface *interface-implementation-map*)) 133 139 134 (defun define-java-interface-implementation (interface implementation &optional lisp-this)135 (register-java-interface-implementation136 interface137 (jmake-proxy interface implementation lisp-this)))138 139 140 ;Let's load it so asdf package is already defined when loading config.lisp 140 141 (require 'asdf)
Note: See TracChangeset
for help on using the changeset viewer.