alien.inline: added with-c-library word
							parent
							
								
									dc80d8575f
								
							
						
					
					
						commit
						4a5cb3aac3
					
				| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
! Copyright (C) 2009 Jeremy Hughes.
 | 
			
		||||
! See http://factorcode.org/license.txt for BSD license.
 | 
			
		||||
USING: help.markup help.syntax kernel strings effects ;
 | 
			
		||||
USING: help.markup help.syntax kernel strings effects quotations ;
 | 
			
		||||
IN: alien.inline
 | 
			
		||||
 | 
			
		||||
: $binding-note ( x -- )
 | 
			
		||||
| 
						 | 
				
			
			@ -198,6 +198,12 @@ HELP: delete-inline-library
 | 
			
		|||
{ $description "Delete the shared library file corresponding to " { $snippet "name" } "." }
 | 
			
		||||
{ $notes "Must be executed in the vocabulary where " { $snippet "name" } " is defined. " } ;
 | 
			
		||||
 | 
			
		||||
HELP: with-c-library
 | 
			
		||||
{ $values
 | 
			
		||||
    { "name" string } { "quot" quotation }
 | 
			
		||||
}
 | 
			
		||||
{ $description "Calls " { $link define-c-library } ", then the quotation, then " { $link compile-c-library } ", then sets all variables bound by " { $snippet "define-c-library" } " to " { $snippet "f" } "." } ;
 | 
			
		||||
 | 
			
		||||
ARTICLE: "alien.inline" "Inline C"
 | 
			
		||||
{ $vocab-link "alien.inline" }
 | 
			
		||||
;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ generalizations grouping io.directories io.files
 | 
			
		|||
io.files.info io.files.temp kernel lexer math math.order
 | 
			
		||||
math.ranges multiline namespaces sequences source-files
 | 
			
		||||
splitting strings system vocabs.loader vocabs.parser words
 | 
			
		||||
alien.c-types alien.structs make parser ;
 | 
			
		||||
alien.c-types alien.structs make parser continuations ;
 | 
			
		||||
IN: alien.inline
 | 
			
		||||
 | 
			
		||||
<PRIVATE
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +15,10 @@ SYMBOL: library-is-c++
 | 
			
		|||
SYMBOL: compiler-args
 | 
			
		||||
SYMBOL: c-strings
 | 
			
		||||
 | 
			
		||||
: cleanup-variables ( -- )
 | 
			
		||||
    { c-library library-is-c++ compiler-args c-strings }
 | 
			
		||||
    [ off ] each ;
 | 
			
		||||
 | 
			
		||||
: function-types-effect ( -- function types effect )
 | 
			
		||||
    scan scan swap ")" parse-tokens
 | 
			
		||||
    [ "(" subseq? not ] filter swap parse-arglist ;
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +118,10 @@ PRIVATE>
 | 
			
		|||
    c-library-name [ remove-library ]
 | 
			
		||||
    [ library-path dup exists? [ delete-file ] [ drop ] if ] bi ;
 | 
			
		||||
 | 
			
		||||
: with-c-library ( name quot -- )
 | 
			
		||||
    [ [ define-c-library ] dip call compile-c-library ]
 | 
			
		||||
    [ cleanup-variables ] [ ] cleanup ; inline
 | 
			
		||||
 | 
			
		||||
SYNTAX: C-LIBRARY: scan define-c-library ;
 | 
			
		||||
 | 
			
		||||
SYNTAX: COMPILE-AS-C++ t library-is-c++ set ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue