1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types byte-arrays growable kernel math sequences
4 sequences.private struct-arrays ;
8 { underlying struct-array }
9 { length array-capacity }
10 { c-type read-only } ;
12 : <struct-vector> ( capacity struct-class -- struct-vector )
13 [ <struct-array> 0 ] keep struct-vector boa ; inline
15 M: struct-vector byte-length underlying>> byte-length ;
17 M: struct-vector new-sequence
18 [ c-type>> <struct-array> ] [ [ >fixnum ] [ c-type>> ] bi* ] 2bi
21 M: struct-vector contract 2drop ;
23 M: struct-array new-resizable c-type>> <struct-vector> ;
25 INSTANCE: struct-vector growable