Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gray:stream-file-length generic #1511

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/core/grayPackage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/core/lispStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
12 changes: 12 additions & 0 deletions src/lisp/kernel/clos/streams.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
Loading