2 group [ first2 normalize-c-arg 2array ] map
unzip [ "," ?tail drop ] map
]
- [ dup "void" = [ drop { } ] [ 1array ] if ]
+ [ [ { } ] [ name>> 1array ] if-void ]
bi* <effect> ;
: function-quot ( return library function types -- quot )
'[ _ _ _ _ alien-invoke ] ;
:: make-function ( return library function parameters -- word quot effect )
- return function normalize-c-arg :> ( return-c-type function )
+ return function normalize-c-arg :> ( return function )
function create-in dup reset-generic
- return-c-type library function
+ return library function
parameters return parse-arglist [ function-quot ] dip ;
: parse-arg-tokens ( -- tokens )
make-function define-declared ;
: callback-quot ( return types abi -- quot )
- [ [ ] 3curry dip alien-callback ] 3curry ;
-
- : library-abi ( lib -- abi )
- library [ abi>> ] [ "cdecl" ] if* ;
+ '[ [ _ _ _ ] dip alien-callback ] ;
:: make-callback-type ( lib return type-name parameters -- word quot effect )
- return type-name normalize-c-arg :> ( return type-name )
+ return type-name normalize-c-arg :> ( return-c-type type-name )
type-name current-vocab create :> type-word
type-word [ reset-generic ] [ reset-c-type ] bi
void* type-word typedef
parameters return parse-arglist :> ( types callback-effect )
type-word callback-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 return-c-type types lib library-abi callback-quot (( quot -- alien )) ;
: (CALLBACK:) ( -- word quot effect )
"c-library" get
PREDICATE: alien-callback-type-word < typedef-word
"callback-effect" word-prop ;
-