 ! (c)2010 Joe Groff, Erik Charlebois bsd license
 USING: accessors alien.c-types arrays classes.singleton combinators
-delegate fry generic.parser kernel math parser sequences words ;
+delegate fry generic.parser kernel macros math parser sequences words ;
 IN: alien.enums
 
 <PRIVATE

    base-type>> ;
PRIVATE>

GENERIC: enum>number ( enum -- number )
M: integer enum>number ;

: number>enum ( number enum-c-type -- enum )
    c-type-boxer-quot call( x -- y ) ; inline

<PRIVATE
: enum-boxer ( members -- quot )
    [ first2 swap '[ _ ] 2array ]
    { } map-as [ ] suffix '[ _ case ] ;
PRIVATE>

M: enum-c-type c-type-boxed-class drop object ;
M: enum-c-type c-type-boxer-quot members>> enum-boxer ;


: define-enum-constructor ( word -- )
    [ name>> "<" ">" surround create-in ] keep
    [ number>enum ] curry (( number -- enum )) define-inline ;

PRIVATE>

