]> gitweb.factorcode.org Git - factor.git/commitdiff
Disallow C functions and parameter names that contain an asterisk
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 23 Jul 2009 20:48:10 +0000 (15:48 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 23 Jul 2009 20:48:10 +0000 (15:48 -0500)
basis/alien/parser/parser.factor

index df1dd15bfb7ad62ed10ca1f704092babc5717fef..8e050b395035a56b329fe9d32f930f6d2595625e 100644 (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 ;