]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'inlinec' into marshall
authorJeremy Hughes <jedahu@gmail.com>
Sat, 11 Jul 2009 07:58:25 +0000 (19:58 +1200)
committerJeremy Hughes <jedahu@gmail.com>
Sat, 11 Jul 2009 07:58:25 +0000 (19:58 +1200)
* inlinec: (49 commits)
  alien.inline.compiler: documentation
  alien.inline.compiler: fixed library-path and made other words private
  alien.inline: renamed compiler-args to linker-args
  alien.inline: added with-c-library word
  alien.inline: added documentation
  alien.inline: better names
  alien.inline: remove vocab argument from define-c-struct
  alien.inline: made define-c-function and define-c-function' standalone
  alien.inline: fix library name and us remove-library
  alien.inline.compile: write library files to resource:alien-inline-libs
  Revert "Remove unused vocabulary" -- committed patch from the wrong machine
  Remove unused vocabulary
  Fixing some test failures after url.encoding change
  FUEL: Font lock/indentation for M::.
  replace 2array "." join with "." glue
  contributors: exclude merges to make patch counts more reasonable
  alien.libraries: add remove-library word, fix dlclose and dll-valid? VM primitives
  alien.libraries: add dispose method for library tuple, and remove-library word; add-library first calls remove-library to properly close the library when reloading
  changed single byte writes to write1
  removed usages of sprintf
  ...

Conflicts:
basis/alien/inline/compiler/compiler.factor
basis/alien/inline/inline.factor

1  2 
basis/alien/inline/inline.factor

index 7a2713767c48f1f55b277a063fa1d5154c644a29,1b1820779cd8d1f7af3468dd89a3ca4b398b1718..d68f4fd32d7f6d4bec502c122a62fc20006a1349
@@@ -6,21 -6,45 +6,25 @@@ generalizations grouping io.directorie
  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
  SYMBOL: c-library
  SYMBOL: library-is-c++
- SYMBOL: compiler-args
+ SYMBOL: linker-args
  SYMBOL: c-strings
  
 -: function-types-effect ( -- function types effect )
 -    scan scan swap ")" parse-tokens
 -    [ "(" subseq? not ] filter swap parse-arglist ;
 -
 +<PRIVATE
+ : cleanup-variables ( -- )
+     { c-library library-is-c++ linker-args c-strings }
+     [ off ] each ;
  : arg-list ( types -- params )
      CHAR: a swap length CHAR: a + [a,b]
      [ 1string ] map ;
  
- : append-function-body ( prototype-str -- str )
-     " {\n" append parse-here append "\n}\n" append ;
 -: factor-function ( function types effect -- word quot effect )
 -    annotate-effect [ c-library get ] 3dip
 -    [ [ factorize-type ] map ] dip
 -    types-effect>params-return factorize-type -roll
 -    concat make-function ;
 -
 -: prototype-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 ] <effect> prototype-string ;
 -
+ : append-function-body ( prototype-str body -- str )
+     [ swap % " {\n" % % "\n}\n" % ] "" make ;
  
  : compile-library? ( -- ? )
      c-library get library-path dup exists? [
  
  : compile-library ( -- )
      library-is-c++ get [ C++ ] [ C ] if
-     compiler-args get
+     linker-args get
      c-strings get "\n" join
      c-library get compile-to-library ;
+ : c-library-name ( name -- name' )
+     [ current-vocab name>> % "_" % % ] "" make ;
  PRIVATE>
  
- : c-function-string ( function types effect -- str )
 +: function-types-effect ( -- function types effect )
 +    scan scan swap ")" parse-tokens
 +    [ "(" subseq? not ] filter swap parse-arglist ;
 +
-     library-is-c++ get [ "extern \"C\" " prepend ] when
-     append-function-body ;
++: prototype-string ( function types effect -- str )
 +    [ [ cify-type ] map ] dip
 +    types-effect>params-return cify-type -rot
 +    [ " " join ] map ", " join
 +    "(" prepend ")" append 3array " " join
- : c-function-string' ( function types return -- str )
-     [ dup arg-list ] <effect> c-function-string
-     append-function-body ;
++    library-is-c++ get [ "extern \"C\" " prepend ] when ;
 +
++: prototype-string' ( function types return -- str )
++    [ dup arg-list ] <effect> c-function-string ;
 +
 +: factor-function ( function types effect -- word quot effect )
 +    annotate-effect [ c-library get ] 3dip
 +    [ [ factorize-type ] map ] dip
 +    types-effect>params-return factorize-type -roll
 +    concat make-function ;
 +
  : define-c-library ( name -- )
-     [ current-vocab name>> % "_" % % ] "" make c-library set
+     c-library-name c-library set
      V{ } clone c-strings set
-     V{ } clone compiler-args set ;
+     V{ } clone linker-args set ;
  
  : compile-c-library ( -- )
      compile-library? [ compile-library ] when