2009-08-12 10:37:09 -04:00
|
|
|
! (c)Joe Groff bsd license
|
2009-08-12 15:59:33 -04:00
|
|
|
USING: classes.struct kernel prettyprint.backend prettyprint.custom
|
2009-08-12 10:37:09 -04:00
|
|
|
prettyprint.sections see.private sequences words ;
|
|
|
|
|
IN: classes.struct.prettyprint
|
|
|
|
|
|
2009-08-19 19:53:44 -04:00
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
|
|
: struct-definer-word ( class -- word )
|
|
|
|
|
struct-slots dup length 2 >=
|
|
|
|
|
[ second offset>> 0 = \ UNION-STRUCT: \ STRUCT: ? ]
|
|
|
|
|
[ drop \ STRUCT: ] if ;
|
|
|
|
|
|
|
|
|
|
: struct>assoc ( struct -- assoc )
|
|
|
|
|
[ class struct-slots ] [ struct-slot-values ] bi zip filter-tuple-assoc ;
|
|
|
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
|
2009-08-12 10:37:09 -04:00
|
|
|
M: struct-class see-class*
|
2009-08-19 19:53:44 -04:00
|
|
|
<colon dup struct-definer-word pprint-word dup pprint-word
|
|
|
|
|
<block struct-slots [ pprint-slot ] each
|
2009-08-12 10:37:09 -04:00
|
|
|
block> pprint-; block> ;
|
|
|
|
|
|
2009-08-12 15:59:33 -04:00
|
|
|
M: struct pprint-delims
|
|
|
|
|
drop \ S{ \ } ;
|
|
|
|
|
|
2009-08-19 19:53:44 -04:00
|
|
|
M: struct >pprint-sequence
|
|
|
|
|
[ class ] [ struct-slot-values ] bi class-slot-sequence ;
|
|
|
|
|
|
|
|
|
|
M: struct pprint*
|
|
|
|
|
[ [ \ S{ ] dip [ class ] [ struct>assoc ] bi \ } (pprint-tuple) ] ?pprint-tuple ;
|