]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/syntax/syntax.factor
41aed994461ddddb22c8c3c1226d3e44b79594bc
[factor.git] / basis / alien / syntax / syntax.factor
1 ! Copyright (C) 2005, 2010 Slava Pestov, Alex Chapman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays alien alien.c-types alien.arrays
4 alien.strings kernel math namespaces parser sequences words
5 quotations math.parser splitting grouping effects assocs
6 combinators lexer strings.parser alien.parser fry vocabs.parser
7 words.constant alien.libraries ;
8 IN: alien.syntax
9
10 SYNTAX: DLL" lexer get skip-blank parse-string dlopen suffix! ;
11
12 SYNTAX: ALIEN: 16 scan-base <alien> suffix! ;
13
14 SYNTAX: BAD-ALIEN <bad-alien> suffix! ;
15
16 SYNTAX: LIBRARY: scan current-library set ;
17
18 SYNTAX: FUNCTION:
19     (FUNCTION:) make-function define-declared ;
20
21 SYNTAX: FUNCTION-ALIAS:
22     scan create-function
23     (FUNCTION:) (make-function) define-declared ;
24
25 SYNTAX: CALLBACK:
26     (CALLBACK:) define-inline ;
27
28 SYNTAX: TYPEDEF:
29     scan-c-type CREATE-C-TYPE dup save-location typedef ;
30
31 SYNTAX: C-ENUM:
32     scan dup "f" =
33     [ drop ]
34     [ (CREATE-C-TYPE) dup save-location int swap typedef ] if
35     0 parse-enum-members ;
36
37 SYNTAX: C-TYPE:
38     void CREATE-C-TYPE typedef ;
39
40 SYNTAX: &:
41     scan current-library get '[ _ _ address-of ] append! ;
42
43 SYNTAX: C-GLOBAL: scan-c-type CREATE-WORD define-global ;
44
45 SYNTAX: pointer:
46     scan-c-type <pointer> suffix! ;