]> gitweb.factorcode.org Git - factor.git/blob - basis/io/mmap/functor/functor.factor
change math.floats.env tests not to use any libm functions, which don't reliably...
[factor.git] / basis / io / mmap / functor / functor.factor
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
4 words fry ;
5 IN: io.mmap.functor
6
7 SLOT: address
8 SLOT: length
9
10 : mapped-file>direct ( mapped-file type -- alien length )
11     [ [ address>> ] [ length>> ] bi ] dip
12     heap-size [ 1 - + ] keep /i ;
13
14 FUNCTOR: define-mapped-array ( T -- )
15
16 <mapped-A>                DEFINES <mapped-${T}-array>
17 <A>                       IS      <direct-${T}-array>
18 with-mapped-A-file        DEFINES with-mapped-${T}-file
19 with-mapped-A-file-reader DEFINES with-mapped-${T}-file-reader
20
21 WHERE
22
23 : <mapped-A> ( mapped-file -- direct-array )
24     T mapped-file>direct <A> ; inline
25
26 : with-mapped-A-file ( path quot -- )
27     '[ <mapped-A> @ ] with-mapped-file ; inline
28
29 : with-mapped-A-file-reader ( path quot -- )
30     '[ <mapped-A> @ ] with-mapped-file-reader ; inline
31
32 ;FUNCTOR