]> gitweb.factorcode.org Git - factor.git/blob - core/io/streams/memory/memory.factor
9e07143839f93905e64e1f17c2c9362c4215a080
[factor.git] / core / io / streams / memory / memory.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors alien alien.accessors math io ;
4 IN: io.streams.memory
5
6 TUPLE: memory-stream alien ;
7
8 : <memory-stream> ( alien -- stream )
9     memory-stream boa ;
10
11 INSTANCE: memory-stream input-stream
12
13 M: memory-stream stream-element-type drop +byte+ ;
14
15 M: memory-stream stream-read1
16     [ 1 over <displaced-alien> ] change-alien drop
17     0 alien-unsigned-1 ; inline
18
19 : with-memory-reader ( alien quot -- )
20     [ <memory-stream> ] dip with-input-stream* ; inline