: 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 ]
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 }
: 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>
: 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 <range> ] bi@