alien.inline: made define-c-function and define-c-function' standalone
							parent
							
								
									59f0dbb516
								
							
						
					
					
						commit
						2e7f337b3d
					
				| 
						 | 
				
			
			@ -39,8 +39,8 @@ SYMBOL: c-strings
 | 
			
		|||
: prototype-string' ( function types return -- str )
 | 
			
		||||
    [ dup arg-list ] <effect> 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 ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue