change data-map( ) syntax to work with c-type[symbolic-constant] types

db4
Joe Groff 2009-10-16 12:28:08 -05:00
parent a37bc4828f
commit 7830082154
2 changed files with 5 additions and 2 deletions

View File

@ -92,9 +92,11 @@ IN: alien.data.map.tests
: vmerge-transpose ( a b c d -- ac bd ac bd )
[ (vmerge) ] bi-curry@ bi* ; inline
CONSTANT: plane-count 4
: fold-rgba-planes ( r g b a -- rgba )
[ vmerge-transpose vmerge-transpose ]
data-map( uchar-16 uchar-16 uchar-16 uchar-16 -- uchar-16[4] ) ;
data-map( uchar-16 uchar-16 uchar-16 uchar-16 -- uchar-16[plane-count] ) ;
[
B{

View File

@ -2,6 +2,7 @@
USING: accessors alien alien.c-types alien.data alien.parser arrays
byte-arrays combinators effects.parser fry generalizations kernel
lexer locals macros make math math.ranges parser sequences sequences.private ;
FROM: alien.arrays => array-length ;
IN: alien.data.map
ERROR: bad-data-map-input-length byte-length iter-size remainder ;
@ -36,7 +37,7 @@ M: data-map-param nth-unsafe
INSTANCE: data-map-param immutable-sequence
: c-type-count ( in/out -- c-type count iter-length )
dup array? [ unclip swap product >fixnum ] [ 1 ] if
dup array? [ unclip swap array-length >fixnum ] [ 1 ] if
2dup swap heap-size * >fixnum ; inline
MACRO: >param ( in -- quot: ( array -- param ) )