Skip to content

Commit

Permalink
Have coerceToPathname use Gray stream PATHNAME generic
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Dec 21, 2023
1 parent c7118e2 commit e29e40c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/org/armedbear/lisp/GrayStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ public LispObject fileLength() {
return f.execute(clos);
}

public static final Symbol PATHNAME
= PACKAGE_GRAY_STREAMS_JAVA.addExternalSymbol("JAVA/PATHNAME");
@Override
public Pathname getPathname() {
Function f = checkFunction(PATHNAME.getSymbolFunction());
return (Pathname)f.execute(clos);
}

public static final Symbol LINE_COLUMN
= PACKAGE_GRAY_STREAMS_JAVA.addExternalSymbol("JAVA/LINE-COLUMN");
public int getCharPos() {
Expand Down Expand Up @@ -295,6 +303,7 @@ public void _clearInput() {
Autoload.autoloadFile(GrayStream.FINISH_OUTPUT, "gray-streams-java");
Autoload.autoloadFile(GrayStream.FILE_POSITION, "gray-streams-java");
Autoload.autoloadFile(GrayStream.FILE_LENGTH, "gray-streams-java");
Autoload.autoloadFile(GrayStream.PATHNAME, "gray-streams-java");
Autoload.autoloadFile(GrayStream.LINE_COLUMN, "gray-streams-java");
}
}
10 changes: 4 additions & 6 deletions src/org/armedbear/lisp/Lisp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2143,12 +2143,10 @@ public static Pathname coerceToPathname(LispObject arg)
return (Pathname) arg;
if (arg instanceof AbstractString)
return (Pathname)Pathname.create(((AbstractString)arg).toString());
if (arg instanceof FileStream)
return ((FileStream)arg).getPathname();
if (arg instanceof JarStream)
return ((JarStream)arg).getPathname();
if (arg instanceof URLStream)
return ((URLStream)arg).getPathname();
Stream s = checkStream(arg);
Pathname p = s.getPathname();
if (p != null)
return p;
type_error(arg, list(Symbol.OR,
Symbol.STRING,
Symbol.PATHNAME, Symbol.JAR_PATHNAME, Symbol.URL_PATHNAME,
Expand Down
5 changes: 5 additions & 0 deletions src/org/armedbear/lisp/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,11 @@ protected int _readChar() throws IOException {
return n;
}

public Pathname getPathname()
{
return null;
}

/** Puts a character back into the (underlying) stream
*
* @param n
Expand Down
3 changes: 3 additions & 0 deletions src/org/armedbear/lisp/gray-streams-java.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
(defun java/file-length (object)
(gray-streams:stream-file-length object))

(defun java/pathname (object)
(gray-streams::gray-pathname object))

(defun java/line-column (object)
(gray-streams:stream-line-column object))

Expand Down

0 comments on commit e29e40c

Please sign in to comment.