From 7ecadf0a6813526628f0d50498c9f2b5ef5155de Mon Sep 17 00:00:00 2001 From: Jeremy Hughes Date: Mon, 6 Jul 2009 11:28:41 +1200 Subject: [PATCH] alien.inline: renamed and refactored prototype-string --- basis/alien/inline/inline.factor | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/basis/alien/inline/inline.factor b/basis/alien/inline/inline.factor index 8337c44649..9669387040 100644 --- a/basis/alien/inline/inline.factor +++ b/basis/alien/inline/inline.factor @@ -40,19 +40,20 @@ SYMBOL: c-strings 7 narray >quotation ] dip ; -: prototype-string ( function types effect -- str ) +: append-function-body ( prototype-str -- str ) + " {\n" append parse-here append "\n}\n" append ; + +: c-function-string ( function types effect -- str ) [ [ cify-type ] map ] dip types-effect>params-return cify-type -rot [ " " join ] map ", " join "(" prepend ")" append 3array " " join - library-is-c++ get [ "extern \"C\" " prepend ] when ; - -: 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 ; + library-is-c++ get [ "extern \"C\" " prepend ] when + append-function-body ; +: c-function-string' ( function types return -- str ) + [ dup arg-list ] c-function-string + append-function-body ; : library-path ( -- str ) "lib" c-library get library-suffix @@ -81,23 +82,20 @@ PRIVATE> c-library get 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 ; + [ factor-function define-declared ] 3keep + c-function-string 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 ; + out>> c-function-string' c-strings get push ; : define-c-marshalled ( function types effect -- ) [ marshalled-function define-declared ] 3keep - prototype-string - append-function-body c-strings get push ; + c-function-string c-strings get push ; : define-c-marshalled' ( function effect -- ) [ in>> ] keep [ marshalled-function define-declared ] 3keep - out>> prototype-string' - append-function-body c-strings get push ; + out>> c-function-string' c-strings get push ; : define-c-link ( str -- ) "-l" prepend compiler-args get push ;