diff --git a/basis/alien/parser/parser.factor b/basis/alien/parser/parser.factor index e4ff5789d2..abda8539e9 100644 --- a/basis/alien/parser/parser.factor +++ b/basis/alien/parser/parser.factor @@ -10,16 +10,22 @@ IN: alien.parser : parse-c-type-name ( name -- word ) dup search [ ] [ no-word ] ?if ; -: parse-c-type ( string -- type ) +: (parse-c-type) ( string -- type ) { - { [ dup "void" = ] [ drop void ] } - { [ CHAR: ] over member? ] [ parse-array-type parse-c-type-name prefix ] } - { [ dup search c-type-word? ] [ parse-c-type-name ] } - { [ "**" ?tail ] [ drop void* ] } - { [ "*" ?tail ] [ parse-c-type-name resolve-pointer-type ] } - [ dup search [ no-c-type ] [ no-word ] ?if ] + { [ dup "void" = ] [ drop void ] } + { [ CHAR: ] over member? ] [ parse-array-type parse-c-type-name prefix ] } + { [ dup search ] [ parse-c-type-name ] } + { [ "**" ?tail ] [ drop void* ] } + { [ "*" ?tail ] [ parse-c-type-name resolve-pointer-type ] } + [ dup search [ ] [ no-word ] ?if ] } cond ; +: valid-c-type? ( c-type -- ? ) + { [ array? ] [ c-type-name? ] } 1|| ; + +: parse-c-type ( string -- type ) + (parse-c-type) dup valid-c-type? [ no-c-type ] unless ; + : scan-c-type ( -- c-type ) scan dup "{" = [ drop \ } parse-until >array ] diff --git a/extra/alien/data/map/map-tests.factor b/extra/alien/data/map/map-tests.factor index 25b07c381b..7a492ab0c5 100644 --- a/extra/alien/data/map/map-tests.factor +++ b/extra/alien/data/map/map-tests.factor @@ -13,6 +13,17 @@ IN: alien.data.map.tests byte-array>float-array ] unit-test +[ + float-4-array{ + float-4{ 0.0 0.0 0.0 0.0 } + float-4{ 1.0 1.0 1.0 1.0 } + float-4{ 2.0 2.0 2.0 2.0 } + } +] [ + 3 iota [ float-4-with ] data-map( object -- float-4 ) + byte-array>float-4-array +] unit-test + [ float-4-array{ float-4{ 0.0 1.0 2.0 3.0 } diff --git a/extra/alien/data/map/map.factor b/extra/alien/data/map/map.factor index 8039015a85..72f5cb5517 100644 --- a/extra/alien/data/map/map.factor +++ b/extra/alien/data/map/map.factor @@ -117,8 +117,8 @@ MACRO: data-map! ( ins outs -- ) : parse-data-map-effect ( accum -- accum ) ")" parse-effect - [ in>> [ parse-c-type ] map parsed ] - [ out>> [ parse-c-type ] map parsed ] bi ; + [ in>> [ (parse-c-type) ] map parsed ] + [ out>> [ (parse-c-type) ] map parsed ] bi ; PRIVATE> diff --git a/extra/grid-meshes/grid-meshes.factor b/extra/grid-meshes/grid-meshes.factor index 9a9fd91a64..b63b3d791c 100644 --- a/extra/grid-meshes/grid-meshes.factor +++ b/extra/grid-meshes/grid-meshes.factor @@ -13,7 +13,7 @@ TUPLE: grid-mesh dim buffer row-length ; : vertex-array-row ( range z0 z1 -- vertices ) '[ _ _ [ 0.0 swap 1.0 float-4-boa ] bi-curry@ bi ] - data-map( void -- float-4[2] ) ; inline + data-map( object -- float-4[2] ) ; inline : vertex-array ( dim -- vertices ) first2 [ [ 0.0 1.0 1.0 ] dip /f ] bi@