]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.prettyprint: pprint pointer objects as "type*" in c-type contexts
authorJoe Groff <arcata@gmail.com>
Mon, 22 Feb 2010 05:32:34 +0000 (21:32 -0800)
committerJoe Groff <arcata@gmail.com>
Mon, 22 Feb 2010 05:32:34 +0000 (21:32 -0800)
basis/alien/prettyprint/prettyprint.factor

index 489ea0b10a9ffb1715f05261b62b203ab7147896..52e9978a5f5363abdc53c2601ca5a6cc02973a28 100644 (file)
@@ -19,9 +19,19 @@ M: c-type-word definer drop \ C-TYPE: f ;
 M: c-type-word definition drop f ;
 M: c-type-word declarations. drop ;
 
+<PRIVATE
+GENERIC: pointer-string ( pointer -- string/f )
+M: object pointer-string drop f ;
+M: word pointer-string name>> ;
+M: pointer pointer-string to>> pointer-string [ CHAR: * suffix ] [ f ] if* ;
+PRIVATE>
+
 GENERIC: pprint-c-type ( c-type -- )
 M: word pprint-c-type pprint-word ;
-M: pointer pprint-c-type pprint* ;
+M: pointer pprint-c-type
+    dup pointer-string
+    [ swap present-text ]
+    [ pprint* ] if* ;
 M: wrapper pprint-c-type wrapped>> pprint-word ;
 M: string pprint-c-type text ;
 M: array pprint-c-type pprint* ;