Fix <direct-struct-array>
parent
7836b2c6f4
commit
74df92d12d
|
@ -1,6 +1,7 @@
|
|||
IN: struct-arrays.tests
|
||||
USING: struct-arrays tools.test kernel math sequences
|
||||
alien.syntax alien.c-types destructors libc accessors ;
|
||||
alien.syntax alien.c-types destructors libc accessors
|
||||
destructors ;
|
||||
|
||||
C-STRUCT: test-struct
|
||||
{ "int" "x" }
|
||||
|
@ -27,3 +28,12 @@ C-STRUCT: test-struct
|
|||
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
||||
[ ] [ ALIEN: 123 10 "test-struct" <direct-struct-array> drop ] unit-test
|
||||
|
||||
[ ] [
|
||||
[
|
||||
10 "test-struct" malloc-struct-array
|
||||
underlying>> &free drop
|
||||
] with-destructors
|
||||
] unit-test
|
|
@ -32,9 +32,9 @@ ERROR: bad-byte-array-length byte-array ;
|
|||
] keep struct-array boa ; inline
|
||||
|
||||
: <direct-struct-array> ( alien length c-type -- struct-array )
|
||||
struct-array boa ; inline
|
||||
heap-size struct-array boa ; inline
|
||||
|
||||
: malloc-struct-array ( length c-type -- struct-array )
|
||||
heap-size [ calloc ] 2keep <direct-struct-array> ;
|
||||
[ heap-size calloc ] 2keep <direct-struct-array> ;
|
||||
|
||||
INSTANCE: struct-array sequence
|
||||
|
|
Loading…
Reference in New Issue