[armedbear-cvs] r11618 - in trunk/abcl/src/org/armedbear/lisp/scripting: . lisp
Alessio Stalla
astalla at common-lisp.net
Mon Feb 2 22:40:58 UTC 2009
Author: astalla
Date: Mon Feb 2 22:40:56 2009
New Revision: 11618
Log:
Added support for a configuration file in the CLASSPATH for ABCL when
loaded through JSR-223.
Added:
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/config.lisp
Modified:
trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/packages.lisp
Modified: trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Mon Feb 2 22:40:56 2009
@@ -27,36 +27,11 @@
import java.io.StringWriter;
import java.math.BigInteger;
import java.util.Map;
+import java.util.Properties;
-import javax.script.AbstractScriptEngine;
-import javax.script.Bindings;
-import javax.script.Compilable;
-import javax.script.CompiledScript;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptException;
-import javax.script.SimpleBindings;
-
-import org.armedbear.lisp.Bignum;
-import org.armedbear.lisp.ConditionThrowable;
-import org.armedbear.lisp.Cons;
-import org.armedbear.lisp.DoubleFloat;
-import org.armedbear.lisp.Fixnum;
-import org.armedbear.lisp.Function;
-import org.armedbear.lisp.Interpreter;
-import org.armedbear.lisp.JavaObject;
-import org.armedbear.lisp.Keyword;
-import org.armedbear.lisp.Lisp;
-import org.armedbear.lisp.LispCharacter;
-import org.armedbear.lisp.LispObject;
-import org.armedbear.lisp.LispThread;
-import org.armedbear.lisp.SimpleString;
-import org.armedbear.lisp.SimpleVector;
-import org.armedbear.lisp.SingleFloat;
-import org.armedbear.lisp.Stream;
-import org.armedbear.lisp.Symbol;
+import javax.script.*;
+
+import org.armedbear.lisp.*;
import org.armedbear.lisp.scripting.util.ReaderInputStream;
import org.armedbear.lisp.scripting.util.WriterOutputStream;
@@ -68,43 +43,44 @@
private Function evalScript;
private Function compileScript;
private Function evalCompiledScript;
+ private boolean configured = false;
- public AbclScriptEngine(Interpreter interpreter, boolean enableThrowingDebugger) {
-
- this.interpreter = interpreter;
- Interpreter.initializeLisp();
- final LispThread thread = LispThread.currentThread();
- this.nonThrowingDebugHook = Symbol.DEBUGGER_HOOK.getSymbolValue();
+ public AbclScriptEngine(boolean enableThrowingDebugger) {
+ this();
if (enableThrowingDebugger) {
try {
- installThrowingDebuggerHook(thread);
+ installThrowingDebuggerHook(LispThread.currentThread());
} catch (ConditionThrowable e) {
throw new InternalError("Can't set throwing debugger hook!");
}
}
+ }
+
+ public AbclScriptEngine() {
+ interpreter = Interpreter.createInstance();
+ interpreter.initializeLisp();
+ this.nonThrowingDebugHook = Symbol.DEBUGGER_HOOK.getSymbolValue();
try {
loadFromClasspath("/org/armedbear/lisp/scripting/lisp/packages.lisp");
loadFromClasspath("/org/armedbear/lisp/scripting/lisp/abcl-script.lisp");
+ loadFromClasspath("/org/armedbear/lisp/scripting/lisp/config.lisp");
+ if(getClass().getResource("/abcl-script-config.lisp") != null) {
+ System.out.println("ABCL: loading configuration from " + getClass().getResource("/abcl-script-config.lisp"));
+ loadFromClasspath("/abcl-script-config.lisp");
+ }
+ interpreter.eval("(abcl-script:configure-abcl)");
evalScript = (Function) this.findSymbol("EVAL-SCRIPT", "ABCL-SCRIPT").getSymbolFunction();
compileScript = (Function) this.findSymbol("COMPILE-SCRIPT", "ABCL-SCRIPT").getSymbolFunction();
evalCompiledScript = (Function) this.findSymbol("EVAL-COMPILED-SCRIPT", "ABCL-SCRIPT").getSymbolFunction();
} catch (ConditionThrowable e) {
- throw new Error(e);
+ throw new RuntimeException(e);
}
}
-
- public AbclScriptEngine(Interpreter interpreter) {
- this(interpreter, false);
- }
-
- public AbclScriptEngine(boolean enableThrowingDebugger) {
- this(Interpreter.createInstance(), enableThrowingDebugger);
- }
-
- public AbclScriptEngine() {
- this(Interpreter.createInstance(), true);
+
+ public boolean isConfigured() {
+ return configured;
}
-
+
public Interpreter getInterpreter() {
return interpreter;
}
Modified: trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp (original)
+++ trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp Mon Feb 2 22:40:56 2009
@@ -15,6 +15,18 @@
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;;;
+;;; As a special exception, the copyright holders of this library give you
+;;; permission to link this library with independent modules to produce an
+;;; executable, regardless of the license terms of these independent
+;;; modules, and to copy and distribute the resulting executable under
+;;; terms of your choice, provided that you also meet, for each linked
+;;; independent module, the terms and conditions of the license of that
+;;; module. An independent module is a module which is not derived from
+;;; or based on this library. If you modify this library, you may extend
+;;; this exception to your version of the library, but you are not
+;;; obligated to do so. If you do not wish to do so, delete this
+;;; exception statement from your version.
(in-package :abcl-script)
@@ -107,4 +119,7 @@
(defun define-java-interface-implementation (interface implementation &optional lisp-this)
(register-java-interface-implementation
interface
- (jmake-proxy interface implementation lisp-this)))
\ No newline at end of file
+ (jmake-proxy interface implementation lisp-this)))
+
+;Let's load it so asdf package is already defined when loading config.lisp
+(require 'asdf)
\ No newline at end of file
Added: trunk/abcl/src/org/armedbear/lisp/scripting/lisp/config.lisp
==============================================================================
--- (empty file)
+++ trunk/abcl/src/org/armedbear/lisp/scripting/lisp/config.lisp Mon Feb 2 22:40:56 2009
@@ -0,0 +1,60 @@
+;;; config.lisp
+;;;
+;;; Copyright (C) 2008 Alessio Stalla
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License
+;;; as published by the Free Software Foundation; either version 2
+;;; of the License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program; if not, write to the Free Software
+;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;;;
+;;; As a special exception, the copyright holders of this library give you
+;;; permission to link this library with independent modules to produce an
+;;; executable, regardless of the license terms of these independent
+;;; modules, and to copy and distribute the resulting executable under
+;;; terms of your choice, provided that you also meet, for each linked
+;;; independent module, the terms and conditions of the license of that
+;;; module. An independent module is a module which is not derived from
+;;; or based on this library. If you modify this library, you may extend
+;;; this exception to your version of the library, but you are not
+;;; obligated to do so. If you do not wish to do so, delete this
+;;; exception statement from your version.
+
+
+(in-package :abcl-script)
+
+(defparameter *abcl-debug* nil)
+
+(defparameter *swank-dir* nil)
+
+(defparameter *swank-port* 4005)
+
+(defparameter *use-throwing-debugger* t)
+
+(defparameter *compile-using-temp-files* nil)
+
+(defconstant +standard-debugger-hook+ *debugger-hook*)
+
+(defun configure-abcl ()
+ (setq *debugger-hook*
+ (if *use-throwing-debugger*
+ #'sys::%debugger-hook-function
+ +standard-debugger-hook+))
+ (when *abcl-debug*
+ (unless *swank-dir*
+ (error "Swank directory not specified, please set *swank-dir*"))
+ (pushnew *swank-dir* asdf:*central-registry* :test #'equal)
+ (asdf:oos 'asdf:load-op :swank)
+ (ext:make-thread (lambda () (funcall (find-symbol
+ (symbol-name '#:create-server)
+ :swank)
+ :port *swank-port*))
+ :name "ABCL script - Swank thread")))
\ No newline at end of file
Modified: trunk/abcl/src/org/armedbear/lisp/scripting/lisp/packages.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/scripting/lisp/packages.lisp (original)
+++ trunk/abcl/src/org/armedbear/lisp/scripting/lisp/packages.lisp Mon Feb 2 22:40:56 2009
@@ -15,16 +15,36 @@
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;;;
+;;; As a special exception, the copyright holders of this library give you
+;;; permission to link this library with independent modules to produce an
+;;; executable, regardless of the license terms of these independent
+;;; modules, and to copy and distribute the resulting executable under
+;;; terms of your choice, provided that you also meet, for each linked
+;;; independent module, the terms and conditions of the license of that
+;;; module. An independent module is a module which is not derived from
+;;; or based on this library. If you modify this library, you may extend
+;;; this exception to your version of the library, but you are not
+;;; obligated to do so. If you do not wish to do so, delete this
+;;; exception statement from your version.
(defpackage :abcl-script
(:use :cl :java)
- (:export #:eval-script
- #:compile-script
- #:eval-compiled-script
- #:define-java-interface-implementation
- #:find-java-interface-implementation
- #:register-java-interface-implementation
- #:remove-java-interface-implementation))
-
+ (:export
+ #:*abcl-debug*
+ #:eval-script
+ #:compile-script
+ #:*compile-using-temp-files*
+ #:configure-abcl
+ #:eval-compiled-script
+ #:define-java-interface-implementation
+ #:find-java-interface-implementation
+ #:register-java-interface-implementation
+ #:remove-java-interface-implementation
+ #:+standard-debugger-hook+
+ #:*swank-dir*
+ #:*swank-port*
+ #:*use-throwing-debugger*))
+
(defpackage :abcl-script-user
(:use :cl :ext :java :abcl-script))
\ No newline at end of file
More information about the armedbear-cvs
mailing list