Changeset 11618
- Timestamp:
- 02/02/09 22:40:56 (14 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp/scripting
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java
r11558 r11618 28 28 import java.math.BigInteger; 29 29 import java.util.Map; 30 31 import javax.script.AbstractScriptEngine; 32 import javax.script.Bindings; 33 import javax.script.Compilable; 34 import javax.script.CompiledScript; 35 import javax.script.Invocable; 36 import javax.script.ScriptContext; 37 import javax.script.ScriptEngine; 38 import javax.script.ScriptEngineFactory; 39 import javax.script.ScriptException; 40 import javax.script.SimpleBindings; 41 42 import org.armedbear.lisp.Bignum; 43 import org.armedbear.lisp.ConditionThrowable; 44 import org.armedbear.lisp.Cons; 45 import org.armedbear.lisp.DoubleFloat; 46 import org.armedbear.lisp.Fixnum; 47 import org.armedbear.lisp.Function; 48 import org.armedbear.lisp.Interpreter; 49 import org.armedbear.lisp.JavaObject; 50 import org.armedbear.lisp.Keyword; 51 import org.armedbear.lisp.Lisp; 52 import org.armedbear.lisp.LispCharacter; 53 import org.armedbear.lisp.LispObject; 54 import org.armedbear.lisp.LispThread; 55 import org.armedbear.lisp.SimpleString; 56 import org.armedbear.lisp.SimpleVector; 57 import org.armedbear.lisp.SingleFloat; 58 import org.armedbear.lisp.Stream; 59 import org.armedbear.lisp.Symbol; 30 import java.util.Properties; 31 32 import javax.script.*; 33 34 import org.armedbear.lisp.*; 60 35 import org.armedbear.lisp.scripting.util.ReaderInputStream; 61 36 import org.armedbear.lisp.scripting.util.WriterOutputStream; … … 69 44 private Function compileScript; 70 45 private Function evalCompiledScript; 71 72 public AbclScriptEngine(Interpreter interpreter, boolean enableThrowingDebugger) { 73 74 this.interpreter = interpreter; 75 Interpreter.initializeLisp(); 76 final LispThread thread = LispThread.currentThread(); 77 this.nonThrowingDebugHook = Symbol.DEBUGGER_HOOK.getSymbolValue(); 46 private boolean configured = false; 47 48 public AbclScriptEngine(boolean enableThrowingDebugger) { 49 this(); 78 50 if (enableThrowingDebugger) { 79 51 try { 80 installThrowingDebuggerHook( thread);52 installThrowingDebuggerHook(LispThread.currentThread()); 81 53 } catch (ConditionThrowable e) { 82 54 throw new InternalError("Can't set throwing debugger hook!"); 83 55 } 84 56 } 57 } 58 59 public AbclScriptEngine() { 60 interpreter = Interpreter.createInstance(); 61 interpreter.initializeLisp(); 62 this.nonThrowingDebugHook = Symbol.DEBUGGER_HOOK.getSymbolValue(); 85 63 try { 86 64 loadFromClasspath("/org/armedbear/lisp/scripting/lisp/packages.lisp"); 87 65 loadFromClasspath("/org/armedbear/lisp/scripting/lisp/abcl-script.lisp"); 66 loadFromClasspath("/org/armedbear/lisp/scripting/lisp/config.lisp"); 67 if(getClass().getResource("/abcl-script-config.lisp") != null) { 68 System.out.println("ABCL: loading configuration from " + getClass().getResource("/abcl-script-config.lisp")); 69 loadFromClasspath("/abcl-script-config.lisp"); 70 } 71 interpreter.eval("(abcl-script:configure-abcl)"); 88 72 evalScript = (Function) this.findSymbol("EVAL-SCRIPT", "ABCL-SCRIPT").getSymbolFunction(); 89 73 compileScript = (Function) this.findSymbol("COMPILE-SCRIPT", "ABCL-SCRIPT").getSymbolFunction(); 90 74 evalCompiledScript = (Function) this.findSymbol("EVAL-COMPILED-SCRIPT", "ABCL-SCRIPT").getSymbolFunction(); 91 75 } catch (ConditionThrowable e) { 92 throw new Error(e); 93 } 94 } 95 96 public AbclScriptEngine(Interpreter interpreter) { 97 this(interpreter, false); 98 } 99 100 public AbclScriptEngine(boolean enableThrowingDebugger) { 101 this(Interpreter.createInstance(), enableThrowingDebugger); 102 } 103 104 public AbclScriptEngine() { 105 this(Interpreter.createInstance(), true); 106 } 107 76 throw new RuntimeException(e); 77 } 78 } 79 80 public boolean isConfigured() { 81 return configured; 82 } 83 108 84 public Interpreter getInterpreter() { 109 85 return interpreter; -
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp
r11558 r11618 16 16 ;;; along with this program; if not, write to the Free Software 17 17 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 ;;; 19 ;;; As a special exception, the copyright holders of this library give you 20 ;;; permission to link this library with independent modules to produce an 21 ;;; executable, regardless of the license terms of these independent 22 ;;; modules, and to copy and distribute the resulting executable under 23 ;;; terms of your choice, provided that you also meet, for each linked 24 ;;; independent module, the terms and conditions of the license of that 25 ;;; module. An independent module is a module which is not derived from 26 ;;; or based on this library. If you modify this library, you may extend 27 ;;; this exception to your version of the library, but you are not 28 ;;; obligated to do so. If you do not wish to do so, delete this 29 ;;; exception statement from your version. 18 30 19 31 (in-package :abcl-script) … … 109 121 interface 110 122 (jmake-proxy interface implementation lisp-this))) 123 124 ;Let's load it so asdf package is already defined when loading config.lisp 125 (require 'asdf) -
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/packages.lisp
r11450 r11618 16 16 ;;; along with this program; if not, write to the Free Software 17 17 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 ;;; 19 ;;; As a special exception, the copyright holders of this library give you 20 ;;; permission to link this library with independent modules to produce an 21 ;;; executable, regardless of the license terms of these independent 22 ;;; modules, and to copy and distribute the resulting executable under 23 ;;; terms of your choice, provided that you also meet, for each linked 24 ;;; independent module, the terms and conditions of the license of that 25 ;;; module. An independent module is a module which is not derived from 26 ;;; or based on this library. If you modify this library, you may extend 27 ;;; this exception to your version of the library, but you are not 28 ;;; obligated to do so. If you do not wish to do so, delete this 29 ;;; exception statement from your version. 18 30 19 31 (defpackage :abcl-script 20 32 (:use :cl :java) 21 (:export #:eval-script 22 #:compile-script 23 #:eval-compiled-script 24 #:define-java-interface-implementation 25 #:find-java-interface-implementation 26 #:register-java-interface-implementation 27 #:remove-java-interface-implementation)) 28 33 (:export 34 #:*abcl-debug* 35 #:eval-script 36 #:compile-script 37 #:*compile-using-temp-files* 38 #:configure-abcl 39 #:eval-compiled-script 40 #:define-java-interface-implementation 41 #:find-java-interface-implementation 42 #:register-java-interface-implementation 43 #:remove-java-interface-implementation 44 #:+standard-debugger-hook+ 45 #:*swank-dir* 46 #:*swank-port* 47 #:*use-throwing-debugger*)) 48 29 49 (defpackage :abcl-script-user 30 50 (:use :cl :ext :java :abcl-script))
Note: See TracChangeset
for help on using the changeset viewer.