1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types arrays assocs effects grouping kernel
4 parser sequences splitting words fry locals lexer namespaces ;
7 : parse-arglist ( parameters return -- types effect )
8 [ 2 group unzip [ "," ?tail drop ] map ]
9 [ [ { } ] [ 1array ] if-void ]
12 : function-quot ( return library function types -- quot )
13 '[ _ _ _ _ alien-invoke ] ;
15 :: make-function ( return library function parameters -- word quot effect )
16 function create-in dup reset-generic
17 return library function
18 parameters return parse-arglist [ function-quot ] dip ;
20 : (FUNCTION:) ( -- word quot effect )
21 scan "c-library" get scan ";" parse-tokens
22 [ "()" subseq? not ] filter
25 : define-function ( return library function parameters -- )
26 make-function define-declared ;