Skip to content

peek-char method of flexi-streams:in-memory-stream  #43

@ccqpein

Description

@ccqpein

Hi guys, I am trying to run JSON parser (yason:parse) with flexi-streams:in-memory-stream directly, because (yason:parse) can accept string steam input directly.

Then SBCL gives me the error when I did it. After checking the code of yason::parse and the error message, I found there are two generic functions of SBCL that needed to be implemented: SB-GRAY:STREAM-READ-CHAR and SB-GRAY:STREAM-PEEK-CHAR

So I tried to implement by code:

(defmethod SB-GRAY:STREAM-READ-CHAR ((s flexi-streams:in-memory-stream))
  (code-char (read-byte s)))

(defmethod SB-GRAY:STREAM-PEEK-CHAR ((s flexi-streams:in-memory-stream))
  (let ((char (code-char (flexi-streams:peek-byte s))))
    char))

Then yason:parse works fine with flexi-streams:in-memory-stream (at least now).

Do you guys trying to implement peek-char for flexi-streams:in-memory-stream? My code just work, I am not sure I met all hidden details of flexi-streams:in-memory-stream. It would be nice if flexi-stream has peek-char natively.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions