]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of factorcode.org:/git/factor
authorJoe Groff <arcata@gmail.com>
Sun, 28 Aug 2011 00:04:43 +0000 (17:04 -0700)
committerJoe Groff <arcata@gmail.com>
Sun, 28 Aug 2011 00:04:43 +0000 (17:04 -0700)
basis/bit-arrays/bit-arrays-tests.factor
basis/bit-arrays/bit-arrays.factor
basis/nibble-arrays/nibble-arrays-tests.factor
basis/nibble-arrays/nibble-arrays.factor
extra/graphviz/ffi/ffi.factor
extra/graphviz/render/render.factor

index 46089e3f7b97d90cfe089cfe36b6198b75e045bc..3e9daa291d8b368ff63f826dbdda4ce8b83177e6 100644 (file)
@@ -2,6 +2,8 @@ USING: alien sequences sequences.private arrays bit-arrays kernel
 tools.test math random ;
 IN: bit-arrays.tests
 
+[ -1 <bit-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
+
 [ 100 ] [ 100 <bit-array> length ] unit-test
 
 [
index ade7d8ddac0f399c765920b7c8349625a725a6fa..6097bed4f91f4907f2370e75b873f85657a8f815 100644 (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.
 USING: alien alien.data accessors io.binary math math.bitwise
 alien.accessors kernel kernel.private sequences
@@ -41,8 +41,12 @@ TUPLE: bit-array
 
 PRIVATE>
 
+ERROR: bad-array-length n ;
+
 : <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
 
index 363f30678dadefff30c3522fda26915c563ce31d..92a38e509b87e67fbab630d9935ccf6d8659cb1c 100644 (file)
@@ -1,6 +1,8 @@
 USING: nibble-arrays tools.test sequences kernel math ;
 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
 [ 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
index 712b62f20b0bd248e1847c94b39fd69840aee9ee..0e7298165cdf6d0460d0135fbc3da0291d89ba7d 100644 (file)
@@ -30,7 +30,10 @@ CONSTANT: nibble BIN: 1111
 
 PRIVATE>
 
+ERROR: bad-array-length n ;
+
 : <nibble-array> ( n -- nibble-array )
+    dup 0 < [ bad-array-length ] when
     dup nibbles>bytes <byte-array> nibble-array boa ; inline
 
 M: nibble-array length length>> ;
index 2ec65cf7cab07ab0f8d41a1509d28945a082229c..50fccf0a1fb99387075416f0d2d796f46dd056b3 100644 (file)
@@ -3,12 +3,9 @@
 USING: accessors alien alien.c-types alien.destructors
 alien.libraries alien.syntax combinators debugger destructors
 fry io kernel literals math prettyprint sequences splitting
-system words.constant
-graphviz
-;
+system memoize graphviz ;
 IN: graphviz.ffi
 
-<<
 "libgraph" {
     { [ os macosx? ] [ "libgraph.dylib" ] }
     { [ os unix?   ] [ "libgraph.so"    ] }
@@ -21,7 +18,6 @@ IN: graphviz.ffi
     { [ os unix?   ] [ "libgvc.so"    ] }
     { [ os winnt?  ] [ "gvc.dll"      ] }
 } cond cdecl add-library
->>
 
 LIBRARY: libgraph
 
@@ -85,11 +81,7 @@ FUNCTION: int agsafeset ( void* obj,
 LIBRARY: libgvc
 
 ! 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
 
 FUNCTION: GVC_t* gvContext ( ) ;
@@ -112,7 +104,6 @@ M: ffi-errors error.
     int-gvFreeContext dup zero? [ drop ] [ ffi-errors ] if ;
 
 DESTRUCTOR: gvFreeContext
->>
 
 ! Layout
 
@@ -130,8 +121,6 @@ FUNCTION: int gvRenderFilename ( GVC_t* gvc,
 
 ! Supported layout engines (dot, neato, etc.) and output
 ! formats (png, jpg, etc.)
-
-<<
 <PRIVATE
 
 ENUM: api_t
@@ -152,7 +141,6 @@ FUNCTION: c-string
     ] with-destructors ;
 
 PRIVATE>
->>
 
-CONSTANT: supported-engines $[ API_layout plugin-list ]
-CONSTANT: supported-formats $[ API_device plugin-list ]
+MEMO: supported-engines ( -- seq ) API_layout plugin-list ;
+MEMO: supported-formats ( -- seq ) API_device plugin-list ;
index 0fd17a68b3a9f55a24e90c82bf264fbcff54e157..76857b1b85a65fb6c7268bc18add52cb6196c005 100644 (file)
@@ -1,11 +1,9 @@
 ! Copyright (C) 2011 Alex Vondrak.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators continuations destructors
-images.viewer io.backend io.files.unique kernel locals
-namespaces parser sequences summary unicode.case words
-graphviz.ffi
-graphviz.builder
-;
+USING: accessors combinators compiler.units continuations
+destructors images.viewer io.backend io.files.unique kernel
+locals namespaces parser sequences summary unicode.case words
+graphviz.ffi graphviz.builder ;
 IN: graphviz.render
 
 SYMBOL: default-layout
@@ -109,8 +107,6 @@ PRIVATE>
 : preview-window ( graph -- )
     (preview) image-window ; inline
 
-<<
-
 <PRIVATE
 
 : define-graphviz-by-engine ( -K -- )
@@ -130,7 +126,7 @@ 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