From ehuelsmann at common-lisp.net Wed Oct 1 19:58:46 2008 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 1 Oct 2008 15:58:46 -0400 (EDT) Subject: [armedbear-cvs] r11330 - public_html Message-ID: <20081001195846.9392E63095@common-lisp.net> Author: ehuelsmann Date: Wed Oct 1 15:58:45 2008 New Revision: 11330 Modified: public_html/index.shtml Log: Main project page XHTML conformance. Patch by: Alessio Stalla Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Wed Oct 1 15:58:45 2008 @@ -12,59 +12,52 @@

-
+

Armed Bear

The right of the people to keep and arm bears shall not be infringed! -
- -
-

- - - About ABCL - + +


+ About ABCL +

Armed Bear Common Lisp (ABCL) is an implementation of ANSI Common Lisp that runs in a Java virtual machine. It provides a runtime system, a compiler that compiles Lisp source to JVM bytecode, and an interactive REPL for program development. -

+

ABCL is distributed under the terms of the GNU General Public License, with a special linking exception. If you link ABCL with your own program, then you do not need to release the source code for that program. However, any changes that you make to ABCL itself must be released in accordance with the terms of the GPL. -

+

ABCL runs on platforms that support Java 1.4 (or later), including Linux, Windows, and Mac OS X. -

+

ABCL is free software and comes with ABSOLUTELY NO WARRANTY. -

+

The latest version is 0.0.10, released March 6, 2007.

-

- - Download - + Download +

+ abcl-0.0.10.tar.gz (source, 632987 bytes) -

+

abcl-0.0.10.zip (source, 1012345 bytes)

-

- - Repository - + Repository +

The project's Common-Lisp.net Subversion repository can be checked @@ -73,59 +66,58 @@ $ svn co svn://common-lisp.net/project/armedbear/svn/trunk/j j -

Please note that the minimum required JDK version for development - versions of ABCL has been raised to 1.5.

+ Please note that the minimum required JDK version for development + versions of ABCL has been raised to 1.5.
-
+

- - Bugs - + Bugs +

ABCL is a young implementation (particularly by Lisp standards). You are certain to encounter bugs. -

+

ABCL 0.0.10 fails 67 out of 21696 tests in the GCL ANSI test suite. Recent development snapshots perform considerably better, failing only 55 tests. -

+

ABCL's CLOS is intolerably slow and does not handle on-the-fly redefinition of classes correctly. There is no support for the long form of DEFINE-METHOD-COMBINATION, and certain other required CLOS features are also missing. Enough CLOS is there to run ASDF and CL-PPCRE, if you're in no hurry. There's no MOP worth mentioning. -

+

Since this is an early public release, there might be build problems as well as runtime bugs. -

+

Please report problems to the j development mailing list (you must be subscribed to post).

- - Installation - + Installation +

The README file in the root directory of the source distribution contains instructions for building ABCL. -

+

Java 1.4 or later is required - see the note above on recent development versions - Java 1.5 is recommended. There are + unresolved performance issues with Java 1.6. To build ABCL, you'll need the full JDK; the JRE is not enough.
Recent performance tests have shown Java 1.6 Update 10 - a Release Candidate as of this writing - to be as fast as Java 1.5.

-
+

Back to Common-lisp.net.

From ehuelsmann at common-lisp.net Wed Oct 1 20:18:10 2008 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 1 Oct 2008 16:18:10 -0400 (EDT) Subject: [armedbear-cvs] r11331 - trunk/j/src/org/armedbear/lisp Message-ID: <20081001201810.8CC744060@common-lisp.net> Author: ehuelsmann Date: Wed Oct 1 16:18:10 2008 New Revision: 11331 Modified: trunk/j/src/org/armedbear/lisp/Closure.java Log: Java 1.5+ for each looping construct. Patch by: Ville Voutilainen Modified: trunk/j/src/org/armedbear/lisp/Closure.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/Closure.java (original) +++ trunk/j/src/org/armedbear/lisp/Closure.java Wed Oct 1 16:18:10 2008 @@ -297,18 +297,18 @@ ArrayList vars = new ArrayList(); if (requiredParameters != null) { - for (int i = 0; i < requiredParameters.length; i++) - vars.add(requiredParameters[i].var); + for (Parameter parameter : requiredParameters) + vars.add(parameter.var); } if (optionalParameters != null) { - for (int i = 0; i < optionalParameters.length; i++) + for (Parameter parameter : optionalParameters) { - vars.add(optionalParameters[i].var); - if (optionalParameters[i].svar != NIL) - vars.add((Symbol)optionalParameters[i].svar); + vars.add(parameter.var); + if (parameter.svar != NIL) + vars.add((Symbol)parameter.svar); if (!bindInitForms) - if (!optionalParameters[i].initForm.constantp()) + if (!parameter.initForm.constantp()) bindInitForms = true; } } @@ -318,13 +318,13 @@ } if (keywordParameters != null) { - for (int i = 0; i < keywordParameters.length; i++) + for (Parameter parameter : keywordParameters) { - vars.add(keywordParameters[i].var); - if (keywordParameters[i].svar != NIL) - vars.add((Symbol)keywordParameters[i].svar); + vars.add(parameter.var); + if (parameter.svar != NIL) + vars.add((Symbol)parameter.svar); if (!bindInitForms) - if (!keywordParameters[i].initForm.constantp()) + if (!parameter.initForm.constantp()) bindInitForms = true; } } @@ -615,8 +615,8 @@ Environment ext = new Environment(environment); if (specials != null) { - for (int i = 0; i < specials.length; i++) - ext.declareSpecial(specials[i]); + for (Symbol special : specials) + ext.declareSpecial(special); } bindRequiredParameters(ext, thread, first, second, third, fourth, fifth, sixth, seventh, eighth); @@ -653,17 +653,17 @@ bindAuxVars(ext, thread); if (specials != null) { special: - for (int i = 0; i < specials.length; i++) { - for (int j = 0; j < variables.length; j++) - if (specials[i] == variables[j]) + for (Symbol special : specials) { + for (Symbol var : variables) + if (special == var) continue special; if (auxVars != null) - for (int j = 0; j < auxVars.length; j++) - if (specials[i] == auxVars[j].var) + for (Parameter parameter : auxVars) + if (special == parameter.var) continue special; - ext.declareSpecial(specials[i]); + ext.declareSpecial(special); } } try @@ -682,9 +682,9 @@ return true; if (specials != null) { - for (int i = specials.length; i-- > 0;) + for (Symbol special : specials) { - if (sym == specials[i]) + if (sym == special) return true; } } @@ -815,9 +815,8 @@ if ((argsLeft % 2) != 0) error(new ProgramError("Odd number of keyword arguments.")); LispObject allowOtherKeysValue = null; - for (int k = 0; k < keywordParameters.length; k++) + for (Parameter parameter : keywordParameters) { - Parameter parameter = keywordParameters[k]; Symbol keyword = parameter.keyword; LispObject value = null; boolean unbound = true; @@ -884,9 +883,9 @@ } // Unused keyword argument. boolean ok = false; - for (int k = keywordParameters.length; k-- > 0;) + for (Parameter parameter : keywordParameters) { - if (keywordParameters[k].keyword == keyword) + if (parameter.keyword == keyword) { // Found it! ok = true; @@ -1041,9 +1040,8 @@ LispThread thread) throws ConditionThrowable { - for (int i = 0; i < optionalParameters.length; i++) + for (Parameter parameter : optionalParameters) { - Parameter parameter = optionalParameters[i]; LispObject value; if (parameter.initVal != null) value = parameter.initVal; @@ -1059,9 +1057,8 @@ LispThread thread) throws ConditionThrowable { - for (int i = 0; i < keywordParameters.length; i++) + for (Parameter parameter : keywordParameters) { - Parameter parameter = keywordParameters[i]; LispObject value; if (parameter.initVal != null) value = parameter.initVal; @@ -1089,9 +1086,8 @@ throws ConditionThrowable { // Aux variable processing is analogous to LET* processing. - for (int i = 0; i < auxVars.length; i++) + for (Parameter parameter : auxVars) { - Parameter parameter = auxVars[i]; Symbol sym = parameter.var; LispObject value; From ehuelsmann at common-lisp.net Wed Oct 1 20:36:53 2008 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 1 Oct 2008 16:36:53 -0400 (EDT) Subject: [armedbear-cvs] r11332 - public_html Message-ID: <20081001203653.4F37563095@common-lisp.net> Author: ehuelsmann Date: Wed Oct 1 16:36:52 2008 New Revision: 11332 Modified: public_html/index.shtml Log: Mention our testing environments on the website. Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Wed Oct 1 16:36:52 2008 @@ -93,7 +93,15 @@ well as runtime bugs.

Please report problems to the j development mailing list - (you must be subscribed to post). + (you must be subscribed to post).

+ +
The project is using several ways to test standards compliance as well + as practical applicability of ABCL by using these projects' test suites + as 'compliance' indicators: +
    +
  • ANSI Common Lisp compliance tests
  • +
  • Maxima - Computer algebra system
  • +
From ehuelsmann at common-lisp.net Wed Oct 1 20:39:17 2008 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 1 Oct 2008 16:39:17 -0400 (EDT) Subject: [armedbear-cvs] r11333 - trunk/j/src/org/armedbear/lisp Message-ID: <20081001203917.40C965060@common-lisp.net> Author: ehuelsmann Date: Wed Oct 1 16:39:16 2008 New Revision: 11333 Modified: trunk/j/src/org/armedbear/lisp/SpecialOperators.java Log: Code simplification. Patch by: Philip Hudson Modified: trunk/j/src/org/armedbear/lisp/SpecialOperators.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/SpecialOperators.java (original) +++ trunk/j/src/org/armedbear/lisp/SpecialOperators.java Wed Oct 1 16:39:16 2008 @@ -281,13 +281,7 @@ final LispThread thread = LispThread.currentThread(); final Environment ext = new Environment(env); args = ext.processDeclarations(args); - LispObject result = NIL; - while (args != NIL) - { - result = eval(args.car(), ext, thread); - args = args.cdr(); - } - return result; + return progn(args, ext, thread); } }; @@ -299,13 +293,7 @@ throws ConditionThrowable { LispThread thread = LispThread.currentThread(); - LispObject result = NIL; - while (args != NIL) - { - result = eval(args.car(), env, thread); - args = ((Cons)args).cdr; - } - return result; + return progn(args, env, thread); } }; From ehuelsmann at common-lisp.net Thu Oct 2 21:26:11 2008 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Thu, 2 Oct 2008 17:26:11 -0400 (EDT) Subject: [armedbear-cvs] r11334 - trunk/j/src/org/armedbear/lisp Message-ID: <20081002212611.99B986D23F@common-lisp.net> Author: ehuelsmann Date: Thu Oct 2 17:26:10 2008 New Revision: 11334 Modified: trunk/j/src/org/armedbear/lisp/Closure.java Log: Cleanup patch. Patch by: Ville Voutilainen. Modified: trunk/j/src/org/armedbear/lisp/Closure.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/Closure.java (original) +++ trunk/j/src/org/armedbear/lisp/Closure.java Thu Oct 2 17:26:10 2008 @@ -291,18 +291,12 @@ specials = processDeclarations(); } - // Also sets bindInitForms. - private final Symbol[] processVariables() + private final void processParameters(ArrayList vars, + final Parameter[] parameters) { - ArrayList vars = new ArrayList(); - if (requiredParameters != null) - { - for (Parameter parameter : requiredParameters) - vars.add(parameter.var); - } - if (optionalParameters != null) + if (parameters != null) { - for (Parameter parameter : optionalParameters) + for (Parameter parameter : parameters) { vars.add(parameter.var); if (parameter.svar != NIL) @@ -312,22 +306,23 @@ bindInitForms = true; } } - if (restVar != null) + } + + // Also sets bindInitForms. + private final Symbol[] processVariables() + { + ArrayList vars = new ArrayList(); + if (requiredParameters != null) { - vars.add(restVar); + for (Parameter parameter : requiredParameters) + vars.add(parameter.var); } - if (keywordParameters != null) + processParameters(vars, optionalParameters); + if (restVar != null) { - for (Parameter parameter : keywordParameters) - { - vars.add(parameter.var); - if (parameter.svar != NIL) - vars.add((Symbol)parameter.svar); - if (!bindInitForms) - if (!parameter.initForm.constantp()) - bindInitForms = true; - } + vars.add(restVar); } + processParameters(vars, keywordParameters); Symbol[] array = new Symbol[vars.size()]; vars.toArray(array); return array; From ehuelsmann at common-lisp.net Sat Oct 11 18:17:27 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann,,,) Date: Sat, 11 Oct 2008 18:17:27 +0000 Subject: [armedbear-cvs] r11343 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sat Oct 11 18:17:27 2008 New Revision: 11343 Log: PSETF should macroexpand-1 any macros which it receives as its arguments. Modified: trunk/j/src/org/armedbear/lisp/psetf.lisp Modified: trunk/j/src/org/armedbear/lisp/psetf.lisp ============================================================================== --- trunk/j/src/org/armedbear/lisp/psetf.lisp (original) +++ trunk/j/src/org/armedbear/lisp/psetf.lisp Sat Oct 11 18:17:27 2008 @@ -36,7 +36,7 @@ :format-control "Odd number of arguments to PSETF.")) (multiple-value-bind (dummies vals newval setter getter) - (get-setf-expansion (car a) env) + (get-setf-expansion (macroexpand-1 (car a) env) env) (declare (ignore getter)) (let*-bindings (mapcar #'list dummies vals)) (mv-bindings (list newval (cadr a))) From ehuelsmann at common-lisp.net Sat Oct 11 21:40:22 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann,,,) Date: Sat, 11 Oct 2008 21:40:22 +0000 Subject: [armedbear-cvs] r11344 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sat Oct 11 21:40:21 2008 New Revision: 11344 Log: Fix PSETQ.7: PSETQ on a symbol-macrolet bound symbol should behave like psetf. Modified: trunk/j/src/org/armedbear/lisp/macros.lisp Modified: trunk/j/src/org/armedbear/lisp/macros.lisp ============================================================================== --- trunk/j/src/org/armedbear/lisp/macros.lisp (original) +++ trunk/j/src/org/armedbear/lisp/macros.lisp Sat Oct 11 21:40:21 2008 @@ -109,14 +109,26 @@ ,setter))) (push (list (car d) (car v)) let-list))))) -(defmacro psetq (&rest args) +(defmacro psetq (&environment env &rest args) (do ((l args (cddr l)) (forms nil) (bindings nil)) ((endp l) (list* 'let* (reverse bindings) (reverse (cons nil forms)))) - (let ((sym (gensym))) - (push (list sym (cadr l)) bindings) - (push (list 'setq (car l) sym) forms)))) + (if (and (symbolp (car l)) + (eq (car l) (macroexpand-1 (car l) env))) + (let ((sym (gensym))) + (push (list sym (cadr l)) bindings) + (push (list 'setq (car l) sym) forms)) + (multiple-value-bind + (dummies vals newval setter getter) + (get-setf-expansion (macroexpand-1 (car l) env) env) + (declare (ignore getter)) + (do ((d dummies (cdr d)) + (v vals (cdr v))) + ((null d)) + (push (list (car d) (car v)) bindings)) + (push (list (car newval) (cadr l)) bindings) + (push setter forms))))) (defmacro time (form) `(%time #'(lambda () ,form))) From ehuelsmann at common-lisp.net Sat Oct 11 22:01:04 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann,,,) Date: Sat, 11 Oct 2008 22:01:04 +0000 Subject: [armedbear-cvs] r11345 - trunk/j Message-ID: Author: ehuelsmann Date: Sat Oct 11 22:01:04 2008 New Revision: 11345 Log: Updates to build.xml (mostly assorted Windows fixes). Patch by: Mark Evenson (evenson at panix dot com) Modified: trunk/j/build.xml Modified: trunk/j/build.xml ============================================================================== --- trunk/j/build.xml (original) +++ trunk/j/build.xml Sat Oct 11 22:01:04 2008 @@ -67,29 +67,21 @@ - + - - - - - - - - + Building ABCL version: ${abcl.version} @@ -114,7 +106,6 @@ - @@ -176,6 +167,8 @@ Compiled ABCL with java version: ${java.version} + + @@ -184,10 +177,9 @@ - - - + + @@ -224,7 +216,7 @@ file="${build.classes.dir}/org/armedbear/lisp/build"/> - + @@ -335,15 +327,17 @@ - + + + + value="${java.path}"/> + value= "${java.options}"/> + value="${basedir}/src/org/armedbear/lisp/libabcl.so"/> @@ -360,7 +354,7 @@ - + @@ -417,49 +411,65 @@ - + + - - - - - - - - - - + + + + + + + + + - + + + - + - - + value="${j.install.data.dir}/j/themes"/> + + - + value="${j.install.data.dir}/doc/j"/> + - - - - + + + + - - + + + + + + + + + + + @@ -510,7 +520,7 @@ - + From ehuelsmann at common-lisp.net Sat Oct 11 22:01:57 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann,,,) Date: Sat, 11 Oct 2008 22:01:57 +0000 Subject: [armedbear-cvs] r11346 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sat Oct 11 22:01:57 2008 New Revision: 11346 Log: The recent PUSH/PUSHNEW/POP and PSETF/PSETQ fixes warrent a new version number. Update to 0.0.10.22. Modified: trunk/j/src/org/armedbear/lisp/Version.java Modified: trunk/j/src/org/armedbear/lisp/Version.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/Version.java (original) +++ trunk/j/src/org/armedbear/lisp/Version.java Sat Oct 11 22:01:57 2008 @@ -29,6 +29,6 @@ public static String getVersion() { - return "0.0.10.21"; + return "0.0.10.22"; } } From ehuelsmann at common-lisp.net Sun Oct 12 06:35:41 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann,,,) Date: Sun, 12 Oct 2008 06:35:41 +0000 Subject: [armedbear-cvs] r11347 - trunk/j Message-ID: Author: ehuelsmann Date: Sun Oct 12 06:35:40 2008 New Revision: 11347 Log: Fix Windows wrapper creation. Modified: trunk/j/abcl.bat.in trunk/j/build.xml Modified: trunk/j/abcl.bat.in ============================================================================== --- trunk/j/abcl.bat.in (original) +++ trunk/j/abcl.bat.in Sun Oct 12 06:35:40 2008 @@ -1 +1 @@ -"@JAVA@" @JAVA_OPTIONS@ -cp "@ABCL_CLASSPATH@" org.armedbear.lisp.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 +"@JAVA@" @ABCL_JAVA_OPTIONS@ -cp "@ABCL_CLASSPATH@" org.armedbear.lisp.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 Modified: trunk/j/build.xml ============================================================================== --- trunk/j/build.xml (original) +++ trunk/j/build.xml Sun Oct 12 06:35:40 2008 @@ -1,526 +1,528 @@ - - - Armed Bear Common Lisp - - - - - - - - - - - - - - Main Ant targets: - abcl.compile - -- compile ABCL to ${build.classes.dir} - abcl.jar - -- create packaged ${abcl.jar.path} - abcl.wrapper - -- create executable wrapper for ABCL - abcl.source.zip abcl.source.tar - -- create source distributions in ${dist.dir} - abcl.clean - -- remove ABCL intermediate files - Corresponding targets for J exist, but currently aren't as well tested. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Building ABCL version: ${abcl.version} - - - - - - - - abcl.hostname: ${abcl.hostname} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compiled ABCL with java version: ${java.version} - - - - - - - - - - - - - - - - - - - - - - - - java.version: ${java.version} - - - - WARNING: Java version ${java.version} not recommended. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
-
- - - Invoke ABCL with JPDA listener on port 6789 - - - - - - - - - - - - - Creates in-place exectuable shell wrapper in '${abcl.wrapper.file}' - - - - - - - - - - - - - - - - - - - - N.B. This wrapper requires '${abcl.jar.path}' not be moved. - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Using '${abcl.source.eol}' to drive line-ending transformations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- + + + Armed Bear Common Lisp + + + + + + + + + + + + + + Main Ant targets: + abcl.compile + -- compile ABCL to ${build.classes.dir} + abcl.jar + -- create packaged ${abcl.jar.path} + abcl.wrapper + -- create executable wrapper for ABCL + abcl.source.zip abcl.source.tar + -- create source distributions in ${dist.dir} + abcl.clean + -- remove ABCL intermediate files + Corresponding targets for J exist, but currently aren't as well tested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Building ABCL version: ${abcl.version} + + + + + + + + abcl.hostname: ${abcl.hostname} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Compiled ABCL with java version: ${java.version} + + + + + + + + + + + + + + + + + + + + + + + + java.version: ${java.version} + + + + WARNING: Java version ${java.version} not recommended. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+ + + Invoke ABCL with JPDA listener on port 6789 + + + + + + + + + + + + + Creates in-place exectuable shell wrapper in '${abcl.wrapper.file}' + + + + + + + + + + + + + + + + + + + + N.B. This wrapper requires '${abcl.jar.path}' not be moved. + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Using '${abcl.source.eol}' to drive line-ending transformations. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ From ehuelsmann at common-lisp.net Sun Oct 12 07:40:43 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann,,,) Date: Sun, 12 Oct 2008 07:40:43 +0000 Subject: [armedbear-cvs] r11348 - trunk/j Message-ID: Author: ehuelsmann Date: Sun Oct 12 07:40:43 2008 New Revision: 11348 Log: Add build/ and dist/ directories to svn:ignore. Modified: trunk/j/ (props changed) From ehuelsmann at common-lisp.net Mon Oct 13 09:44:42 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Mon, 13 Oct 2008 09:44:42 +0000 Subject: [armedbear-cvs] r11349 - trunk/j Message-ID: Author: ehuelsmann Date: Mon Oct 13 09:44:41 2008 New Revision: 11349 Log: Add 2 more files to the root level include pattern. Modified: trunk/j/build.xml Modified: trunk/j/build.xml ============================================================================== --- trunk/j/build.xml (original) +++ trunk/j/build.xml Mon Oct 13 09:44:41 2008 @@ -475,7 +475,9 @@ + + From ehuelsmann at common-lisp.net Mon Oct 13 09:45:22 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Mon, 13 Oct 2008 09:45:22 +0000 Subject: [armedbear-cvs] r11350 - trunk/j Message-ID: Author: ehuelsmann Date: Mon Oct 13 09:45:22 2008 New Revision: 11350 Log: Set svn:eol-style. Modified: trunk/j/build.xml (contents, props changed) Modified: trunk/j/build.xml ============================================================================== --- trunk/j/build.xml (original) +++ trunk/j/build.xml Mon Oct 13 09:45:22 2008 @@ -1,530 +1,530 @@ - - - Armed Bear Common Lisp - - - - - - - - - - - - - - Main Ant targets: - abcl.compile - -- compile ABCL to ${build.classes.dir} - abcl.jar - -- create packaged ${abcl.jar.path} - abcl.wrapper - -- create executable wrapper for ABCL - abcl.source.zip abcl.source.tar - -- create source distributions in ${dist.dir} - abcl.clean - -- remove ABCL intermediate files - Corresponding targets for J exist, but currently aren't as well tested. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Building ABCL version: ${abcl.version} - - - - - - - - abcl.hostname: ${abcl.hostname} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compiled ABCL with java version: ${java.version} - - - - - - - - - - - - - - - - - - - - - - - - java.version: ${java.version} - - - - WARNING: Java version ${java.version} not recommended. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
-
- - - Invoke ABCL with JPDA listener on port 6789 - - - - - - - - - - - - - Creates in-place exectuable shell wrapper in '${abcl.wrapper.file}' - - - - - - - - - - - - - - - - - - - - N.B. This wrapper requires '${abcl.jar.path}' not be moved. - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Using '${abcl.source.eol}' to drive line-ending transformations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- + + + Armed Bear Common Lisp + + + + + + + + + + + + + + Main Ant targets: + abcl.compile + -- compile ABCL to ${build.classes.dir} + abcl.jar + -- create packaged ${abcl.jar.path} + abcl.wrapper + -- create executable wrapper for ABCL + abcl.source.zip abcl.source.tar + -- create source distributions in ${dist.dir} + abcl.clean + -- remove ABCL intermediate files + Corresponding targets for J exist, but currently aren't as well tested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Building ABCL version: ${abcl.version} + + + + + + + + abcl.hostname: ${abcl.hostname} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Compiled ABCL with java version: ${java.version} + + + + + + + + + + + + + + + + + + + + + + + + java.version: ${java.version} + + + + WARNING: Java version ${java.version} not recommended. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+ + + Invoke ABCL with JPDA listener on port 6789 + + + + + + + + + + + + + Creates in-place exectuable shell wrapper in '${abcl.wrapper.file}' + + + + + + + + + + + + + + + + + + + + N.B. This wrapper requires '${abcl.jar.path}' not be moved. + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Using '${abcl.source.eol}' to drive line-ending transformations. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ From ehuelsmann at common-lisp.net Mon Oct 13 10:42:52 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Mon, 13 Oct 2008 10:42:52 +0000 Subject: [armedbear-cvs] r11351 - trunk/j Message-ID: Author: ehuelsmann Date: Mon Oct 13 10:42:52 2008 New Revision: 11351 Log: Additional changes in preparation of a release: work on buildability of the tarbal. Patch by: Mark Evenson. Modified: trunk/j/build.xml Modified: trunk/j/build.xml ============================================================================== --- trunk/j/build.xml (original) +++ trunk/j/build.xml Mon Oct 13 10:42:52 2008 @@ -71,7 +71,7 @@
- + - @@ -279,6 +278,7 @@ + - @@ -478,12 +478,26 @@ - - + + + + + + + + + + + + + Using '${abcl.source.eol}' to drive line-ending transformations. @@ -496,12 +510,13 @@ preservelastmodified="true"> + - + From ehuelsmann at common-lisp.net Mon Oct 13 11:57:19 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Mon, 13 Oct 2008 11:57:19 +0000 Subject: [armedbear-cvs] r11352 - trunk/j Message-ID: Author: ehuelsmann Date: Mon Oct 13 11:57:19 2008 New Revision: 11352 Log: README updates in preparation of a release. Patch by: Mark Evenson. Modified: trunk/j/README Modified: trunk/j/README ============================================================================== --- trunk/j/README (original) +++ trunk/j/README Mon Oct 13 11:57:19 2008 @@ -1,46 +1,63 @@ GENERAL INFORMATION -------------------- +=================== -Armed Bear Common Lisp is an implementation of ANSI Common Lisp that runs in a -Java virtual machine. +Armed Bear Common Lisp is an implementation of ANSI Common Lisp that +runs in a Java virtual machine. LICENSE -------- +======= -Armed Bear Common Lisp is distributed under the GNU General Public License -(with a special exception described below). +Armed Bear Common Lisp is distributed under the GNU General Public +License (with a special exception described below). -A copy of GNU General Public License (GPL) is included in this distribution, in -the file COPYING. +A copy of GNU General Public License (GPL) is included in this +distribution, in the file COPYING. -Linking this software statically or dynamically with other modules is making a -combined work based on this software. Thus, the terms and conditions of the GNU -General Public License cover the whole combination. - -As a special exception, the copyright holders of this software give you -permission to link this software 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 software. If you modify this -software, you may extend this exception to your version of the software, but -you are not obligated to do so. If you do not wish to do so, delete this +Linking this software statically or dynamically with other modules is +making a combined work based on this software. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this software give +you permission to link this software 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 software. If you modify this software, +you may extend this exception to your version of the software, but you +are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. -INSTALLATION ------------- +BUILDING +======== -To build ABCL, you'll need a 1.4 or 1.5 JDK and a supported Common Lisp -implementation (SBCL, CMUCL, OpenMCL, Allegro, LispWorks, or CLISP). +To build ABCL, you'll need -Edit the file customizations.lisp, in the directory containing this README -file, to suit your situation, paying attention to the comments in the file. +1) a 1.5 JDK, -Start up one of the supported Common Lisp implementations in the directory -containing this README file. +and either + +2.1) a supported Common Lisp implementation (SBCL, CMUCL, OpenMCL, + Allegro, LispWorks, or CLISP) + +or + +2.2) a version of Apache Ant (post 1.7.1) + + +Lisp-based +---------- + +Copy the file 'customizations.lisp.in' to customization.lisp', in the +directory containing this README file, editing to suit your situation, +paying attention to the comments in the file. + +Start up one of the supported Common Lisp implementations in the +directory containing this README file. Load build-abcl.lisp: @@ -52,34 +69,49 @@ Wait for the build to finish and exit the host Lisp. -Use abcl.bat on Windows or ./abcl on Unix to start ABCL. (Note that abcl.bat -and abcl contain absolute paths, so you'll need to edit the relevant file if -you move things around after the build.) +Use abcl.bat on Windows or ./abcl on Unix to start ABCL. (Note that +abcl.bat and abcl contain absolute paths, so you'll need to edit the +relevant file if you move things around after the build.) -If the build fails in the javac stage, you might have better luck with this: +If the build fails in the javac stage, you might have better luck with +this: (build-abcl:build-abcl :clean t :full t :batch nil) -This invokes javac separately for each .java file, which is considerably slower -but avoids running into limitations on command line length. +This invokes javac separately for each .java file, which is +considerably slower but avoids running into limitations on command +line length. + +Ant-based +--------- + +With ant-1.7.1 in your path executing + + ant -find build.xml abcl.wrapper + +from the directory containing this README file will create an +executable wrapper ('abcl' under UNIX, 'abcl.bat' under Windows) which +can use to run ABCL. BUGS ----- +==== -ABCL is a very young implementation. You are certain to encounter bugs. +ABCL is a very young implementation. You are certain to encounter +bugs. ABCL 0.0.9 fails 54 out of 21344 tests in the GCL ANSI test suite. -ABCL's CLOS does not handle on-the-fly redefinition of classes correctly, and -in any event is intolerably slow. There is no support for the long form of -DEFINE-METHOD-COMBINATION, and certain other required CLOS features are also -missing. Enough CLOS is there to run ASDF and CL-PPCRE, if you're in no hurry. +ABCL's CLOS does not handle on-the-fly redefinition of classes +correctly, and in any event is intolerably slow. There is no support +for the long form of DEFINE-METHOD-COMBINATION, and certain other +required CLOS features are also missing. Enough CLOS is there to run +ASDF and CL-PPCRE, if you're in no hurry. There is no MOP worth mentioning. -Since this is a very early public release, there might be build problems as -well as runtime bugs. +Since this is a very early public release, there might be build +problems as well as runtime bugs. Please report problems to the j-devel mailing list: From ehuelsmann at common-lisp.net Tue Oct 14 10:22:55 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Tue, 14 Oct 2008 10:22:55 +0000 Subject: [armedbear-cvs] r11353 - trunk/j Message-ID: Author: ehuelsmann Date: Tue Oct 14 10:22:55 2008 New Revision: 11353 Log: Short route to creating a release: add sources which build-abcl.lisp depends on. Modified: trunk/j/build.xml Modified: trunk/j/build.xml ============================================================================== --- trunk/j/build.xml (original) +++ trunk/j/build.xml Tue Oct 14 10:22:55 2008 @@ -106,6 +106,8 @@ + + From ehuelsmann at common-lisp.net Sat Oct 18 21:16:14 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 18 Oct 2008 21:16:14 +0000 Subject: [armedbear-cvs] r11354 - trunk/j Message-ID: Author: ehuelsmann Date: Sat Oct 18 21:16:11 2008 New Revision: 11354 Log: More steps toward a release: - Mark some files with native line endings, such as README - Edit README to reflect the current situation Modified: trunk/j/COPYING (props changed) trunk/j/Makefile.in (props changed) trunk/j/README (contents, props changed) trunk/j/abcl.bat.in (contents, props changed) trunk/j/abcl.in (props changed) trunk/j/build-abcl.lisp (props changed) trunk/j/build.properties (props changed) trunk/j/configure (props changed) trunk/j/configure.ac (props changed) trunk/j/customizations.lisp.in (contents, props changed) trunk/j/j.bat.in (props changed) trunk/j/j.in (props changed) trunk/j/make-jar.bat.in (props changed) trunk/j/make-jar.in (props changed) Modified: trunk/j/README ============================================================================== --- trunk/j/README (original) +++ trunk/j/README Sat Oct 18 21:16:11 2008 @@ -2,14 +2,14 @@ =================== Armed Bear Common Lisp is an implementation of ANSI Common Lisp that -runs in a Java virtual machine. +runs in a Java virtual machine. It compiles its code to Java byte code. LICENSE ======= Armed Bear Common Lisp is distributed under the GNU General Public -License (with a special exception described below). +License with classpath exception (described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING. @@ -35,22 +35,25 @@ BUILDING ======== -To build ABCL, you'll need +If you want to build ABCL, you have 2 options. The first option +applies when you come from a lisp background. The second option is more +appropriate when you come from Java development: -1) a 1.5 JDK, + I) Bootstrap ABCL using a Common Lisp implementation + Supported implementations for this process: SBCL, CMUCL, OpenMCL, + Allegro CL, LispWorks or CLISP -and either +II) Use the Ant make-like build tool for Java environments + The tested lowest working version is Ant 1.7.0 -2.1) a supported Common Lisp implementation (SBCL, CMUCL, OpenMCL, - Allegro, LispWorks, or CLISP) -or +In both cases you need a supported JDK version (1.5 and 1.6 have been +tested). Just the JRE isn't enough. -2.2) a version of Apache Ant (post 1.7.1) -Lisp-based ----------- +I. Lisp-based build +------------------- Copy the file 'customizations.lisp.in' to customization.lisp', in the directory containing this README file, editing to suit your situation, @@ -69,38 +72,38 @@ Wait for the build to finish and exit the host Lisp. -Use abcl.bat on Windows or ./abcl on Unix to start ABCL. (Note that -abcl.bat and abcl contain absolute paths, so you'll need to edit the -relevant file if you move things around after the build.) +Use abcl.bat on Windows or ./abcl on Unix to start ABCL. +Note: abcl.bat and abcl contain absolute paths, so you'll need +to edit them if you move things around after the build. -If the build fails in the javac stage, you might have better luck with -this: +In case of failure in the javac stage, you might try this: (build-abcl:build-abcl :clean t :full t :batch nil) -This invokes javac separately for each .java file, which is -considerably slower but avoids running into limitations on command -line length. +This invokes javac separately for each .java file, which avoids running +into limitations on command line length (but is a lot slower). -Ant-based ---------- -With ant-1.7.1 in your path executing +II. Ant-based build +------------------- + +With Ant in your path, executing ant -find build.xml abcl.wrapper from the directory containing this README file will create an -executable wrapper ('abcl' under UNIX, 'abcl.bat' under Windows) which -can use to run ABCL. +executable wrapper ('abcl' under UNIX, 'abcl.bat' under Windows). +Use this wrapper to start the ABCL Java program. BUGS ==== -ABCL is a very young implementation. You are certain to encounter -bugs. - -ABCL 0.0.9 fails 54 out of 21344 tests in the GCL ANSI test suite. +A lot of (renewed) energy has been spent to make ABCL a compliant +and practically useable Common Lisp implementation. Because of this, +ABCL 0.0.11 now fails only 49 out of 21344 tests in the ANSI CL test +suite. Next to that, the fail count of the Maxima test suite has been +reduced from over 1400 in 0.0.10 to little more than 600 in 0.0.11. ABCL's CLOS does not handle on-the-fly redefinition of classes correctly, and in any event is intolerably slow. There is no support @@ -110,7 +113,7 @@ There is no MOP worth mentioning. -Since this is a very early public release, there might be build +Since this is a early public release, there might be build problems as well as runtime bugs. Please report problems to the j-devel mailing list: @@ -119,5 +122,6 @@ Have fun! -Peter Graves -October 18, 2005 +On behalf of all ABCL development team and contributors, +Erik Huelsmann +October 18, 2008 Modified: trunk/j/abcl.bat.in ============================================================================== --- trunk/j/abcl.bat.in (original) +++ trunk/j/abcl.bat.in Sat Oct 18 21:16:11 2008 @@ -1 +1 @@ -"@JAVA@" @ABCL_JAVA_OPTIONS@ -cp "@ABCL_CLASSPATH@" org.armedbear.lisp.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 +"@JAVA@" @ABCL_JAVA_OPTIONS@ -cp "@ABCL_CLASSPATH@" org.armedbear.lisp.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 Modified: trunk/j/customizations.lisp.in ============================================================================== --- trunk/j/customizations.lisp.in (original) +++ trunk/j/customizations.lisp.in Sat Oct 18 21:16:11 2008 @@ -1,38 +1,38 @@ -;;; Copy this file to "customizations.lisp" - -;;; User customizations for the build. - -;;; This file is LOADed by INITIALIZE-BUILD (in build-abcl.lisp). - -;;; The variable *PLATFORM-IS-WINDOWS* should be true on Windows platforms. You -;;; can, of course, substitute your own test for this in the code below, or add -;;; a section for OS X, or Solaris, or whatever... - -;;; You MUST set *JDK* to the location of the JDK you want to use. Remove or -;;; comment out settings that don't apply to your situation. - -;;; You don't really need to specify anything but *JDK*. *JAVA-COMPILER* and -;;; *JAR* default to javac and jar, respectively, from the configured JDK. - -;;; Directories should be specified with a trailing slash (or, on Windows, a -;;; trailing backslash). - -(in-package "BUILD-ABCL") - -;; Standard compiler options. -(setq *javac-options* "-g") -(setq *jikes-options* "+D -g") - -;; *PLATFORM* will be either :WINDOWS, :DARWIN, :LINUX, or :UNKNOWN. -(case *platform* - (:windows - (setq *jdk* "C:\\Program Files\\Java\\jdk1.5.0_11\\") - #+(or) (setq *java-compiler* "jikes") - ) - (:darwin - (setq *jdk* "/usr/") - (setq *java-compiler* "jikes") - #+(or) (setq *jar* "jar")) - ((:linux :unknown) - (setq *jdk* "/home/peter/sun/jdk1.5.0_11/") - (setq *jar* "fastjar"))) +;;; Copy this file to "customizations.lisp" + +;;; User customizations for the build. + +;;; This file is LOADed by INITIALIZE-BUILD (in build-abcl.lisp). + +;;; The variable *PLATFORM-IS-WINDOWS* should be true on Windows platforms. You +;;; can, of course, substitute your own test for this in the code below, or add +;;; a section for OS X, or Solaris, or whatever... + +;;; You MUST set *JDK* to the location of the JDK you want to use. Remove or +;;; comment out settings that don't apply to your situation. + +;;; You don't really need to specify anything but *JDK*. *JAVA-COMPILER* and +;;; *JAR* default to javac and jar, respectively, from the configured JDK. + +;;; Directories should be specified with a trailing slash (or, on Windows, a +;;; trailing backslash). + +(in-package "BUILD-ABCL") + +;; Standard compiler options. +(setq *javac-options* "-g") +(setq *jikes-options* "+D -g") + +;; *PLATFORM* will be either :WINDOWS, :DARWIN, :LINUX, or :UNKNOWN. +(case *platform* + (:windows + (setq *jdk* "C:\\Program Files\\Java\\jdk1.5.0_16\\") + #+(or) (setq *java-compiler* "jikes") + ) + (:darwin + (setq *jdk* "/usr/") + (setq *java-compiler* "jikes") + #+(or) (setq *jar* "jar")) + ((:linux :unknown) + (setq *jdk* "/home/peter/sun/jdk1.5.0_16/") + (setq *jar* "fastjar"))) From ehuelsmann at common-lisp.net Sat Oct 18 21:43:18 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 18 Oct 2008 21:43:18 +0000 Subject: [armedbear-cvs] r11355 - trunk/j Message-ID: Author: ehuelsmann Date: Sat Oct 18 21:43:18 2008 New Revision: 11355 Log: Make the website and the README contain the same numbers. Modified: trunk/j/README Modified: trunk/j/README ============================================================================== --- trunk/j/README (original) +++ trunk/j/README Sat Oct 18 21:43:18 2008 @@ -101,7 +101,7 @@ A lot of (renewed) energy has been spent to make ABCL a compliant and practically useable Common Lisp implementation. Because of this, -ABCL 0.0.11 now fails only 49 out of 21344 tests in the ANSI CL test +ABCL 0.0.11 now fails only 47 out of 21702 tests in the ANSI CL test suite. Next to that, the fail count of the Maxima test suite has been reduced from over 1400 in 0.0.10 to little more than 600 in 0.0.11. From ehuelsmann at common-lisp.net Sat Oct 18 21:50:37 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 18 Oct 2008 21:50:37 +0000 Subject: [armedbear-cvs] r11356 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sat Oct 18 21:50:37 2008 New Revision: 11356 Log: Update the version, preparation of the release 0.0.11. Modified: trunk/j/src/org/armedbear/lisp/Version.java Modified: trunk/j/src/org/armedbear/lisp/Version.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/Version.java (original) +++ trunk/j/src/org/armedbear/lisp/Version.java Sat Oct 18 21:50:37 2008 @@ -29,6 +29,6 @@ public static String getVersion() { - return "0.0.10.22"; + return "0.0.11"; } } From ehuelsmann at common-lisp.net Sat Oct 18 22:07:12 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 18 Oct 2008 22:07:12 +0000 Subject: [armedbear-cvs] r11357 - public_html Message-ID: Author: ehuelsmann Date: Sat Oct 18 22:07:10 2008 New Revision: 11357 Log: Update website to point to 0.0.11 release. Modified: public_html/index.shtml Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Sat Oct 18 22:07:10 2008 @@ -32,14 +32,15 @@ License, with a special linking exception. If you link ABCL with your own program, then you do not need to release the source code for that program. However, any changes that you make to ABCL itself must be - released in accordance with the terms of the GPL. + released in accordance with the terms of the GPL. The license is the + same as used by GNU Classpath and J2SE (Java).

- ABCL runs on platforms that support Java 1.4 (or later), including Linux, + ABCL runs on platforms that support Java 1.5 (or later), including Linux, Windows, and Mac OS X.

ABCL is free software and comes with ABSOLUTELY NO WARRANTY.

- The latest version is 0.0.10, released March 6, 2007. + The latest version is 0.0.11, released October 18, 2008.

@@ -48,10 +49,10 @@

- abcl-0.0.10.tar.gz + abcl-0.0.10.tar.gz (source, 632987 bytes)

- abcl-0.0.10.zip + abcl-0.0.10.zip (source, 1012345 bytes)
@@ -66,8 +67,6 @@ $ svn co svn://common-lisp.net/project/armedbear/svn/trunk/j j - Please note that the minimum required JDK version for development - versions of ABCL has been raised to 1.5. @@ -76,12 +75,16 @@

- ABCL is a young implementation (particularly by Lisp standards). You - are certain to encounter bugs. + ABCL is a young implementation (particularly by Lisp standards). + Even though a lot of energy is spent resolving issues, you may + well encounter bugs. A number of people have testified to the + quality of ABCL being good enough for their needs though. See + the testimonials page.

- ABCL 0.0.10 fails 67 out of 21696 tests in the GCL ANSI test suite. - Recent development snapshots perform considerably better, failing only - 55 tests. + ABCL 0.0.11 fails 47 out of 21702 tests in the GCL ANSI test suite. + Most notable recent fixes relate to special variables handling + and making sure the correct environments are used with for example + LET/LET* and FLET/LABELS.

ABCL's CLOS is intolerably slow and does not handle on-the-fly redefinition of classes correctly. There is no support for the long @@ -113,13 +116,12 @@ The README file in the root directory of the source distribution contains instructions for building ABCL.

- Java 1.4 or later is required - see the note above on recent development - versions - + Java 1.5 or higher is required; Java 1.5 is recommended. There are - unresolved performance issues with Java 1.6. To build ABCL, you'll need + performance issues with early versions of Java 1.6. To build ABCL, you'll need the full JDK; the JRE is not enough.
Recent performance tests have shown Java 1.6 Update 10 - a Release Candidate as of this writing - to be as fast as Java 1.5.
From ehuelsmann at common-lisp.net Sat Oct 18 22:10:12 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 18 Oct 2008 22:10:12 +0000 Subject: [armedbear-cvs] r11358 - public_html Message-ID: Author: ehuelsmann Date: Sat Oct 18 22:10:11 2008 New Revision: 11358 Log: Fix naming of download files (links were already right). Modified: public_html/index.shtml Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Sat Oct 18 22:10:11 2008 @@ -49,10 +49,10 @@
- abcl-0.0.10.tar.gz + abcl-0.0.11.tar.gz (source, 632987 bytes)

- abcl-0.0.10.zip + abcl-0.0.11.zip (source, 1012345 bytes)
From ehuelsmann at common-lisp.net Sat Oct 18 22:24:58 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 18 Oct 2008 22:24:58 +0000 Subject: [armedbear-cvs] r11359 - branches/scripting Message-ID: Author: ehuelsmann Date: Sat Oct 18 22:24:57 2008 New Revision: 11359 Log: Create scripting branch for implementation of scripting JSR. Added: branches/scripting/ - copied from r11358, /trunk/ From ehuelsmann at common-lisp.net Sun Oct 19 06:07:34 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sun, 19 Oct 2008 06:07:34 +0000 Subject: [armedbear-cvs] r11360 - in branches/scripting/j/src: META-INF META-INF/services org/armedbear/lisp/scripting org/armedbear/lisp/scripting/lisp org/armedbear/lisp/scripting/lisp/test org/armedbear/lisp/scripting/util Message-ID: Author: ehuelsmann Date: Sun Oct 19 06:07:32 2008 New Revision: 11360 Log: Initial import of ABCL scripting engine implementation. Patch by: Alessio Stalla Added: branches/scripting/j/src/META-INF/ branches/scripting/j/src/META-INF/services/ branches/scripting/j/src/META-INF/services/javax.script.ScriptEngineFactory (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/ branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngineFactory.java (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/ branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/packages.lisp (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/test/ branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/test/AbclTest.java (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/util/ branches/scripting/j/src/org/armedbear/lisp/scripting/util/ReaderInputStream.java (contents, props changed) branches/scripting/j/src/org/armedbear/lisp/scripting/util/WriterOutputStream.java (contents, props changed) Added: branches/scripting/j/src/META-INF/services/javax.script.ScriptEngineFactory ============================================================================== --- (empty file) +++ branches/scripting/j/src/META-INF/services/javax.script.ScriptEngineFactory Sun Oct 19 06:07:32 2008 @@ -0,0 +1 @@ +org.armedbear.lisp.scripting.AbclScriptEngineFactory \ No newline at end of file Added: branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Sun Oct 19 06:07:32 2008 @@ -0,0 +1,437 @@ +/* + * AbclScriptEngine.java + * + * 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. + */ + +package org.armedbear.lisp.scripting; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringWriter; +import java.math.BigInteger; +import java.util.Map; + +import javax.script.AbstractScriptEngine; +import javax.script.Bindings; +import javax.script.Invocable; +import javax.script.ScriptContext; +import javax.script.ScriptEngineFactory; +import javax.script.ScriptException; +import javax.script.SimpleBindings; + +import org.armedbear.lisp.AbstractString; +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.SingleFloat; +import org.armedbear.lisp.Stream; +import org.armedbear.lisp.Symbol; +import org.armedbear.lisp.scripting.util.ReaderInputStream; +import org.armedbear.lisp.scripting.util.WriterOutputStream; + + +public class AbclScriptEngine extends AbstractScriptEngine implements Invocable { + + private Interpreter interpreter; + private LispObject nonThrowingDebugHook; + private Function evalScript; + + public AbclScriptEngine(Interpreter interpreter, boolean enableThrowingDebugger) { + this.interpreter = interpreter; + Interpreter.initializeLisp(); + final LispThread thread = LispThread.currentThread(); + this.nonThrowingDebugHook = Symbol.DEBUGGER_HOOK.getSymbolValue(); + if (enableThrowingDebugger) { + try { + installThrowingDebuggerHook(thread); + } catch (ConditionThrowable e) { + throw new InternalError("Can't set throwing debugger hook!"); + } + } + try { + loadFromClasspath("/org/armedbear/lisp/scripting/lisp/packages.lisp"); + loadFromClasspath("/org/armedbear/lisp/scripting/lisp/abcl-script.lisp"); + evalScript = (Function) this.findSymbol("EVAL-SCRIPT", "ABCL-SCRIPT").getSymbolFunction(); + } catch (ConditionThrowable e) { + e.printStackTrace(); + } + } + + public AbclScriptEngine(Interpreter interpreter) { + this(interpreter, false); + } + + public AbclScriptEngine(boolean enableThrowingDebugger) { + this(Interpreter.createInstance(), enableThrowingDebugger); + } + + public AbclScriptEngine() { + this(Interpreter.createInstance(), true); + } + + public Interpreter getInterpreter() { + return interpreter; + } + + public void installNonThrowingDebugHook() { + installNonThrowingDebugHook(LispThread.currentThread()); + } + + public void installNonThrowingDebugHook(LispThread thread) { + thread.setSpecialVariable(Symbol.DEBUGGER_HOOK, this.nonThrowingDebugHook); + } + + public void installThrowingDebuggerHook(LispThread thread) throws ConditionThrowable { + Symbol dbgrhkfunSym; + dbgrhkfunSym = Lisp.PACKAGE_SYS.findAccessibleSymbol("%DEBUGGER-HOOK-FUNCTION"); + LispObject throwingDebugHook = dbgrhkfunSym.getSymbolFunction(); + thread.setSpecialVariable(Symbol.DEBUGGER_HOOK, throwingDebugHook); + } + + public void installThrowingDebuggerHook() throws ConditionThrowable { + installThrowingDebuggerHook(LispThread.currentThread()); + } + + public void setStandardInput(InputStream stream, LispThread thread) { + thread.setSpecialVariable(Symbol.STANDARD_INPUT, new Stream(stream, Symbol.CHARACTER, true)); + } + + public void setStandardInput(InputStream stream) { + setStandardInput(stream, LispThread.currentThread()); + } + + public void setInterpreter(Interpreter interpreter) { + this.interpreter = interpreter; + } + + public static String escape(String s) { + StringBuffer b = new StringBuffer(); + int len = s.length(); + char c; + for (int i = 0; i < len; ++i) { + c = s.charAt(i); + if (c == '\\' || c == '"') { + b.append('\\'); + } + b.append(c); + } + return b.toString(); + } + + public LispObject loadFromClasspath(String classpathResource) throws ConditionThrowable { + InputStream istream = getClass().getResourceAsStream(classpathResource); + Stream stream = new Stream(istream, Symbol.CHARACTER); + return load(stream); + } + + public LispObject load(Stream stream) throws ConditionThrowable { + Symbol keyword_verbose = Lisp.internKeyword("VERBOSE"); + Symbol keyword_print = Lisp.internKeyword("PRINT"); + /* + * load (filespec &key (verbose *load-verbose*) (print *load-print*) + * (if-does-not-exist t) (external-format :default) + */ + return Symbol.LOAD.getSymbolFunction().execute( + new LispObject[] { stream, keyword_verbose, Lisp.NIL, + keyword_print, Lisp.T, Keyword.IF_DOES_NOT_EXIST, + Lisp.T, Keyword.EXTERNAL_FORMAT, Keyword.DEFAULT }); + } + + public LispObject load(String filespec) throws ConditionThrowable { + return load(filespec, true); + } + + public LispObject load(String filespec, boolean compileIfNecessary) throws ConditionThrowable { + if (isCompiled(filespec) || !compileIfNecessary) { + return interpreter.eval("(load \"" + escape(filespec) + "\")"); + } else { + return compileAndLoad(filespec); + } + } + + public static boolean isCompiled(String filespec) { + if (filespec.endsWith(".abcl")) { + return true; + } + File source; + File compiled; + if (filespec.endsWith(".lisp")) { + source = new File(filespec); + compiled = new File(filespec.substring(0, filespec.length() - 5) + + ".abcl"); + } else { + source = new File(filespec + ".lisp"); + compiled = new File(filespec + ".abcl"); + } + if (!source.exists()) { + throw new IllegalArgumentException("The source file " + filespec + " cannot be found"); + } + return compiled.exists() + && compiled.lastModified() >= source.lastModified(); + } + + public LispObject compileFile(String filespec) throws ConditionThrowable { + return interpreter.eval("(compile-file \"" + escape(filespec) + "\")"); + } + + public LispObject compileAndLoad(String filespec) throws ConditionThrowable { + return interpreter.eval("(load (compile-file \"" + escape(filespec) + "\"))"); + } + + public static boolean functionp(LispObject obj) { + return obj instanceof Function; + } + + public JavaObject jsetq(String symbol, Object value) throws ConditionThrowable { + Symbol s = findSymbol(symbol); + JavaObject jo; + if (value instanceof JavaObject) { + jo = (JavaObject) value; + } else { + jo = new JavaObject(value); + } + s.setSymbolValue(jo); + return jo; + } + + public Symbol findSymbol(String name, String pkg) throws ConditionThrowable { + Cons values = (Cons) (interpreter.eval("(cl:multiple-value-list (find-symbol (symbol-name '#:" + + escape(name) + ")" + (pkg == null ? "" : " :" + escape(pkg)) + + "))")); + if(values.cadr() == Lisp.NIL) { + return null; + } else { + return (Symbol) values.car(); + } + } + + public Symbol findSymbol(String name) throws ConditionThrowable { + //Known bug: doesn't handle escaped ':' e.g. |a:b| + int i = name.indexOf(':'); + if(i < 0) { + return findSymbol(name, null); + } else { + return findSymbol(name.substring(i + 1), name.substring(0, i)); + } + } + + public Function findFunction(String name) throws ConditionThrowable { + return (Function) interpreter.eval("#'" + name); + } + + @Override + public Bindings createBindings() { + return new SimpleBindings(); + } + + private static LispObject makeBindings(Bindings bindings) throws ConditionThrowable { + if (bindings == null || bindings.size() == 0) { + return Lisp.NIL; + } + LispObject[] argList = new LispObject[bindings.size()]; + int i = 0; + for (Map.Entry entry : bindings.entrySet()) { + argList[i++] = Symbol.CONS.execute(new SimpleString(entry.getKey()), toLisp(entry.getValue())); + } + return Symbol.LIST.getSymbolFunction().execute(argList); + } + + @Override + public ScriptContext getContext() { + return super.getContext(); + } + + @Override + public Object eval(String code, ScriptContext ctx) throws ScriptException { + ReaderInputStream in = null; + WriterOutputStream out = null; + LispObject retVal = null; + try { + in = new ReaderInputStream(ctx.getReader()); + out = new WriterOutputStream(ctx.getWriter()); + retVal = evalScript.execute(makeBindings(ctx.getBindings(ScriptContext.GLOBAL_SCOPE)), + makeBindings(ctx.getBindings(ScriptContext.ENGINE_SCOPE)), + new Stream(in, Symbol.CHARACTER), + new Stream(out, Symbol.CHARACTER), + new SimpleString(code), new JavaObject(ctx)); + return toJava(retVal); + } catch (ConditionThrowable e) { + throw new ScriptException(new Exception(e)); + } catch (IOException e) { + throw new ScriptException(e); + } + } + + @Override + public Object eval(Reader code, ScriptContext ctx) throws ScriptException { + StringWriter w = new StringWriter(); + int i; + try { + i = code.read(); + while (i != -1) { + w.write(i); + i = code.read(); + } + return eval(w.toString(), ctx); + } catch (IOException e) { + return new ScriptException(e); + } + } + + @Override + public ScriptEngineFactory getFactory() { + return new AbclScriptEngineFactory(); + } + + public static String decoratedVariableName(String jvar) { + return jvar.toUpperCase(); + } + + private static Object toJava(LispObject lispObject) { + if(lispObject instanceof JavaObject) { + return ((JavaObject) lispObject).getObject(); + } else if(lispObject instanceof SingleFloat) { + return ((SingleFloat) lispObject).value; + } else if(lispObject instanceof DoubleFloat) { + return ((DoubleFloat) lispObject).value; + } else if(lispObject instanceof LispCharacter) { + return ((LispCharacter) lispObject).value; + } else if(lispObject instanceof Bignum) { + return ((Bignum) lispObject).value; + } else if(lispObject instanceof Fixnum) { + return ((Fixnum) lispObject).value; + } else if(lispObject instanceof SimpleString) { + return ((SimpleString) lispObject).javaInstance(); + } else { + return lispObject; + } + } + + public static LispObject toLisp(Object javaObject) { + if(javaObject instanceof LispObject) { + return (LispObject) javaObject; + } else if(javaObject instanceof Float) { + return new SingleFloat((Float) javaObject); + } else if(javaObject instanceof Double) { + return new DoubleFloat((Double) javaObject); + } else if(javaObject instanceof Character) { + return LispCharacter.getInstance((Character) javaObject); + } else if(javaObject instanceof Long) { + return new Bignum((Long) javaObject); + } else if(javaObject instanceof BigInteger) { + return new Bignum((BigInteger) javaObject); + } else if(javaObject instanceof Integer) { + return new Fixnum((Integer) javaObject); + } else if(javaObject instanceof String) { + return new SimpleString((String) javaObject); + } else { + return new JavaObject(javaObject); + } + } + + @SuppressWarnings("unchecked") + @Override + public T getInterface(Class clasz) { + try { + Symbol s = findSymbol("find-java-interface-implementation", "abcl-script"); + Object obj = s.getSymbolFunction().execute(new JavaObject(clasz)); + if(obj instanceof JavaObject) { + return (T) ((JavaObject) obj).getObject(); + } else { + return null; + } + } catch (ConditionThrowable e) { + throw new Error(e); + } + } + + @SuppressWarnings("unchecked") + @Override + public T getInterface(Object thiz, Class clasz) { + try { + Symbol s = findSymbol("implement-java-interface", "abcl-script"); + Object obj = s.getSymbolFunction().execute(new JavaObject(clasz), (LispObject) thiz); + return (T) ((JavaObject) obj).getObject(); + } catch (ConditionThrowable e) { + throw new Error(e); + } + } + + @Override + public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException { + try { + Symbol s = findSymbol(name); + if(s != null) { + LispObject f = s.getSymbolFunction(); + if(f != null && f instanceof Function) { + LispObject[] wrappedArgs = new LispObject[args.length]; + for(int i = 0; i < args.length; ++i) { + wrappedArgs[i] = toLisp(args[i]); + } + switch(args.length) { + case 0: + return LispThread.currentThread().execute(f); + case 1: + return LispThread.currentThread().execute(f, wrappedArgs[0]); + case 2: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1]); + case 3: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1], wrappedArgs[2]); + case 4: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1], wrappedArgs[2], wrappedArgs[3]); + case 5: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1], wrappedArgs[2], wrappedArgs[3], wrappedArgs[4]); + case 6: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1], wrappedArgs[2], wrappedArgs[3], wrappedArgs[4], wrappedArgs[5]); + case 7: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1], wrappedArgs[2], wrappedArgs[3], wrappedArgs[4], wrappedArgs[5], wrappedArgs[6]); + case 8: + return LispThread.currentThread().execute(f, wrappedArgs[0], wrappedArgs[1], wrappedArgs[2], wrappedArgs[3], wrappedArgs[4], wrappedArgs[5], wrappedArgs[6], wrappedArgs[7]); + default: + return LispThread.currentThread().execute(f, wrappedArgs); + } + } else { + throw new NoSuchMethodException(name); + } + } else { + throw new NoSuchMethodException(name); + } + } catch (ConditionThrowable e) { + throw new ScriptException(new RuntimeException(e)); + } + } + + @Override + public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { + throw new UnsupportedOperationException("Common Lisp does not have methods in the Java sense."); + } + +} Added: branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngineFactory.java ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngineFactory.java Sun Oct 19 06:07:32 2008 @@ -0,0 +1,133 @@ +/* + * AbclScriptEngineFactory.java + * + * 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. + */ + +package org.armedbear.lisp.scripting; + +import java.util.ArrayList; +import java.util.List; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineFactory; + +public class AbclScriptEngineFactory implements ScriptEngineFactory { + + private static final AbclScriptEngine THE_ONLY_ONE_ENGINE = new AbclScriptEngine(true); + + @Override + public String getEngineName() { + return "ABCL Script"; + } + + @Override + public String getEngineVersion() { + return "0.1"; + } + + @Override + public List getExtensions() { + List extensions = new ArrayList(1); + extensions.add("lisp"); + return extensions; + } + + @Override + public String getLanguageName() { + return "ANSI Common Lisp"; + } + + @Override + public String getLanguageVersion() { + return "ANSI X3.226:1994"; + } + + public static String escape(String raw) { + StringBuilder sb = new StringBuilder(); + int len = raw.length(); + char c; + for(int i = 0; i < len; ++i) { + c = raw.charAt(i); + if(c != '"') { + sb.append(c); + } else { + sb.append("\\\""); + } + } + return sb.toString(); + } + + @Override + public String getMethodCallSyntax(String obj, String method, String... args) { + StringBuilder sb = new StringBuilder(); + sb.append("(jcall \""); + sb.append(method); + sb.append("\" "); + sb.append(AbclScriptEngine.decoratedVariableName(obj)); + for(String arg : args) { + sb.append(" "); + sb.append(AbclScriptEngine.decoratedVariableName(arg)); + } + sb.append(")"); + return sb.toString(); + } + + @Override + public List getMimeTypes() { + return new ArrayList(); + } + + @Override + public List getNames() { + List names = new ArrayList(1); + names.add("ABCL"); + names.add("cl"); + names.add("Lisp"); + names.add("Common Lisp"); + return names; + } + + @Override + public String getOutputStatement(String str) { + return "(cl:print \"" + str + "\")"; + } + + @Override + public Object getParameter(String key) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getProgram(String... statements) { + StringBuilder sb = new StringBuilder(); + sb.append("(cl:progn"); + for(String stmt : statements) { + sb.append("\n\t"); + sb.append(stmt); + } + sb.append(")"); + return sb.toString(); + } + + @Override + public ScriptEngine getScriptEngine() { + return THE_ONLY_ONE_ENGINE; + } + +} Added: branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp Sun Oct 19 06:07:32 2008 @@ -0,0 +1,102 @@ +;;; abcl-script.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. + +(in-package :abcl-script) + +(defvar *java-interface-implementations* (make-hash-table :test #'equal)) + +(defconstant +global-scope+ + (jfield "javax.script.ScriptContext" "GLOBAL_SCOPE")) + +(defconstant +engine-scope+ + (jfield "javax.script.ScriptContext" "ENGINE_SCOPE")) + +(defconstant +put-binding+ (jmethod "javax.script.Bindings" + "put" + "java.lang.String" + "java.lang.Object")) + +(defconstant +get-bindings+ (jmethod "javax.script.ScriptContext" + "getBindings" + "int")) + +(defun generate-bindings (bindings) + (let ((*package* (find-package :abcl-script-user))) + (mapcar (lambda (binding) (list (read-from-string (car binding)) + (cdr binding))) + bindings))) + +(defun generate-java-bindings (bindings-list actual-bindings java-bindings) + (loop :for binding :in actual-bindings + :for jbinding :in bindings-list + :collect `(jcall +put-binding+ + ,java-bindings ,(car jbinding) ,(car binding)))) + +(defun eval-script (global-bindings engine-bindings stdin stdout + code-string script-context) + (let ((*package* (find-package :abcl-script-user)) + (*standard-input* stdin) + (*standard-output* stdout) + (actual-global-bindings (generate-bindings global-bindings)) + (actual-engine-bindings (generate-bindings engine-bindings))) + (eval `(let ((*standard-input* ,stdin) + (*standard-output* ,stdout) + (*package* (find-package :abcl-script-user))) + (let (, at actual-global-bindings) + (let (, at actual-engine-bindings) + (prog1 + (progn + ,@(read-from-string + (concatenate 'string "(" code-string ")"))) + (finish-output *standard-output*) + ,@(generate-java-bindings + global-bindings + actual-global-bindings + (jcall +get-bindings+ script-context +global-scope+)) + ,@(generate-java-bindings + engine-bindings + actual-engine-bindings + (jcall +get-bindings+ script-context +engine-scope+))))))))) + +(defstruct (java-interface-implementation (:type list)) + (method-definitions (list) :type list)) + +(defun define-java-interface-implementation (interface &rest method-definitions) + (register-java-interface-implementation + (canonicalize-interface interface) + (make-java-interface-implementation :method-definitions method-definitions))) + +(defun canonicalize-interface (interface) + (cond + ((stringp interface) interface) + ((jclass-interface-p interface) (jclass-name interface)) + (t (error "not an interface: ~A" interface)))) + +(defun register-java-interface-implementation (interface implementation) + (setf (gethash (canonicalize-interface interface) + *java-interface-implementations*) + (implement-java-interface interface implementation))) + +(defun find-java-interface-implementation (interface) + (gethash (canonicalize-interface interface) + *java-interface-implementations*)) + +(defun implement-java-interface (interface implementation) + (apply #'jinterface-implementation + `(,interface + ,@(java-interface-implementation-method-definitions implementation)))) \ No newline at end of file Added: branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/packages.lisp ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/packages.lisp Sun Oct 19 06:07:32 2008 @@ -0,0 +1,27 @@ +;;; packages.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. + +(defpackage :abcl-script + (:use :cl :java) + (:export #:eval-script + #:define-java-interface-implementation + #:find-java-interface-implementation + #:implement-java-interface)) + +(defpackage :abcl-script-user + (:use :cl :ext :java :abcl-script)) \ No newline at end of file Added: branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/test/AbclTest.java ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/test/AbclTest.java Sun Oct 19 06:07:32 2008 @@ -0,0 +1,104 @@ +package org.armedbear.lisp.scripting; + +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.StringReader; +import java.io.StringWriter; + +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptException; +import javax.script.SimpleScriptContext; + +import junit.framework.TestCase; + +import org.armedbear.lisp.ConditionThrowable; +import org.armedbear.lisp.Cons; +import org.armedbear.lisp.Fixnum; +import org.armedbear.lisp.Lisp; +import org.armedbear.lisp.LispObject; +import org.armedbear.lisp.scripting.AbclScriptEngine; + +public class AbclTest extends TestCase { + + private static AbclScriptEngine engine = new AbclScriptEngine(false); + + public void testBindings() { + try { + engine.put("foo", 42); + assertEquals(new Integer(42), engine.eval("foo")); + engine.eval("(setq foo 45)"); + assertEquals(new Integer(45), engine.get("foo")); + } catch (ScriptException e) { + e.printStackTrace(); + fail("Exception was thrown."); + } + } + + public void testContext() { + try { + SimpleScriptContext ctx = new SimpleScriptContext(); + ctx.setReader(new StringReader("\"test\"")); + StringWriter out = new StringWriter(); + ctx.setWriter(out); + Bindings bindings = engine.createBindings(); + ctx.setBindings(bindings, ScriptContext.ENGINE_SCOPE); + + bindings.put("bar", 42); + assertEquals(new Integer(42), engine.eval("bar", ctx)); + engine.eval("(setq bar 45)", ctx); + assertEquals(new Integer(45), bindings.get("bar")); + + engine.eval("(princ (read))", ctx); + assertEquals("test", out.toString()); + } catch (ScriptException e) { + e.printStackTrace(); + fail("Exception was thrown."); + } + } + + public void testFunctions() { + try { + assertEquals(42, ((Fixnum) engine.invokeFunction("+", 40, 2)).value); + assertEquals(Lisp.NIL, engine.invokeFunction("car", new Cons(Lisp.NIL, Lisp.NIL))); + assertEquals(9, ((Fixnum) engine.invokeFunction("length", "megaceppa")).value); + } catch (Throwable t) { + t.printStackTrace(); + fail("Exception: " + t); + } + } + + public void testInterface() { + try { + engine.eval("(define-java-interface-implementation \"java.lang.Comparable\" \"compareTo\" (lambda (obj) 42))"); + Comparable comp = engine.getInterface(Comparable.class); + assertEquals(42, comp.compareTo(null)); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception: " + e); + } + } + + public static void main(String[] args) { + AbclScriptEngine engine = new AbclScriptEngine(false); + try { + //System.out.println(((LispObject) engine.eval("(print (read))")).writeToString()); + SimpleScriptContext ctx = new SimpleScriptContext(); + ctx.setReader(new InputStreamReader(System.in)); + ctx.setWriter(new OutputStreamWriter(System.out)); + Bindings bindings = engine.createBindings(); + bindings.put("x", 3); + ctx.setBindings(bindings, ctx.ENGINE_SCOPE); + engine.eval("(print \"Hello, World!\")"); + System.out.println("EVAL returned: " + ((LispObject) engine.eval("(print x) (print (jcall (jmethod \"java.lang.Integer\" \"intValue\") x)) (print (type-of (jcall (jmethod \"java.lang.Integer\" \"intValue\") x))) (print 4)", ctx)).writeToString()); + engine.put("y", 42); + System.out.println("EVAL returned: " + ((LispObject) engine.eval("(print y) (print (jcall (jmethod \"java.lang.Integer\" \"intValue\") y)) (setq y 45)")).writeToString()); + System.out.println("y = " + engine.get("y")); + } catch (ScriptException e) { + e.printStackTrace(); + } catch (ConditionThrowable e) { + e.printStackTrace(); + } + } + +} Added: branches/scripting/j/src/org/armedbear/lisp/scripting/util/ReaderInputStream.java ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/util/ReaderInputStream.java Sun Oct 19 06:07:32 2008 @@ -0,0 +1,79 @@ +package org.armedbear.lisp.scripting.util; + +import java.io.*; + +public class ReaderInputStream extends InputStream { + + private final Reader reader; + private final Writer writer; + private final PipedInputStream inPipe; + + public ReaderInputStream(Reader reader) throws IOException { + this(reader, null); + } + + public ReaderInputStream(final Reader reader, String encoding) throws IOException { + this.reader = reader; + inPipe = new PipedInputStream(); + OutputStream outPipe = new PipedOutputStream(inPipe); + writer = (encoding == null) ? new OutputStreamWriter(outPipe) : new OutputStreamWriter(outPipe, encoding); + } + + public int read() throws IOException { + if(doRead()) { + return inPipe.read(); + } else { + return -1; + } + } + + public int read(byte b[]) throws IOException { + return super.read(b); + } + + public int read(byte b[], int off, int len) throws IOException { + if(len <= 0) { + return 0; + } + int n = read(); + if(n == -1) { + return -1; + } else { + b[off] = (byte)n; + } + return 1; + } + + public long skip(long n) throws IOException { + return super.skip(n); + } + + public int available() throws IOException { + return 0; + } + + public synchronized void close() throws IOException { + close(reader); + close(writer); + close(inPipe); + } + + private static void close(Closeable cl) { + try { + cl.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private boolean doRead() throws IOException { + int n = reader.read(); + if(n == -1) { + return false; + } + writer.write(n); + writer.flush(); + return true; + } + +} \ No newline at end of file Added: branches/scripting/j/src/org/armedbear/lisp/scripting/util/WriterOutputStream.java ============================================================================== --- (empty file) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/util/WriterOutputStream.java Sun Oct 19 06:07:32 2008 @@ -0,0 +1,64 @@ +package org.armedbear.lisp.scripting.util; + +import java.io.*; + +public class WriterOutputStream extends OutputStream { + + private final Reader reader; + private final Writer writer; + private final PipedOutputStream outPipe; + + public WriterOutputStream(Writer writer) throws IOException { + this(writer, null); + } + + public WriterOutputStream(final Writer writer, String encoding) throws IOException { + this.writer = writer; + outPipe = new PipedOutputStream(); + InputStream inPipe = new PipedInputStream(outPipe); + reader = (encoding == null) ? new InputStreamReader(inPipe) : new InputStreamReader(inPipe, encoding); + } + + @Override + public void write(int b) throws IOException { + doWrite(b); + writer.flush(); + } + + @Override + public void flush() throws IOException { + super.flush(); + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + super.write(b, off, len); + } + + @Override + public void write(byte[] b) throws IOException { + super.write(b); + } + + public synchronized void close() throws IOException { + close(reader); + close(writer); + close(outPipe); + } + + private static void close(Closeable cl) { + try { + cl.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void doWrite(int n) throws IOException { + outPipe.write(n); + outPipe.flush(); + n = reader.read(); + writer.write(n); + } + +} \ No newline at end of file From vvoutilainen at common-lisp.net Mon Oct 20 21:13:18 2008 From: vvoutilainen at common-lisp.net (Ville Voutilainen) Date: Mon, 20 Oct 2008 21:13:18 +0000 Subject: [armedbear-cvs] r11361 - trunk/j/src/org/armedbear/lisp Message-ID: Author: vvoutilainen Date: Mon Oct 20 21:13:17 2008 New Revision: 11361 Log: iRemove old cruft that escaped previous cleanup rounds. The 8-parameter version of execute() had a separate special variable handling loop that has been long since refactored elsewhere. Modified: trunk/j/src/org/armedbear/lisp/Closure.java Modified: trunk/j/src/org/armedbear/lisp/Closure.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/Closure.java (original) +++ trunk/j/src/org/armedbear/lisp/Closure.java Mon Oct 20 21:13:17 2008 @@ -597,8 +597,6 @@ final LispThread thread = LispThread.currentThread(); SpecialBinding lastSpecialBinding = thread.lastSpecialBinding; Environment ext = new Environment(environment); - for (Symbol special : specials) - ext.declareSpecial(special); bindRequiredParameters(ext, thread, first, second, third, fourth, fifth, sixth, seventh, eighth); return bindParametersAndExecute(ext, thread, From astalla at common-lisp.net Tue Oct 21 18:37:23 2008 From: astalla at common-lisp.net (Alessio Stalla) Date: Tue, 21 Oct 2008 18:37:23 +0000 Subject: [armedbear-cvs] r11362 - branches/scripting/j Message-ID: Author: astalla Date: Tue Oct 21 18:37:21 2008 New Revision: 11362 Log: Modified build.xml to integrate Java Scripting API support for ABCL. Modified: branches/scripting/j/build.xml Modified: branches/scripting/j/build.xml ============================================================================== --- branches/scripting/j/build.xml (original) +++ branches/scripting/j/build.xml Tue Oct 21 18:37:21 2008 @@ -100,6 +100,8 @@ + + @@ -108,6 +110,7 @@ + @@ -115,12 +118,15 @@ + + + @@ -298,6 +304,8 @@ value="${build}"/> + + From ehuelsmann at common-lisp.net Sat Oct 25 21:44:08 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sat, 25 Oct 2008 21:44:08 +0000 Subject: [armedbear-cvs] r11363 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sat Oct 25 21:44:03 2008 New Revision: 11363 Log: Make sure WrongNumberOfArgumentsException errors get reported with a message instead of #. Modified: trunk/j/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java Modified: trunk/j/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java (original) +++ trunk/j/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java Sat Oct 25 21:44:03 2008 @@ -32,6 +32,8 @@ // own Java class as a convenience for the implementation. super(StandardClass.PROGRAM_ERROR); this.operator = operator; + setFormatControl(getMessage()); + setFormatArguments(NIL); } public String getMessage() From vvoutilainen at common-lisp.net Sun Oct 26 13:21:32 2008 From: vvoutilainen at common-lisp.net (Ville Voutilainen) Date: Sun, 26 Oct 2008 13:21:32 +0000 Subject: [armedbear-cvs] r11364 - trunk/j/src/org/armedbear/lisp Message-ID: Author: vvoutilainen Date: Sun Oct 26 13:21:32 2008 New Revision: 11364 Log: Fix behaviour with symbolic links. Modified: trunk/j/src/org/armedbear/lisp/directory.lisp Modified: trunk/j/src/org/armedbear/lisp/directory.lisp ============================================================================== --- trunk/j/src/org/armedbear/lisp/directory.lisp (original) +++ trunk/j/src/org/armedbear/lisp/directory.lisp Sun Oct 26 13:21:32 2008 @@ -69,9 +69,9 @@ (matching-entries ())) (dolist (entry entries) (cond ((file-directory-p entry) - (when (pathname-match-p (pathname-as-file entry) pathname) + (when (pathname-match-p (file-namestring (pathname-as-file entry)) (file-namestring pathname)) (push entry matching-entries))) - ((pathname-match-p entry pathname) + ((pathname-match-p (file-namestring entry) (file-namestring pathname)) (push entry matching-entries)))) matching-entries))) ;; Not wild. From ehuelsmann at common-lisp.net Sun Oct 26 19:50:08 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sun, 26 Oct 2008 19:50:08 +0000 Subject: [armedbear-cvs] r11365 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sun Oct 26 19:50:07 2008 New Revision: 11365 Log: Patch by Mark Evenson to provide the (optional) RUN-SHELL-COMMAND function. Modified: trunk/j/src/org/armedbear/lisp/asdf.lisp Modified: trunk/j/src/org/armedbear/lisp/asdf.lisp ============================================================================== --- trunk/j/src/org/armedbear/lisp/asdf.lisp (original) +++ trunk/j/src/org/armedbear/lisp/asdf.lisp Sun Oct 26 19:50:07 2008 @@ -1115,7 +1115,10 @@ :wait t))) #+ecl ;; courtesy of Juan Jose Garcia Ripoll (si:system command) - #-(or openmcl clisp lispworks allegro scl cmu sbcl ecl) + + #+abcl + (ext:run-shell-command command :output *verbose-out*) + #-(or openmcl clisp lispworks allegro scl cmu sbcl ecl abcl) (error "RUN-SHELL-PROGRAM not implemented for this Lisp") )) From ehuelsmann at common-lisp.net Sun Oct 26 21:06:24 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sun, 26 Oct 2008 21:06:24 +0000 Subject: [armedbear-cvs] r11366 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sun Oct 26 21:06:24 2008 New Revision: 11366 Log: Instead of new (...), use .valueOf(...), allowing jvm caches. Suggested by: dmiles (on #lisp, freenode.org IRC) Modified: trunk/j/src/org/armedbear/lisp/DoubleFloat.java trunk/j/src/org/armedbear/lisp/Fixnum.java trunk/j/src/org/armedbear/lisp/LispCharacter.java trunk/j/src/org/armedbear/lisp/SimpleString.java trunk/j/src/org/armedbear/lisp/SingleFloat.java Modified: trunk/j/src/org/armedbear/lisp/DoubleFloat.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/DoubleFloat.java (original) +++ trunk/j/src/org/armedbear/lisp/DoubleFloat.java Sun Oct 26 21:06:24 2008 @@ -201,14 +201,14 @@ public Object javaInstance() { - return new Double(value); + return Double.valueOf(value); } public Object javaInstance(Class c) { String cn = c.getName(); if (cn.equals("java.lang.Float") || cn.equals("float")) - return new Float(value); + return Float.valueOf((float)value); return javaInstance(); } Modified: trunk/j/src/org/armedbear/lisp/Fixnum.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/Fixnum.java (original) +++ trunk/j/src/org/armedbear/lisp/Fixnum.java Sun Oct 26 21:06:24 2008 @@ -53,18 +53,18 @@ public Object javaInstance() { - return new Integer(value); + return Integer.valueOf(value); } public Object javaInstance(Class c) { String cn = c.getName(); if (cn.equals("java.lang.Byte") || cn.equals("byte")) - return new Byte(((Integer)javaInstance()).byteValue()); + return Byte.valueOf((byte)value); if (cn.equals("java.lang.Short") || cn.equals("short")) - return new Short(((Integer)javaInstance()).shortValue()); + return Short.valueOf((short)value); if (cn.equals("java.lang.Long") || cn.equals("long")) - return new Long(((Integer)javaInstance()).longValue()); + return Long.valueOf((long)value); return javaInstance(); } Modified: trunk/j/src/org/armedbear/lisp/LispCharacter.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/LispCharacter.java (original) +++ trunk/j/src/org/armedbear/lisp/LispCharacter.java Sun Oct 26 21:06:24 2008 @@ -172,7 +172,7 @@ public Object javaInstance() { - return new Character(value); + return Character.valueOf(value); } public Object javaInstance(Class c) Modified: trunk/j/src/org/armedbear/lisp/SimpleString.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/SimpleString.java (original) +++ trunk/j/src/org/armedbear/lisp/SimpleString.java Sun Oct 26 21:06:24 2008 @@ -267,12 +267,12 @@ public String getStringValue() { - return new String(chars); + return String.valueOf(chars); } public Object javaInstance() { - return new String(chars); + return String.valueOf(chars); } public Object javaInstance(Class c) Modified: trunk/j/src/org/armedbear/lisp/SingleFloat.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/SingleFloat.java (original) +++ trunk/j/src/org/armedbear/lisp/SingleFloat.java Sun Oct 26 21:06:24 2008 @@ -201,14 +201,14 @@ public Object javaInstance() { - return new Float(value); + return Float.valueOf(value); } public Object javaInstance(Class c) { String cn = c.getName(); if (cn.equals("java.lang.Float") || cn.equals("float")) - return new Float(value); + return Float.valueOf(value); return javaInstance(); } From ehuelsmann at common-lisp.net Sun Oct 26 22:38:01 2008 From: ehuelsmann at common-lisp.net (Erik Huelsmann) Date: Sun, 26 Oct 2008 22:38:01 +0000 Subject: [armedbear-cvs] r11367 - trunk/j/src/org/armedbear/lisp Message-ID: Author: ehuelsmann Date: Sun Oct 26 22:38:01 2008 New Revision: 11367 Log: Remove useless level of indirection. Modified: trunk/j/src/org/armedbear/lisp/LispError.java Modified: trunk/j/src/org/armedbear/lisp/LispError.java ============================================================================== --- trunk/j/src/org/armedbear/lisp/LispError.java (original) +++ trunk/j/src/org/armedbear/lisp/LispError.java Sun Oct 26 22:38:01 2008 @@ -38,11 +38,6 @@ initialize(initArgs); } - protected void initialize(LispObject initArgs) throws ConditionThrowable - { - super.initialize(initArgs); - } - public LispError(String message) throws ConditionThrowable { super(StandardClass.ERROR); From astalla at common-lisp.net Tue Oct 28 21:16:06 2008 From: astalla at common-lisp.net (Alessio Stalla) Date: Tue, 28 Oct 2008 21:16:06 +0000 Subject: [armedbear-cvs] r11368 - in branches/scripting/j/src/org/armedbear/lisp: . scripting scripting/lisp scripting/lisp/test Message-ID: Author: astalla Date: Tue Oct 28 21:16:05 2008 New Revision: 11368 Log: New jimplement-interface functionality allowing some sort of limited single-dispatch OO. Changed LispObject.javaObject() to return this instead of signaling an error. Removed: branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/test/ Modified: branches/scripting/j/src/org/armedbear/lisp/Autoload.java branches/scripting/j/src/org/armedbear/lisp/JProxy.java branches/scripting/j/src/org/armedbear/lisp/LispObject.java branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp branches/scripting/j/src/org/armedbear/lisp/java.lisp branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp Modified: branches/scripting/j/src/org/armedbear/lisp/Autoload.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/Autoload.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/Autoload.java Tue Oct 28 21:16:05 2008 @@ -488,6 +488,7 @@ autoload(PACKAGE_EXT, "thread-lock", "ThreadLock", true); autoload(PACKAGE_EXT, "thread-unlock", "ThreadLock", true); autoload(PACKAGE_JAVA, "%jnew-proxy", "JProxy"); + autoload(PACKAGE_JAVA, "%jimplement-interface", "JProxy"); autoload(PACKAGE_JAVA, "%jnew-runtime-class", "RuntimeClass"); autoload(PACKAGE_JAVA, "%jredefine-method", "RuntimeClass"); autoload(PACKAGE_JAVA, "%jregister-handler", "JHandler"); Modified: branches/scripting/j/src/org/armedbear/lisp/JProxy.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/JProxy.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/JProxy.java Tue Oct 28 21:16:05 2008 @@ -121,4 +121,83 @@ return null; } } + + //NEW IMPLEMENTATION by Alessio Stalla + + + + private static final Primitive _JIMPLEMENT_INTERFACE = + new Primitive("%jimplement-interface", PACKAGE_JAVA, false, + "interface &rest method-names-and-defs") { + + public LispObject execute(LispObject[] args) throws ConditionThrowable { + int length = args.length; + if (length < 3 || length % 2 != 1) { + return error(new WrongNumberOfArgumentsException(this)); + } + final Map lispDefinedMethods = new HashMap(); + for (int i = 1; i < length; i += 2) { + lispDefinedMethods.put(args[i].getStringValue(), (Function) args[i + 1]); + } + final Class iface = (Class) args[0].javaInstance(); + return new Function() { + + public LispObject execute(LispObject lispProxy) { + Object proxy = Proxy.newProxyInstance( + iface.getClassLoader(), + new Class[] { iface }, + new LispHandler2(lispProxy, lispDefinedMethods)); + return new JavaObject(proxy); + } + + }; + + } + }; + + private static class LispHandler2 implements InvocationHandler { + + private Map lispDefinedMethods; + private LispObject lispProxy; + + LispHandler2(LispObject lispProxy, Map lispDefinedMethods) { + this.lispProxy = lispProxy; + this.lispDefinedMethods = lispDefinedMethods; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws ConditionThrowable { + String methodName = method.getName(); + + //TODO are these implemented correctly? + if(methodName.equals("hashCode")) { + return lispProxy.hashCode(); + } + if (methodName.equals("equals")) { + return (args[0] instanceof LispObject) && (T == lispProxy.EQ((LispObject) args[0])); + } + if (methodName.equals("toString")) { + return lispProxy.writeToString(); + } + + Function f = lispDefinedMethods.get(methodName); + if (f != null) { + try { + LispObject lispArgs = NIL; + if (args != null) { + for (int i = args.length - 1 ; 0 <= i ; i--) { + lispArgs = lispArgs.push(new JavaObject(args[i])); + } + } + lispArgs = lispArgs.push(lispProxy); + LispObject result = evalCall(f, lispArgs, new Environment(), + LispThread.currentThread()); + return (method.getReturnType() == void.class ? null : result.javaInstance()); + } catch (ConditionThrowable t) { + t.printStackTrace(); + } + } + return null; + } + } + } Modified: branches/scripting/j/src/org/armedbear/lisp/LispObject.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/LispObject.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/LispObject.java Tue Oct 28 21:16:05 2008 @@ -85,8 +85,9 @@ public Object javaInstance() throws ConditionThrowable { - return error(new LispError("The value " + writeToString() + - " is not of primitive type.")); + return this; + /*return error(new LispError("The value " + writeToString() + + " is not of primitive type."));*/ } public Object javaInstance(Class c) throws ConditionThrowable Modified: branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp (original) +++ branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp Tue Oct 28 21:16:05 2008 @@ -187,6 +187,8 @@ (autoload 'jregister-handler "java") (export 'jinterface-implementation "JAVA") (autoload 'jinterface-implementation "java") +(export 'jimplement-interface "JAVA") +(autoload 'jimplement-interface "java") (export 'jobject-class "JAVA") (autoload 'jobject-class "java") (export 'jclass-superclass "JAVA") Modified: branches/scripting/j/src/org/armedbear/lisp/java.lisp ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/java.lisp (original) +++ branches/scripting/j/src/org/armedbear/lisp/java.lisp Tue Oct 28 21:16:05 2008 @@ -63,6 +63,45 @@ (push method-name method-names-and-defs))) (apply #'%jnew-proxy interface method-names-and-defs))) +(defun jimplement-interface (interface &rest method-names-and-defs) + "Creates and returns an implementation of a Java interface with + methods calling Lisp closures as given in METHOD-NAMES-AND-DEFS. + + INTERFACE is either a Java interface or a string naming one. + + METHOD-NAMES-AND-DEFS is an alternating list of method names + (strings) and method definitions (closures). + + For missing methods, a dummy implementation is provided that + returns nothing or null depending on whether the return type is + void or not. This is for convenience only, and a warning is issued + for each undefined method." + (let ((interface (jclass interface)) + (implemented-methods + (loop for m in method-names-and-defs + for i from 0 + if (evenp i) + do (assert (stringp m) (m) "Method names must be strings: ~s" m) and collect m + else + do (assert (or (symbolp m) (functionp m)) (m) "Methods must be function designators: ~s" m))) + (null (make-immediate-object nil :ref))) + (loop for method across + (jclass-methods interface :declared nil :public t) + for method-name = (jmethod-name method) + when (not (member method-name implemented-methods :test #'string=)) + do + (let* ((void-p (string= (jclass-name (jmethod-return-type method)) "void")) + (arglist '(&rest ignore)) + (def `(lambda + ,arglist + ,(when arglist '(declare (ignore ignore))) + ,(if void-p '(values) null)))) + (warn "Implementing dummy method ~a for interface ~a" + method-name (jclass-name interface)) + (push (coerce def 'function) method-names-and-defs) + (push method-name method-names-and-defs))) + (apply #'%jimplement-interface interface method-names-and-defs))) + (defun jobject-class (obj) "Returns the Java class that OBJ belongs to" (jcall (jmethod "java.lang.Object" "getClass") obj)) Modified: branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Tue Oct 28 21:16:05 2008 @@ -36,7 +36,6 @@ import javax.script.ScriptException; import javax.script.SimpleBindings; -import org.armedbear.lisp.AbstractString; import org.armedbear.lisp.Bignum; import org.armedbear.lisp.ConditionThrowable; import org.armedbear.lisp.Cons; @@ -51,6 +50,7 @@ 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; @@ -336,7 +336,45 @@ } public static LispObject toLisp(Object javaObject) { - if(javaObject instanceof LispObject) { + if(javaObject == null) { + return Lisp.NIL; + } else if(javaObject instanceof Boolean) { + return ((Boolean)javaObject).booleanValue() ? Lisp.T : Lisp.NIL; + } else if(javaObject instanceof Byte) { + return new Fixnum(((Byte)javaObject).intValue()); + } else if(javaObject instanceof Integer) { + return new Fixnum(((Integer)javaObject).intValue()); + } else if(javaObject instanceof Short) { + return new Fixnum(((Short)javaObject).shortValue()); + } else if(javaObject instanceof Long) { + return new Bignum((Long)javaObject); + } else if(javaObject instanceof BigInteger) { + return new Bignum((BigInteger) javaObject); + } else if(javaObject instanceof Float) { + return new SingleFloat(((Float)javaObject).floatValue()); + } else if(javaObject instanceof Double) { + return new DoubleFloat(((Double)javaObject).doubleValue()); + } else if(javaObject instanceof String) { + return new SimpleString((String)javaObject); + } else if(javaObject instanceof Character) { + return LispCharacter.getInstance((Character)javaObject); + } else if(javaObject instanceof Object[]) { + Object[] array = (Object[]) javaObject; + SimpleVector v = new SimpleVector(array.length); + for(int i = array.length; i > 0; --i) { + try { + v.aset(i, new JavaObject(array[i])); + } catch (ConditionThrowable e) { + throw new Error("Can't set simplevector index " + i, e); + } + } + return v; + } else if(javaObject instanceof LispObject) { + return (LispObject) javaObject; + } else { + return new JavaObject(javaObject); + } + /*if(javaObject instanceof LispObject) { return (LispObject) javaObject; } else if(javaObject instanceof Float) { return new SingleFloat((Float) javaObject); @@ -354,32 +392,26 @@ return new SimpleString((String) javaObject); } else { return new JavaObject(javaObject); - } + }*/ } @SuppressWarnings("unchecked") @Override public T getInterface(Class clasz) { - try { - Symbol s = findSymbol("find-java-interface-implementation", "abcl-script"); - Object obj = s.getSymbolFunction().execute(new JavaObject(clasz)); - if(obj instanceof JavaObject) { - return (T) ((JavaObject) obj).getObject(); - } else { - return null; - } - } catch (ConditionThrowable e) { - throw new Error(e); - } + return getInterface(Lisp.NIL, clasz); } @SuppressWarnings("unchecked") @Override public T getInterface(Object thiz, Class clasz) { try { - Symbol s = findSymbol("implement-java-interface", "abcl-script"); - Object obj = s.getSymbolFunction().execute(new JavaObject(clasz), (LispObject) thiz); - return (T) ((JavaObject) obj).getObject(); + Symbol s = findSymbol("find-java-interface-implementation", "abcl-script"); + Object obj = s.getSymbolFunction().execute(new JavaObject(clasz)); + if(obj instanceof Function) { + return (T) ((JavaObject) ((Function) obj).execute((LispObject) thiz)).getObject(); + } else { + return null; + } } catch (ConditionThrowable e) { throw new Error(e); } Modified: branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp (original) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp Tue Oct 28 21:16:05 2008 @@ -97,6 +97,6 @@ *java-interface-implementations*)) (defun implement-java-interface (interface implementation) - (apply #'jinterface-implementation + (apply #'jimplement-interface `(,interface ,@(java-interface-implementation-method-definitions implementation)))) \ No newline at end of file From astalla at common-lisp.net Thu Oct 30 06:30:26 2008 From: astalla at common-lisp.net (Alessio Stalla) Date: Thu, 30 Oct 2008 06:30:26 +0000 Subject: [armedbear-cvs] r11369 - in branches/scripting/j/src/org/armedbear/lisp: . scripting Message-ID: Author: astalla Date: Thu Oct 30 06:30:25 2008 New Revision: 11369 Log: Introduced jmake-invocation-handler and jmake-proxy. Modified: branches/scripting/j/src/org/armedbear/lisp/Autoload.java branches/scripting/j/src/org/armedbear/lisp/JProxy.java branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp branches/scripting/j/src/org/armedbear/lisp/java.lisp branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Modified: branches/scripting/j/src/org/armedbear/lisp/Autoload.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/Autoload.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/Autoload.java Thu Oct 30 06:30:25 2008 @@ -489,6 +489,8 @@ autoload(PACKAGE_EXT, "thread-unlock", "ThreadLock", true); autoload(PACKAGE_JAVA, "%jnew-proxy", "JProxy"); autoload(PACKAGE_JAVA, "%jimplement-interface", "JProxy"); + autoload(PACKAGE_JAVA, "%jmake-invocation-handler", "JProxy"); + autoload(PACKAGE_JAVA, "%jmake-proxy", "JProxy"); autoload(PACKAGE_JAVA, "%jnew-runtime-class", "RuntimeClass"); autoload(PACKAGE_JAVA, "%jredefine-method", "RuntimeClass"); autoload(PACKAGE_JAVA, "%jregister-handler", "JHandler"); Modified: branches/scripting/j/src/org/armedbear/lisp/JProxy.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/JProxy.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/JProxy.java Thu Oct 30 06:30:25 2008 @@ -122,10 +122,104 @@ } } - //NEW IMPLEMENTATION by Alessio Stalla + //NEW IMPLEMENTATION by Alessio Stalla - + public static class LispInvocationHandler implements InvocationHandler { + + private Function function; + private static Method hashCodeMethod; + private static Method equalsMethod; + private static Method toStringMethod; + + static { + try { + hashCodeMethod = Object.class.getMethod("hashCode", new Class[] {}); + equalsMethod = Object.class.getMethod("equals", new Class[] { Object.class }); + toStringMethod = Object.class.getMethod("toString", new Class[] {}); + } catch (Exception e) { + throw new Error("Something got horribly wrong - can't get a method from Object.class", e); + } + } + + public LispInvocationHandler(Function function) { + this.function = function; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if(hashCodeMethod.equals(method)) { + return proxy.hashCode(); + } + if(equalsMethod.equals(method)) { + return proxy.equals(args[0]); + } + if(toStringMethod.equals(method)) { + return proxy.toString(); + } + + LispObject[] lispArgs = new LispObject[args.length + 2]; + lispArgs[0] = toLispObject(proxy); + lispArgs[1] = new JavaObject(method); + for(int i = 0; i < args.length; i++) { + lispArgs[i + 2] = toLispObject(args[i]); + } + Object retVal = (function.execute(lispArgs)).javaInstance(); + /* DOES NOT WORK due to autoboxing! + if(retVal != null && !method.getReturnType().isAssignableFrom(retVal.getClass())) { + return error(new TypeError(new JavaObject(retVal), new JavaObject(method.getReturnType()))); + }*/ + return retVal; + } + } + private static final Primitive _JMAKE_INVOCATION_HANDLER = + new Primitive("%jmake-invocation-handler", PACKAGE_JAVA, false, + "function") { + + public LispObject execute(LispObject[] args) throws ConditionThrowable { + int length = args.length; + if (length != 1) { + return error(new WrongNumberOfArgumentsException(this)); + } + if(!(args[0] instanceof Function)) { + return error(new TypeError(args[0], Symbol.FUNCTION)); + } + + return new JavaObject(new LispInvocationHandler((Function) args[0])); + } + }; + + private static final Primitive _JMAKE_PROXY = + new Primitive("%jmake-proxy", PACKAGE_JAVA, false, + "interface invocation-handler") { + + public LispObject execute(final LispObject[] args) throws ConditionThrowable { + int length = args.length; + if (length != 2) { + return error(new WrongNumberOfArgumentsException(this)); + } + if(!(args[0] instanceof JavaObject) || + !(((JavaObject) args[0]).javaInstance() instanceof Class)) { + return error(new TypeError(args[0], new SimpleString(Class.class.getName()))); + } + if(!(args[1] instanceof JavaObject) || + !(((JavaObject) args[1]).javaInstance() instanceof InvocationHandler)) { + return error(new TypeError(args[1], new SimpleString(InvocationHandler.class.getName()))); + } + Class iface = (Class) ((JavaObject) args[0]).javaInstance(); + InvocationHandler invocationHandler = (InvocationHandler) ((JavaObject) args[1]).javaInstance(); + Object proxy = Proxy.newProxyInstance( + iface.getClassLoader(), + new Class[] { iface }, + invocationHandler); + return new JavaObject(proxy); + } + }; + + private static LispObject toLispObject(Object obj) { + return (obj instanceof LispObject) ? (LispObject) obj : new JavaObject(obj); + } + private static final Primitive _JIMPLEMENT_INTERFACE = new Primitive("%jimplement-interface", PACKAGE_JAVA, false, "interface &rest method-names-and-defs") { Modified: branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp (original) +++ branches/scripting/j/src/org/armedbear/lisp/autoloads.lisp Thu Oct 30 06:30:25 2008 @@ -189,6 +189,10 @@ (autoload 'jinterface-implementation "java") (export 'jimplement-interface "JAVA") (autoload 'jimplement-interface "java") +(export 'jmake-invocation-handler "JAVA") +(autoload 'jmake-invocation-handler "java") +(export 'jmake-proxy "JAVA") +(autoload 'jmake-proxy "java") (export 'jobject-class "JAVA") (autoload 'jobject-class "java") (export 'jclass-superclass "JAVA") Modified: branches/scripting/j/src/org/armedbear/lisp/java.lisp ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/java.lisp (original) +++ branches/scripting/j/src/org/armedbear/lisp/java.lisp Thu Oct 30 06:30:25 2008 @@ -102,6 +102,15 @@ (push method-name method-names-and-defs))) (apply #'%jimplement-interface interface method-names-and-defs))) +(defun jmake-invocation-handler (function) + (%jmake-invocation-handler function)) + +(defun jmake-proxy (interface invocation-handler) + (let ((handler (if (functionp invocation-handler) + (jmake-invocation-handler invocation-handler) + invocation-handler))) + (%jmake-proxy (jclass interface) handler))) + (defun jobject-class (obj) "Returns the Java class that OBJ belongs to" (jcall (jmethod "java.lang.Object" "getClass") obj)) Modified: branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Thu Oct 30 06:30:25 2008 @@ -277,11 +277,16 @@ try { in = new ReaderInputStream(ctx.getReader()); out = new WriterOutputStream(ctx.getWriter()); + Stream outStream = new Stream(out, Symbol.CHARACTER); retVal = evalScript.execute(makeBindings(ctx.getBindings(ScriptContext.GLOBAL_SCOPE)), makeBindings(ctx.getBindings(ScriptContext.ENGINE_SCOPE)), new Stream(in, Symbol.CHARACTER), - new Stream(out, Symbol.CHARACTER), + outStream, new SimpleString(code), new JavaObject(ctx)); + outStream._finishOutput(); + out.flush(); + in.close(); + out.close(); return toJava(retVal); } catch (ConditionThrowable e) { throw new ScriptException(new Exception(e)); From astalla at common-lisp.net Thu Oct 30 22:11:11 2008 From: astalla at common-lisp.net (Alessio Stalla) Date: Thu, 30 Oct 2008 22:11:11 +0000 Subject: [armedbear-cvs] r11370 - in branches/scripting/j/src/org/armedbear/lisp: . scripting Message-ID: Author: astalla Date: Thu Oct 30 22:11:11 2008 New Revision: 11370 Log: Fixed: proxy handling of no-args methods; problems caused by closing the input stream in AbclScriptEngine.eval. Minor cleanups. Modified: branches/scripting/j/src/org/armedbear/lisp/JProxy.java branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Modified: branches/scripting/j/src/org/armedbear/lisp/JProxy.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/JProxy.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/JProxy.java Thu Oct 30 22:11:11 2008 @@ -157,6 +157,9 @@ return proxy.toString(); } + if(args == null) { + args = new Object[0]; + } LispObject[] lispArgs = new LispObject[args.length + 2]; lispArgs[0] = toLispObject(proxy); lispArgs[1] = new JavaObject(method); Modified: branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java ============================================================================== --- branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java (original) +++ branches/scripting/j/src/org/armedbear/lisp/scripting/AbclScriptEngine.java Thu Oct 30 22:11:11 2008 @@ -285,7 +285,7 @@ new SimpleString(code), new JavaObject(ctx)); outStream._finishOutput(); out.flush(); - in.close(); + //in.close(); out.close(); return toJava(retVal); } catch (ConditionThrowable e) { @@ -320,7 +320,9 @@ return jvar.toUpperCase(); } - private static Object toJava(LispObject lispObject) { + private static Object toJava(LispObject lispObject) throws ConditionThrowable { + return lispObject.javaInstance(); + /* if(lispObject instanceof JavaObject) { return ((JavaObject) lispObject).getObject(); } else if(lispObject instanceof SingleFloat) { @@ -337,7 +339,7 @@ return ((SimpleString) lispObject).javaInstance(); } else { return lispObject; - } + }*/ } public static LispObject toLisp(Object javaObject) { @@ -379,44 +381,22 @@ } else { return new JavaObject(javaObject); } - /*if(javaObject instanceof LispObject) { - return (LispObject) javaObject; - } else if(javaObject instanceof Float) { - return new SingleFloat((Float) javaObject); - } else if(javaObject instanceof Double) { - return new DoubleFloat((Double) javaObject); - } else if(javaObject instanceof Character) { - return LispCharacter.getInstance((Character) javaObject); - } else if(javaObject instanceof Long) { - return new Bignum((Long) javaObject); - } else if(javaObject instanceof BigInteger) { - return new Bignum((BigInteger) javaObject); - } else if(javaObject instanceof Integer) { - return new Fixnum((Integer) javaObject); - } else if(javaObject instanceof String) { - return new SimpleString((String) javaObject); - } else { - return new JavaObject(javaObject); - }*/ } - @SuppressWarnings("unchecked") @Override public T getInterface(Class clasz) { - return getInterface(Lisp.NIL, clasz); + //return getInterface(Lisp.NIL, clasz); + throw new UnsupportedOperationException("Not implemented"); } @SuppressWarnings("unchecked") @Override public T getInterface(Object thiz, Class clasz) { try { - Symbol s = findSymbol("find-java-interface-implementation", "abcl-script"); - Object obj = s.getSymbolFunction().execute(new JavaObject(clasz)); - if(obj instanceof Function) { - return (T) ((JavaObject) ((Function) obj).execute((LispObject) thiz)).getObject(); - } else { - return null; - } + Symbol s = findSymbol("jmake-proxy", "JAVA"); + LispObject f = s.getSymbolFunction(); + JavaObject iface = new JavaObject(clasz); + return (T) ((JavaObject) f.execute(iface, (LispObject) thiz)).javaInstance(); } catch (ConditionThrowable e) { throw new Error(e); }