alien.inline: made define-c-function and define-c-function' standalone

db4
Jeremy Hughes 2009-07-10 23:53:50 +12:00
parent 59f0dbb516
commit 2e7f337b3d
1 changed files with 14 additions and 10 deletions

View File

@ -39,8 +39,8 @@ SYMBOL: c-strings
: prototype-string' ( function types return -- str ) : prototype-string' ( function types return -- str )
[ dup arg-list ] <effect> prototype-string ; [ dup arg-list ] <effect> prototype-string ;
: append-function-body ( prototype-str -- str ) : append-function-body ( prototype-str body -- str )
" {\n" append parse-here append "\n}\n" append ; [ swap % " {\n" % % "\n}\n" % ] "" make ;
: compile-library? ( -- ? ) : compile-library? ( -- ? )
c-library get library-path dup exists? [ c-library get library-path dup exists? [
@ -69,14 +69,18 @@ PRIVATE>
compile-library? [ compile-library ] when compile-library? [ compile-library ] when
c-library get dup library-path "cdecl" add-library ; c-library get dup library-path "cdecl" add-library ;
: define-c-function ( function types effect -- ) : define-c-function ( function types effect body -- )
[ factor-function define-declared ] 3keep prototype-string [
append-function-body c-strings get push ; [ factor-function define-declared ]
[ prototype-string ] 3bi
] dip append-function-body c-strings get push ;
: define-c-function' ( function effect -- ) : define-c-function' ( function effect body -- )
[ in>> ] keep [ factor-function define-declared ] 3keep [
out>> prototype-string' [ in>> ] keep
append-function-body c-strings get push ; [ factor-function define-declared ]
[ out>> prototype-string' ] 3bi
] dip append-function-body c-strings get push ;
: define-c-link ( str -- ) : define-c-link ( str -- )
"-l" prepend compiler-args get push ; "-l" prepend compiler-args get push ;
@ -123,7 +127,7 @@ SYNTAX: C-LINK/FRAMEWORK: scan define-c-link/framework ;
SYNTAX: C-INCLUDE: scan define-c-include ; SYNTAX: C-INCLUDE: scan define-c-include ;
SYNTAX: C-FUNCTION: SYNTAX: C-FUNCTION:
function-types-effect define-c-function ; function-types-effect parse-here define-c-function ;
SYNTAX: C-TYPEDEF: scan scan define-c-typedef ; SYNTAX: C-TYPEDEF: scan scan define-c-typedef ;