From bacffd2e5953ba01890d250613c54f30e293f90b Mon Sep 17 00:00:00 2001 From: "Tarn W. Burton" Date: Sun, 12 Nov 2023 11:02:57 -0500 Subject: [PATCH 1/2] Add gray:stream-file-length --- src/core/grayPackage.cc | 3 +-- src/core/lispStream.cc | 2 +- src/lisp/kernel/clos/streams.lisp | 12 ++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) 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)) From f3af95fd651e43e5253e5c8f435434e5e3b436d8 Mon Sep 17 00:00:00 2001 From: "Tarn W. Burton" Date: Sun, 12 Nov 2023 11:03:13 -0500 Subject: [PATCH 2/2] Update release notes --- RELEASE_NOTES.md | 2 ++ 1 file changed, 2 insertions(+) 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.