! Copyright (C) 2003, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays byte-arrays byte-vectors generic hashtables
-assocs kernel math namespaces make sequences strings sbufs vectors
-words prettyprint.config prettyprint.custom prettyprint.sections
-quotations io io.pathnames io.styles math.parser effects classes.tuple
-math.order classes.tuple.private classes combinators colors ;
+USING: accessors arrays byte-arrays byte-vectors continuations
+generic hashtables assocs kernel math namespaces make sequences
+strings sbufs vectors words prettyprint.config prettyprint.custom
+prettyprint.sections quotations io io.pathnames io.styles math.parser
+effects classes.tuple math.order classes.tuple.private classes
+combinators colors ;
IN: prettyprint.backend
M: effect pprint* effect>string "(" ")" surround text ;
M: tuple pprint*
pprint-tuple ;
+: pprint-c-object ( object content-quot pointer-quot -- )
+ [ c-object-pointers? get ] 2dip
+ [ nip ]
+ [ [ drop ] prepose [ recover ] 2curry ] 2bi if ; inline
+
: do-length-limit ( seq -- trimmed n/f )
length-limit get dup [
over length over [-]
! See http://factorcode.org/license.txt for BSD license.
USING: functors sequences sequences.private kernel words classes
math alien alien.c-types byte-arrays accessors
-specialized-arrays prettyprint.custom ;
+specialized-arrays parser prettyprint.backend prettyprint.custom ;
IN: specialized-arrays.direct.functor
+<PRIVATE
+
+: pprint-direct-array ( direct-array tag -- )
+ pprint-word
+ [ underlying>> ] [ length>> ] bi [ pprint* ] bi@ ;
+
+PRIVATE>
+
FUNCTOR: define-direct-array ( T -- )
A' IS ${T}-array
A DEFINES-CLASS direct-${T}-array
<A> DEFINES <${A}>
+A'@ DEFINES ${A'}@
NTH [ T dup c-type-getter-boxer array-accessor ]
SET-NTH [ T dup c-setter array-accessor ]
M: A byte-length length>> T heap-size * ; inline
+SYNTAX: A'@
+ scan-object scan-object <A> parsed ;
+
M: A pprint-delims drop \ A'{ \ } ;
M: A >pprint-sequence ;
-M: A pprint* pprint-object ;
+M: A pprint*
+ [ pprint-object ]
+ [ \ A'@ pprint-direct-array ]
+ pprint-c-object ;
INSTANCE: A sequence
INSTANCE: A S