Merge branch 'master' of git://factorcode.org/git/factor
commit
badbfef890
|
@ -12,7 +12,7 @@ IN: classes.struct.prettyprint
|
||||||
[ drop \ STRUCT: ] if ;
|
[ drop \ STRUCT: ] if ;
|
||||||
|
|
||||||
: struct>assoc ( struct -- assoc )
|
: struct>assoc ( struct -- assoc )
|
||||||
[ class struct-slots ] [ struct-slot-values ] bi zip filter-tuple-assoc ;
|
[ class struct-slots ] [ struct-slot-values ] bi zip ;
|
||||||
|
|
||||||
: pprint-struct-slot ( slot -- )
|
: pprint-struct-slot ( slot -- )
|
||||||
<flow \ { pprint-word
|
<flow \ { pprint-word
|
||||||
|
|
|
@ -23,7 +23,7 @@ TUPLE: struct-slot-spec < slot-spec
|
||||||
PREDICATE: struct-class < tuple-class
|
PREDICATE: struct-class < tuple-class
|
||||||
{ [ \ struct subclass-of? ] [ all-slots length 1 = ] } 1&& ;
|
{ [ \ struct subclass-of? ] [ all-slots length 1 = ] } 1&& ;
|
||||||
|
|
||||||
: struct-slots ( struct -- slots )
|
: struct-slots ( struct-class -- slots )
|
||||||
"struct-slots" word-prop ;
|
"struct-slots" word-prop ;
|
||||||
|
|
||||||
! struct allocation
|
! struct allocation
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
! Copyright (C) 2007, 2008 Slava Pestov.
|
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs hashtables kernel sequences generic words
|
USING: accessors arrays assocs classes classes.struct
|
||||||
arrays classes slots slots.private classes.tuple
|
classes.struct.prettyprint.private classes.tuple
|
||||||
classes.tuple.private math vectors quotations accessors
|
classes.tuple.private combinators generic hashtables kernel
|
||||||
combinators ;
|
math quotations sequences slots slots.private vectors words
|
||||||
|
continuations fry ;
|
||||||
IN: mirrors
|
IN: mirrors
|
||||||
|
|
||||||
TUPLE: mirror { object read-only } ;
|
TUPLE: mirror { object read-only } ;
|
||||||
|
@ -55,3 +56,13 @@ M: array make-mirror <enum> ;
|
||||||
M: vector make-mirror <enum> ;
|
M: vector make-mirror <enum> ;
|
||||||
M: quotation make-mirror <enum> ;
|
M: quotation make-mirror <enum> ;
|
||||||
M: object make-mirror <mirror> ;
|
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 ;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors classes sequences kernel namespaces
|
USING: accessors classes sequences kernel namespaces
|
||||||
make words math math.parser assocs ;
|
make words math math.parser assocs classes.struct
|
||||||
|
alien.c-types ;
|
||||||
IN: summary
|
IN: summary
|
||||||
|
|
||||||
GENERIC: summary ( object -- string )
|
GENERIC: summary ( object -- string )
|
||||||
|
@ -31,3 +32,11 @@ M: assoc summary
|
||||||
M: f summary object-summary ;
|
M: f summary object-summary ;
|
||||||
|
|
||||||
M: integer summary object-summary ;
|
M: integer summary object-summary ;
|
||||||
|
|
||||||
|
M: struct summary
|
||||||
|
[
|
||||||
|
dup class name>> %
|
||||||
|
" struct of " %
|
||||||
|
byte-length #
|
||||||
|
" bytes " %
|
||||||
|
] "" make ;
|
||||||
|
|
Loading…
Reference in New Issue