1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel combinators alien alien.strings alien.c-types
4 alien.parser alien.syntax arrays assocs effects math.parser
5 prettyprint.backend prettyprint.custom prettyprint.sections
6 definitions see see.private sequences strings words ;
11 { [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
12 { [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
13 [ \ ALIEN: [ alien-address >hex text ] pprint-prefix ]
16 M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
18 M: c-type-word definer drop \ C-TYPE: f ;
19 M: c-type-word definition drop f ;
20 M: c-type-word declarations. drop ;
22 GENERIC: pprint-c-type ( c-type -- )
23 M: word pprint-c-type pprint-word ;
24 M: wrapper pprint-c-type wrapped>> pprint-word ;
25 M: string pprint-c-type text ;
26 M: array pprint-c-type pprint* ;
28 M: typedef-word definer drop \ TYPEDEF: f ;
30 M: typedef-word synopsis*
34 [ "c-type" word-prop pprint-c-type ]
38 : pprint-function-arg ( type name -- )
39 [ pprint-c-type ] [ text ] bi* ;
41 : pprint-function-args ( types names -- )
44 [ [ first2 "," append pprint-function-arg ] each ] dip
45 first2 pprint-function-arg
48 M: alien-function-word definer
49 drop \ FUNCTION: \ ; ;
50 M: alien-function-word definition drop f ;
51 M: alien-function-word synopsis*
54 [ def>> second [ \ LIBRARY: [ text ] pprint-prefix ] when* ]
56 [ def>> first pprint-c-type ]
60 [ def>> fourth ] [ stack-effect in>> ] bi
66 M: alien-callback-type-word definer
67 "callback-abi" word-prop "stdcall" =
68 \ STDCALL-CALLBACK: \ CALLBACK: ?
70 M: alien-callback-type-word definition drop f ;
71 M: alien-callback-type-word synopsis*
75 [ def>> first pprint-c-type ]
79 [ def>> second ] [ "callback-effect" word-prop in>> ] bi