prettyprint ENUM: definitions
parent
d3f770d545
commit
52903ee597
|
@ -8,8 +8,10 @@ TUPLE: enum-c-type base-type members ;
|
|||
CONSULT: c-type-protocol enum-c-type
|
||||
base-type>> ;
|
||||
|
||||
<PRIVATE
|
||||
: map-to-case ( quot: ( x -- y ) -- case )
|
||||
{ } map-as [ ] suffix ; inline
|
||||
PRIVATE>
|
||||
|
||||
: enum-unboxer ( members -- quot )
|
||||
[ first2 '[ _ ] 2array ] map-to-case '[ _ case ] ;
|
||||
|
@ -36,3 +38,5 @@ PRIVATE>
|
|||
: define-enum ( word base-type members -- )
|
||||
[ define-enum-members ] [ <enum-c-type> swap typedef ] bi ;
|
||||
|
||||
PREDICATE: enum-c-type-word < c-type-word
|
||||
"c-type" word-prop enum-c-type? ;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors kernel combinators alien alien.strings alien.c-types
|
||||
alien.parser alien.syntax arrays assocs effects math.parser
|
||||
prettyprint.backend prettyprint.custom prettyprint.sections
|
||||
definitions see see.private sequences strings words ;
|
||||
USING: accessors kernel combinators alien alien.enums
|
||||
alien.strings alien.c-types alien.parser alien.syntax arrays
|
||||
assocs effects math.parser prettyprint.backend prettyprint.custom
|
||||
prettyprint.sections definitions see see.private sequences
|
||||
strings words ;
|
||||
IN: alien.prettyprint
|
||||
|
||||
M: alien pprint*
|
||||
|
@ -110,3 +111,15 @@ M: alien-callback-type-word synopsis*
|
|||
")" text block>
|
||||
]
|
||||
} cleave ;
|
||||
|
||||
M: enum-c-type-word definer
|
||||
drop \ ENUM: \ ; ;
|
||||
M: enum-c-type-word synopsis*
|
||||
{
|
||||
[ seeing-word ]
|
||||
[ definer. ]
|
||||
[ pprint-word ]
|
||||
[ c-type base-type>> dup int eq? [ drop ] [ "<" text pprint-word ] if ]
|
||||
} cleave ;
|
||||
M: enum-c-type-word definition
|
||||
c-type members>> ;
|
||||
|
|
Loading…
Reference in New Issue