Added a new method, STREAM-FILE-POSITION, for compatibility with SBCL's Gray streams

This commit is contained in:
Juan Jose Garcia Ripoll 2008-12-10 16:16:46 +01:00
parent 14d83543a9
commit 80962ea9b4
5 changed files with 22 additions and 4 deletions

View file

@ -75,6 +75,8 @@ ECL 8.9.0:
- We now ship version 0.7.3 of the portable CLX library.
- A new method, STREAM-FILE-POSITION, has been added to the Gray streams package.
* Embedding:
- ECL now implements a more transparent interface for setting and querying

View file

@ -2115,8 +2115,9 @@ ecl_file_position(cl_object strm)
cl_object output;
BEGIN:
#ifdef ECL_CLOS_STREAMS
if (ECL_INSTANCEP(strm))
FEerror("file-position not implemented for CLOS streams", 0);
if (ECL_INSTANCEP(strm)) {
return funcall(2, @'gray::stream-file-position', strm);
}
#endif
if (type_of(strm) != t_stream)
FEtype_error_stream(strm);
@ -2206,8 +2207,9 @@ ecl_file_position_set(cl_object strm, cl_object large_disp)
int extra = 0;
BEGIN:
#ifdef ECL_CLOS_STREAMS
if (ECL_INSTANCEP(strm))
FEerror("file-position not implemented for CLOS streams", 0);
if (ECL_INSTANCEP(strm)) {
return funcall(3, @'gray::stream-file-position', strm, large_disp);
}
#endif
if (type_of(strm) != t_stream)
FEtype_error_stream(strm);

View file

@ -1655,6 +1655,7 @@ cl_symbols[] = {
{GRAY_ "STREAM-CLEAR-INPUT", GRAY_ORDINARY, NULL, -1, OBJNULL},
{GRAY_ "STREAM-CLEAR-OUTPUT", GRAY_ORDINARY, NULL, -1, OBJNULL},
{GRAY_ "STREAM-ELEMENT-TYPE", GRAY_ORDINARY, NULL, 1, OBJNULL},
{GRAY_ "STREAM-FILE-POSITION", GRAY_ORDINARY, NULL, -1, OBJNULL},
{GRAY_ "STREAM-FINISH-OUTPUT", GRAY_ORDINARY, NULL, -1, OBJNULL},
{GRAY_ "STREAM-FORCE-OUTPUT", GRAY_ORDINARY, NULL, -1, OBJNULL},
{GRAY_ "STREAM-FRESH-LINE", GRAY_ORDINARY, NULL, -1, OBJNULL},

View file

@ -1655,6 +1655,7 @@ cl_symbols[] = {
{GRAY_ "STREAM-CLEAR-INPUT",NULL},
{GRAY_ "STREAM-CLEAR-OUTPUT",NULL},
{GRAY_ "STREAM-ELEMENT-TYPE",NULL},
{GRAY_ "STREAM-FILE-POSITION",NULL},
{GRAY_ "STREAM-FINISH-OUTPUT",NULL},
{GRAY_ "STREAM-FORCE-OUTPUT",NULL},
{GRAY_ "STREAM-FRESH-LINE",NULL},

View file

@ -196,6 +196,10 @@
(:documentation
"This is like CL:WRITE-SEQUENCE, but for Gray streams."))
(defgeneric stream-file-position (stream &optional position)
(:documentation
"This is like CL:FILE-POSITION, but for Gray streams."))
;;;
;;; Our class hierarchy looks like the one from Gray streams
@ -520,6 +524,14 @@
(defmethod stream-start-line-p ((stream fundamental-character-output-stream))
(eql (stream-line-column stream) 0))
;; FILE-POSITION
(defmethod stream-file-position ((stream ansi-stream) &optional position)
(file-position stream position))
(defmethod stream-file-position ((stream t) &optional position)
(declare (ignore stream position))
nil)
;; STREAM-P