diff --git a/extra/alien/data/map/map-tests.factor b/extra/alien/data/map/map-tests.factor index e6845d1847..eb47d3675c 100644 --- a/extra/alien/data/map/map-tests.factor +++ b/extra/alien/data/map/map-tests.factor @@ -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{ diff --git a/extra/alien/data/map/map.factor b/extra/alien/data/map/map.factor index d4c24ef18f..48fcbcd97b 100644 --- a/extra/alien/data/map/map.factor +++ b/extra/alien/data/map/map.factor @@ -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 ) )