1 ! Copyright (C) 2008 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types alien.data alien.strings
4 combinators.short-circuit kernel layouts sequences
8 SPECIALIZED-ARRAY: void*
10 : deref? ( alien -- ? )
11 { [ ] [ void* deref ] } 1&& ;
13 : advance ( void* -- void* )
14 cell swap <displaced-alien> ;
16 : alien>strings ( alien encoding -- strings )
17 [ [ dup deref? ] ] dip
18 '[ [ advance ] [ void* deref _ alien>string ] bi ]
21 : strings>alien ( strings encoding -- array )
22 '[ _ malloc-string ] void*-array{ } map-as f suffix ;