diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9f518f6cf2..cb7e50b583 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,8 @@ functions. * New build mode `:bytecode-faso` which builds the kernel as native code (FASO) while the bytecode compiler is active. +* Generic `gray:stream-file-length` which implements `cl:file-length` + for Gray streams. ## Removed * Obsolete `:object`, `:ll`, `:bc`, and `:fasl` build modes. diff --git a/src/core/grayPackage.cc b/src/core/grayPackage.cc index 577679fb6c..15552206a6 100644 --- a/src/core/grayPackage.cc +++ b/src/core/grayPackage.cc @@ -54,7 +54,6 @@ SYMBOL_EXPORT_SC_(GrayPkg, stream_write_sequence); SYMBOL_EXPORT_SC_(GrayPkg, stream_unread_char); SYMBOL_EXPORT_SC_(GrayPkg, stream_peek_char); SYMBOL_EXPORT_SC_(GrayPkg, stream_listen); -SYMBOL_EXPORT_SC_(GrayPkg, streamClearInput); SYMBOL_EXPORT_SC_(GrayPkg, stream_clear_input); SYMBOL_EXPORT_SC_(GrayPkg, stream_clear_output); SYMBOL_EXPORT_SC_(GrayPkg, stream_force_output); @@ -64,7 +63,7 @@ SYMBOL_SHADOW_EXPORT_SC_(GrayPkg, input_stream_p); SYMBOL_SHADOW_EXPORT_SC_(GrayPkg, output_stream_p); SYMBOL_EXPORT_SC_(GrayPkg, stream_interactive_p); SYMBOL_SHADOW_EXPORT_SC_(GrayPkg, stream_element_type); -SYMBOL_EXPORT_SC_(GrayPkg, stream_file_position); +SYMBOL_EXPORT_SC_(GrayPkg, stream_file_length); SYMBOL_EXPORT_SC_(GrayPkg, stream_file_position); SYMBOL_EXPORT_SC_(GrayPkg, stream_line_column); SYMBOL_EXPORT_SC_(GrayPkg, stream_line_length); diff --git a/src/core/lispStream.cc b/src/core/lispStream.cc index aa84709c3c..8f6b020987 100644 --- a/src/core/lispStream.cc +++ b/src/core/lispStream.cc @@ -1459,7 +1459,7 @@ static int clos_stream_interactive_p(T_sp strm) { return !T_sp(eval::funcall(gra static T_sp clos_stream_element_type(T_sp strm) { return eval::funcall(gray::_sym_stream_element_type, strm); } -#define clos_stream_length not_a_file_stream +static T_sp clos_stream_length(T_sp strm) { return eval::funcall(gray::_sym_stream_file_length, strm); } static T_sp clos_stream_get_position(T_sp strm) { return eval::funcall(gray::_sym_stream_file_position, strm); } diff --git a/src/lisp/kernel/clos/streams.lisp b/src/lisp/kernel/clos/streams.lisp index 6026f5f3f4..7b3296d79a 100644 --- a/src/lisp/kernel/clos/streams.lisp +++ b/src/lisp/kernel/clos/streams.lisp @@ -205,6 +205,10 @@ (:documentation "This is like CL:FILE-POSITION, but for Gray streams.")) +(defgeneric stream-file-length (stream) + (:documentation + "This is like CL:FILE-LENGTH, but for Gray streams.")) + (defgeneric stream-file-descriptor (stream &optional direction) (:documentation "Return the file-descriptor underlaying STREAM, or NIL if not @@ -621,6 +625,14 @@ (declare (ignore stream position)) nil) +;; FILE-LENGTH + +(defmethod stream-file-length ((stream ansi-stream)) + (file-length stream)) + +(defmethod stream-file-length ((stream t)) + (error 'type-error :datum stream :expected-type 'file-stream)) + ;; STREAM-P (defmethod streamp ((stream stream))