! (c)Joe Groff bsd license
-USING: accessors alien assocs classes classes.struct
-combinators kernel math prettyprint.backend prettyprint.custom
-prettyprint.sections see.private sequences strings words ;
+USING: accessors alien alien.c-types arrays assocs classes
+classes.struct combinators continuations fry kernel make math
+math.parser mirrors prettyprint.backend prettyprint.custom
+prettyprint.sections see.private sequences strings
+summary words ;
IN: classes.struct.prettyprint
<PRIVATE
M: struct pprint*
[ pprint-struct ]
[ pprint-struct-pointer ] pprint-c-object ;
+
+M: struct summary
+ [
+ dup class name>> %
+ " struct of " %
+ byte-length #
+ " bytes " %
+ ] "" make ;
+
+M: struct make-mirror
+ [
+ [ drop "underlying" ] [ (underlying)>> ] bi 2array 1array
+ ] [
+ '[
+ _ struct>assoc
+ [ [ [ name>> ] [ c-type>> ] bi 2array ] dip ] assoc-map
+ ] [ drop { } ] recover
+ ] bi append ;
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs classes classes.struct
-classes.struct.prettyprint.private classes.tuple
-classes.tuple.private combinators generic hashtables kernel
-math quotations sequences slots slots.private vectors words
-continuations fry ;
+USING: assocs hashtables kernel sequences generic words
+arrays classes slots slots.private classes.tuple
+classes.tuple.private math vectors quotations accessors
+combinators ;
IN: mirrors
TUPLE: mirror { object read-only } ;
M: vector make-mirror <enum> ;
M: quotation make-mirror <enum> ;
M: object make-mirror <mirror> ;
-
-M: struct make-mirror
- [
- [ drop "underlying" ] [ (underlying)>> ] bi 2array 1array
- ] [
- '[
- _ struct>assoc
- [ [ [ name>> ] [ c-type>> ] bi 2array ] dip ] assoc-map
- ] [ drop { } ] recover
- ] bi append ;
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors classes sequences kernel namespaces
-make words math math.parser assocs classes.struct
-alien.c-types ;
+make words math math.parser assocs ;
IN: summary
GENERIC: summary ( object -- string )
M: f summary object-summary ;
M: integer summary object-summary ;
-
-M: struct summary
- [
- dup class name>> %
- " struct of " %
- byte-length #
- " bytes " %
- ] "" make ;