[armedbear-cvs] r13967 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Fri Jun 15 20:41:57 UTC 2012


Author: mevenson
Date: Fri Jun 15 13:41:56 2012
New Revision: 13967

Log:
JAVA:JINPUT-STREAM returns the underlying java.io.InputStream for any PATHNAME resolved by CL:TRUENAME.

SYS:ENSURE-INPUT-STREAM is the primitive wrapping the execution of Pathname.getInputStream().

My name is <evenson.not.org at gmail.com>, and I support this API.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Lisp.java
   trunk/abcl/src/org/armedbear/lisp/Pathname.java
   trunk/abcl/src/org/armedbear/lisp/Symbol.java
   trunk/abcl/src/org/armedbear/lisp/java.lisp

Modified: trunk/abcl/src/org/armedbear/lisp/Lisp.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Lisp.java	Fri Jun 15 07:41:32 2012	(r13966)
+++ trunk/abcl/src/org/armedbear/lisp/Lisp.java	Fri Jun 15 13:41:56 2012	(r13967)
@@ -1064,7 +1064,7 @@
           return (Symbol)// Not reached.       
               type_error(obj, Symbol.SYMBOL);
   }
-
+  
   public static final LispObject checkList(LispObject obj)
 
   {

Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java	Fri Jun 15 07:41:32 2012	(r13966)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java	Fri Jun 15 13:41:56 2012	(r13967)
@@ -2282,6 +2282,22 @@
         return result;
     }
 
+  public static final Primitive GET_INPUT_STREAM = new pf_get_input_stream();
+  @DocString(name="get-input-stream",
+             args="pathname",
+             doc="Returns a java.io.InputStream for resource denoted by PATHNAME.")
+  private static final class pf_get_input_stream extends Primitive {
+    pf_get_input_stream() {
+      super("ensure-input-stream", PACKAGE_SYS, true);
+    }
+    @Override
+    public LispObject execute(LispObject pathname) {
+      Pathname p = (Pathname) coerceToPathname(pathname);
+      return new JavaObject(p.getInputStream());
+    }
+  };
+
+
     public InputStream getInputStream() {
         InputStream result = null;
         if (isJar()) {

Modified: trunk/abcl/src/org/armedbear/lisp/Symbol.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Symbol.java	Fri Jun 15 07:41:32 2012	(r13966)
+++ trunk/abcl/src/org/armedbear/lisp/Symbol.java	Fri Jun 15 13:41:56 2012	(r13967)
@@ -3064,6 +3064,8 @@
     PACKAGE_JAVA.addExternalSymbol("JCLASS-NAME");
   public static final Symbol JCLASS_OF =
     PACKAGE_JAVA.addExternalSymbol("JCLASS-OF");
+  public static final Symbol JINPUT_STREAM =
+    PACKAGE_JAVA.addExternalSymbol("JINPUT-STREAM");
   public static final Symbol JMETHOD_RETURN_TYPE =
     PACKAGE_JAVA.addExternalSymbol("JMETHOD-RETURN-TYPE");
   public static final Symbol JRESOLVE_METHOD =
@@ -3084,6 +3086,8 @@
     PACKAGE_SYS.addExternalSymbol("FLOAT-UNDERFLOW-MODE");
   public static final Symbol FLOAT_OVERFLOW_MODE =
     PACKAGE_SYS.addExternalSymbol("FLOAT-OVERFLOW-MODE");
+  public static final Symbol ENSURE_INPUT_STREAM =
+    PACKAGE_SYS.addExternalSymbol("ENSURE-INPUT-STREAM");
   public static final Symbol CLASS_BYTES =
     PACKAGE_SYS.addExternalSymbol("CLASS-BYTES");
   public static final Symbol _CLASS_SLOTS =

Modified: trunk/abcl/src/org/armedbear/lisp/java.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/java.lisp	Fri Jun 15 07:41:32 2012	(r13966)
+++ trunk/abcl/src/org/armedbear/lisp/java.lisp	Fri Jun 15 13:41:56 2012	(r13967)
@@ -513,4 +513,9 @@
   (declare (ignore initargs))
   (error "make-instance not supported for ~S" class))
 
+(defun jinput-stream (pathname)
+  "Returns a java.io.InputStream for resource denoted by PATHNAME."
+  (sys:ensure-input-stream pathname))
+
 (provide "JAVA")
+




More information about the armedbear-cvs mailing list