]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/syntax/syntax.factor
Merge branch 'master' of git://factorcode.org/git/factor into constraints
[factor.git] / basis / alien / syntax / syntax.factor
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 ;
8 IN: alien.syntax
9
10 SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
11
12 SYNTAX: ALIEN: 16 scan-base <alien> parsed ;
13
14 SYNTAX: BAD-ALIEN <bad-alien> parsed ;
15
16 SYNTAX: LIBRARY: scan "c-library" set ;
17
18 SYNTAX: FUNCTION:
19     (FUNCTION:) define-declared ;
20
21 SYNTAX: CALLBACK:
22     "cdecl" (CALLBACK:) define-inline ;
23
24 SYNTAX: STDCALL-CALLBACK:
25     "stdcall" (CALLBACK:) define-inline ;
26
27 SYNTAX: TYPEDEF:
28     scan-c-type CREATE-C-TYPE typedef ;
29
30 SYNTAX: C-STRUCT:
31     scan current-vocab parse-definition define-struct ; deprecated
32
33 SYNTAX: C-UNION:
34     scan parse-definition define-union ; deprecated
35
36 SYNTAX: C-ENUM:
37     ";" parse-tokens
38     [ [ create-in ] dip define-constant ] each-index ;
39
40 SYNTAX: C-TYPE:
41     "Primitive C type definition not supported" throw ;
42
43 ERROR: no-such-symbol name library ;
44
45 : address-of ( name library -- value )
46     2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
47
48 SYNTAX: &:
49     scan "c-library" get '[ _ _ address-of ] over push-all ;