Skip to content

Commit

Permalink
Merge pull request #1511 from clasp-developers/gray-ext
Browse files Browse the repository at this point in the history
Add gray:stream-file-length generic
  • Loading branch information
yitzchak authored Nov 12, 2023
2 parents 29b38da + f3af95f commit c2df118
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
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

0 comments on commit c2df118

Please sign in to comment.