Fix <direct-struct-array>
parent
7836b2c6f4
commit
74df92d12d
|
@ -1,6 +1,7 @@
|
||||||
IN: struct-arrays.tests
|
IN: struct-arrays.tests
|
||||||
USING: struct-arrays tools.test kernel math sequences
|
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
|
C-STRUCT: test-struct
|
||||||
{ "int" "x" }
|
{ "int" "x" }
|
||||||
|
@ -27,3 +28,12 @@ C-STRUCT: test-struct
|
||||||
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
|
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
|
||||||
] with-destructors
|
] with-destructors
|
||||||
] unit-test
|
] 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
|
] keep struct-array boa ; inline
|
||||||
|
|
||||||
: <direct-struct-array> ( alien length c-type -- struct-array )
|
: <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 )
|
: 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
|
INSTANCE: struct-array sequence
|
||||||
|
|
Loading…
Reference in New Issue