From 2e7f337b3dd6d750f139b40d1dec871aa0220031 Mon Sep 17 00:00:00 2001 From: Jeremy Hughes Date: Fri, 10 Jul 2009 23:53:50 +1200 Subject: [PATCH] alien.inline: made define-c-function and define-c-function' standalone --- basis/alien/inline/inline.factor | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/basis/alien/inline/inline.factor b/basis/alien/inline/inline.factor index 20ccd43e5c..2c0825f8b4 100644 --- a/basis/alien/inline/inline.factor +++ b/basis/alien/inline/inline.factor @@ -39,8 +39,8 @@ SYMBOL: c-strings : prototype-string' ( function types return -- str ) [ dup arg-list ] prototype-string ; -: append-function-body ( prototype-str -- str ) - " {\n" append parse-here append "\n}\n" append ; +: append-function-body ( prototype-str body -- str ) + [ swap % " {\n" % % "\n}\n" % ] "" make ; : compile-library? ( -- ? ) c-library get library-path dup exists? [ @@ -69,14 +69,18 @@ PRIVATE> compile-library? [ compile-library ] when c-library get dup library-path "cdecl" add-library ; -: define-c-function ( function types effect -- ) - [ factor-function define-declared ] 3keep prototype-string - append-function-body c-strings get push ; +: define-c-function ( function types effect body -- ) + [ + [ factor-function define-declared ] + [ prototype-string ] 3bi + ] dip append-function-body c-strings get push ; -: define-c-function' ( function effect -- ) - [ in>> ] keep [ factor-function define-declared ] 3keep - out>> prototype-string' - append-function-body c-strings get push ; +: define-c-function' ( function effect body -- ) + [ + [ in>> ] keep + [ factor-function define-declared ] + [ out>> prototype-string' ] 3bi + ] dip append-function-body c-strings get push ; : define-c-link ( str -- ) "-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-FUNCTION: - function-types-effect define-c-function ; + function-types-effect parse-here define-c-function ; SYNTAX: C-TYPEDEF: scan scan define-c-typedef ;