Merge branch 'master' of factorcode.org:/git/factor

db4
Joe Groff 2011-08-27 17:04:43 -07:00
commit a67a59d5a1
6 changed files with 24 additions and 29 deletions

View File

@ -2,6 +2,8 @@ USING: alien sequences sequences.private arrays bit-arrays kernel
tools.test math random ; tools.test math random ;
IN: bit-arrays.tests IN: bit-arrays.tests
[ -1 <bit-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
[ 100 ] [ 100 <bit-array> length ] unit-test [ 100 ] [ 100 <bit-array> length ] unit-test
[ [

View File

@ -1,4 +1,4 @@
! Copyright (C) 2007, 2010 Slava Pestov. ! Copyright (C) 2007, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.data accessors io.binary math math.bitwise USING: alien alien.data accessors io.binary math math.bitwise
alien.accessors kernel kernel.private sequences alien.accessors kernel kernel.private sequences
@ -41,8 +41,12 @@ TUPLE: bit-array
PRIVATE> PRIVATE>
ERROR: bad-array-length n ;
: <bit-array> ( n -- bit-array ) : <bit-array> ( n -- bit-array )
dup bits>bytes <byte-array> bit-array boa ; inline dup 0 < [ bad-array-length ] when
dup bits>bytes <byte-array>
bit-array boa ; inline
M: bit-array length length>> ; inline M: bit-array length length>> ; inline

View File

@ -1,6 +1,8 @@
USING: nibble-arrays tools.test sequences kernel math ; USING: nibble-arrays tools.test sequences kernel math ;
IN: nibble-arrays.tests IN: nibble-arrays.tests
[ -1 <nibble-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
[ t ] [ 16 iota dup >nibble-array sequence= ] unit-test [ t ] [ 16 iota dup >nibble-array sequence= ] unit-test
[ N{ 4 2 1 3 } ] [ N{ 3 1 2 4 } reverse ] unit-test [ N{ 4 2 1 3 } ] [ N{ 3 1 2 4 } reverse ] unit-test
[ N{ 1 4 9 0 9 4 } ] [ N{ 1 2 3 4 5 6 } [ sq ] map ] unit-test [ N{ 1 4 9 0 9 4 } ] [ N{ 1 2 3 4 5 6 } [ sq ] map ] unit-test

View File

@ -30,7 +30,10 @@ CONSTANT: nibble BIN: 1111
PRIVATE> PRIVATE>
ERROR: bad-array-length n ;
: <nibble-array> ( n -- nibble-array ) : <nibble-array> ( n -- nibble-array )
dup 0 < [ bad-array-length ] when
dup nibbles>bytes <byte-array> nibble-array boa ; inline dup nibbles>bytes <byte-array> nibble-array boa ; inline
M: nibble-array length length>> ; M: nibble-array length length>> ;

View File

@ -3,12 +3,9 @@
USING: accessors alien alien.c-types alien.destructors USING: accessors alien alien.c-types alien.destructors
alien.libraries alien.syntax combinators debugger destructors alien.libraries alien.syntax combinators debugger destructors
fry io kernel literals math prettyprint sequences splitting fry io kernel literals math prettyprint sequences splitting
system words.constant system memoize graphviz ;
graphviz
;
IN: graphviz.ffi IN: graphviz.ffi
<<
"libgraph" { "libgraph" {
{ [ os macosx? ] [ "libgraph.dylib" ] } { [ os macosx? ] [ "libgraph.dylib" ] }
{ [ os unix? ] [ "libgraph.so" ] } { [ os unix? ] [ "libgraph.so" ] }
@ -21,7 +18,6 @@ IN: graphviz.ffi
{ [ os unix? ] [ "libgvc.so" ] } { [ os unix? ] [ "libgvc.so" ] }
{ [ os winnt? ] [ "gvc.dll" ] } { [ os winnt? ] [ "gvc.dll" ] }
} cond cdecl add-library } cond cdecl add-library
>>
LIBRARY: libgraph LIBRARY: libgraph
@ -85,11 +81,7 @@ FUNCTION: int agsafeset ( void* obj,
LIBRARY: libgvc LIBRARY: libgvc
! Graphviz contexts ! Graphviz contexts
! This must be wrapped in << >> so that GVC_t*, gvContext, and
! &gvFreeContext can be used to compute the supported-engines
! and supported-formats constants below.
<<
C-TYPE: GVC_t C-TYPE: GVC_t
FUNCTION: GVC_t* gvContext ( ) ; FUNCTION: GVC_t* gvContext ( ) ;
@ -112,7 +104,6 @@ M: ffi-errors error.
int-gvFreeContext dup zero? [ drop ] [ ffi-errors ] if ; int-gvFreeContext dup zero? [ drop ] [ ffi-errors ] if ;
DESTRUCTOR: gvFreeContext DESTRUCTOR: gvFreeContext
>>
! Layout ! Layout
@ -130,8 +121,6 @@ FUNCTION: int gvRenderFilename ( GVC_t* gvc,
! Supported layout engines (dot, neato, etc.) and output ! Supported layout engines (dot, neato, etc.) and output
! formats (png, jpg, etc.) ! formats (png, jpg, etc.)
<<
<PRIVATE <PRIVATE
ENUM: api_t ENUM: api_t
@ -152,7 +141,6 @@ FUNCTION: c-string
] with-destructors ; ] with-destructors ;
PRIVATE> PRIVATE>
>>
CONSTANT: supported-engines $[ API_layout plugin-list ] MEMO: supported-engines ( -- seq ) API_layout plugin-list ;
CONSTANT: supported-formats $[ API_device plugin-list ] MEMO: supported-formats ( -- seq ) API_device plugin-list ;

View File

@ -1,11 +1,9 @@
! Copyright (C) 2011 Alex Vondrak. ! Copyright (C) 2011 Alex Vondrak.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators continuations destructors USING: accessors combinators compiler.units continuations
images.viewer io.backend io.files.unique kernel locals destructors images.viewer io.backend io.files.unique kernel
namespaces parser sequences summary unicode.case words locals namespaces parser sequences summary unicode.case words
graphviz.ffi graphviz.ffi graphviz.builder ;
graphviz.builder
;
IN: graphviz.render IN: graphviz.render
SYMBOL: default-layout SYMBOL: default-layout
@ -109,8 +107,6 @@ PRIVATE>
: preview-window ( graph -- ) : preview-window ( graph -- )
(preview) image-window ; inline (preview) image-window ; inline
<<
<PRIVATE <PRIVATE
: define-graphviz-by-engine ( -K -- ) : define-graphviz-by-engine ( -K -- )
@ -130,7 +126,7 @@ PRIVATE>
PRIVATE> PRIVATE>
supported-engines [ define-graphviz-by-engine ] each [
supported-formats [ define-graphviz-by-format ] each supported-engines [ define-graphviz-by-engine ] each
supported-formats [ define-graphviz-by-format ] each
>> ] with-compilation-unit