]> gitweb.factorcode.org Git - factor.git/commitdiff
add alternate literal syntax "X-array@ PTR LEN" for direct-arrays. pprint with this...
authorJoe Groff <arcata@gmail.com>
Mon, 31 Aug 2009 01:23:55 +0000 (20:23 -0500)
committerJoe Groff <arcata@gmail.com>
Mon, 31 Aug 2009 01:23:55 +0000 (20:23 -0500)
basis/prettyprint/backend/backend.factor
basis/prettyprint/config/config.factor
basis/specialized-arrays/direct/functor/functor.factor

index 247067673e3d1ec7bfa2acb71ec1d4633e95d2f3..3fb0370ff19d4e9a6bf6fe81ebcb648b5a2bdc40 100644 (file)
@@ -1,10 +1,11 @@
 ! 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 ;
@@ -153,6 +154,11 @@ M: pathname pprint*
 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 [-]
index d986791f94762a817a121729dd84cbf62fb947f7..d42b134d4cd8ca5450fa4622a2216046e61f9cb8 100644 (file)
@@ -13,6 +13,7 @@ SYMBOL: length-limit
 SYMBOL: line-limit
 SYMBOL: string-limit?
 SYMBOL: boa-tuples?
+SYMBOL: c-object-pointers?
 
 4 tab-size set-global
 64 margin set-global
index 2ba436cd58566bbd220536b197b8e11d5c49c286..9003b87e03c4fe6c183ca7af1be011745bac9eec 100755 (executable)
@@ -2,9 +2,17 @@
 ! 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
@@ -15,6 +23,7 @@ A'{     IS ${A'}{
 
 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 ]
@@ -34,11 +43,17 @@ M: A new-sequence drop <A'> ; inline
 
 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