Disallow C functions and parameter names that contain an asterisk

db4
Doug Coleman 2009-07-23 15:48:10 -05:00
parent 739d99d4e8
commit bad8e05937
1 changed files with 12 additions and 3 deletions
basis/alien/parser

View File

@ -1,11 +1,20 @@
! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types arrays assocs effects grouping kernel
parser sequences splitting words fry locals lexer namespaces ;
parser sequences splitting words fry locals lexer namespaces
summary ;
IN: alien.parser
ERROR: invalid-c-name name ;
M: invalid-c-name summary
drop "The C pointer asterisk must be part of the type string." ;
: check-c-name ( string -- string )
dup [ CHAR: * = ] any? [ invalid-c-name ] when ;
: parse-arglist ( parameters return -- types effect )
[ 2 group unzip [ "," ?tail drop ] map ]
[ 2 group unzip [ "," ?tail drop check-c-name ] map ]
[ [ { } ] [ 1array ] if-void ]
bi* <effect> ;
@ -13,7 +22,7 @@ IN: alien.parser
'[ _ _ _ _ alien-invoke ] ;
:: make-function ( return library function parameters -- word quot effect )
function create-in dup reset-generic
function check-c-name create-in dup reset-generic
return library function
parameters return parse-arglist [ function-quot ] dip ;