     base-type>> ;
 PRIVATE>
 
-GENERIC: enum>number ( enum -- number )
+GENERIC: enum>number ( enum -- number ) foldable
 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>
+
+MACRO: number>enum ( enum-c-type -- )
+    c-type members>> enum-boxer ;
 
 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 (( enum -- number )) define-inline ;

PRIVATE>


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

<PRIVATE
