Changeset 11618


Ignore:
Timestamp:
02/02/09 22:40:56 (13 years ago)
Author:
astalla
Message:

Added support for a configuration file in the CLASSPATH for ABCL when
loaded through JSR-223.

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  
    2828import java.math.BigInteger;
    2929import 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;
     30import java.util.Properties;
     31
     32import javax.script.*;
     33
     34import org.armedbear.lisp.*;
    6035import org.armedbear.lisp.scripting.util.ReaderInputStream;
    6136import org.armedbear.lisp.scripting.util.WriterOutputStream;
     
    6944  private Function compileScript;
    7045  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();
    7850    if (enableThrowingDebugger) {
    7951      try {
    80         installThrowingDebuggerHook(thread);
     52        installThrowingDebuggerHook(LispThread.currentThread());
    8153      } catch (ConditionThrowable e) {
    8254        throw new InternalError("Can't set throwing debugger hook!");
    8355      }
    8456    }
     57  }
     58
     59  public AbclScriptEngine() {
     60    interpreter = Interpreter.createInstance();
     61    interpreter.initializeLisp();
     62    this.nonThrowingDebugHook = Symbol.DEBUGGER_HOOK.getSymbolValue();
    8563    try {
    8664      loadFromClasspath("/org/armedbear/lisp/scripting/lisp/packages.lisp");
    8765      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)");
    8872      evalScript = (Function) this.findSymbol("EVAL-SCRIPT", "ABCL-SCRIPT").getSymbolFunction();
    8973      compileScript = (Function) this.findSymbol("COMPILE-SCRIPT", "ABCL-SCRIPT").getSymbolFunction();
    9074      evalCompiledScript = (Function) this.findSymbol("EVAL-COMPILED-SCRIPT", "ABCL-SCRIPT").getSymbolFunction();
    9175    } 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 
    10884  public Interpreter getInterpreter() {
    10985    return interpreter;
  • trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp

    r11558 r11618  
    1616;;; along with this program; if not, write to the Free Software
    1717;;; 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.
    1830
    1931(in-package :abcl-script)
     
    109121   interface
    110122   (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  
    1616;;; along with this program; if not, write to the Free Software
    1717;;; 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.
    1830
    1931(defpackage :abcl-script
    2032  (: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
    2949(defpackage :abcl-script-user
    3050  (:use :cl :ext :java :abcl-script))
Note: See TracChangeset for help on using the changeset viewer.