alien.marshall.syntax: added M-STRUCTURE:

db4
Jeremy Hughes 2009-07-08 17:33:21 +12:00
parent 7d708a17c2
commit eab6d79ac4
3 changed files with 11 additions and 5 deletions

View File

@ -2,7 +2,8 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.marshall arrays assocs USING: accessors alien.c-types alien.marshall arrays assocs
classes.tuple combinators destructors generalizations generic classes.tuple combinators destructors generalizations generic
kernel libc locals parser quotations sequences slots words ; kernel libc locals parser quotations sequences slots words
alien.structs ;
IN: alien.marshall.structs IN: alien.marshall.structs
M: struct-wrapper dispose* underlying>> free ; M: struct-wrapper dispose* underlying>> free ;
@ -35,3 +36,6 @@ M: struct-wrapper dispose* underlying>> free ;
[ type>> ] [ reader>> ] [ writer>> ] [ type>> ] [ reader>> ] [ writer>> ]
} cleave define-struct-accessors } cleave define-struct-accessors
] each ; ] each ;
: define-marshalled-struct ( name vocab fields -- )
[ define-struct ] [ 2drop define-struct-tuple ] 3bi ;

View File

@ -34,3 +34,7 @@ SYNTAX: C-MARSHALLED:
SYNTAX: MARSHALLED: SYNTAX: MARSHALLED:
function-types-effect marshalled-function define-declared ; function-types-effect marshalled-function define-declared ;
SYNTAX: M-STRUCTURE:
scan current-vocab parse-definition
define-marshalled-struct ;

View File

@ -4,8 +4,7 @@ USING: accessors arrays alien alien.c-types alien.structs
alien.arrays alien.strings kernel math namespaces parser alien.arrays alien.strings kernel math namespaces parser
sequences words quotations math.parser splitting grouping sequences words quotations math.parser splitting grouping
effects assocs combinators lexer strings.parser alien.parser effects assocs combinators lexer strings.parser alien.parser
fry vocabs.parser words.constant alien.libraries fry vocabs.parser words.constant alien.libraries ;
alien.marshall.structs ;
IN: alien.syntax IN: alien.syntax
SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ; SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
@ -23,8 +22,7 @@ SYNTAX: TYPEDEF:
scan scan typedef ; scan scan typedef ;
SYNTAX: C-STRUCT: SYNTAX: C-STRUCT:
scan current-vocab parse-definition [ define-struct ] 3keep scan current-vocab parse-definition define-struct ;
2drop define-struct-tuple ;
SYNTAX: C-UNION: SYNTAX: C-UNION:
scan parse-definition define-union ; scan parse-definition define-union ;