alien.inline.*: fixed merge breakage
parent
579aba5625
commit
11183fa5db
|
@ -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 ] <effect> c-function-string ;
|
||||
[ dup arg-list ] <effect> prototype-string ;
|
||||
|
||||
: factor-function ( function types effect -- word quot effect )
|
||||
annotate-effect [ c-library get ] 3dip
|
||||
|
|
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue