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 "cdecl" (CALLBACK:) define-inline ;
24 SYNTAX: STDCALL-CALLBACK:
25 "stdcall" (CALLBACK:) define-inline ;
28 scan-c-type CREATE-C-TYPE typedef ;
31 scan current-vocab parse-definition define-struct ; deprecated
34 scan parse-definition define-union ; deprecated
38 [ [ create-in ] dip define-constant ] each-index ;
41 "Primitive C type definition not supported" throw ;
43 ERROR: no-such-symbol name library ;
45 : address-of ( name library -- value )
46 2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
49 scan "c-library" get '[ _ _ address-of ] over push-all ;