1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors alien alien.c-types alien.accessors math io ;
6 TUPLE: memory-stream alien index ;
8 : <memory-stream> ( alien -- stream )
11 M: memory-stream stream-read1
12 [ [ alien>> ] [ index>> ] bi alien-unsigned-1 ]
13 [ [ 1+ ] change-index drop ] bi ;
15 M: memory-stream stream-read
17 [ index>> ] [ alien>> ] bi <displaced-alien>
18 swap memory>byte-array
19 ] [ [ + ] change-index drop ] 2bi ;