]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/syntax/syntax.factor
Merge branch 'inlinec' into marshall
[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 alien.marshall.structs ;
9 IN: alien.syntax
10
11 SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
12
13 SYNTAX: ALIEN: scan string>number <alien> parsed ;
14
15 SYNTAX: BAD-ALIEN <bad-alien> parsed ;
16
17 SYNTAX: LIBRARY: scan "c-library" set ;
18
19 SYNTAX: FUNCTION:
20     (FUNCTION:) define-declared ;
21
22 SYNTAX: TYPEDEF:
23     scan scan typedef ;
24
25 SYNTAX: C-STRUCT:
26     scan current-vocab parse-definition [ define-struct ] 3keep
27     2drop define-struct-tuple ;
28
29 SYNTAX: C-UNION:
30     scan parse-definition define-union ;
31
32 SYNTAX: C-ENUM:
33     ";" parse-tokens
34     [ [ create-in ] dip define-constant ] each-index ;
35
36 : address-of ( name library -- value )
37     load-library dlsym [ "No such symbol" throw ] unless* ;
38
39 SYNTAX: &:
40     scan "c-library" get '[ _ _ address-of ] over push-all ;