1 ! Copyright (C) 2005, 2009 Slava Pestov, Alex Chapman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays alien alien.c-types alien.structs
4 alien.arrays alien.strings kernel math namespaces parser
5 sequences words quotations math.parser splitting grouping
6 effects assocs combinators lexer strings.parser alien.parser
7 fry vocabs.parser words.constant alien.libraries ;
10 SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
12 SYNTAX: ALIEN: 16 scan-base <alien> parsed ;
14 SYNTAX: BAD-ALIEN <bad-alien> parsed ;
16 SYNTAX: LIBRARY: scan "c-library" set ;
19 (FUNCTION:) define-declared ;
22 scan-c-type CREATE-C-TYPE typedef ;
25 scan current-vocab parse-definition define-struct ; deprecated
28 scan parse-definition define-union ; deprecated
32 [ [ create-in ] dip define-constant ] each-index ;
35 "Primitive C type definition not supported" throw ;
37 ERROR: no-such-symbol name library ;
39 : address-of ( name library -- value )
40 2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
43 scan "c-library" get '[ _ _ address-of ] over push-all ;