]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/arrays/arrays.factor
6a182f8dbfdf712569093caeff2ae6dd95f0324f
[factor.git] / basis / alien / arrays / arrays.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien arrays alien.c-types alien.structs
4 sequences math kernel namespaces fry libc cpu.architecture ;
5 IN: alien.arrays
6
7 UNION: value-type array struct-type ;
8
9 M: array c-type ;
10
11 M: array c-type-class drop object ;
12
13 M: array heap-size unclip [ product ] [ heap-size ] bi* * ;
14
15 M: array c-type-align first c-type-align ;
16
17 M: array c-type-stack-align? drop f ;
18
19 M: array unbox-parameter drop "void*" unbox-parameter ;
20
21 M: array unbox-return drop "void*" unbox-return ;
22
23 M: array box-parameter drop "void*" box-parameter ;
24
25 M: array box-return drop "void*" box-return ;
26
27 M: array stack-size drop "void*" stack-size ;
28
29 M: array c-type-boxer-quot drop [ ] ;
30
31 M: array c-type-unboxer-quot drop [ >c-ptr ] ;
32
33 M: value-type c-type-reg-class drop int-regs ;
34
35 M: value-type c-type-getter
36     drop [ swap <displaced-alien> ] ;
37
38 M: value-type c-type-setter ( type -- quot )
39     [ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri
40     '[ @ swap @ _ memcpy ] ;