]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.parser: make make-callback-type have the same signature as make-function
authorBjörn Lindqvist <bjourne@gmail.com>
Sat, 28 May 2016 14:49:14 +0000 (16:49 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Sat, 28 May 2016 15:21:45 +0000 (17:21 +0200)
basis/alien/parser/parser-tests.factor
basis/alien/parser/parser.factor
basis/gobject-introspection/ffi/ffi.factor

index bd299e0a14be00a6d3663aec0dcac064d7958a65..de2d3bc303d170f9c34dca7f505e873bd26c4c25 100644 (file)
@@ -1,38 +1,47 @@
 ! (c)2009 Joe Groff bsd license
-USING: accessors alien.c-types alien.parser alien.syntax
-compiler.units continuations debugger eval kernel namespaces parser
-sequences sets tools.test vocabs.parser words ;
+USING: accessors alien.c-types alien.parser alien.parser.private
+alien.syntax compiler.units continuations debugger eval fry kernel
+lexer namespaces parser sequences sets tools.test vocabs.parser words
+;
 IN: alien.parser.tests
 
+: with-parsing ( lines quot -- )
+    [ <lexer> ] [ '[ _ with-compilation-unit ] ] bi* with-lexer ; inline
+
 ! (CREATE-C-TYPE)
 { "hello" } [
-    [ "hello" (CREATE-C-TYPE) ] with-compilation-unit
-    name>>
+    { "hello" } [ CREATE-C-TYPE name>> ] with-parsing
 ] unit-test
 
 ! Check that it deletes from old-definitions
 { 0 } [
-    [
+    { } [
         "hello" current-vocab create-word
         old-definitions get first adjoin
         "hello" (CREATE-C-TYPE) drop
         old-definitions get first cardinality
-    ] with-compilation-unit
+    ] with-parsing
 ] unit-test
 
 ! make-callback-type
 { "what-type" } [
-    [ f void "what-type" { } { } make-callback-type ] with-compilation-unit
-    2drop name>>
+    { } [
+        void "what-type" f { } { } make-callback-type 2drop name>>
+    ] with-parsing
 ] unit-test
 
 { 0 } [
-    [
+    { } [
         "hello" current-vocab create-word
         old-definitions get first adjoin
-        f void "hello" { } { } make-callback-type 3drop
+        void "hello" f { } { } make-callback-type 3drop
         old-definitions get first cardinality
-    ] with-compilation-unit
+    ] with-parsing
+] unit-test
+
+! parse-enum-name
+{ t } [
+    { "ayae" } [ parse-enum-name new-definitions get first in? ] with-parsing
 ] unit-test
 
 TYPEDEF: char char2
index aff4ce00af0b8d7b58861c05d93fc9691fc63c04..2ada0714d80fc64e7c61fd08d1e4e17f42ffce71 100755 (executable)
@@ -145,16 +145,15 @@ PRIVATE>
 : callback-quot ( return types abi -- quot )
     '[ [ _ _ _ ] dip alien-callback ] ;
 
-:: make-callback-type ( lib return type-name types names -- word quot effect )
-    type-name (CREATE-C-TYPE) :> type-word
+:: make-callback-type ( return function library types names -- word quot effect )
+    function (CREATE-C-TYPE) :> type-word
     void* type-word typedef
     type-word names return function-effect "callback-effect" set-word-prop
-    type-word lib "callback-library" set-word-prop
-    type-word return types lib library-abi callback-quot ( quot -- alien ) ;
+    type-word library "callback-library" set-word-prop
+    type-word return types library library-abi callback-quot ( quot -- alien ) ;
 
 : (CALLBACK:) ( -- word quot effect )
-    current-library get
-    scan-function-name scan-c-args make-callback-type ;
+    (FUNCTION:) make-callback-type ;
 
 PREDICATE: alien-function-alias-word < word
     def>> {
index 6909285a57ecb0adacdfd102f9538d4e83f5ed25..c501958c9321f07e9a320f0cd1b88ed307e974c1 100644 (file)
@@ -180,9 +180,9 @@ M: type type>data-type
 
 : def-callback-type ( callback -- )
     {
-        [ drop current-library get ]
         [ return>> return-c-type ]
         [ c-type>> ]
+        [ drop current-library get ]
         [ ?suffix-parameters-with-error parameter-names&types ]
     } cleave make-callback-type define-inline ;
 
@@ -258,9 +258,9 @@ M: array-type field-type>c-type type>c-type ;
 
 :: def-signal ( signal type -- )
     signal {
-        [ drop current-library get ]
         [ return>> return-c-type ]
         [ type signal-name ]
+        [ drop current-library get ]
         [
             parameters>> type type>parameter prefix
             user-data-parameter suffix parameter-names&types