2008-04-20 06:15:46 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: alien arrays alien.c-types alien.structs
|
2009-02-06 05:02:00 -05:00
|
|
|
sequences math kernel namespaces fry libc cpu.architecture ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: alien.arrays
|
|
|
|
|
|
|
|
UNION: value-type array struct-type ;
|
|
|
|
|
|
|
|
M: array c-type ;
|
|
|
|
|
2008-11-29 05:59:29 -05:00
|
|
|
M: array c-type-class drop object ;
|
|
|
|
|
2009-02-06 05:02:00 -05:00
|
|
|
M: array heap-size unclip [ product ] [ heap-size ] bi* * ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-08-31 08:45:33 -04:00
|
|
|
M: array c-type-align first c-type-align ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
M: array c-type-stack-align? drop f ;
|
|
|
|
|
|
|
|
M: array unbox-parameter drop "void*" unbox-parameter ;
|
|
|
|
|
|
|
|
M: array unbox-return drop "void*" unbox-return ;
|
|
|
|
|
|
|
|
M: array box-parameter drop "void*" box-parameter ;
|
|
|
|
|
|
|
|
M: array box-return drop "void*" box-return ;
|
|
|
|
|
|
|
|
M: array stack-size drop "void*" stack-size ;
|
|
|
|
|
2009-02-06 05:02:00 -05:00
|
|
|
M: array c-type-boxer-quot drop f ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-02-06 05:36:17 -05:00
|
|
|
M: array c-type-unboxer-quot drop [ >c-ptr ] ;
|
2008-04-20 06:15:46 -04:00
|
|
|
|
2009-02-06 05:02:00 -05:00
|
|
|
M: value-type c-type-reg-class drop int-regs ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
M: value-type c-type-getter
|
|
|
|
drop [ swap <displaced-alien> ] ;
|
|
|
|
|
|
|
|
M: value-type c-type-setter ( type -- quot )
|
2009-02-06 05:02:00 -05:00
|
|
|
[ c-type-getter ] [ c-type-unboxer-quot ] [ heap-size ] tri
|
|
|
|
'[ @ swap @ _ memcpy ] ;
|