1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io.mmap functors accessors alien.c-types math kernel
10 : mapped-file>direct ( mapped-file type -- alien length )
11 [ [ address>> ] [ length>> ] bi ] dip
12 heap-size [ 1- + ] keep /i ;
14 FUNCTOR: define-mapped-array ( T -- )
16 <mapped-A> DEFINES <mapped-${T}-array>
17 <A> IS <direct-${T}-array>
18 with-mapped-A-file DEFINES with-mapped-${T}-file
22 : <mapped-A> ( mapped-file -- direct-array )
23 T mapped-file>direct <A> ; inline
25 : with-mapped-A-file ( path length quot -- )
26 '[ <mapped-A> @ ] with-mapped-file ; inline