remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices
[factor/jcg.git] / basis / io / mmap / functor / functor.factor
blob954d8b43c7bf6edd612d49980748bf58affe58e6
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
7 SLOT: address
8 SLOT: length
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
20 WHERE
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
28 ;FUNCTOR