diff --git a/basis/alien/inline/inline.factor b/basis/alien/inline/inline.factor index d68f4fd32d..2514d30873 100644 --- a/basis/alien/inline/inline.factor +++ b/basis/alien/inline/inline.factor @@ -23,9 +23,6 @@ SYMBOL: c-strings CHAR: a swap length CHAR: a + [a,b] [ 1string ] map ; -: append-function-body ( prototype-str body -- str ) - [ swap % " {\n" % % "\n}\n" % ] "" make ; - : compile-library? ( -- ? ) c-library get library-path dup exists? [ file get [ @@ -44,6 +41,9 @@ SYMBOL: c-strings [ current-vocab name>> % "_" % % ] "" make ; PRIVATE> +: append-function-body ( prototype-str body -- str ) + [ swap % " {\n" % % "\n}\n" % ] "" make ; + : function-types-effect ( -- function types effect ) scan scan swap ")" parse-tokens [ "(" subseq? not ] filter swap parse-arglist ; @@ -56,7 +56,7 @@ PRIVATE> library-is-c++ get [ "extern \"C\" " prepend ] when ; : prototype-string' ( function types return -- str ) - [ dup arg-list ] c-function-string ; + [ dup arg-list ] prototype-string ; : factor-function ( function types effect -- word quot effect ) annotate-effect [ c-library get ] 3dip diff --git a/basis/alien/marshall/syntax/syntax.factor b/basis/alien/marshall/syntax/syntax.factor index c4011a2f77..822eb950e9 100644 --- a/basis/alien/marshall/syntax/syntax.factor +++ b/basis/alien/marshall/syntax/syntax.factor @@ -3,7 +3,7 @@ USING: accessors alien.inline alien.inline.types alien.marshall combinators effects generalizations kernel locals make namespaces quotations sequences words alien.marshall.structs lexer parser -vocabs.parser ; +vocabs.parser multiline ; IN: alien.marshall.syntax :: marshalled-function ( function types effect -- word quot effect ) @@ -22,16 +22,21 @@ IN: alien.marshall.syntax ] [ ] make ] dip ; -: define-c-marshalled ( function types effect -- ) - [ marshalled-function define-declared ] 3keep - c-function-string c-strings get push ; +: define-c-marshalled ( function types effect body -- ) + [ + [ marshalled-function define-declared ] + [ prototype-string ] 3bi + ] dip append-function-body c-strings get push ; -: define-c-marshalled' ( function effect -- ) - [ in>> ] keep [ marshalled-function define-declared ] 3keep - out>> c-function-string' c-strings get push ; +: define-c-marshalled' ( function effect body -- ) + [ + [ in>> ] keep + [ marshalled-function define-declared ] + [ out>> prototype-string' ] 3bi + ] dip append-function-body c-strings get push ; SYNTAX: CM-FUNCTION: - function-types-effect define-c-marshalled ; + function-types-effect parse-here define-c-marshalled ; SYNTAX: M-FUNCTION: function-types-effect marshalled-function define-declared ; @@ -42,4 +47,4 @@ SYNTAX: M-STRUCTURE: SYNTAX: CM-STRUCTURE: scan current-vocab parse-definition - [ define-marshalled-struct ] [ define-c-struct ] 3bi ; + [ define-marshalled-struct ] [ nip define-c-struct ] 3bi ;