2009-05-02 14:45:38 -04:00
|
|
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-05-02 14:45:38 -04:00
|
|
|
USING: alien alien.strings alien.c-types alien.accessors alien.structs
|
|
|
|
arrays words sequences math kernel namespaces fry libc cpu.architecture
|
2009-05-12 05:19:22 -04:00
|
|
|
io.encodings.utf8 ;
|
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-01-28 02:58:57 -05:00
|
|
|
M: array c-type-boxer-quot drop [ ] ;
|
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 ] ;
|
2009-05-02 14:45:38 -04:00
|
|
|
|
|
|
|
PREDICATE: string-type < pair
|
|
|
|
first2 [ "char*" = ] [ word? ] bi* and ;
|
|
|
|
|
|
|
|
M: string-type c-type ;
|
|
|
|
|
|
|
|
M: string-type c-type-class
|
|
|
|
drop object ;
|
|
|
|
|
|
|
|
M: string-type heap-size
|
|
|
|
drop "void*" heap-size ;
|
|
|
|
|
|
|
|
M: string-type c-type-align
|
|
|
|
drop "void*" c-type-align ;
|
|
|
|
|
|
|
|
M: string-type c-type-stack-align?
|
|
|
|
drop "void*" c-type-stack-align? ;
|
|
|
|
|
|
|
|
M: string-type unbox-parameter
|
|
|
|
drop "void*" unbox-parameter ;
|
|
|
|
|
|
|
|
M: string-type unbox-return
|
|
|
|
drop "void*" unbox-return ;
|
|
|
|
|
|
|
|
M: string-type box-parameter
|
|
|
|
drop "void*" box-parameter ;
|
|
|
|
|
|
|
|
M: string-type box-return
|
|
|
|
drop "void*" box-return ;
|
|
|
|
|
|
|
|
M: string-type stack-size
|
|
|
|
drop "void*" stack-size ;
|
|
|
|
|
|
|
|
M: string-type c-type-reg-class
|
|
|
|
drop int-regs ;
|
|
|
|
|
|
|
|
M: string-type c-type-boxer
|
|
|
|
drop "void*" c-type-boxer ;
|
|
|
|
|
|
|
|
M: string-type c-type-unboxer
|
|
|
|
drop "void*" c-type-unboxer ;
|
|
|
|
|
|
|
|
M: string-type c-type-boxer-quot
|
|
|
|
second '[ _ alien>string ] ;
|
|
|
|
|
|
|
|
M: string-type c-type-unboxer-quot
|
|
|
|
second '[ _ string>alien ] ;
|
|
|
|
|
|
|
|
M: string-type c-type-getter
|
|
|
|
drop [ alien-cell ] ;
|
|
|
|
|
|
|
|
M: string-type c-type-setter
|
|
|
|
drop [ set-alien-cell ] ;
|
|
|
|
|
|
|
|
{ "char*" utf8 } "char*" typedef
|
|
|
|
"char*" "uchar*" typedef
|
|
|
|
|