2009-01-16 18:44:29 -05:00
|
|
|
! Copyright (C) 2005, 2009 Slava Pestov, Alex Chapman.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-07-01 17:33:45 -04:00
|
|
|
USING: accessors arrays alien alien.c-types alien.structs
|
|
|
|
alien.arrays alien.strings kernel math namespaces parser
|
|
|
|
sequences words quotations math.parser splitting grouping
|
2008-12-11 01:03:58 -05:00
|
|
|
effects assocs combinators lexer strings.parser alien.parser
|
2009-03-26 00:00:19 -04:00
|
|
|
fry vocabs.parser words.constant alien.libraries ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: alien.syntax
|
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: ALIEN: scan string>number <alien> parsed ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: BAD-ALIEN <bad-alien> parsed ;
|
2008-07-01 17:33:45 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: LIBRARY: scan "c-library" set ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: FUNCTION:
|
2009-04-18 03:37:35 -04:00
|
|
|
(FUNCTION:) define-declared ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: TYPEDEF:
|
|
|
|
scan scan typedef ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: C-STRUCT:
|
2009-05-14 23:31:29 -04:00
|
|
|
scan current-vocab parse-definition define-struct ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: C-UNION:
|
|
|
|
scan parse-definition define-union ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: C-ENUM:
|
2007-09-20 18:09:08 -04:00
|
|
|
";" parse-tokens
|
2009-01-16 18:44:29 -05:00
|
|
|
[ [ create-in ] dip define-constant ] each-index ;
|
2008-12-11 01:03:58 -05:00
|
|
|
|
2009-01-21 20:55:33 -05:00
|
|
|
: address-of ( name library -- value )
|
|
|
|
load-library dlsym [ "No such symbol" throw ] unless* ;
|
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: &:
|
|
|
|
scan "c-library" get '[ _ _ address-of ] over push-all ;
|