]> gitweb.factorcode.org Git - factor.git/commitdiff
Specialized array overhaul
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 10 Sep 2009 03:33:34 +0000 (22:33 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 10 Sep 2009 03:33:34 +0000 (22:33 -0500)
- Replace hand-written specialized-arrays.* subvocabularies with new system; instead of USE:ing specialized-arrays.T, do SPECIALIZED-ARRAY: T
- Ditto for specialized-vectors; use SPECIALIZED-VECTOR:
- io.mmap.functor: removed entirely, use <mapped-array> instead
- struct-arrays and struct-vectors have been removed because specialized arrays and vectors subsume them entirely

172 files changed:
basis/alien/c-types/c-types-docs.factor
basis/alien/c-types/c-types.factor
basis/alien/complex/functor/functor.factor
basis/alien/structs/structs.factor
basis/bootstrap/compiler/timing/tags.txt [new file with mode: 0644]
basis/checksums/md5/md5.factor
basis/classes/struct/struct-tests.factor
basis/classes/struct/struct.factor
basis/cocoa/messages/messages.factor
basis/compiler/tests/alien.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/core-foundation/dictionaries/dictionaries.factor
basis/core-foundation/fsevents/fsevents.factor
basis/db/postgresql/lib/lib.factor
basis/game-input/dinput/dinput.factor
basis/images/bitmap/bitmap.factor
basis/images/bitmap/loading/loading.factor
basis/images/tiff/tiff.factor
basis/io/backend/unix/multiplexers/epoll/epoll.factor
basis/io/backend/unix/multiplexers/kqueue/kqueue.factor
basis/io/files/info/unix/freebsd/freebsd.factor
basis/io/files/info/unix/macosx/macosx.factor
basis/io/files/info/unix/netbsd/netbsd.factor
basis/io/files/info/unix/openbsd/openbsd.factor
basis/io/files/info/unix/unix.factor
basis/io/files/info/windows/windows.factor
basis/io/files/windows/nt/nt.factor
basis/io/launcher/windows/windows.factor
basis/io/mmap/alien/alien.factor [deleted file]
basis/io/mmap/bool/bool.factor [deleted file]
basis/io/mmap/char/char.factor [deleted file]
basis/io/mmap/double/double.factor [deleted file]
basis/io/mmap/float/float.factor [deleted file]
basis/io/mmap/functor/functor.factor [deleted file]
basis/io/mmap/int/int.factor [deleted file]
basis/io/mmap/long/long.factor [deleted file]
basis/io/mmap/longlong/longlong.factor [deleted file]
basis/io/mmap/mmap-tests.factor
basis/io/mmap/mmap.factor
basis/io/mmap/short/short.factor [deleted file]
basis/io/mmap/uchar/uchar.factor [deleted file]
basis/io/mmap/uint/uint.factor [deleted file]
basis/io/mmap/ulong/ulong.factor [deleted file]
basis/io/mmap/ulonglong/ulonglong.factor [deleted file]
basis/io/mmap/ushort/ushort.factor [deleted file]
basis/io/pipes/unix/unix.factor
basis/math/blas/matrices/matrices.factor
basis/math/blas/vectors/vectors.factor
basis/math/vectors/simd/alien/alien-tests.factor
basis/math/vectors/specialization/specialization-tests.factor
basis/math/vectors/specialization/specialization.factor
basis/opengl/opengl.factor
basis/opengl/shaders/shaders.factor
basis/opengl/textures/textures.factor
basis/random/mersenne-twister/mersenne-twister.factor
basis/sequences/complex/complex-docs.factor
basis/sequences/complex/complex-tests.factor
basis/serialize/serialize-tests.factor
basis/specialized-arrays/alien/alien.factor [deleted file]
basis/specialized-arrays/bool/bool.factor [deleted file]
basis/specialized-arrays/char/char.factor [deleted file]
basis/specialized-arrays/complex-double/complex-double-tests.factor [deleted file]
basis/specialized-arrays/complex-double/complex-double.factor [deleted file]
basis/specialized-arrays/complex-float/complex-float.factor [deleted file]
basis/specialized-arrays/double/double.factor [deleted file]
basis/specialized-arrays/float/float.factor [deleted file]
basis/specialized-arrays/functor/functor.factor [deleted file]
basis/specialized-arrays/functor/summary.txt [deleted file]
basis/specialized-arrays/int/int.factor [deleted file]
basis/specialized-arrays/long/long.factor [deleted file]
basis/specialized-arrays/longlong/longlong.factor [deleted file]
basis/specialized-arrays/ptrdiff_t/ptrdiff_t.factor [deleted file]
basis/specialized-arrays/short/short.factor [deleted file]
basis/specialized-arrays/specialized-arrays-docs.factor
basis/specialized-arrays/specialized-arrays-tests.factor
basis/specialized-arrays/specialized-arrays.factor
basis/specialized-arrays/uchar/uchar.factor [deleted file]
basis/specialized-arrays/uint/uint.factor [deleted file]
basis/specialized-arrays/ulong/ulong.factor [deleted file]
basis/specialized-arrays/ulonglong/ulonglong.factor [deleted file]
basis/specialized-arrays/ushort/ushort.factor [deleted file]
basis/specialized-vectors/alien/alien.factor [deleted file]
basis/specialized-vectors/bool/bool.factor [deleted file]
basis/specialized-vectors/char/char.factor [deleted file]
basis/specialized-vectors/double/double.factor [deleted file]
basis/specialized-vectors/float/float.factor [deleted file]
basis/specialized-vectors/functor/functor.factor [deleted file]
basis/specialized-vectors/functor/summary.txt [deleted file]
basis/specialized-vectors/int/int.factor [deleted file]
basis/specialized-vectors/long/long.factor [deleted file]
basis/specialized-vectors/longlong/longlong.factor [deleted file]
basis/specialized-vectors/short/short.factor [deleted file]
basis/specialized-vectors/specialized-vectors-docs.factor
basis/specialized-vectors/specialized-vectors-tests.factor
basis/specialized-vectors/specialized-vectors.factor
basis/specialized-vectors/uchar/uchar.factor [deleted file]
basis/specialized-vectors/uint/uint.factor [deleted file]
basis/specialized-vectors/ulong/ulong.factor [deleted file]
basis/specialized-vectors/ulonglong/ulonglong.factor [deleted file]
basis/specialized-vectors/ushort/ushort.factor [deleted file]
basis/struct-arrays/authors.txt [deleted file]
basis/struct-arrays/prettyprint/prettyprint.factor [deleted file]
basis/struct-arrays/struct-arrays-docs.factor [deleted file]
basis/struct-arrays/struct-arrays-tests.factor [deleted file]
basis/struct-arrays/struct-arrays.factor [deleted file]
basis/struct-arrays/summary.txt [deleted file]
basis/struct-arrays/tags.txt [deleted file]
basis/struct-vectors/struct-vectors-docs.factor [deleted file]
basis/struct-vectors/struct-vectors-tests.factor [deleted file]
basis/struct-vectors/struct-vectors.factor [deleted file]
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/shaker/strip-struct-arrays.factor [deleted file]
basis/ui/backend/windows/windows.factor
basis/ui/pens/gradient/gradient.factor
basis/ui/pens/polygon/polygon.factor
basis/ui/pixel-formats/pixel-formats.factor
basis/unix/utilities/utilities.factor
basis/windows/com/wrapper/wrapper.factor
basis/windows/dinput/constants/constants.factor
basis/windows/ole32/ole32-tests.factor
basis/windows/ole32/ole32.factor
basis/windows/shell32/shell32.factor
basis/x11/clipboard/clipboard.factor
basis/x11/glx/glx.factor
basis/x11/xim/xim.factor
core/assocs/assocs-tests.factor
core/generic/single/single-tests.factor
core/vocabs/parser/parser.factor
extra/alien/marshall/marshall.factor
extra/alien/marshall/private/private.factor
extra/benchmark/dawes/dawes.factor
extra/benchmark/dispatch2/dispatch2.factor
extra/benchmark/dispatch3/dispatch3.factor
extra/benchmark/fasta/fasta.factor
extra/benchmark/nbody-simd/nbody-simd.factor
extra/benchmark/nbody/nbody.factor
extra/benchmark/raytracer-simd/authors.txt [new file with mode: 0644]
extra/benchmark/raytracer-simd/raytracer-simd.factor [new file with mode: 0644]
extra/benchmark/raytracer/raytracer.factor
extra/benchmark/simd-1/authors.txt [new file with mode: 0644]
extra/benchmark/simd-1/simd-1.factor [new file with mode: 0644]
extra/benchmark/spectral-norm/spectral-norm.factor
extra/benchmark/struct-arrays/struct-arrays.factor
extra/bunny/fixed-pipeline/fixed-pipeline.factor
extra/bunny/model/model.factor
extra/gpu/demos/bunny/bunny.factor
extra/gpu/demos/bunny/deploy.factor [new file with mode: 0644]
extra/gpu/framebuffers/framebuffers.factor
extra/gpu/render/render-docs.factor
extra/gpu/render/render.factor
extra/gpu/shaders/shaders.factor
extra/gpu/state/state.factor
extra/gpu/textures/textures.factor
extra/gpu/util/util.factor
extra/gpu/util/wasd/wasd.factor
extra/grid-meshes/grid-meshes.factor
extra/half-floats/half-floats-tests.factor
extra/half-floats/half-floats.factor
extra/id3/id3.factor
extra/images/normalization/normalization.factor
extra/jamshred/gl/gl.factor
extra/jamshred/player/player.factor
extra/jamshred/tunnel/tunnel-tests.factor
extra/jamshred/tunnel/tunnel.factor
extra/llvm/invoker/invoker.factor
extra/llvm/types/types.factor
extra/nurbs/nurbs.factor
extra/openal/openal.factor
extra/synth/buffers/buffers.factor
extra/system-info/linux/linux.factor
extra/system-info/windows/windows.factor
extra/terrain/terrain.factor

index 3a7c3a74051f466fe4700695d89de21fc1c5e66b..d9e1f7124accd7a86747cd7cc214bf21fd0bf11a 100755 (executable)
@@ -51,7 +51,7 @@ HELP: c-setter
 HELP: <c-array>
 { $values { "len" "a non-negative integer" } { "c-type" "a C type" } { "array" byte-array } }
 { $description "Creates a byte array large enough to hold " { $snippet "n" } " values of a C type." }
-{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, a " { $link specialized-array-vocab-not-loaded } " error will be thrown. The vocabulary can be loaded with a " { $link POSTPONE: USING: } " form as usual, or with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary set for details on the underlying sequence type constructed." }
+{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. The vocabulary can be loaded with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." }
 { $errors "Throws an error if the type does not exist, the necessary specialized array vocabulary is not loaded, or the requested size is negative." } ;
 
 HELP: <c-object>
@@ -73,7 +73,7 @@ HELP: byte-array>memory
 HELP: malloc-array
 { $values { "n" "a non-negative integer" } { "type" "a C type" } { "alien" alien } }
 { $description "Allocates an unmanaged memory block large enough to hold " { $snippet "n" } " values of a C type, then wraps the memory in a sequence object using " { $link <c-direct-array> } "." }
-{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, a " { $link specialized-array-vocab-not-loaded } " error will be thrown. The vocabulary can be loaded with a " { $link POSTPONE: USING: } " form as usual, or with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary set for details on the underlying sequence type constructed." }
+{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. The vocabulary can be loaded with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." }
 { $warning "Don't forget to deallocate the memory with a call to " { $link free } "." }
 { $errors "Throws an error if the type does not exist, if the requested size is negative, if a direct specialized array class appropriate to the type is not loaded, or if memory allocation fails." } ;
 
@@ -132,13 +132,13 @@ HELP: malloc-string
 
 HELP: require-c-array
 { $values { "c-type" "a C type" } }
-{ $description { $link require } "s any unloaded vocabularies needed to construct a specialized array of " { $snippet "c-type" } " using the " { $link <c-array> } " or " { $link <c-direct-array> } " vocabularies." }
-{ $notes "This word must be called inside a compilation unit. See the " { $vocab-link "specialized-arrays" } " vocabulary set for details on the underlying sequence types loaded." } ;
+{ $description "Generates a specialized array of " { $snippet "c-type" } " using the " { $link <c-array> } " or " { $link <c-direct-array> } " vocabularies." }
+{ $notes "This word must be called inside a compilation unit. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence types loaded." } ;
 
 HELP: <c-direct-array>
 { $values { "alien" c-ptr } { "len" integer } { "c-type" "a C type" } { "array" "a specialized direct array" } }
 { $description "Constructs a new specialized array of length " { $snippet "len" } " and element type " { $snippet "c-type" } " over the range of memory referenced by " { $snippet "alien" } "." }
-{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, a " { $link specialized-array-vocab-not-loaded } " error will be thrown. The vocabulary can be loaded with a " { $link POSTPONE: USING: } " form as usual, or with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary set for details on the underlying sequence type constructed." } ;
+{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. The vocabulary can be loaded with the " { $link require-c-array } " word. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." } ;
 
 ARTICLE: "c-strings" "C strings"
 "C string types are arrays with shape " { $snippet "{ \"char*\" encoding }" } ", where " { $snippet "encoding" } " is an encoding descriptor. The type " { $snippet "\"char*\"" } " is an alias for " { $snippet "{ \"char*\" utf8 }" } ". See " { $link "encodings-descriptors" } " for information about encoding descriptors."
index aa2ac2f93d6c6a4eb1a2693e76f30a7145a372eb..b177ab35d4e09b22dbfdc8663570ba82535cfea7 100755 (executable)
@@ -21,11 +21,7 @@ TUPLE: abstract-c-type
 { getter callable }
 { setter callable }
 size
-align
-array-class
-array-constructor
-(array)-constructor
-direct-array-constructor ;
+align ;
 
 TUPLE: c-type < abstract-c-type
 boxer
@@ -75,9 +71,6 @@ M: string c-type ( name -- type )
         ] ?if
     ] if ;
 
-: ?require-word ( word/pair -- )
-    dup word? [ drop ] [ first require ] ?if ;
-
 ! These words being foldable means that words need to be
 ! recompiled if a C type is redefined. Even so, folding the
 ! size facilitates some optimizations.
@@ -89,55 +82,28 @@ M: abstract-c-type heap-size size>> ;
 
 GENERIC: require-c-array ( c-type -- )
 
-M: object require-c-array
-    drop ;
-
-M: c-type require-c-array
-    array-class>> ?require-word ;
-
-M: string require-c-array
-    c-type require-c-array ;
-
-M: array require-c-array
-    first c-type require-c-array ;
-
-ERROR: specialized-array-vocab-not-loaded vocab word ;
+M: array require-c-array first require-c-array ;
 
-: c-array-constructor ( c-type -- word )
-    array-constructor>> dup array?
-    [ first2 specialized-array-vocab-not-loaded ] when ; foldable
+GENERIC: c-array-constructor ( c-type -- word )
 
-: c-(array)-constructor ( c-type -- word )
-    (array)-constructor>> dup array?
-    [ first2 specialized-array-vocab-not-loaded ] when ; foldable
+GENERIC: c-(array)-constructor ( c-type -- word )
 
-: c-direct-array-constructor ( c-type -- word )
-    direct-array-constructor>> dup array?
-    [ first2 specialized-array-vocab-not-loaded ] when ; foldable
+GENERIC: c-direct-array-constructor ( c-type -- word )
 
 GENERIC: <c-array> ( len c-type -- array )
-M: object <c-array>
-    c-array-constructor execute( len -- array ) ; inline
+
 M: string <c-array>
-    c-type <c-array> ; inline
-M: array <c-array>
-    first c-type <c-array> ; inline
+    c-array-constructor execute( len -- array ) ; inline
 
 GENERIC: (c-array) ( len c-type -- array )
-M: object (c-array)
-    c-(array)-constructor execute( len -- array ) ; inline
+
 M: string (c-array)
-    c-type (c-array) ; inline
-M: array (c-array)
-    first c-type (c-array) ; inline
+    c-(array)-constructor execute( len -- array ) ; inline
 
 GENERIC: <c-direct-array> ( alien len c-type -- array )
-M: object <c-direct-array>
-    c-direct-array-constructor execute( alien len -- array ) ; inline
+
 M: string <c-direct-array>
-    c-type <c-direct-array> ; inline
-M: array <c-direct-array>
-    first c-type <c-direct-array> ; inline
+    c-direct-array-constructor execute( alien len -- array ) ; inline
 
 : malloc-array ( n type -- alien )
     [ heap-size calloc ] [ <c-direct-array> ] 2bi ; inline
@@ -347,32 +313,6 @@ M: long-long-type box-return ( type -- )
 : if-void ( type true false -- )
     pick "void" = [ drop nip call ] [ nip call ] if ; inline
 
-: ?lookup ( vocab word -- word/pair )
-    over vocab [ swap lookup ] [ 2array ] if ;
-
-: set-array-class* ( c-type vocab-stem type-stem -- c-type )
-    {
-        [
-            [ "specialized-arrays." prepend ]
-            [ "-array" append ] bi* ?lookup >>array-class
-        ]
-        [
-            [ "specialized-arrays." prepend ]
-            [ "<" "-array>" surround ] bi* ?lookup >>array-constructor
-        ]
-        [
-            [ "specialized-arrays." prepend ]
-            [ "(" "-array)" surround ] bi* ?lookup >>(array)-constructor
-        ]
-        [
-            [ "specialized-arrays." prepend ]
-            [ "<direct-" "-array>" surround ] bi* ?lookup >>direct-array-constructor
-        ]
-    } 2cleave ;
-
-: set-array-class ( c-type stem -- c-type )
-    dup set-array-class* ;
-
 CONSTANT: primitive-types
     {
         "char" "uchar"
@@ -395,7 +335,6 @@ CONSTANT: primitive-types
         [ >c-ptr ] >>unboxer-quot
         "box_alien" >>boxer
         "alien_offset" >>unboxer
-        "alien" "void*" set-array-class*
     "void*" define-primitive-type
 
     <long-long-type>
@@ -407,7 +346,6 @@ CONSTANT: primitive-types
         8 >>align
         "box_signed_8" >>boxer
         "to_signed_8" >>unboxer
-        "longlong" set-array-class
     "longlong" define-primitive-type
 
     <long-long-type>
@@ -419,7 +357,6 @@ CONSTANT: primitive-types
         8 >>align
         "box_unsigned_8" >>boxer
         "to_unsigned_8" >>unboxer
-        "ulonglong" set-array-class
     "ulonglong" define-primitive-type
 
     <c-type>
@@ -431,7 +368,6 @@ CONSTANT: primitive-types
         bootstrap-cell >>align
         "box_signed_cell" >>boxer
         "to_fixnum" >>unboxer
-        "long" set-array-class
     "long" define-primitive-type
 
     <c-type>
@@ -443,7 +379,6 @@ CONSTANT: primitive-types
         bootstrap-cell >>align
         "box_unsigned_cell" >>boxer
         "to_cell" >>unboxer
-        "ulong" set-array-class
     "ulong" define-primitive-type
 
     <c-type>
@@ -455,7 +390,6 @@ CONSTANT: primitive-types
         4 >>align
         "box_signed_4" >>boxer
         "to_fixnum" >>unboxer
-        "int" set-array-class
     "int" define-primitive-type
 
     <c-type>
@@ -467,7 +401,6 @@ CONSTANT: primitive-types
         4 >>align
         "box_unsigned_4" >>boxer
         "to_cell" >>unboxer
-        "uint" set-array-class
     "uint" define-primitive-type
 
     <c-type>
@@ -479,7 +412,6 @@ CONSTANT: primitive-types
         2 >>align
         "box_signed_2" >>boxer
         "to_fixnum" >>unboxer
-        "short" set-array-class
     "short" define-primitive-type
 
     <c-type>
@@ -491,7 +423,6 @@ CONSTANT: primitive-types
         2 >>align
         "box_unsigned_2" >>boxer
         "to_cell" >>unboxer
-        "ushort" set-array-class
     "ushort" define-primitive-type
 
     <c-type>
@@ -503,7 +434,6 @@ CONSTANT: primitive-types
         1 >>align
         "box_signed_1" >>boxer
         "to_fixnum" >>unboxer
-        "char" set-array-class
     "char" define-primitive-type
 
     <c-type>
@@ -515,7 +445,6 @@ CONSTANT: primitive-types
         1 >>align
         "box_unsigned_1" >>boxer
         "to_cell" >>unboxer
-        "uchar" set-array-class
     "uchar" define-primitive-type
 
     <c-type>
@@ -525,7 +454,6 @@ CONSTANT: primitive-types
         1 >>align
         "box_boolean" >>boxer
         "to_boolean" >>unboxer
-        "bool" set-array-class
     "bool" define-primitive-type
 
     <c-type>
@@ -539,7 +467,6 @@ CONSTANT: primitive-types
         "to_float" >>unboxer
         float-rep >>rep
         [ >float ] >>unboxer-quot
-        "float" set-array-class
     "float" define-primitive-type
 
     <c-type>
@@ -553,7 +480,6 @@ CONSTANT: primitive-types
         "to_double" >>unboxer
         double-rep >>rep
         [ >float ] >>unboxer-quot
-        "double" set-array-class
     "double" define-primitive-type
 
     "long" "ptrdiff_t" typedef
index b05059e9cbff1ae5dd8760023a3c13ba57510f45..b1f9c2be850fa808f2e3ebaf6a951b70b58eb314 100644 (file)
@@ -26,7 +26,6 @@ T-class c-type
 <T> 1quotation >>unboxer-quot
 *T 1quotation >>boxer-quot
 number >>boxed-class
-T set-array-class
 drop
 
 ;FUNCTOR
index 05558040e8d55023ebb7db494f25a3e6b6e40118..a80adf5137814976f8d41bee8ac6a89ea1c30861 100755 (executable)
@@ -66,4 +66,4 @@ M: struct-type stack-size
     [ name>> = ] with find nip offset>> ;
 
 USE: vocabs.loader
-"struct-arrays" require
+"specialized-arrays" require
diff --git a/basis/bootstrap/compiler/timing/tags.txt b/basis/bootstrap/compiler/timing/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index d59976fb7e48b5daecb2e6fdbbe3b730780a7728..a2b6d4fd79e49b0bbe80489ac220500f29cb605a 100644 (file)
@@ -5,7 +5,8 @@ math.functions math.parser namespaces splitting grouping strings
 sequences byte-arrays locals sequences.private macros fry
 io.encodings.binary math.bitwise checksums accessors
 checksums.common checksums.stream combinators combinators.smart
-specialized-arrays.uint literals hints ;
+specialized-arrays literals hints ;
+SPECIALIZED-ARRAY: uint
 IN: checksums.md5
 
 SINGLETON: md5
index d76013e138ca7ee8308a2db65e1a75ff11cbe8a4..22d194d2a4983a390404d2ff0e9c94948db85221 100755 (executable)
@@ -5,9 +5,11 @@ classes.struct classes.tuple.private combinators
 compiler.tree.debugger compiler.units destructors
 io.encodings.utf8 io.pathnames io.streams.string kernel libc
 literals math mirrors multiline namespaces prettyprint
-prettyprint.config see sequences specialized-arrays.char
-specialized-arrays.int specialized-arrays.ushort
-struct-arrays system tools.test ;
+prettyprint.config see sequences specialized-arrays
+system tools.test ;
+SPECIALIZED-ARRAY: char
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: ushort
 IN: classes.struct.tests
 
 <<
@@ -301,9 +303,11 @@ STRUCT: struct-test-array-slots
 STRUCT: struct-test-optimization
     { x { "int" 3 } } { y int } ;
 
+SPECIALIZED-ARRAY: struct-test-optimization
+
 [ t ] [ [ struct-test-optimization memory>struct y>> ] { memory>struct y>> } inlined? ] unit-test
 [ t ] [
-    [ 3 struct-test-optimization <direct-struct-array> third y>> ]
+    [ 3 <direct-struct-test-optimization-array> third y>> ]
     { <tuple> <tuple-boa> memory>struct y>> } inlined?
 ] unit-test
 
index dc7fa965db490b56598e0eba39cb84965dba7442..24d7e592bdab89ebcbaf086883f114225454a3c1 100755 (executable)
@@ -4,13 +4,14 @@ alien.structs.fields arrays byte-arrays classes classes.parser
 classes.tuple classes.tuple.parser classes.tuple.private
 combinators combinators.short-circuit combinators.smart
 definitions functors.backend fry generalizations generic.parser
-kernel kernel.private lexer libc locals macros make math math.order
-parser quotations sequences slots slots.private struct-arrays vectors
-words compiler.tree.propagation.transforms specialized-arrays.uchar ;
+kernel kernel.private lexer libc locals macros make math
+math.order parser quotations sequences slots slots.private
+specialized-arrays vectors words
+compiler.tree.propagation.transforms ;
 FROM: slots => reader-word writer-word ;
 IN: classes.struct
 
-! struct class
+SPECIALIZED-ARRAY: uchar
 
 ERROR: struct-must-have-slots ;
 
index 7342451c386bb693806d177b414236b9619b49b3..c0d8939a7adc7d9e87d7131ab4cc9668fe078546 100755 (executable)
@@ -5,9 +5,11 @@ classes.struct continuations combinators compiler compiler.alien
 stack-checker kernel math namespaces make quotations sequences
 strings words cocoa.runtime io macros memoize io.encodings.utf8
 effects libc libc.private lexer init core-foundation fry
-generalizations specialized-arrays.alien ;
+generalizations specialized-arrays ;
 IN: cocoa.messages
 
+SPECIALIZED-ARRAY: void*
+
 : make-sender ( method function -- quot )
     [ over first , f , , second , \ alien-invoke , ] [ ] make ;
 
index 1428ba1b662a94ff2535f0e821053b85a46b39ee..484b1f4f2f8d49a60eb5c41845e7098bb50c45df 100755 (executable)
@@ -3,8 +3,10 @@ alien.syntax arrays classes.struct combinators
 compiler continuations effects io io.backend io.pathnames
 io.streams.string kernel math memory namespaces
 namespaces.private parser quotations sequences
-specialized-arrays.float stack-checker stack-checker.errors
-system threads tools.test words specialized-arrays.char ;
+specialized-arrays stack-checker stack-checker.errors
+system threads tools.test words ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: char
 IN: compiler.tests.alien
 
 <<
index 06e68d3e3575278e73f72f85be600befd446f92c..4c6e8f55d74d06fff41cd3ff4597d375a21ed047 100644 (file)
@@ -8,8 +8,9 @@ math.functions math.private strings layouts
 compiler.tree.propagation.info compiler.tree.def-use
 compiler.tree.debugger compiler.tree.checker
 slots.private words hashtables classes assocs locals
-specialized-arrays.double system sorting math.libm
+specialized-arrays system sorting math.libm
 math.intervals quotations effects alien ;
+SPECIALIZED-ARRAY: double
 IN: compiler.tree.propagation.tests
 
 [ V{ } ] [ [ ] final-classes ] unit-test
index f758e0e63a3ddb3ee6ecd07f2721b7802f6bb1e7..cc0175e0eaa5807ada0750ad2ad8acbd6f4ba6b4 100644 (file)
@@ -1,9 +1,11 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.syntax core-foundation kernel assocs
-specialized-arrays.alien math sequences accessors ;
+specialized-arrays math sequences accessors ;
 IN: core-foundation.dictionaries
 
+SPECIALIZED-ARRAY: void*
+
 TYPEDEF: void* CFDictionaryRef
 TYPEDEF: void* CFMutableDictionaryRef
 TYPEDEF: void* CFDictionaryKeyCallBacks*
index 7eba7d14c9b800fa83f14098635907a40e6b18d0..9a22046a3a3ae27adb1a4c40a8435b82bebc1f12 100755 (executable)
@@ -3,12 +3,15 @@
 USING: alien alien.c-types alien.strings alien.syntax kernel
 math sequences namespaces make assocs init accessors
 continuations combinators io.encodings.utf8 destructors locals
-arrays specialized-arrays.alien classes.struct
-specialized-arrays.int specialized-arrays.longlong
-core-foundation core-foundation.run-loop core-foundation.strings
+arrays specialized-arrays classes.struct core-foundation
+core-foundation.run-loop core-foundation.strings
 core-foundation.time ;
 IN: core-foundation.fsevents
 
+SPECIALIZED-ARRAY: void*
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: longlong
+
 CONSTANT: kFSEventStreamCreateFlagUseCFTypes 2
 CONSTANT: kFSEventStreamCreateFlagWatchRoot 4
 
index 0d50d1ab2c915f5cddb8fa31bca87c3dc23a3676..2278afe4edb8d821892062ada4013fba6d2f8ea4 100644 (file)
@@ -6,7 +6,9 @@ db.types tools.walker ascii splitting math.parser combinators
 libc calendar.format byte-arrays destructors prettyprint
 accessors strings serialize io.encodings.binary io.encodings.utf8
 alien.strings io.streams.byte-array summary present urls
-specialized-arrays.uint specialized-arrays.alien db.private ;
+specialized-arrays db.private ;
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: void*
 IN: db.postgresql.lib
 
 : postgresql-result-error-message ( res -- str/f )
index 6c72dc05cc9b8512f20532affbbe83b712f2ee5e..ea3100f95f6f99a2dfb1d70a1de1e6d3b1e09fe3 100755 (executable)
@@ -3,11 +3,13 @@ assocs byte-arrays combinators continuations game-input
 game-input.dinput.keys-array io.encodings.utf16
 io.encodings.utf16n kernel locals math math.bitwise
 math.rectangles namespaces parser sequences shuffle
-struct-arrays ui.backend.windows vectors windows.com
+specialized-arrays ui.backend.windows vectors windows.com
 windows.dinput windows.dinput.constants windows.errors
 windows.kernel32 windows.messages windows.ole32
 windows.user32 classes.struct ;
+SPECIALIZED-ARRAY: DIDEVICEOBJECTDATA
 IN: game-input.dinput
+
 CONSTANT: MOUSE-BUFFER-SIZE 16
 
 SINGLETON: dinput-game-input-backend
@@ -70,12 +72,9 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
 
 : find-mouse ( -- )
     GUID_SysMouse device-for-guid
-    [ configure-mouse ]
-    [ +mouse-device+ set-global ] bi
-    0 0 0 0 8 f <array> mouse-state boa
-    +mouse-state+ set-global
-    MOUSE-BUFFER-SIZE DIDEVICEOBJECTDATA <struct-array>
-    +mouse-buffer+ set-global ;
+    [ configure-mouse ] [ +mouse-device+ set-global ] bi
+    0 0 0 0 8 f <array> mouse-state boa +mouse-state+ set-global
+    MOUSE-BUFFER-SIZE <DIDEVICEOBJECTDATA-array> +mouse-buffer+ set-global ;
 
 : device-info ( device -- DIDEVICEIMAGEINFOW )
     DIDEVICEINSTANCEW <struct>
index cb73e4e27488207634448ad172b8343875bd413f..8580a766b3d661e3361aa2b2aae204e0080bf1ab 100755 (executable)
@@ -5,8 +5,10 @@ combinators compression.run-length endian fry grouping images
 images.bitmap.loading images.loader io io.binary
 io.encodings.binary io.encodings.string io.files
 io.streams.limited kernel locals macros math math.bitwise
-math.functions namespaces sequences specialized-arrays.uint
-specialized-arrays.ushort strings summary ;
+math.functions namespaces sequences specialized-arrays
+strings summary ;
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: ushort
 IN: images.bitmap
 
 : write2 ( n -- ) 2 >le write ;
index 82805fb6887d3b64a598cb04b281d73d6ba64b28..823cfcd03a9f67c519103a62146b49ef164013e1 100644 (file)
@@ -4,8 +4,9 @@ USING: accessors arrays byte-arrays combinators
 compression.run-length fry grouping images images.loader io
 io.binary io.encodings.8-bit io.encodings.binary
 io.encodings.string io.streams.limited kernel math math.bitwise
-sequences specialized-arrays.ushort summary ;
+sequences specialized-arrays summary ;
 QUALIFIED-WITH: bitstreams b
+SPECIALIZED-ARRAY: ushort
 IN: images.bitmap.loading
 
 SINGLETON: bitmap-image
index 0d16bf75d4a314afdff02ad217a894e2e5203f36..c589349dff2fbd43d6b17c6dafd8ac17e09ef984 100755 (executable)
@@ -5,8 +5,9 @@ compression.lzw endian fry grouping images io
 io.binary io.encodings.ascii io.encodings.binary
 io.encodings.string io.encodings.utf8 io.files kernel math
 math.bitwise math.order math.parser pack prettyprint sequences
-strings math.vectors specialized-arrays.float locals
+strings math.vectors specialized-arrays locals
 images.loader ;
+SPECIALIZED-ARRAY: float
 IN: images.tiff
 
 SINGLETON: tiff-image
index 11fa5620f2b1eb41c987d83e4bb3014c046c65c6..b9c224c6294bb3d2c2f739dd9b2badb97e97c80f 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors classes.struct kernel destructors bit-arrays
-sequences assocs struct-arrays math namespaces locals fry unix
-unix.linux.epoll unix.time io.ports io.backend.unix
-io.backend.unix.multiplexers ;
+sequences assocs specialized-arrays math namespaces
+locals fry unix unix.linux.epoll unix.time io.ports
+io.backend.unix io.backend.unix.multiplexers ;
+SPECIALIZED-ARRAY: epoll-event
 IN: io.backend.unix.multiplexers.epoll
 
 TUPLE: epoll-mx < mx events ;
@@ -16,7 +17,7 @@ TUPLE: epoll-mx < mx events ;
 : <epoll-mx> ( -- mx )
     epoll-mx new-mx
         max-events epoll_create dup io-error >>fd
-        max-events epoll-event <struct-array> >>events ;
+        max-events <epoll-event-array> >>events ;
 
 M: epoll-mx dispose* fd>> close-file ;
 
index ab3308916db6787c6bf3bf24b2b15ec09493069c..c777e57f1db528649fa30fb949576323d35ff6c2 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types combinators destructors
-io.backend.unix kernel math.bitwise sequences struct-arrays unix
-unix.kqueue unix.time assocs io.backend.unix.multiplexers
-classes.struct ;
+io.backend.unix kernel math.bitwise sequences
+specialized-arrays unix unix.kqueue unix.time assocs
+io.backend.unix.multiplexers classes.struct ;
+SPECIALIZED-ARRAY: kevent
 IN: io.backend.unix.multiplexers.kqueue
 
 TUPLE: kqueue-mx < mx events ;
@@ -15,7 +16,7 @@ CONSTANT: max-events 256
 : <kqueue-mx> ( -- mx )
     kqueue-mx new-mx
         kqueue dup io-error >>fd
-        max-events \ kevent <struct-array> >>events ;
+        max-events <kevent-array> >>events ;
 
 M: kqueue-mx dispose* fd>> close-file ;
 
index cdf158bd2f091c863533a8647d0481b227649269..f1d6b4db665b85d280d27cad1b15586ee329e989 100644 (file)
@@ -4,7 +4,9 @@ USING: accessors alien.c-types alien.syntax combinators
 io.backend io.files io.files.info io.files.unix kernel math system unix
 unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd
 sequences grouping alien.strings io.encodings.utf8 unix.types
-arrays io.files.info.unix classes.struct struct-arrays ;
+arrays io.files.info.unix classes.struct
+specialized-arrays ;
+SPECIALIZED-ARRAY: statfs
 IN: io.files.info.unix.freebsd
 
 TUPLE: freebsd-file-system-info < unix-file-system-info
@@ -50,6 +52,6 @@ M: freebsd statvfs>file-system-info ( file-system-info statvfs -- file-system-in
 
 M: freebsd file-systems ( -- array )
     f 0 0 getfsstat dup io-error
-    \ statfs <struct-array>
+    <statfs-array>
     [ dup byte-length 0 getfsstat io-error ]
     [ [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ] bi ;
index 9ce235ecd7e695a76f1400a348db93ca92d794e1..ac5f8c23b1119eac1d0017b3c4bfebffc52894a8 100755 (executable)
@@ -1,10 +1,12 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.strings combinators
-grouping io.encodings.utf8 io.files kernel math sequences
-system unix io.files.unix specialized-arrays.uint arrays
-unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx
-io.files.info.unix io.files.info classes.struct struct-arrays ;
+grouping io.encodings.utf8 io.files kernel math sequences system
+unix io.files.unix arrays unix.statfs.macosx unix.statvfs.macosx
+unix.getfsstat.macosx io.files.info.unix io.files.info
+classes.struct specialized-arrays ;
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: statfs64
 IN: io.files.info.unix.macosx
 
 TUPLE: macosx-file-system-info < unix-file-system-info
@@ -12,7 +14,7 @@ io-size owner type-id filesystem-subtype ;
 
 M: macosx file-systems ( -- array )
     f <void*> dup 0 getmntinfo64 dup io-error
-    [ *void* ] dip \ statfs64 <direct-struct-array>
+    [ *void* ] dip <direct-statfs64-array>
     [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ;
 
 M: macosx new-file-system-info macosx-file-system-info new ;
index 10d9a7eb8b5bcd065642079574e4442320ee1dbd..9e37ec8aa99e05ae5da059dbf35c7bfcf08c13fb 100755 (executable)
@@ -4,8 +4,9 @@ USING: alien.syntax kernel unix.stat math unix
 combinators system io.backend accessors alien.c-types
 io.encodings.utf8 alien.strings unix.types io.files.unix
 io.files io.files.info unix.statvfs.netbsd unix.getfsstat.netbsd arrays
-grouping sequences io.encodings.utf8 classes.struct struct-arrays
-io.files.info.unix ;
+grouping sequences io.encodings.utf8 classes.struct
+specialized-arrays io.files.info.unix ;
+SPECIALIZED-ARRAY: statvfs
 IN: io.files.info.unix.netbsd
 
 TUPLE: netbsd-file-system-info < unix-file-system-info
@@ -47,6 +48,6 @@ M: netbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-inf
 
 M: netbsd file-systems ( -- array )
     f 0 0 getvfsstat dup io-error
-    \ statvfs <struct-array>
+    <statvfs-array>
     [ dup byte-length 0 getvfsstat io-error ]
     [ [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ] bi ;
index 68c9d2ca1254e00d5e92de9925ff36b31a1f1fcb..fe94f70fd82d615d821c281c8a03c7731bce7d91 100755 (executable)
@@ -4,8 +4,9 @@ USING: accessors alien.c-types alien.strings alien.syntax
 combinators io.backend io.files io.files.info io.files.unix kernel math
 sequences system unix unix.getfsstat.openbsd grouping
 unix.statfs.openbsd unix.statvfs.openbsd unix.types
-arrays io.files.info.unix classes.struct struct-arrays
-io.encodings.utf8 ;
+arrays io.files.info.unix classes.struct
+specialized-arrays io.encodings.utf8 ;
+SPECIALIZED-ARRAY: statvfs
 IN: io.files.unix.openbsd
 
 TUPLE: openbsd-file-system-info < unix-file-system-info
@@ -48,6 +49,6 @@ M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-in
 
 M: openbsd file-systems ( -- seq )
     f 0 0 getfsstat dup io-error
-    \ statfs <struct-array>
+    <statfs-array>
     [ dup byte-length 0 getfsstat io-error ]
     [ [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ] bi ;
index 20b3513c6cd26b47d51983e25ed4fdcdccd51368..0b52237a6d077eb3b7bbfb507a8d7a43c51d663b 100644 (file)
@@ -3,8 +3,10 @@
 USING: accessors kernel system math math.bitwise strings arrays
 sequences combinators combinators.short-circuit alien.c-types
 vocabs.loader calendar calendar.unix io.files.info
-io.files.types io.backend io.directories unix unix.stat unix.time unix.users
-unix.groups classes.struct struct-arrays ;
+io.files.types io.backend io.directories unix unix.stat
+unix.time unix.users unix.groups classes.struct
+specialized-arrays ;
+SPECIALIZED-ARRAY: timeval
 IN: io.files.info.unix
 
 TUPLE: unix-file-system-info < file-system-info
@@ -184,7 +186,7 @@ M: unix copy-file-and-info ( from to -- )
 
 : timestamps>byte-array ( timestamps -- byte-array )
     [ [ timestamp>timeval ] [ \ timeval <struct> ] if* ] map
-    \ timeval >struct-array ;
+    >timeval-array ;
 
 PRIVATE>
 
index 385a1eb196d77476c1506dde51f76b37d20557c9..bb3a412669ba304e13846bce8c946449d4d8bd09 100755 (executable)
@@ -6,7 +6,8 @@ windows.time windows accessors alien.c-types combinators
 generalizations system alien.strings io.encodings.utf16n
 sequences splitting windows.errors fry continuations destructors
 calendar ascii combinators.short-circuit locals classes.struct
-specialized-arrays.ushort ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: ushort
 IN: io.files.info.windows
 
 :: round-up-to ( n multiple -- n' )
index 17cfa0977ed4aa4cee8623320468fe3d3915063e..97754cf237ae9e8114161d960d8e4a483ed8abe6 100755 (executable)
@@ -5,7 +5,8 @@ windows.kernel32 kernel libc math threads system environment
 alien.c-types alien.arrays alien.strings sequences combinators
 combinators.short-circuit ascii splitting alien strings assocs
 namespaces make accessors tr windows.time windows.shell32
-windows.errors specialized-arrays.ushort classes.struct ;
+windows.errors specialized-arrays classes.struct ;
+SPECIALIZED-ARRAY: ushort
 IN: io.files.windows.nt
 
 M: winnt cwd
index 45aeec0a8098c1d3241df78643f402de5984a5d8..475be5d70c614508ea8e2adb33099b85c6df2551 100755 (executable)
@@ -1,13 +1,13 @@
 ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types arrays continuations io
-io.backend.windows io.pipes.windows.nt io.pathnames libc io.ports
-windows.types math windows.kernel32
-namespaces make io.launcher kernel sequences windows.errors
-splitting system threads init strings combinators
-io.backend accessors concurrency.flags io.files assocs
-io.files.private windows destructors specialized-arrays.ushort
-specialized-arrays.alien classes classes.struct ;
+io.backend.windows io.pipes.windows.nt io.pathnames libc
+io.ports windows.types math windows.kernel32 namespaces make
+io.launcher kernel sequences windows.errors splitting system
+threads init strings combinators io.backend accessors
+concurrency.flags io.files assocs io.files.private windows
+destructors specialized-arrays.alien classes classes.struct ;
+SPECIALIZED-ARRAY: ushort
 IN: io.launcher.windows
 
 TUPLE: CreateProcess-args
diff --git a/basis/io/mmap/alien/alien.factor b/basis/io/mmap/alien/alien.factor
deleted file mode 100755 (executable)
index bf72148..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.alien ;
-IN: io.mmap.alien
-
-<< "void*" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/bool/bool.factor b/basis/io/mmap/bool/bool.factor
deleted file mode 100755 (executable)
index 5352bbf..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.bool ;
-IN: io.mmap.bool
-
-<< "bool" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/char/char.factor b/basis/io/mmap/char/char.factor
deleted file mode 100755 (executable)
index fc5f14f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.char ;
-IN: io.mmap.char
-
-<< "char" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/double/double.factor b/basis/io/mmap/double/double.factor
deleted file mode 100755 (executable)
index 708286b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.double ;
-IN: io.mmap.double
-
-<< "double" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/float/float.factor b/basis/io/mmap/float/float.factor
deleted file mode 100755 (executable)
index 71685a4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.float ;
-IN: io.mmap.float
-
-<< "float" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/functor/functor.factor b/basis/io/mmap/functor/functor.factor
deleted file mode 100644 (file)
index a80ce3b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: io.mmap functors accessors alien.c-types math kernel
-words fry ;
-IN: io.mmap.functor
-
-SLOT: address
-SLOT: length
-
-: mapped-file>direct ( mapped-file type -- alien length )
-    [ [ address>> ] [ length>> ] bi ] dip
-    heap-size [ 1 - + ] keep /i ;
-
-FUNCTOR: define-mapped-array ( T -- )
-
-<mapped-A>                DEFINES <mapped-${T}-array>
-<A>                       IS      <direct-${T}-array>
-with-mapped-A-file        DEFINES with-mapped-${T}-file
-with-mapped-A-file-reader DEFINES with-mapped-${T}-file-reader
-
-WHERE
-
-: <mapped-A> ( mapped-file -- direct-array )
-    T mapped-file>direct <A> ; inline
-
-: with-mapped-A-file ( path quot -- )
-    '[ <mapped-A> @ ] with-mapped-file ; inline
-
-: with-mapped-A-file-reader ( path quot -- )
-    '[ <mapped-A> @ ] with-mapped-file-reader ; inline
-
-;FUNCTOR
diff --git a/basis/io/mmap/int/int.factor b/basis/io/mmap/int/int.factor
deleted file mode 100755 (executable)
index 1f6bd2a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.int ;
-IN: io.mmap.int
-
-<< "int" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/long/long.factor b/basis/io/mmap/long/long.factor
deleted file mode 100755 (executable)
index 70a9c46..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.long ;
-IN: io.mmap.long
-
-<< "long" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/longlong/longlong.factor b/basis/io/mmap/longlong/longlong.factor
deleted file mode 100755 (executable)
index 426f872..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.longlong ;
-IN: io.mmap.longlong
-
-<< "longlong" define-mapped-array >>
\ No newline at end of file
index 0e1cd1a03691904e6c758e68f68d153a915112ae..4847b0701c494dab1a7d7cf1ee1e986fa42d28a7 100644 (file)
@@ -1,13 +1,13 @@
-USING: io io.mmap io.mmap.char io.files io.files.temp
+USING: io io.mmap io.files io.files.temp
 io.directories kernel tools.test continuations sequences
 io.encodings.ascii accessors math ;
 IN: io.mmap.tests
 
 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
 [ ] [ "12345" "mmap-test-file.txt" temp-file ascii set-file-contents ] unit-test
-[ ] [ "mmap-test-file.txt" temp-file [ CHAR: 2 0 pick set-nth drop ] with-mapped-char-file ] unit-test
-[ 5 ] [ "mmap-test-file.txt" temp-file [ length ] with-mapped-char-file ] unit-test
-[ 5 ] [ "mmap-test-file.txt" temp-file [ length ] with-mapped-char-file-reader ] unit-test
+[ ] [ "mmap-test-file.txt" temp-file [ "char" <mapped-array> CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
+[ 5 ] [ "mmap-test-file.txt" temp-file [ "char" <mapped-array> length ] with-mapped-file ] unit-test
+[ 5 ] [ "mmap-test-file.txt" temp-file [ "char" <mapped-array> length ] with-mapped-file-reader ] unit-test
 [ "22345" ] [ "mmap-test-file.txt" temp-file ascii file-contents ] unit-test
 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
 
index aa3ac624a07b5893621c5f40622fca946bf8bb59..704a585dd44da68c077ab67e33e74817e8642423 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
+! Copyright (C) 2007, 2009 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations destructors io.files io.files.info
 io.backend kernel quotations system alien alien.accessors
@@ -30,6 +30,11 @@ PRIVATE>
 : <mapped-file> ( path -- mmap )
     [ (mapped-file-r/w) ] prepare-mapped-file ;
 
+: <mapped-array> ( mmap c-type -- direct-array )
+    [ [ address>> ] [ length>> ] bi ] dip
+    [ heap-size /i ] keep
+    <c-direct-array> ; inline
+
 HOOK: close-mapped-file io-backend ( mmap -- )
 
 M: mapped-file dispose* ( mmap -- ) close-mapped-file ;
diff --git a/basis/io/mmap/short/short.factor b/basis/io/mmap/short/short.factor
deleted file mode 100755 (executable)
index c19d70d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.short ;
-IN: io.mmap.short
-
-<< "short" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/uchar/uchar.factor b/basis/io/mmap/uchar/uchar.factor
deleted file mode 100755 (executable)
index 03b6cd4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.uchar ;
-IN: io.mmap.uchar
-
-<< "uchar" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/uint/uint.factor b/basis/io/mmap/uint/uint.factor
deleted file mode 100755 (executable)
index a379349..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.uint ;
-IN: io.mmap.uint
-
-<< "uint" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/ulong/ulong.factor b/basis/io/mmap/ulong/ulong.factor
deleted file mode 100755 (executable)
index dfdae5d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.ulong ;
-IN: io.mmap.ulong
-
-<< "ulong" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/ulonglong/ulonglong.factor b/basis/io/mmap/ulonglong/ulonglong.factor
deleted file mode 100755 (executable)
index 1d6bd0e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.ulonglong ;
-IN: io.mmap.ulonglong
-
-<< "ulonglong" define-mapped-array >>
\ No newline at end of file
diff --git a/basis/io/mmap/ushort/ushort.factor b/basis/io/mmap/ushort/ushort.factor
deleted file mode 100755 (executable)
index fc63313..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: io.mmap.functor specialized-arrays.ushort ;
-IN: io.mmap.ushort
-
-<< "ushort" define-mapped-array >>
\ No newline at end of file
index f94733ca560021b8ae3f962bd84afe2bd8820f36..7319ad1db8270f96a1edda8fdbe20cfa3f0af1bb 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: system kernel unix math sequences
-io.backend.unix io.ports specialized-arrays.int accessors ;
-IN: io.pipes.unix
+io.backend.unix io.ports specialized-arrays accessors ;
 QUALIFIED: io.pipes
+SPECIALIZED-ARRAY: int
+IN: io.pipes.unix
 
 M: unix io.pipes:(pipe) ( -- pair )
     2 <int-array>
index c315021ed4765cbb441c45b82a29ececc9a60905..a051fb250de2b53bb73d17cc8bdc2aea3b93c408 100755 (executable)
@@ -3,9 +3,12 @@ combinators.short-circuit fry kernel locals macros
 math math.blas.ffi math.blas.vectors math.blas.vectors.private
 math.complex math.functions math.order functors words
 sequences sequences.merged sequences.private shuffle
-specialized-arrays.float specialized-arrays.double
-specialized-arrays.complex-float specialized-arrays.complex-double
-parser prettyprint.backend prettyprint.custom ascii ;
+parser prettyprint.backend prettyprint.custom ascii
+specialized-arrays ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: double
+SPECIALIZED-ARRAY: complex-float
+SPECIALIZED-ARRAY: complex-double
 IN: math.blas.matrices
 
 TUPLE: blas-matrix-base underlying ld rows cols transpose ;
index 2b573ab6edc6c10bb5af6c3bd9f836b195e54399..c08fdb612081d0caa7410973a9d2250a9c631bf3 100755 (executable)
@@ -2,8 +2,11 @@ USING: accessors alien alien.c-types arrays ascii byte-arrays combinators
 combinators.short-circuit fry kernel math math.blas.ffi
 math.complex math.functions math.order sequences sequences.private
 functors words locals parser prettyprint.backend prettyprint.custom
-specialized-arrays.float specialized-arrays.double
-specialized-arrays.complex-float specialized-arrays.complex-double ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: double
+SPECIALIZED-ARRAY: complex-float
+SPECIALIZED-ARRAY: complex-double
 IN: math.blas.vectors
 
 TUPLE: blas-vector-base underlying length inc ;
index 52b8db9bd1d9f0be38e97229f23e7e8b08925a48..87540dd9a5b0d56903739bef84218adc8142d6da 100644 (file)
@@ -1,8 +1,9 @@
-IN: math.vectors.simd.alien.tests
 USING: cpu.architecture math.vectors.simd
 math.vectors.simd.intrinsics accessors math.vectors.simd.alien
 kernel classes.struct tools.test compiler sequences byte-arrays
-alien math kernel.private specialized-arrays.float combinators ;
+alien math kernel.private specialized-arrays combinators ;
+SPECIALIZED-ARRAY: float
+IN: math.vectors.simd.alien.tests
 
 ! Vector alien intrinsics
 [ float-4{ 1 2 3 4 } ] [
index 5b6f1eac7174a15e70b023b7532808a1de8d8d82..f9f241bb6f05684978fc2dc21ffa6b04b863794f 100644 (file)
@@ -1,8 +1,9 @@
 IN: math.vectors.specialization.tests
 USING: compiler.tree.debugger math.vectors tools.test kernel
-kernel.private math specialized-arrays.double
-specialized-arrays.complex-float
-specialized-arrays.float ;
+kernel.private math specialized-arrays ;
+SPECIALIZED-ARRAY: double
+SPECIALIZED-ARRAY: complex-float
+SPECIALIZED-ARRAY: float
 
 [ V{ t } ] [
     [ { double-array double-array } declare distance 0.0 < not ] final-literals
index acf8dada3877d3741ad0d96589b0e1e54745e2a4..21ec9f64f3c03757b61a2a48a1fa41e50ec676b1 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: words kernel make sequences effects kernel.private accessors
-combinators math math.intervals math.vectors namespaces assocs fry
-splitting classes.algebra generalizations locals
-compiler.tree.propagation.info ;
+USING: alien.c-types words kernel make sequences effects
+kernel.private accessors combinators math math.intervals
+math.vectors namespaces assocs fry splitting classes.algebra
+generalizations locals compiler.tree.propagation.info ;
 IN: math.vectors.specialization
 
 SYMBOLS: -> +vector+ +scalar+ +nonnegative+ ;
@@ -99,12 +99,14 @@ M: vector-word subwords specializations values [ word? ] filter ;
     array-type elt-type word word-schema inputs signature-for-schema ;
 
 :: specialize-vector-words ( array-type elt-type simd -- )
-    vector-words keys [
-        [ array-type elt-type simd specialize-vector-word ]
-        [ array-type elt-type input-signature ]
-        [ ]
-        tri add-specialization
-    ] each ;
+    elt-type number class<= [
+        vector-words keys [
+            [ array-type elt-type simd specialize-vector-word ]
+            [ array-type elt-type input-signature ]
+            [ ]
+            tri add-specialization
+        ] each
+    ] when ;
 
 : find-specialization ( classes word -- word/f )
     specializations
index 0a037287fe012c3c6ddc8d7a7c944c074ee9769c..75f327664d0c3bef944944a10ea0e780616347c5 100755 (executable)
@@ -7,7 +7,9 @@ continuations kernel libc math macros namespaces math.vectors
 math.parser opengl.gl combinators combinators.smart arrays
 sequences splitting words byte-arrays assocs vocabs
 colors colors.constants accessors generalizations locals fry
-specialized-arrays.float specialized-arrays.uint ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: uint
 IN: opengl
 
 : gl-color ( color -- ) >rgba-components glColor4d ; inline
index 9d5f4810e1f78cc97287bfc520b489d1b283f605..26ffd0cf88e25617a01780a1d78febee69069c26 100755 (executable)
@@ -2,8 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel opengl.gl alien.c-types continuations namespaces
 assocs alien alien.strings libc opengl math sequences combinators
-macros arrays io.encodings.ascii fry specialized-arrays.uint
+macros arrays io.encodings.ascii fry specialized-arrays
 destructors accessors ;
+SPECIALIZED-ARRAY: uint
 IN: opengl.shaders
 
 : with-gl-shader-source-ptr ( string quot -- )
index 528aaaa12f67a8e10dcc6f64f19421cdd522f6fb..28d920d8d6a16ed3b22540af5767fb71065b67a6 100755 (executable)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs cache colors.constants destructors kernel
-opengl opengl.gl opengl.capabilities combinators images
-images.tesselation grouping specialized-arrays.float sequences math
-math.vectors math.matrices generalizations fry arrays namespaces
-system locals literals ;
+USING: accessors assocs cache colors.constants destructors
+kernel opengl opengl.gl opengl.capabilities combinators images
+images.tesselation grouping sequences math math.vectors
+math.matrices generalizations fry arrays namespaces system
+locals literals specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: opengl.textures
 
 SYMBOL: non-power-of-2-textures?
index 966c5b2e608e7801fbd9598f6064a519d10bfd23..3a44066cafa64d8b5efaaccfe1096004a742842e 100644 (file)
@@ -4,7 +4,8 @@
 ! http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
 USING: kernel math namespaces sequences sequences.private system
 init accessors math.ranges random math.bitwise combinators
-specialized-arrays.uint fry ;
+specialized-arrays fry ;
+SPECIALIZED-ARRAY: uint
 IN: random.mersenne-twister
 
 <PRIVATE
index 65dd520fd8c847fa6cb36c96fa7393dd48140135..87ee32a0fc942a9d278375179c1f776573d07ec9 100644 (file)
@@ -12,9 +12,9 @@ ABOUT: "sequences.complex"
 HELP: complex-sequence
 { $class-description "Sequence wrapper class that transforms a sequence of " { $link real } " number values into a sequence of " { $link complex } " values, treating the underlying sequence as pairs of alternating real and imaginary values."  }
 { $examples { $example <"
-USING: prettyprint
-specialized-arrays.double sequences.complex
-sequences arrays ;
+USING: prettyprint specialized-arrays ;
+sequences.complex sequences arrays ;
+SPECIALIZED-ARRAY: double
 double-array{ 1.0 -1.0 -2.0 2.0 3.0 0.0 } <complex-sequence> >array .
 "> "{ C{ 1.0 -1.0 } C{ -2.0 2.0 } C{ 3.0 0.0 } }" } } ;
 
@@ -23,8 +23,9 @@ HELP: <complex-sequence>
 { $description "Wraps " { $snippet "sequence" } " in a " { $link complex-sequence } "." }
 { $examples { $example <"
 USING: prettyprint
-specialized-arrays.double sequences.complex
+specialized-arrays sequences.complex
 sequences arrays ;
+SPECIALIZED-ARRAY: double
 double-array{ 1.0 -1.0 -2.0 2.0 3.0 0.0 } <complex-sequence> second .
 "> "C{ -2.0 2.0 }" } } ;
 
index 5861bc8b028bc0d69b6c2df31e63f54cfcd18749..04a80c6beee487cce08a8a08a0917ca0a6504d62 100644 (file)
@@ -1,5 +1,6 @@
-USING: specialized-arrays.float sequences.complex
+USING: specialized-arrays sequences.complex
 kernel sequences tools.test arrays accessors ;
+SPECIALIZED-ARRAY: float
 IN: sequences.complex.tests
 
 : test-array ( -- x )
index b6a4b1a86fb915194abc8d1e3b24331811da8e20..99c8adefb65a5e337403b6ca50468974b5513ba8 100644 (file)
@@ -2,9 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 ! 
 USING: tools.test kernel serialize io io.streams.byte-array
-alien arrays byte-arrays bit-arrays specialized-arrays.double
+alien arrays byte-arrays bit-arrays specialized-arrays
 sequences math prettyprint parser classes math.constants
 io.encodings.binary random assocs serialize.private ;
+SPECIALIZED-ARRAY: double
 IN: serialize.tests
 
 : test-serialize-cell ( a -- ? )
diff --git a/basis/specialized-arrays/alien/alien.factor b/basis/specialized-arrays/alien/alien.factor
deleted file mode 100644 (file)
index 465d166..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.alien
-
-<< "void*" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/bool/bool.factor b/basis/specialized-arrays/bool/bool.factor
deleted file mode 100644 (file)
index 759ee91..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.bool
-
-<< "bool" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/char/char.factor b/basis/specialized-arrays/char/char.factor
deleted file mode 100644 (file)
index cdf78ee..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.char
-
-<< "char" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/complex-double/complex-double-tests.factor b/basis/specialized-arrays/complex-double/complex-double-tests.factor
deleted file mode 100644 (file)
index 9f2bcc9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-USING: kernel sequences specialized-arrays.complex-double tools.test ;
-IN: specialized-arrays.complex-double.tests
-
-[ C{ 3.0 2.0 } ]
-[ complex-double-array{ 1.0 C{ 3.0 2.0 } 5.0 } second ] unit-test
-
-[ C{ 1.0 0.0 } ]
-[ complex-double-array{ 1.0 C{ 3.0 2.0 } 5.0 } first ] unit-test
-
-[ complex-double-array{ 1.0 C{ 6.0 -7.0 } 5.0 } ] [
-    complex-double-array{ 1.0 C{ 3.0 2.0 } 5.0 } 
-    dup [ C{ 6.0 -7.0 } 1 ] dip set-nth
-] unit-test
diff --git a/basis/specialized-arrays/complex-double/complex-double.factor b/basis/specialized-arrays/complex-double/complex-double.factor
deleted file mode 100644 (file)
index 00b07fb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.complex-double
-
-<< "complex-double" define-array >>
diff --git a/basis/specialized-arrays/complex-float/complex-float.factor b/basis/specialized-arrays/complex-float/complex-float.factor
deleted file mode 100644 (file)
index 5348343..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.complex-float
-
-<< "complex-float" define-array >>
diff --git a/basis/specialized-arrays/double/double.factor b/basis/specialized-arrays/double/double.factor
deleted file mode 100644 (file)
index 95324bd..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.double
-
-<< "double" define-array >>
-
-! Specializer hints. These should really be generalized, and placed
-! somewhere else
-USING: hints math.vectors arrays kernel math accessors sequences ;
-
-HINTS: <double-array> { 2 } { 3 } ;
-
-HINTS: (double-array) { 2 } { 3 } ;
-
-! Type functions
-USING: words classes.algebra compiler.tree.propagation.info
-math.intervals ;
-
-\ norm-sq [
-    class>> double-array class<= [ float 0. 1/0. [a,b] <class/interval-info> ] [ object-info ] if
-] "outputs" set-word-prop
-
-\ distance [
-    [ class>> double-array class<= ] both?
-    [ float 0. 1/0. [a,b] <class/interval-info> ] [ object-info ] if
-] "outputs" set-word-prop
diff --git a/basis/specialized-arrays/float/float.factor b/basis/specialized-arrays/float/float.factor
deleted file mode 100644 (file)
index 5d9da66..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.float
-
-<< "float" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/functor/functor.factor b/basis/specialized-arrays/functor/functor.factor
deleted file mode 100755 (executable)
index b4d0524..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: functors sequences sequences.private prettyprint.custom
-kernel words classes math math.vectors.specialization parser
-alien.c-types byte-arrays accessors summary alien specialized-arrays ;
-IN: specialized-arrays.functor
-
-ERROR: bad-byte-array-length byte-array type ;
-
-M: bad-byte-array-length summary
-    drop "Byte array length doesn't divide type width" ;
-
-: (underlying) ( n c-type -- array )
-    heap-size * (byte-array) ; inline
-
-: <underlying> ( n type -- array )
-    heap-size * <byte-array> ; inline
-
-FUNCTOR: define-array ( T -- )
-
-A            DEFINES-CLASS ${T}-array
-S            DEFINES-CLASS ${T}-sequence
-<A>          DEFINES <${A}>
-(A)          DEFINES (${A})
-<direct-A>   DEFINES <direct-${A}>
->A           DEFINES >${A}
-byte-array>A DEFINES byte-array>${A}
-
-A{           DEFINES ${A}{
-A@           DEFINES ${A}@
-
-NTH          [ T dup c-type-getter-boxer array-accessor ]
-SET-NTH      [ T dup c-setter array-accessor ]
-
-WHERE
-
-MIXIN: S
-
-TUPLE: A
-{ underlying c-ptr read-only }
-{ length array-capacity read-only } ;
-
-: <direct-A> ( alien len -- specialized-array ) A boa ; inline
-
-: <A> ( n -- specialized-array ) [ T <underlying> ] keep <direct-A> ; inline
-
-: (A) ( n -- specialized-array ) [ T (underlying) ] keep <direct-A> ; inline
-
-: byte-array>A ( byte-array -- specialized-array )
-    dup length T heap-size /mod 0 = [ drop T bad-byte-array-length ] unless
-    <direct-A> ; inline
-
-M: A clone [ underlying>> clone ] [ length>> ] bi <direct-A> ; inline
-
-M: A length length>> ; inline
-
-M: A nth-unsafe underlying>> NTH call ; inline
-
-M: A set-nth-unsafe underlying>> SET-NTH call ; inline
-
-: >A ( seq -- specialized-array ) A new clone-like ;
-
-M: A like drop dup A instance? [ >A ] unless ; inline
-
-M: A new-sequence drop (A) ; inline
-
-M: A equal? over A instance? [ sequence= ] [ 2drop f ] if ;
-
-M: A resize
-    [
-        [ T heap-size * ] [ underlying>> ] bi*
-        resize-byte-array
-    ] [ drop ] 2bi
-    <direct-A> ; inline
-
-M: A byte-length underlying>> length ; inline
-M: A pprint-delims drop \ A{ \ } ;
-M: A >pprint-sequence ;
-
-SYNTAX: A{ \ } [ >A ] parse-literal ;
-SYNTAX: A@ scan-object scan-object <direct-A> parsed ;
-
-INSTANCE: A specialized-array
-
-A T c-type-boxed-class f specialize-vector-words
-
-T c-type
-    \ A >>array-class
-    \ <A> >>array-constructor
-    \ (A) >>(array)-constructor
-    \ <direct-A> >>direct-array-constructor
-    drop
-
-;FUNCTOR
diff --git a/basis/specialized-arrays/functor/summary.txt b/basis/specialized-arrays/functor/summary.txt
deleted file mode 100644 (file)
index 77cb2d4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Code generation for specialized arrays
diff --git a/basis/specialized-arrays/int/int.factor b/basis/specialized-arrays/int/int.factor
deleted file mode 100644 (file)
index 37f4b59..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.int
-
-<< "int" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/long/long.factor b/basis/specialized-arrays/long/long.factor
deleted file mode 100644 (file)
index 2cba642..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.long
-
-<< "long" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/longlong/longlong.factor b/basis/specialized-arrays/longlong/longlong.factor
deleted file mode 100644 (file)
index 195dd78..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.longlong
-
-<< "longlong" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/ptrdiff_t/ptrdiff_t.factor b/basis/specialized-arrays/ptrdiff_t/ptrdiff_t.factor
deleted file mode 100644 (file)
index 4fd7d82..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.alien
-
-<< "ptrdiff_t" define-array >>
diff --git a/basis/specialized-arrays/short/short.factor b/basis/specialized-arrays/short/short.factor
deleted file mode 100644 (file)
index 3891462..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.short
-
-<< "short" define-array >>
\ No newline at end of file
index e0645456ecde5d8fcd95b517528264ffb4927c5d..bb5c7d38d6d67cefe56c1884fa6804a44c5b67df 100755 (executable)
@@ -1,43 +1,52 @@
-USING: help.markup help.syntax byte-arrays ;
+USING: help.markup help.syntax byte-arrays alien ;
 IN: specialized-arrays
 
-ARTICLE: "specialized-arrays" "Specialized arrays"
-"The " { $vocab-link "specialized-arrays" } " vocabulary implements fixed-length sequence types for storing machine values in a space-efficient manner without boxing."
-$nl
-"For each primitive C type " { $snippet "T" } ", a set of words are defined in the vocabulary named " { $snippet "specialized-arrays.T" } ":"
+HELP: SPECIALIZED-ARRAY:
+{ $syntax "SPECIALIZED-ARRAY: type" }
+{ $values { "type" "a C type" } }
+{ $description "Brings a specialized array for holding values of " { $snippet "type" } " into the vocabulary search path. The generated words are documented in " { $link "specialized-array-words" } "." } ;
+
+ARTICLE: "specialized-array-words" "Specialized array words"
+"The " { $link POSTPONE: SPECIALIZED-ARRAY: } " parsing word generates the specialized array type if it hasn't been generated already, and adds the following words to the vocabulary search path, where " { $snippet "T" } " is the C type in question:"
 { $table
     { { $snippet "T-array" } { "The class of arrays with elements of type " { $snippet "T" } } }
     { { $snippet "<T-array>" } { "Constructor for arrays with elements of type " { $snippet "T" } "; stack effect " { $snippet "( len -- array )" } } }
-    { { $snippet "<direct-T-array>" } { "Constructor for arrays with elements of type " { $snippet "T" } "; stack effect " { $snippet "( alien len -- array )" } } }
+    { { $snippet "(T-array)" } { "Constructor for arrays with elements of type " { $snippet "T" } ", where the initial contents are uninitialized; stack effect " { $snippet "( len -- array )" } } }
+    { { $snippet "malloc-T-array" } { "Constructor for arrays with elements of type " { $snippet "T" } " backed by newly-allocated unmanaged memory; stack effect " { $snippet "( alien len -- array )" } } }
+    { { $snippet "<direct-T-array>" } { "Constructor for arrays with elements of type " { $snippet "T" } " backed by raw memory; stack effect " { $snippet "( alien len -- array )" } } }
     { { $snippet "byte-array>T-array" } { "Converts a byte array into a specialized array by interpreting the bytes in as machine-specific values. Code which uses this word is unportable" } }
     { { $snippet ">T-array" } { "Converts a sequence into a specialized array of type " { $snippet "T" } "; stack effect " { $snippet "( seq -- array )" } } }
     { { $snippet "T-array{" } { "Literal syntax, consists of a series of values terminated by " { $snippet "}" } } }
 }
-"Each specialized array has a " { $slot "underlying" } " slot holding a " { $link byte-array } " with the raw data. This data can be passed to C functions."
-$nl
-"The primitive C types for which specialized arrays exist:"
-{ $list
-    { $snippet "char" }
-    { $snippet "uchar" }
-    { $snippet "short" }
-    { $snippet "ushort" }
-    { $snippet "int" }
-    { $snippet "uint" }
-    { $snippet "long" }
-    { $snippet "ulong" }
-    { $snippet "longlong" }
-    { $snippet "ulonglong" }
-    { $snippet "float" }
-    { $snippet "double" }
-    { $snippet "complex-float" }
-    { $snippet "complex-double" }
-    { $snippet "void*" }
-    { $snippet "bool" }
-}
-"Note that " { $vocab-link "specialized-arrays.bool" } " behaves like a C " { $snippet "bool[]" } " array, and each element takes up 8 bits of space. For a more space-efficient boolean array, see " { $link "bit-arrays" } "."
-$nl
-"Specialized arrays are generated with a functor in the " { $vocab-link "specialized-arrays.functor" } " vocabulary."
+"Behind the scenes, these words are placed in a vocabulary named " { $snippet "specialized-arrays.instances.T" } ", however this vocabulary should not be placed in a " { $link POSTPONE: USING: } " form directly. Instead, always use " { $link POSTPONE: SPECIALIZED-ARRAY: } ". This ensures that the vocabulary can get generated the first time it is needed." ;
+
+ARTICLE: "specialized-array-c" "Passing specialized arrays to C functions"
+"Each specialized array has a " { $slot "underlying" } " slot holding a " { $link byte-array } " with the raw data. Passing a specialized array as a parameter to a C function call will automatically extract the underlying data. To get at the underlying data directly, call the " { $link >c-ptr } " word on a specialized array." ;
+
+ARTICLE: "specialized-array-math" "Vector arithmetic with specialized arrays"
+"Each specialized array with a numeric type generates specialized versions of the " { $link "math-vectors" } " words. The compiler substitutes calls for these words if it can statically determine input types. The " { $snippet "optimized." } " word in the " { $vocab-link "compiler.tree.debugger" } " vocabulary can be used to determine if this optimization is being performed for a particular piece of code." ;
+
+ARTICLE: "specialized-array-examples" "Specialized array examples"
+"Let's import specialized float arrays:"
+{ $code "USING: specialized-arrays math.constants math.functions ;" "SPECIALIZED-ARRAY: float" }
+"Creating a float array with 3 elements:"
+{ $code "1.0 [ sin ] [ cos ] [ tan ] tri float-array{ } 3sequence ." }
+"Create a float array and sum the elements:"
+{ $code
+    "1000 iota [ 1000 /f pi * sin ] float-array{ } map-as"
+    "0.0 [ + ] reduce ."
+} ;
+
+ARTICLE: "specialized-arrays" "Specialized arrays"
+"The " { $vocab-link "specialized-arrays" } " vocabulary implements fixed-length sequence types for storing machine values in a space-efficient manner without boxing."
 $nl
-"The " { $vocab-link "specialized-vectors" } " vocabulary provides resizable versions of the above." ;
+"A specialized array type needs to be generated for each element type. This is done with a parsing word:"
+{ $subsection POSTPONE: SPECIALIZED-ARRAY: }
+"This parsing word adds new words to the search path:"
+{ $subsection "specialized-array-words" }
+{ $subsection "specialized-array-c" }
+{ $subsection "specialized-array-math" }
+{ $subsection "specialized-array-examples" }
+"The " { $vocab-link "specialized-vectors" } " vocabulary provides a resizable version of this abstraction." ;
 
 ABOUT: "specialized-arrays"
index 19f98ff31f64cfe744333af9f84cad348946932e..3290eccd2f8e3fb06d95236d105a071ef5f4e09f 100755 (executable)
@@ -1,9 +1,16 @@
 IN: specialized-arrays.tests
-USING: tools.test alien.syntax specialized-arrays sequences
-specialized-arrays.int specialized-arrays.bool
-specialized-arrays.ushort alien.c-types accessors kernel
-specialized-arrays.char specialized-arrays.uint
-specialized-arrays.float arrays combinators compiler ;
+USING: tools.test alien.syntax specialized-arrays
+specialized-arrays sequences alien.c-types accessors
+kernel arrays combinators compiler classes.struct
+combinators.smart compiler.tree.debugger math libc destructors
+sequences.private ;
+
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: bool
+SPECIALIZED-ARRAY: ushort
+SPECIALIZED-ARRAY: char
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: float
 
 [ t ] [ { 1 2 3 } >int-array int-array? ] unit-test
 
@@ -37,3 +44,65 @@ specialized-arrays.float arrays combinators compiler ;
     3 ALIEN: 123 100 <direct-ushort-array> new-sequence
     dup [ drop 0 ] change-each
 ] unit-test
+
+STRUCT: test-struct
+    { x int }
+    { y int } ;
+
+SPECIALIZED-ARRAY: test-struct
+
+[ 1 ] [
+    1 test-struct-array{ } new-sequence length
+] unit-test
+
+[ V{ test-struct } ] [
+    [ [ test-struct-array <struct> ] test-struct-array{ } output>sequence first ] final-classes
+] unit-test
+
+: make-point ( x y -- struct )
+    test-struct <struct-boa> ;
+
+[ 5/4 ] [
+    2 <test-struct-array>
+    1 2 make-point over set-first
+    3 4 make-point over set-second
+    0 [ [ x>> ] [ y>> ] bi / + ] reduce
+] unit-test
+
+[ 5/4 ] [
+    [
+        2 malloc-test-struct-array
+        dup &free drop
+        1 2 make-point over set-first
+        3 4 make-point over set-second
+        0 [ [ x>> ] [ y>> ] bi / + ] reduce
+    ] with-destructors
+] unit-test
+
+[ ] [ ALIEN: 123 10 <direct-test-struct-array> drop ] unit-test
+
+[ ] [
+    [
+        10 malloc-test-struct-array
+        &free drop
+    ] with-destructors
+] unit-test
+
+[ 15 ] [ 15 10 <test-struct-array> resize length ] unit-test
+
+[ S{ test-struct f 12 20 } ] [
+    test-struct-array{
+        S{ test-struct f  4 20 } 
+        S{ test-struct f 12 20 }
+        S{ test-struct f 20 20 }
+    } second
+] unit-test
+
+! Regression
+STRUCT: fixed-string { text char[100] } ;
+
+SPECIALIZED-ARRAY: fixed-string
+
+[ { ALIEN: 123 ALIEN: 223 ALIEN: 323 ALIEN: 423 } ] [
+    ALIEN: 123 4 <direct-fixed-string-array> [ (underlying)>> ] { } map-as
+] unit-test
index f3b75af95804bde492bc8ec4e92e1464a7a8f4a9..3a1ce48e683fc6494e2bc93b7a76b8cce1d0518c 100755 (executable)
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences vocabs vocabs.loader ;
+USING: accessors alien alien.c-types assocs byte-arrays classes
+compiler.units functors io kernel lexer libc math
+math.vectors.specialization namespaces parser
+prettyprint.custom sequences sequences.private strings summary
+vocabs vocabs.loader vocabs.parser words ;
 IN: specialized-arrays
 
 MIXIN: specialized-array
+
 INSTANCE: specialized-array sequence
 
 GENERIC: direct-array-syntax ( obj -- word )
 
+ERROR: bad-byte-array-length byte-array type ;
+
+M: bad-byte-array-length summary
+    drop "Byte array length doesn't divide type width" ;
+
+: (underlying) ( n c-type -- array )
+    heap-size * (byte-array) ; inline
+
+: <underlying> ( n type -- array )
+    heap-size * <byte-array> ; inline
+
+<PRIVATE
+
+FUNCTOR: define-array ( T -- )
+
+A            DEFINES-CLASS ${T}-array
+S            DEFINES-CLASS ${T}-sequence
+<A>          DEFINES <${A}>
+(A)          DEFINES (${A})
+<direct-A>   DEFINES <direct-${A}>
+malloc-A     DEFINES malloc-${A}
+>A           DEFINES >${A}
+byte-array>A DEFINES byte-array>${A}
+
+A{           DEFINES ${A}{
+A@           DEFINES ${A}@
+
+NTH          [ T dup c-type-getter-boxer array-accessor ]
+SET-NTH      [ T dup c-setter array-accessor ]
+
+WHERE
+
+MIXIN: S
+
+TUPLE: A
+{ underlying c-ptr read-only }
+{ length array-capacity read-only } ;
+
+: <direct-A> ( alien len -- specialized-array ) A boa ; inline
+
+: <A> ( n -- specialized-array ) [ T <underlying> ] keep <direct-A> ; inline
+
+: (A) ( n -- specialized-array ) [ T (underlying) ] keep <direct-A> ; inline
+
+: malloc-A ( len -- specialized-array ) [ T heap-size calloc ] keep <direct-A> ; inline
+
+: byte-array>A ( byte-array -- specialized-array )
+    dup length T heap-size /mod 0 = [ drop T bad-byte-array-length ] unless
+    <direct-A> ; inline
+
+M: A clone [ underlying>> clone ] [ length>> ] bi <direct-A> ; inline
+
+M: A length length>> ; inline
+
+M: A nth-unsafe underlying>> NTH call ; inline
+
+M: A set-nth-unsafe underlying>> SET-NTH call ; inline
+
+: >A ( seq -- specialized-array ) A new clone-like ;
+
+M: A like drop dup A instance? [ >A ] unless ; inline
+
+M: A new-sequence drop (A) ; inline
+
+M: A equal? over A instance? [ sequence= ] [ 2drop f ] if ;
+
+M: A resize
+    [
+        [ T heap-size * ] [ underlying>> ] bi*
+        resize-byte-array
+    ] [ drop ] 2bi
+    <direct-A> ; inline
+
+M: A byte-length underlying>> length ; inline
+M: A pprint-delims drop \ A{ \ } ;
+M: A >pprint-sequence ;
+
+SYNTAX: A{ \ } [ >A ] parse-literal ;
+SYNTAX: A@ scan-object scan-object <direct-A> parsed ;
+
+INSTANCE: A specialized-array
+
+A T c-type-boxed-class f specialize-vector-words
+
+;FUNCTOR
+
+: underlying-type ( c-type -- c-type' )
+    dup c-types get at string? [
+        c-types get at underlying-type
+    ] when ;
+
+: specialized-array-vocab ( c-type -- vocab )
+    "specialized-arrays.instances." prepend ;
+
+: defining-array-message ( type -- )
+    "quiet" get [ drop ] [
+        "Generating specialized " " arrays..." surround print
+    ] if ;
+
+PRIVATE>
+
+: define-array-vocab ( type  -- vocab )
+    underlying-type
+    dup specialized-array-vocab vocab
+    [ ] [
+        [ defining-array-message ]
+        [
+            [
+                dup specialized-array-vocab
+                [ define-array ] with-current-vocab
+            ] with-compilation-unit
+        ]
+        [ specialized-array-vocab ]
+        tri
+    ] ?if ;
+
+M: string require-c-array define-array-vocab drop ;
+
+ERROR: specialized-array-vocab-not-loaded c-type ;
+
+M: string c-array-constructor
+    underlying-type
+    dup [ "<" "-array>" surround ] [ specialized-array-vocab ] bi lookup
+    [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
+
+M: string c-(array)-constructor
+    underlying-type
+    dup [ "(" "-array)" surround ] [ specialized-array-vocab ] bi lookup
+    [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
+
+M: string c-direct-array-constructor
+    underlying-type
+    dup [ "<direct-" "-array>" surround ] [ specialized-array-vocab ] bi lookup
+    [ ] [ specialized-array-vocab-not-loaded ] ?if ; foldable
+
+SYNTAX: SPECIALIZED-ARRAY:
+    scan define-array-vocab use-vocab ;
+
 "prettyprint" vocab [
     "specialized-arrays.prettyprint" require
 ] when
diff --git a/basis/specialized-arrays/uchar/uchar.factor b/basis/specialized-arrays/uchar/uchar.factor
deleted file mode 100644 (file)
index c6ed4f3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.uchar
-
-<< "uchar" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/uint/uint.factor b/basis/specialized-arrays/uint/uint.factor
deleted file mode 100644 (file)
index 1534a3d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.uint
-
-<< "uint" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/ulong/ulong.factor b/basis/specialized-arrays/ulong/ulong.factor
deleted file mode 100644 (file)
index 27dc129..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.ulong
-
-<< "ulong" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/ulonglong/ulonglong.factor b/basis/specialized-arrays/ulonglong/ulonglong.factor
deleted file mode 100644 (file)
index cbb2b3c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.ulonglong
-
-<< "ulonglong" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/ushort/ushort.factor b/basis/specialized-arrays/ushort/ushort.factor
deleted file mode 100644 (file)
index e0989aa..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USE: specialized-arrays.functor
-IN: specialized-arrays.ushort
-
-<< "ushort" define-array >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/alien/alien.factor b/basis/specialized-vectors/alien/alien.factor
deleted file mode 100644 (file)
index 2b9855f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.alien ;
-IN: specialized-vectors.alien
-
-<< "void*" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/bool/bool.factor b/basis/specialized-vectors/bool/bool.factor
deleted file mode 100644 (file)
index 75d452a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.bool ;
-IN: specialized-vectors.bool
-
-<< "bool" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/char/char.factor b/basis/specialized-vectors/char/char.factor
deleted file mode 100644 (file)
index c34167c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.char ;
-IN: specialized-vectors.char
-
-<< "char" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/double/double.factor b/basis/specialized-vectors/double/double.factor
deleted file mode 100644 (file)
index 5e77162..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.double ;
-IN: specialized-vectors.double
-
-<< "double" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/float/float.factor b/basis/specialized-vectors/float/float.factor
deleted file mode 100644 (file)
index 010b448..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.float ;
-IN: specialized-vectors.float
-
-<< "float" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/functor/functor.factor b/basis/specialized-vectors/functor/functor.factor
deleted file mode 100644 (file)
index 27bba3f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types functors sequences sequences.private growable
-prettyprint.custom kernel words classes math parser ;
-QUALIFIED: vectors.functor
-IN: specialized-vectors.functor
-
-FUNCTOR: define-vector ( T -- )
-
-V   DEFINES-CLASS ${T}-vector
-
-A   IS      ${T}-array
-S   IS      ${T}-sequence
-<A> IS      <${A}>
-
->V  DEFERS >${V}
-V{  DEFINES ${V}{
-
-WHERE
-
-V A <A> vectors.functor:define-vector
-
-M: V contract 2drop ;
-
-M: V byte-length underlying>> byte-length ;
-
-M: V pprint-delims drop \ V{ \ } ;
-
-M: V >pprint-sequence ;
-
-M: V pprint* pprint-object ;
-
-SYNTAX: V{ \ } [ >V ] parse-literal ;
-
-INSTANCE: V growable
-INSTANCE: V S
-
-;FUNCTOR
diff --git a/basis/specialized-vectors/functor/summary.txt b/basis/specialized-vectors/functor/summary.txt
deleted file mode 100644 (file)
index dc26fa6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Code generation for specialized vectors
diff --git a/basis/specialized-vectors/int/int.factor b/basis/specialized-vectors/int/int.factor
deleted file mode 100644 (file)
index d77e6fd..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.int ;
-IN: specialized-vectors.int
-
-<< "int" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/long/long.factor b/basis/specialized-vectors/long/long.factor
deleted file mode 100644 (file)
index a026054..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.long ;
-IN: specialized-vectors.long
-
-<< "long" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/longlong/longlong.factor b/basis/specialized-vectors/longlong/longlong.factor
deleted file mode 100644 (file)
index e272ea0..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.longlong ;
-IN: specialized-vectors.longlong
-
-<< "longlong" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/short/short.factor b/basis/specialized-vectors/short/short.factor
deleted file mode 100644 (file)
index 26ffad4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.short ;
-IN: specialized-vectors.short
-
-<< "short" define-vector >>
\ No newline at end of file
index 5c0a15cb7557f9ff341794c4b4b0475d8dc0c376..9c575fe73a0b8a01d5b0df024275294bc72db9a2 100644 (file)
@@ -1,35 +1,28 @@
-USING: help.markup help.syntax byte-vectors ;
+USING: help.markup help.syntax byte-vectors alien byte-arrays ;
 IN: specialized-vectors
 
-ARTICLE: "specialized-vectors" "Specialized vectors"
-"The " { $vocab-link "specialized-vectors" } " vocabulary implements resizable sequence types for storing machine values in a space-efficient manner without boxing."
-$nl
-"For each primitive C type " { $snippet "T" } ", a set of words are defined:"
+HELP: SPECIALIZED-VECTOR:
+{ $syntax "SPECIALIZED-VECTOR: type" }
+{ $values { "type" "a C type" } }
+{ $description "Brings a specialized vector for holding values of " { $snippet "type" } " into the vocabulary search path. The generated words are documented in " { $link "specialized-vector-words" } "." } ;
+
+ARTICLE: "specialized-vector-words" "Specialized vector words"
+"The " { $link POSTPONE: SPECIALIZED-VECTOR: } " parsing word generates the specialized vector type if it hasn't been generated already, and adds the following words to the vocabulary search path, where " { $snippet "T" } " is the C type in question:"
 { $table
     { { $snippet "T-vector" } { "The class of vectors with elements of type " { $snippet "T" } } }
     { { $snippet "<T-vector>" } { "Constructor for vectors with elements of type " { $snippet "T" } "; stack effect " { $snippet "( len -- vector )" } } }
     { { $snippet ">T-vector" } { "Converts a sequence into a specialized vector of type " { $snippet "T" } "; stack effect " { $snippet "( seq -- vector )" } } }
     { { $snippet "T-vector{" } { "Literal syntax, consists of a series of values terminated by " { $snippet "}" } } }
 }
-"The primitive C types for which specialized vectors exist:"
-{ $list
-    { $snippet "char" }
-    { $snippet "uchar" }
-    { $snippet "short" }
-    { $snippet "ushort" }
-    { $snippet "int" }
-    { $snippet "uint" }
-    { $snippet "long" }
-    { $snippet "ulong" }
-    { $snippet "longlong" }
-    { $snippet "ulonglong" }
-    { $snippet "float" }
-    { $snippet "double" }
-    { $snippet "void*" }
-    { $snippet "bool" }
-}
-"Specialized vectors are generated with a functor in the " { $vocab-link "specialized-vectors.functor" } " vocabulary."
-$nl
-"The " { $vocab-link "specialized-arrays" } " vocabulary provides fixed-length versions of the above." ;
+"Behind the scenes, these words are placed in a vocabulary named " { $snippet "specialized-vectors.instances.T" } ", however this vocabulary should not be placed in a " { $link POSTPONE: USING: } " form directly. Instead, always use " { $link POSTPONE: SPECIALIZED-VECTOR: } ". This ensures that the vocabulary can get generated the first time it is needed." ;
+
+ARTICLE: "specialized-vector-c" "Passing specialized arrays to C functions"
+"Each specialized array has a " { $slot "underlying" } " slot holding a specialized array, which in turn has an " { $slot "underlying" } " slot holding a " { $link byte-array } " with the raw data. Passing a specialized vector as a parameter to a C function call will automatically extract the underlying data. To get at the underlying data directly, call the " { $link >c-ptr } " word on a specialized vector." ;
+
+ARTICLE: "specialized-vectors" "Specialized vectors"
+"The " { $vocab-link "specialized-vectors" } " vocabulary implements resizable sequence types for storing machine values in a space-efficient manner without boxing."
+{ $subsection "specialized-vector-words" }
+{ $subsection "specialized-vector-c" }
+"The " { $vocab-link "specialized-arrays" } " vocabulary provides a fixed-length version of this abstraction." ;
 
 ABOUT: "specialized-vectors"
index 82def17e4471521dff66c5e96e09de18f13a8d59..edff828b13dda9c0a5b24ddb066808190d6224f9 100644 (file)
@@ -1,8 +1,9 @@
 IN: specialized-vectors.tests
-USING: specialized-arrays.float
-specialized-vectors.float
-specialized-vectors.double
+USING: specialized-arrays specialized-vectors
 tools.test kernel sequences ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-VECTOR: float
+SPECIALIZED-VECTOR: double
 
 [ 3 ] [ double-vector{ 1 2 } 3 over push length ] unit-test
 
index 5df602c78d91a3d9cc9d184f3e70673df3f03126..19f32a7fdbf0df27fd303dc610f3ee0be76e6804 100644 (file)
@@ -1,3 +1,72 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.c-types assocs compiler.units functors
+growable io kernel lexer namespaces parser prettyprint.custom
+sequences specialized-arrays specialized-arrays.private strings
+vocabs vocabs.parser ;
+QUALIFIED: vectors.functor
 IN: specialized-vectors
+
+<PRIVATE
+
+FUNCTOR: define-vector ( T -- )
+
+V   DEFINES-CLASS ${T}-vector
+
+A   IS      ${T}-array
+S   IS      ${T}-sequence
+<A> IS      <${A}>
+
+>V  DEFERS >${V}
+V{  DEFINES ${V}{
+
+WHERE
+
+V A <A> vectors.functor:define-vector
+
+M: V contract 2drop ;
+
+M: V byte-length underlying>> byte-length ;
+
+M: V pprint-delims drop \ V{ \ } ;
+
+M: V >pprint-sequence ;
+
+M: V pprint* pprint-object ;
+
+SYNTAX: V{ \ } [ >V ] parse-literal ;
+
+INSTANCE: V growable
+INSTANCE: V S
+
+;FUNCTOR
+
+: specialized-vector-vocab ( type -- vocab )
+    "specialized-vectors.instances." prepend ;
+
+: defining-vector-message ( type -- )
+    "quiet" get [ drop ] [
+        "Generating specialized " " vectors..." surround print
+    ] if ;
+
+PRIVATE>
+
+: define-vector-vocab ( type  -- vocab )
+    underlying-type
+    dup specialized-vector-vocab vocab
+    [ ] [
+        [ defining-vector-message ]
+        [
+            [
+                dup specialized-vector-vocab
+                [ define-vector ] with-current-vocab
+            ] with-compilation-unit
+        ]
+        [ specialized-vector-vocab ]
+        tri
+    ] ?if ;
+
+SYNTAX: SPECIALIZED-VECTOR:
+    scan
+    [ define-array-vocab use-vocab ]
+    [ define-vector-vocab use-vocab ] bi ;
diff --git a/basis/specialized-vectors/uchar/uchar.factor b/basis/specialized-vectors/uchar/uchar.factor
deleted file mode 100644 (file)
index 76cbd15..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.uchar ;
-IN: specialized-vectors.uchar
-
-<< "uchar" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/uint/uint.factor b/basis/specialized-vectors/uint/uint.factor
deleted file mode 100644 (file)
index 9580087..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.uint ;
-IN: specialized-vectors.uint
-
-<< "uint" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/ulong/ulong.factor b/basis/specialized-vectors/ulong/ulong.factor
deleted file mode 100644 (file)
index 486a9dd..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.ulong ;
-IN: specialized-vectors.ulong
-
-<< "ulong" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/ulonglong/ulonglong.factor b/basis/specialized-vectors/ulonglong/ulonglong.factor
deleted file mode 100644 (file)
index c06ccec..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.ulonglong ;
-IN: specialized-vectors.ulonglong
-
-<< "ulonglong" define-vector >>
\ No newline at end of file
diff --git a/basis/specialized-vectors/ushort/ushort.factor b/basis/specialized-vectors/ushort/ushort.factor
deleted file mode 100644 (file)
index 6968607..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-vectors.functor specialized-arrays.ushort ;
-IN: specialized-vectors.ushort
-
-<< "ushort" define-vector >>
\ No newline at end of file
diff --git a/basis/struct-arrays/authors.txt b/basis/struct-arrays/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/basis/struct-arrays/prettyprint/prettyprint.factor b/basis/struct-arrays/prettyprint/prettyprint.factor
deleted file mode 100644 (file)
index 77fb684..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-! (c)Joe Groff bsd license
-USING: accessors arrays kernel prettyprint.backend
-prettyprint.custom prettyprint.sections sequences struct-arrays ;
-IN: struct-arrays.prettyprint
-
-M: struct-array pprint-delims
-    drop \ struct-array{ \ } ;
-
-M: struct-array >pprint-sequence
-    [ >array ] [ class>> ] bi prefix ;
-
-: pprint-struct-array-pointer ( struct-array -- )
-    \ struct-array@ 
-    [ [ class>> pprint-word ] [ underlying>> pprint* ] [ length>> pprint* ] tri ]
-    pprint-prefix ;
-
-M: struct-array pprint*
-    [ pprint-object ]
-    [ pprint-struct-array-pointer ] pprint-c-object ;
-
diff --git a/basis/struct-arrays/struct-arrays-docs.factor b/basis/struct-arrays/struct-arrays-docs.factor
deleted file mode 100644 (file)
index 8483901..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-IN: struct-arrays
-USING: classes.struct help.markup help.syntax alien strings math multiline ;
-
-HELP: struct-array
-{ $class-description "The class of C struct and union arrays."
-$nl
-"The " { $slot "underlying" } " slot holds a " { $link c-ptr } " with the raw data. This pointer can be passed to C functions." } ;
-
-HELP: <struct-array>
-{ $values { "length" integer } { "struct-class" struct-class } { "struct-array" struct-array } }
-{ $description "Creates a new array for holding values of the specified struct type." } ;
-
-HELP: <direct-struct-array>
-{ $values { "alien" c-ptr } { "length" integer } { "struct-class" struct-class } { "struct-array" struct-array } }
-{ $description "Creates a new array for holding values of the specified C type, backed by the memory at " { $snippet "alien" } "." } ;
-
-HELP: struct-array-on
-{ $values { "struct" struct } { "length" integer } { "struct-array" struct-array } }
-{ $description "Create a new array for holding values of " { $snippet "struct" } "'s C type, backed by the memory starting at " { $snippet "struct" } "'s address." }
-{ $examples
-"This word is useful with the FFI. When a C function has a pointer to a struct as its return type (or a C callback has a struct pointer as an argument type), Factor automatically wraps the pointer in a " { $link struct } " object. If the pointer actually references an array of objects, this word will convert the struct object to a struct array object:"
-{ $code <" USING: alien.syntax classes.struct struct-arrays ;
-IN: scratchpad
-
-STRUCT: zim { zang int } { zung int } ;
-
-FUNCTION: zim* zingle ( ) ; ! Returns a pointer to 20 zims
-
-zingle 20 struct-array-on "> }
-} ;
-
-HELP: struct-array{
-{ $syntax "struct-array{ class value value value ... }" }
-{ $description "Literal syntax for a " { $link struct-array } " containing structs of the given " { $link struct } " class." } ;
-
-HELP: struct-array@
-{ $syntax "struct-array@ class alien length" }
-{ $description "Literal syntax for a " { $link struct-array } " at a particular memory address. The prettyprinter uses this syntax when the memory backing a struct array object is invalid. This syntax should not generally be used in source code." } ;
-
-{ POSTPONE: struct-array{ POSTPONE: struct-array@ } related-words
-
-ARTICLE: "struct-arrays" "C struct and union arrays"
-"The " { $vocab-link "struct-arrays" } " vocabulary implements arrays specialized for holding C struct and union values."
-{ $subsection struct-array }
-{ $subsection <struct-array> }
-{ $subsection <direct-struct-array> }
-{ $subsection struct-array-on }
-"Struct arrays have literal syntax:"
-{ $subsection POSTPONE: struct-array{ } ;
-
-ABOUT: "struct-arrays"
diff --git a/basis/struct-arrays/struct-arrays-tests.factor b/basis/struct-arrays/struct-arrays-tests.factor
deleted file mode 100755 (executable)
index 24caafa..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-IN: struct-arrays.tests
-USING: classes.struct struct-arrays tools.test kernel math sequences
-alien.syntax alien.c-types destructors libc accessors sequences.private
-compiler.tree.debugger combinators.smart ;
-
-STRUCT: test-struct-array
-    { x int }
-    { y int } ;
-
-[ 1 ] [
-    1 struct-array{ test-struct-array } new-sequence length
-] unit-test
-
-[ V{ test-struct-array } ] [
-    [ [ test-struct-array <struct> ] struct-array{ test-struct-array } output>sequence first ] final-classes
-] unit-test
-
-: make-point ( x y -- struct )
-    test-struct-array <struct-boa> ;
-
-[ 5/4 ] [
-    2 test-struct-array <struct-array>
-    1 2 make-point over set-first
-    3 4 make-point over set-second
-    0 [ [ x>> ] [ y>> ] bi / + ] reduce
-] unit-test
-
-[ 5/4 ] [
-    [
-        2 test-struct-array malloc-struct-array
-        dup &free drop
-        1 2 make-point over set-first
-        3 4 make-point over set-second
-        0 [ [ x>> ] [ y>> ] bi / + ] reduce
-    ] with-destructors
-] unit-test
-
-[ ] [ ALIEN: 123 10 test-struct-array <direct-struct-array> drop ] unit-test
-
-[ ] [
-    [
-        10 test-struct-array malloc-struct-array
-        &free drop
-    ] with-destructors
-] unit-test
-
-[ 15 ] [ 15 10 test-struct-array <struct-array> resize length ] unit-test
-
-[ S{ test-struct-array f 12 20 } ] [
-    struct-array{ test-struct-array
-        S{ test-struct-array f  4 20 } 
-        S{ test-struct-array f 12 20 }
-        S{ test-struct-array f 20 20 }
-    } second
-] unit-test
-
-! Regression
-STRUCT: fixed-string { text char[100] } ;
-
-[ { ALIEN: 123 ALIEN: 223 ALIEN: 323 ALIEN: 423 } ] [
-    ALIEN: 123 4 fixed-string <direct-struct-array> [ (underlying)>> ] { } map-as
-] unit-test
-
-[ 10 "int" <struct-array> ] must-fail
-
-STRUCT: wig { x int } ;
-: <bacon> ( -- wig ) 0 wig <struct-boa> ; inline
-: waterfall ( -- a b ) 1 wig <struct-array> <bacon> swap first x>> ; inline
-
-[ t ] [ [ waterfall ] { x>> } inlined? ] unit-test
\ No newline at end of file
diff --git a/basis/struct-arrays/struct-arrays.factor b/basis/struct-arrays/struct-arrays.factor
deleted file mode 100755 (executable)
index c578082..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types alien.structs byte-arrays
-classes classes.struct kernel libc math parser sequences
-sequences.private words fry memoize compiler.units ;
-IN: struct-arrays
-
-TUPLE: struct-array
-{ underlying c-ptr read-only }
-{ length array-capacity read-only }
-{ element-size array-capacity read-only }
-{ class read-only }
-{ ctor read-only } ;
-
-<PRIVATE
-
-: (nth-ptr) ( i struct-array -- alien )
-    [ element-size>> * >fixnum ] [ underlying>> ] bi <displaced-alien> ; inline
-
-: (struct-element-constructor) ( struct-class -- word )
-    [
-        "struct-array-ctor" f <word>
-        [ swap '[ _ memory>struct ] (( alien -- object )) define-inline ] keep
-    ] with-compilation-unit ;
-
-! Foldable memo word. This is an optimization; by precompiling a
-! constructor for array elements, we avoid memory>struct's slow path.
-MEMO: struct-element-constructor ( struct-class -- word )
-    (struct-element-constructor) ; foldable
-
-PRIVATE>
-
-M: struct-array length length>> ; inline
-
-M: struct-array byte-length [ length>> ] [ element-size>> ] bi * ; inline
-
-M: struct-array nth-unsafe
-    [ (nth-ptr) ] [ ctor>> ] bi execute( alien -- object ) ; inline
-
-M: struct-array set-nth-unsafe
-    [ (nth-ptr) swap ] [ element-size>> ] bi memcpy ; inline
-
-ERROR: not-a-struct-class struct-class ;
-
-: <direct-struct-array> ( alien length struct-class -- struct-array )
-    dup struct-class? [ not-a-struct-class ] unless
-    [ heap-size ] [ ] [ struct-element-constructor ]
-    tri struct-array boa ; inline
-
-M: struct-array new-sequence
-    [ element-size>> * (byte-array) ] [ class>> ] 2bi
-    <direct-struct-array> ; inline
-
-M: struct-array resize ( n seq -- newseq )
-    [ [ element-size>> * ] [ underlying>> ] bi resize ] [ class>> ] 2bi
-    <direct-struct-array> ; inline
-
-: <struct-array> ( length struct-class -- struct-array )
-    [ heap-size * <byte-array> ] 2keep <direct-struct-array> ; inline
-
-ERROR: bad-byte-array-length byte-array ;
-
-: byte-array>struct-array ( byte-array c-type -- struct-array )
-    [
-        heap-size
-        [ dup length ] dip /mod 0 =
-        [ drop bad-byte-array-length ] unless
-    ] keep <direct-struct-array> ; inline
-
-: struct-array-on ( struct length -- struct-array )
-    [ [ >c-ptr ] [ class ] bi ] dip swap <direct-struct-array> ; inline    
-
-: malloc-struct-array ( length c-type -- struct-array )
-    [ heap-size calloc ] 2keep <direct-struct-array> ; inline
-
-INSTANCE: struct-array sequence
-
-M: struct-type <c-array> ( len c-type -- array )
-    dup c-array-constructor
-    [ execute( len -- array ) ]
-    [ <struct-array> ] ?if ; inline
-
-M: struct-type <c-direct-array> ( alien len c-type -- array )
-    dup c-direct-array-constructor
-    [ execute( alien len -- array ) ]
-    [ <direct-struct-array> ] ?if ; inline
-
-: >struct-array ( sequence class -- struct-array )
-    [ dup length ] dip <struct-array>
-    [ 0 swap copy ] keep ; inline
-
-SYNTAX: struct-array{
-    \ } scan-word [ >struct-array ] curry parse-literal ;
-
-SYNTAX: struct-array@
-    scan-word [ scan-object scan-object ] dip <direct-struct-array> parsed ;
-
-USING: vocabs vocabs.loader ;
-
-"prettyprint" vocab [ "struct-arrays.prettyprint" require ] when
diff --git a/basis/struct-arrays/summary.txt b/basis/struct-arrays/summary.txt
deleted file mode 100644 (file)
index 0458b5a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Arrays of C structs and unions
diff --git a/basis/struct-arrays/tags.txt b/basis/struct-arrays/tags.txt
deleted file mode 100644 (file)
index 42d711b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-collections
diff --git a/basis/struct-vectors/struct-vectors-docs.factor b/basis/struct-vectors/struct-vectors-docs.factor
deleted file mode 100644 (file)
index fe1b899..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-IN: struct-vectors
-USING: help.markup help.syntax classes.struct alien strings math ;
-
-HELP: struct-vector
-{ $class-description "The class of growable C struct and union arrays." } ;
-
-HELP: <struct-vector>
-{ $values { "capacity" integer } { "struct-class" struct-class } { "struct-vector" struct-vector } }
-{ $description "Creates a new vector with the given initial capacity." } ;
-
-ARTICLE: "struct-vectors" "C struct and union vectors"
-"The " { $vocab-link "struct-vectors" } " vocabulary implements vectors specialized for holding C struct and union values. These are growable versions of " { $vocab-link "struct-arrays" } "."
-{ $subsection struct-vector }
-{ $subsection <struct-vector> } ;
-
-ABOUT: "struct-vectors"
diff --git a/basis/struct-vectors/struct-vectors-tests.factor b/basis/struct-vectors/struct-vectors-tests.factor
deleted file mode 100644 (file)
index dec2e96..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-IN: struct-vectors.tests
-USING: struct-vectors tools.test alien.c-types classes.struct accessors
-namespaces kernel sequences ;
-
-STRUCT: point { x float } { y float } ;
-
-: make-point ( x y -- point ) point <struct-boa> ;
-
-[ ] [ 1 point <struct-vector> "v" set ] unit-test
-
-[ 1.5 6.0 ] [
-    1.0 2.0 make-point "v" get push
-    3.0 4.5 make-point "v" get push
-    1.5 6.0 make-point "v" get push
-    "v" get pop [ x>> ] [ y>> ] bi
-] unit-test
\ No newline at end of file
diff --git a/basis/struct-vectors/struct-vectors.factor b/basis/struct-vectors/struct-vectors.factor
deleted file mode 100644 (file)
index d4aa03c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types byte-arrays growable kernel math sequences
-sequences.private struct-arrays ;
-IN: struct-vectors
-
-TUPLE: struct-vector
-{ underlying struct-array }
-{ length array-capacity }
-{ c-type read-only } ;
-
-: <struct-vector> ( capacity struct-class -- struct-vector )
-    [ <struct-array> 0 ] keep struct-vector boa ; inline
-
-M: struct-vector byte-length underlying>> byte-length ;
-
-M: struct-vector new-sequence
-    [ c-type>> <struct-array> ] [ [ >fixnum ] [ c-type>> ] bi* ] 2bi
-    struct-vector boa ;
-
-M: struct-vector contract 2drop ;
-
-M: struct-array new-resizable c-type>> <struct-vector> ;
-
-INSTANCE: struct-vector growable
index e46d702e1f045a854123d4643a1148ba64283dca..42d1ee2a9fbe4f0a49eb4d563b4dc6ef12b213da 100755 (executable)
@@ -72,13 +72,6 @@ IN: tools.deploy.shaker
     "vocab:tools/deploy/shaker/strip-destructors.factor"
     run-file ;
 
-: strip-struct-arrays ( -- )
-    "struct-arrays" vocab [
-        "Stripping dynamic struct array code" show
-        "vocab:tools/deploy/shaker/strip-struct-arrays.factor"
-        run-file
-    ] when ;
-
 : strip-call ( -- )
     "Stripping stack effect checking from call( and execute(" show
     "vocab:tools/deploy/shaker/strip-call.factor" run-file ;
@@ -498,7 +491,6 @@ SYMBOL: deploy-vocab
 : strip ( -- )
     init-stripper
     strip-libc
-    strip-struct-arrays
     strip-destructors
     strip-call
     strip-cocoa
diff --git a/basis/tools/deploy/shaker/strip-struct-arrays.factor b/basis/tools/deploy/shaker/strip-struct-arrays.factor
deleted file mode 100644 (file)
index 022b5f1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-USING: kernel stack-checker.transforms ;
-IN: struct-arrays.private
-
-: struct-element-constructor ( c-type -- word )
-    "Struct array usages must be compiled" throw ;
-
-<<
-
-\ struct-element-constructor [
-    (struct-element-constructor) [ ] curry
-] 1 define-transform
-
->>
\ No newline at end of file
index fd06b2cb760f7a5984097b3da8fff288759ded29..2be6e70df8d4be613c020778f927a39c6696882c 100755 (executable)
@@ -1,17 +1,20 @@
 ! Copyright (C) 2005, 2006 Doug Coleman.
 ! Portions copyright (C) 2007, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.strings arrays assocs ui ui.private
-ui.gadgets ui.gadgets.private ui.backend ui.clipboards
-ui.gadgets.worlds ui.gestures ui.event-loop io kernel math
-math.vectors namespaces make sequences strings vectors words
-windows.kernel32 windows.gdi32 windows.user32 windows.opengl32
-windows.messages windows.types windows.offscreen windows.nt
-threads libc combinators fry combinators.short-circuit continuations
-command-line shuffle opengl ui.render math.bitwise locals
-accessors math.rectangles math.order calendar ascii sets
-io.encodings.utf16n windows.errors literals ui.pixel-formats 
-ui.pixel-formats.private memoize classes struct-arrays classes.struct ;
+USING: alien alien.c-types alien.strings arrays assocs ui
+ui.private ui.gadgets ui.gadgets.private ui.backend
+ui.clipboards ui.gadgets.worlds ui.gestures ui.event-loop io
+kernel math math.vectors namespaces make sequences strings
+vectors words windows.kernel32 windows.gdi32 windows.user32
+windows.opengl32 windows.messages windows.types
+windows.offscreen windows.nt threads libc combinators fry
+combinators.short-circuit continuations command-line shuffle
+opengl ui.render math.bitwise locals accessors math.rectangles
+math.order calendar ascii sets io.encodings.utf16n
+windows.errors literals ui.pixel-formats
+ui.pixel-formats.private memoize classes
+specialized-arrays classes.struct ;
+SPECIALIZED-ARRAY: POINT
 IN: ui.backend.windows
 
 SINGLETON: windows-ui-backend
@@ -758,7 +761,7 @@ M: windows-ui-backend beep ( -- )
 : client-area>RECT ( hwnd -- RECT )
     RECT <struct>
     [ GetClientRect win32-error=0/f ]
-    [ >c-ptr "POINT" byte-array>struct-array [ ClientToScreen drop ] with each ]
+    [ >c-ptr byte-array>POINT-array [ ClientToScreen drop ] with each ]
     [ nip ] 2tri ;
 
 : hwnd>RECT ( hwnd -- RECT )
index 042e2d34466ca7310f36e65a50246991ebbcbb78..53b4357d44f52871f148eb1743d8b16cd849a3f6 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors math math.vectors locals sequences
-specialized-arrays.float colors arrays combinators
+specialized-arrays colors arrays combinators
 opengl opengl.gl ui.pens ui.pens.caching ;
+SPECIALIZED-ARRAY: float
 IN: ui.pens.gradient
 
 ! Gradient pen
index d244cc71d2d3aa9f32c39f6e840b9c106f1625e8..a39a5cb7cdba4cbec476d80ed922e931da884bec 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors colors help.markup help.syntax kernel opengl
-opengl.gl sequences specialized-arrays.float math.vectors
-ui.gadgets ui.pens ;
+opengl.gl sequences math.vectors ui.gadgets ui.pens
+specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: ui.pens.polygon
 
 ! Polygon pen
index f463ae2b687fec53180373cd0cda9c86b4b0cd4a..5dcd9bde9ad4f09ad610e75c41d342c8a3c0a545 100644 (file)
@@ -1,6 +1,7 @@
 USING: accessors assocs classes destructors functors kernel
-lexer math parser sequences specialized-arrays.int ui.backend
+lexer math parser sequences specialized-arrays ui.backend
 words ;
+SPECIALIZED-ARRAY: int
 IN: ui.pixel-formats
 
 SYMBOLS:
index e1d26eab66f15b8aee02a9038cff23ac4be14611..8d141ccb247d61b0a736cb335bd736d707f7b949 100644 (file)
@@ -1,10 +1,12 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.strings
-combinators.short-circuit fry kernel layouts sequences
-specialized-arrays.alien accessors ;
+combinators.short-circuit fry kernel layouts sequences accessors
+specialized-arrays ;
 IN: unix.utilities
 
+SPECIALIZED-ARRAY: void*
+
 : more? ( alien -- ? )
     { [ ] [ *void* ] } 1&& ;
 
index 2cf6b31cf5095891a6d545b27083e6f2afc709fb..e69fc5b820e0d391d21764b14c8a1387ce1125b4 100755 (executable)
@@ -3,7 +3,8 @@ init windows.com.syntax.private windows.com continuations kernel
 namespaces windows.ole32 libc vocabs assocs accessors arrays
 sequences quotations combinators math words compiler.units
 destructors fry math.parser generalizations sets
-specialized-arrays.alien windows.kernel32 classes.struct ;
+specialized-arrays windows.kernel32 classes.struct ;
+SPECIALIZED-ARRAY: void*
 IN: windows.com.wrapper
 
 TUPLE: com-wrapper < disposable callbacks vtbls ;
index ec70a3cdd621be386fd3b5e48cef9f7e3b568db7..e0bfafc5c4e7adad2ef12e8af00c5d73a0a84519 100755 (executable)
@@ -2,7 +2,8 @@ USING: windows.dinput windows.kernel32 windows.ole32 windows.com
 windows.com.syntax alien alien.c-types alien.syntax kernel system namespaces
 combinators sequences fry math accessors macros words quotations
 libc continuations generalizations splitting locals assocs init
-struct-arrays memoize classes.struct ;
+specialized-arrays memoize classes.struct ;
+SPECIALIZED-ARRAY: DIOBJECTDATAFORMAT
 IN: windows.dinput.constants
 
 ! Some global variables aren't provided by the DirectInput DLL (they're in the
@@ -49,7 +50,7 @@ MEMO: heap-size* ( c-type -- n ) heap-size ;
     DIOBJECTDATAFORMAT <struct-boa> ;
 
 :: malloc-DIOBJECTDATAFORMAT-array ( struct array -- alien )
-    [let | alien [ array length DIOBJECTDATAFORMAT malloc-struct-array ] |
+    [let | alien [ array length malloc-DIOBJECTDATAFORMAT-array ] |
         array [| args i |
             struct args <DIOBJECTDATAFORMAT>
             i alien set-nth
index c8358f5aa6bf86abdec4d63832527c5783ea93e5..e7c92b599600b00e83e36b528c1f67ee9f5695eb 100644 (file)
@@ -1,6 +1,7 @@
 USING: kernel tools.test windows.ole32 alien.c-types
-classes.struct specialized-arrays.uchar windows.kernel32
+classes.struct specialized-arrays windows.kernel32
 windows.com.syntax ;
+SPECIALIZED-ARRAY: uchar
 IN: windows.ole32.tests
 
 [ t ] [
index c7ccf38e432504c10e9696d8cf31914aa95bca67..9e117c85225df02f23c73cecfdecdae3f343ce8b 100755 (executable)
@@ -1,8 +1,9 @@
 USING: alien alien.syntax alien.c-types alien.strings math
-kernel sequences windows.errors windows.types io
-accessors math.order namespaces make math.parser windows.kernel32
-combinators locals specialized-arrays.uchar
-literals splitting grouping classes.struct combinators.smart ;
+kernel sequences windows.errors windows.types io accessors
+math.order namespaces make math.parser windows.kernel32
+combinators locals specialized-arrays literals splitting
+grouping classes.struct combinators.smart ;
+SPECIALIZED-ARRAY: uchar
 IN: windows.ole32
 
 LIBRARY: ole32
index 47fed998c48defd0a4b2a5e5c5f256dcdc61cc0b..6b4e0d797eae1bf02ee6f55a8b59fa819a5bc0bf 100644 (file)
@@ -4,7 +4,8 @@ USING: alien alien.c-types alien.strings alien.syntax
 classes.struct combinators io.encodings.utf16n io.files
 io.pathnames kernel windows.errors windows.com
 windows.com.syntax windows.user32 windows.ole32 windows
-specialized-arrays.ushort ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: ushort
 IN: windows.shell32
 
 CONSTANT: CSIDL_DESKTOP HEX: 00
index 5cf645344371637ccb6a7daf4b21b0272bc434eb..c08ff1d1768989bc4436f7967001d0338ce07d0f 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.strings classes.struct
 io.encodings.utf8 kernel namespaces sequences
-specialized-arrays.int x11 x11.constants x11.xlib ;
+specialized-arrays x11 x11.constants x11.xlib ;
+SPECIALIZED-ARRAY: int
 IN: x11.clipboard
 
 ! This code was based on by McCLIM's Backends/CLX/port.lisp
index 67ac0e8cc1ac1e6aeec3b1bd0a2c8f8107c6d39a..5bc58e5f0aa5961cd8ead8d54b3e9cd01d3cccc6 100644 (file)
@@ -3,8 +3,9 @@
 !
 ! based on glx.h from xfree86, and some of glxtokens.h
 USING: alien alien.c-types alien.syntax x11 x11.xlib x11.syntax
-namespaces make kernel sequences parser words specialized-arrays.int
-accessors ;
+namespaces make kernel sequences parser words
+specialized-arrays accessors ;
+SPECIALIZED-ARRAY: int
 IN: x11.glx
 
 LIBRARY: glx
index 54f20a28ddc70499a00afc6fb336db6e4879eddd..06add388b18fa4744551f61c0e93110cd4e2f7b3 100644 (file)
@@ -2,8 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.strings arrays byte-arrays
 hashtables io io.encodings.string kernel math namespaces
-sequences strings continuations x11 x11.xlib specialized-arrays.uint
-accessors io.encodings.utf16n ;
+sequences strings continuations x11 x11.xlib
+specialized-arrays accessors io.encodings.utf16n ;
+SPECIALIZED-ARRAY: uint
 IN: x11.xim
 
 SYMBOL: xim
index 9e36f9f00cc6cbbe2ff28de7bc8a818cc934313f..78c17a1cc0acad1e9e218208c138885c65d1e25e 100644 (file)
@@ -1,6 +1,7 @@
 USING: kernel math namespaces make tools.test vectors sequences
 sequences.private hashtables io prettyprint assocs
-continuations specialized-arrays.double ;
+continuations specialized-arrays ;
+SPECIALIZED-ARRAY: double
 IN: assocs.tests
 
 [ t ] [ H{ } dup assoc-subset? ] unit-test
index f59268b770312caa7566d8bfe88a4d5adf969753..554e287a3b7831f0346ff29d12ab1bf02474fc2d 100644 (file)
@@ -1,9 +1,10 @@
-USING: tools.test math math.functions math.constants generic.standard
-generic.single strings sequences arrays kernel accessors words
-specialized-arrays.double byte-arrays bit-arrays parser namespaces
-make quotations stack-checker vectors growable hashtables sbufs
-prettyprint byte-vectors bit-vectors specialized-vectors.double
+USING: tools.test math math.functions math.constants
+generic.standard generic.single strings sequences arrays kernel
+accessors words byte-arrays bit-arrays parser namespaces make
+quotations stack-checker vectors growable hashtables sbufs
+prettyprint byte-vectors bit-vectors specialized-vectors
 definitions generic sets graphs assocs grouping see eval ;
+SPECIALIZED-VECTOR: double
 IN: generic.single.tests
 
 GENERIC: lo-tag-test ( obj -- obj' )
index 7ac0bd2e58fd6b1298da969a847f5d9a8c9d7269..2fc9d05d79e13a5910c49e8f4c427311492ae2b1 100755 (executable)
@@ -86,6 +86,11 @@ PRIVATE>
     [ manifest get (>>current-vocab) ]
     [ words>> <extra-words> (add-qualified) ] bi ;
 
+: with-current-vocab ( name quot -- )
+    manifest get clone manifest [
+        [ set-current-vocab ] dip call
+    ] with-variable ; inline
+
 TUPLE: no-current-vocab ;
 
 : no-current-vocab ( -- vocab )
index d861178fadf32d84a7463d3f59099a9d0ec22a21..2cae12264168235a1d90c7c3af77d0f5c3fe8c86 100644 (file)
@@ -4,15 +4,22 @@ USING: accessors alien alien.c-types alien.inline.types
 alien.marshall.private alien.strings byte-arrays classes
 combinators combinators.short-circuit destructors fry
 io.encodings.utf8 kernel libc sequences
-specialized-arrays.alien specialized-arrays.bool
-specialized-arrays.char specialized-arrays.double
-specialized-arrays.float specialized-arrays.int
-specialized-arrays.long specialized-arrays.longlong
-specialized-arrays.short specialized-arrays.uchar
-specialized-arrays.uint specialized-arrays.ulong
-specialized-arrays.ulonglong specialized-arrays.ushort strings
-unix.utilities vocabs.parser words libc.private struct-arrays
-locals generalizations math ;
+specialized-arrays strings unix.utilities vocabs.parser
+words libc.private locals generalizations math ;
+SPECIALIZED-ARRAY: bool
+SPECIALIZED-ARRAY: char
+SPECIALIZED-ARRAY: double
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: long
+SPECIALIZED-ARRAY: longlong
+SPECIALIZED-ARRAY: short
+SPECIALIZED-ARRAY: uchar
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: ulong
+SPECIALIZED-ARRAY: ulonglong
+SPECIALIZED-ARRAY: ushort
+SPECIALIZED-ARRAY: void*
 IN: alien.marshall
 
 << primitive-types [ [ "void*" = ] [ "bool" = ] bi or not ]
@@ -39,7 +46,6 @@ M: class-wrapper c++-type class name>> parse-c++-type ;
         { [ dup not ] [ ] }
         { [ dup byte-array? ] [ malloc-byte-array ] }
         { [ dup alien-wrapper? ] [ underlying>> ] }
-        { [ dup struct-array? ] [ underlying>> ] }
     } cond ;
 
 : marshall-primitive ( n -- n )
index 70b03e2bab061ddbb2202210a84c72313fa41457..c85b722d11d3d4ddef3d9711c9e5279b0f041646 100644 (file)
@@ -2,8 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.inline arrays
 combinators fry functors kernel lexer libc macros math
-sequences specialized-arrays.alien libc.private
+sequences specialized-arrays libc.private
 combinators.short-circuit ;
+SPECIALIZED-ARRAY: void*
 IN: alien.marshall.private
 
 : bool>arg ( ? -- 1/0/obj )
index 5cd40bc0981d1a8b40525c1af40c91052352cc17..ebfa37cdbcd817a0b18a121a6b5e9e2d3a36857a 100644 (file)
@@ -1,16 +1,15 @@
-USING: sequences hints kernel math specialized-arrays.int fry ;
+USING: sequences kernel math specialized-arrays fry ;
+SPECIALIZED-ARRAY: int
 IN: benchmark.dawes
 
 ! Phil Dawes's performance problem
 
 : count-ones ( int-array -- n ) [ 1 = ] count ; inline
 
-HINTS: count-ones int-array ;
-
 : make-int-array ( -- int-array )
-    120000 [ 255 bitand ] int-array{ } map-as ;
+    120000 [ 255 bitand ] int-array{ } map-as ; inline
 
 : dawes-benchmark ( -- )
-    make-int-array 200 swap '[ _ count-ones ] replicate drop ;
+    200 make-int-array '[ _ count-ones ] replicate drop ;
 
 MAIN: dawes-benchmark
index c9d4f9ffa282d3a047bffb8ac43079f3ec91856b..5dcefdda5a0ec7019746b4be188827910c433d43 100644 (file)
@@ -1,5 +1,6 @@
 USING: make math sequences splitting grouping
-kernel columns specialized-arrays.double bit-arrays ;
+kernel columns specialized-arrays bit-arrays ;
+SPECIALIZED-ARRAY: double
 IN: benchmark.dispatch2
 
 : sequences ( -- seq )
index 94925f0d7958853e6ad724880605b72940feea4f..58301b57af14328d57ca20b5b6efb8c1f2e3e3c5 100644 (file)
@@ -1,6 +1,7 @@
 USING: sequences math mirrors splitting grouping
 kernel make assocs alien.syntax columns
-specialized-arrays.double bit-arrays ;
+specialized-arrays bit-arrays ;
+SPECIALIZED-ARRAY: double
 IN: benchmark.dispatch3
 
 GENERIC: g ( obj -- str )
index c1d554a5a3919dc7ddd3631a7abbcee6a3250460..5b1a50c9e6226d373d4cc98f51495a050701a365 100755 (executable)
@@ -1,7 +1,8 @@
 ! Based on http://shootout.alioth.debian.org/gp4/benchmark.php?test=fasta&lang=java&id=2
 USING: math kernel io io.files locals multiline assocs sequences
-sequences.private benchmark.reverse-complement hints io.encodings.ascii
-byte-arrays specialized-arrays.double ;
+sequences.private benchmark.reverse-complement hints
+io.encodings.ascii byte-arrays specialized-arrays ;
+SPECIALIZED-ARRAY: double
 IN: benchmark.fasta
 
 CONSTANT: IM 139968
index e83f3ddc01d26979ffdf60203de86b4b0b294b2a..e8bef58923beae7076aa7f7d4c680b96a96a718a 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors fry kernel locals math math.constants
 math.functions math.vectors math.vectors.simd prettyprint
-combinators.smart sequences hints struct-arrays classes.struct ;
+combinators.smart sequences hints classes.struct
+specialized-arrays ;
 IN: benchmark.nbody-simd
 
 : solar-mass ( -- x ) 4 pi sq * ; inline
@@ -13,6 +14,8 @@ STRUCT: body
 { velocity double-4 }
 { mass double } ;
 
+SPECIALIZED-ARRAY: body
+
 : <body> ( location velocity mass -- body )
     [ days-per-year v*n ] [ solar-mass * ] bi* body <struct-boa> ; inline
 
@@ -46,16 +49,14 @@ STRUCT: body
 : offset-momentum ( body offset -- body )
     vneg solar-mass v/n >>velocity ; inline
 
-TUPLE: nbody-system { bodies struct-array read-only } ;
-
 : init-bodies ( bodies -- )
     [ first ] [ [ [ velocity>> ] [ mass>> ] bi v*n ] [ v+ ] map-reduce ] bi
     offset-momentum drop ; inline
 
 : <nbody-system> ( -- system )
     [ <sun> <jupiter> <saturn> <uranus> <neptune> ]
-    struct-array{ body } output>sequence nbody-system boa
-    dup bodies>> init-bodies ; inline
+    body-array{ } output>sequence
+    dup init-bodies ; inline
 
 :: each-pair ( bodies pair-quot: ( other-body body -- ) each-quot: ( body -- ) -- )
     bodies [| body i |
@@ -77,7 +78,6 @@ TUPLE: nbody-system { bodies struct-array read-only } ;
     [ [ other-body ] 2dip '[ body mass>> _ * _ n*v v+ ] change-velocity drop ] 2bi ; inline
 
 : advance ( system dt -- )
-    [ bodies>> ] dip
     [ '[ _ update-velocity ] [ drop ] each-pair ]
     [ '[ _ update-position ] each ]
     2bi ; inline
@@ -89,7 +89,7 @@ TUPLE: nbody-system { bodies struct-array read-only } ;
     [ [ mass>> ] bi@ * ] [ [ location>> ] bi@ distance ] 2bi / ; inline
 
 : energy ( system -- x )
-    [ 0.0 ] dip bodies>> [ newton's-law - ] [ inertia + ] each-pair ; inline
+    [ 0.0 ] dip [ newton's-law - ] [ inertia + ] each-pair ; inline
 
 : nbody ( n -- )
     >fixnum
index 983da8882176f1a7697d8fea8cdd6746c6599740..fc1cbaa12c211bc24ad38471376a6edb422823ca 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors specialized-arrays.double fry kernel locals math
-math.constants math.functions math.vectors prettyprint combinators.smart
-sequences hints arrays ;
+USING: accessors specialized-arrays fry kernel locals math
+math.constants math.functions math.vectors prettyprint
+combinators.smart sequences hints arrays ;
+SPECIALIZED-ARRAY: double
 IN: benchmark.nbody
 
 : solar-mass ( -- x ) 4 pi sq * ; inline
diff --git a/extra/benchmark/raytracer-simd/authors.txt b/extra/benchmark/raytracer-simd/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/extra/benchmark/raytracer-simd/raytracer-simd.factor b/extra/benchmark/raytracer-simd/raytracer-simd.factor
new file mode 100644 (file)
index 0000000..3712972
--- /dev/null
@@ -0,0 +1,187 @@
+! Factor port of the raytracer benchmark from
+! http://www.ffconsultancy.com/free/ray_tracer/languages.html
+
+USING: arrays accessors io io.files io.files.temp
+io.encodings.binary kernel math math.constants math.functions
+math.vectors math.vectors.simd math.parser make sequences
+sequences.private words hints classes.struct ;
+IN: benchmark.raytracer-simd
+
+! parameters
+
+! Normalized { -1 -3 2 }.
+CONSTANT: light
+    double-4{
+        -0.2672612419124244
+        -0.8017837257372732
+        0.5345224838248488
+        0.0
+    }
+
+CONSTANT: oversampling 4
+
+CONSTANT: levels 3
+
+CONSTANT: size 200
+
+: delta ( -- n ) epsilon sqrt ; inline
+
+TUPLE: ray { orig double-4 read-only } { dir double-4 read-only } ;
+
+C: <ray> ray
+
+TUPLE: hit { normal double-4 read-only } { lambda float read-only } ;
+
+C: <hit> hit
+
+GENERIC: intersect-scene ( hit ray scene -- hit )
+
+TUPLE: sphere { center double-4 read-only } { radius float read-only } ;
+
+C: <sphere> sphere
+
+: sphere-v ( sphere ray -- v )
+    [ center>> ] [ orig>> ] bi* v- ; inline
+
+: sphere-b ( v ray -- b )
+    dir>> v. ; inline
+
+: sphere-d ( sphere b v -- d )
+    [ radius>> sq ] [ sq ] [ norm-sq ] tri* - + ; inline
+
+: -+ ( x y -- x-y x+y )
+    [ - ] [ + ] 2bi ; inline
+
+: sphere-t ( b d -- t )
+    -+ dup 0.0 <
+    [ 2drop 1/0. ] [ [ [ 0.0 > ] keep ] dip ? ] if ; inline
+
+: sphere-b&v ( sphere ray -- b v )
+    [ sphere-v ] [ nip ] 2bi
+    [ sphere-b ] [ drop ] 2bi ; inline
+
+: ray-sphere ( sphere ray -- t )
+    [ drop ] [ sphere-b&v ] 2bi
+    [ drop ] [ sphere-d ] 3bi
+    dup 0.0 < [ 3drop 1/0. ] [ sqrt sphere-t nip ] if ; inline
+
+: if-ray-sphere ( hit ray sphere quot -- hit )
+    #! quot: hit ray sphere l -- hit
+    [
+        [ ] [ swap ray-sphere nip ] [ 2drop lambda>> ] 3tri
+        [ drop ] [ < ] 2bi
+    ] dip [ 3drop ] if ; inline
+
+: sphere-n ( ray sphere l -- n )
+    [ [ orig>> ] [ dir>> ] bi ] [ center>> ] [ ] tri*
+    swap [ v*n ] dip v- v+ ; inline
+
+M: sphere intersect-scene ( hit ray sphere -- hit )
+    [ [ sphere-n normalize ] keep <hit> nip ] if-ray-sphere ;
+
+HINTS: M\ sphere intersect-scene { hit ray sphere } ;
+
+TUPLE: group < sphere { objs array read-only } ;
+
+: <group> ( objs bound -- group )
+    [ center>> ] [ radius>> ] bi rot group boa ; inline
+
+: make-group ( bound quot -- )
+    swap [ { } make ] dip <group> ; inline
+
+M: group intersect-scene ( hit ray group -- hit )
+    [ drop objs>> [ intersect-scene ] with each ] if-ray-sphere ;
+
+HINTS: M\ group intersect-scene { hit ray group } ;
+
+CONSTANT: initial-hit T{ hit f double-4{ 0.0 0.0 0.0 0.0 } 1/0. }
+
+: initial-intersect ( ray scene -- hit )
+    [ initial-hit ] 2dip intersect-scene ; inline
+
+: ray-o ( ray hit -- o )
+    [ [ orig>> ] [ normal>> delta v*n ] bi* ]
+    [ [ dir>> ] [ lambda>> ] bi* v*n ]
+    2bi v+ v+ ; inline
+
+: sray-intersect ( ray scene hit -- ray )
+    swap [ ray-o light vneg <ray> ] dip initial-intersect ; inline
+
+: ray-g ( hit -- g ) normal>> light v. ; inline
+
+: cast-ray ( ray scene -- g )
+    2dup initial-intersect dup lambda>> 1/0. = [
+        3drop 0.0
+    ] [
+        [ sray-intersect lambda>> 1/0. = ] keep swap
+        [ ray-g neg ] [ drop 0.0 ] if
+    ] if ; inline
+
+: create-center ( c r d -- c2 )
+    [ 3.0 12.0 sqrt / * ] dip n*v v+ ; inline
+
+DEFER: create ( level c r -- scene )
+
+: create-step ( level c r d -- scene )
+    over [ create-center ] dip 2.0 / [ 1 - ] 2dip create ;
+
+: create-offsets ( quot -- )
+    {
+        double-4{ -1.0 1.0 -1.0 0.0 }
+        double-4{ 1.0 1.0 -1.0 0.0 }
+        double-4{ -1.0 1.0 1.0 0.0 }
+        double-4{ 1.0 1.0 1.0 0.0 }
+    } swap each ; inline
+
+: create-bound ( c r -- sphere ) 3.0 * <sphere> ;
+
+: create-group ( level c r -- scene )
+    2dup create-bound [
+        2dup <sphere> ,
+        [ [ 3dup ] dip create-step , ] create-offsets 3drop
+    ] make-group ;
+
+: create ( level c r -- scene )
+    pick 1 = [ <sphere> nip ] [ create-group ] if ;
+
+: ss-point ( dx dy -- point )
+    [ oversampling /f ] bi@ 0.0 0.0 double-4-boa ;
+
+: ss-grid ( -- ss-grid )
+    oversampling [ oversampling [ ss-point ] with map ] map ;
+
+: ray-grid ( point ss-grid -- ray-grid )
+    [
+        [ v+ normalize double-4{ 0.0 0.0 -4.0 0.0 } swap <ray> ] with map
+    ] with map ;
+
+: ray-pixel ( scene point -- n )
+    ss-grid ray-grid [ 0.0 ] 2dip
+    [ [ swap cast-ray + ] with each ] with each ;
+
+: pixel-grid ( -- grid )
+    size reverse [
+        size [
+            [ size 0.5 * - ] bi@ swap size
+            0.0 double-4-boa
+        ] with map
+    ] map ;
+
+: pgm-header ( w h -- )
+    "P5\n" % swap # " " % # "\n255\n" % ;
+
+: pgm-pixel ( n -- ) 255 * 0.5 + >fixnum , ;
+
+: ray-trace ( scene -- pixels )
+    pixel-grid [ [ ray-pixel ] with map ] with map ;
+
+: run ( -- string )
+    levels double-4{ 0.0 -1.0 0.0 0.0 } 1.0 create ray-trace [
+        size size pgm-header
+        [ [ oversampling sq / pgm-pixel ] each ] each
+    ] B{ } make ;
+
+: raytracer-main ( -- )
+    run "raytracer.pnm" temp-file binary set-file-contents ;
+
+MAIN: raytracer-main
index 4b60576bd1b1d437945b99bb6b7f3eb016c2f43a..96f345510f0a400efa44501de37e59c8f49c22e9 100755 (executable)
@@ -1,10 +1,11 @@
 ! Factor port of the raytracer benchmark from
 ! http://www.ffconsultancy.com/free/ray_tracer/languages.html
 
-USING: arrays accessors specialized-arrays.double io io.files
+USING: arrays accessors specialized-arrays io io.files
 io.files.temp io.encodings.binary kernel math math.constants
 math.functions math.vectors math.parser make sequences
 sequences.private words hints ;
+SPECIALIZED-ARRAY: double
 IN: benchmark.raytracer
 
 ! parameters
diff --git a/extra/benchmark/simd-1/authors.txt b/extra/benchmark/simd-1/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/extra/benchmark/simd-1/simd-1.factor b/extra/benchmark/simd-1/simd-1.factor
new file mode 100644 (file)
index 0000000..d5576b8
--- /dev/null
@@ -0,0 +1,30 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel io math math.functions math.parser math.vectors
+math.vectors.simd sequences specialized-arrays ;
+SPECIALIZED-ARRAY: float-4
+IN: benchmark.simd-1
+
+: <point> ( n -- float-4 )
+    >float [ sin ] [ cos 3 * ] [ sin sq 2 / ] tri
+    0.0 float-4-boa ; inline
+
+: make-points ( len -- points )
+    iota [ <point> ] float-4-array{ } map-as ; inline
+
+: normalize-points ( points -- )
+    [ normalize ] change-each ; inline
+
+: max-points ( points -- point )
+    [ ] [ vmax ] map-reduce ; inline
+
+: print-point ( point -- )
+    [ number>string ] { } map-as ", " join print ; inline
+
+: simd-benchmark ( len -- )
+    >fixnum make-points [ normalize-points ] [ max-points ] bi print-point ;
+
+: main ( -- )
+    5000000 simd-benchmark ;
+
+MAIN: main
index b86e11e239d69757fca872e90c4579f89c431b6b..4f93367b8a48e687e01c69b19bbd901c9f6370ae 100644 (file)
@@ -1,8 +1,9 @@
 ! Factor port of
 ! http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnorm&lang=all
-USING: specialized-arrays.double kernel math math.functions
+USING: specialized-arrays kernel math math.functions
 math.vectors sequences sequences.private prettyprint words hints
 locals ;
+SPECIALIZED-ARRAY: double
 IN: benchmark.spectral-norm
 
 :: inner-loop ( u n quot -- seq )
index faed2f4dcad3f02e9ec093aacd459fbfbf8baf02..799ef2d46760342d9535295a00cb4d763ad0dead 100644 (file)
@@ -2,11 +2,13 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors classes.struct combinators.smart fry kernel
 math math.functions math.order math.parser sequences
-struct-arrays io ;
+specialized-arrays io ;
 IN: benchmark.struct-arrays
 
 STRUCT: point { x float } { y float } { z float } ;
 
+SPECIALIZED-ARRAY: point
+
 : xyz ( point -- x y z )
     [ x>> ] [ y>> ] [ z>> ] tri ; inline
 
@@ -19,7 +21,7 @@ STRUCT: point { x float } { y float } { z float } ;
     1 + ; inline
 
 : make-points ( len -- points )
-    point <struct-array> dup 0 [ init-point ] reduce drop ; inline
+    <point-array> dup 0 [ init-point ] reduce drop ; inline
 
 : point-norm ( point -- norm )
     [ xyz [ absq ] tri@ ] sum-outputs sqrt ; inline
index 0791773ba74107abf337a27e90e8712d6ff7f52f..07528c35e80ef1e8fa8e311a3acb5399f6ebd4e9 100755 (executable)
@@ -1,6 +1,6 @@
 USING: alien.c-types continuations destructors kernel
-opengl opengl.gl bunny.model specialized-arrays.float
-accessors ;
+opengl opengl.gl bunny.model specialized-arrays accessors ;
+SPECIALIZED-ARRAY: float
 IN: bunny.fixed-pipeline
 
 TUPLE: bunny-fixed-pipeline ;
index 387193690270436f674a6a313112882f4270a671..dd6730b57f1382d41f9592fb8460eeda57946589 100755 (executable)
@@ -2,8 +2,9 @@ USING: accessors alien.c-types arrays combinators destructors
 http.client io io.encodings.ascii io.files io.files.temp kernel
 math math.matrices math.parser math.vectors opengl
 opengl.capabilities opengl.gl opengl.demo-support sequences
-splitting vectors words specialized-arrays.float
-specialized-arrays.uint ;
+splitting vectors words specialized-arrays ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: uint
 IN: bunny.model
 
 : numbers ( str -- seq )
index 44ce63692e403a9ee50b46707e39352a3d5460a9..10e49984a1c63d5cb052493af8ca67799f1fc1de 100755 (executable)
@@ -1,12 +1,14 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types arrays classes.struct combinators
-combinators.short-circuit game-worlds gpu gpu.buffers gpu.util.wasd
-gpu.framebuffers gpu.render gpu.shaders gpu.state gpu.textures gpu.util
-grouping http.client images images.loader io io.encodings.ascii io.files
-io.files.temp kernel math math.matrices math.parser math.vectors
-method-chains sequences specialized-arrays.float specialized-vectors.uint
-splitting struct-vectors threads ui ui.gadgets ui.gadgets.worlds
-ui.pixel-formats ;
+combinators.short-circuit game-worlds gpu gpu.buffers
+gpu.util.wasd gpu.framebuffers gpu.render gpu.shaders gpu.state
+gpu.textures gpu.util grouping http.client images images.loader
+io io.encodings.ascii io.files io.files.temp kernel math
+math.matrices math.parser math.vectors method-chains sequences
+splitting threads ui ui.gadgets ui.gadgets.worlds
+ui.pixel-formats specialized-arrays specialized-vectors ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-VECTOR: uint
 IN: gpu.demos.bunny
 
 GLSL-SHADER-FILE: bunny-vertex-shader vertex-shader "bunny.v.glsl"
@@ -51,6 +53,8 @@ VERTEX-FORMAT: bunny-vertex
     { f        float-components 1 f } ;
 VERTEX-STRUCT: bunny-vertex-struct bunny-vertex
 
+SPECIALIZED-VECTOR: bunny-vertex-struct
+
 UNIFORM-TUPLE: bunny-uniforms < mvp-uniforms
     { "light-position" vec3-uniform  f }
     { "color"          vec4-uniform  f }
@@ -86,7 +90,7 @@ UNIFORM-TUPLE: loading-uniforms
     ] when* ;
 
 : parse-bunny-model ( -- vertexes indexes )
-    100000 bunny-vertex-struct <struct-vector>
+    100000 <bunny-vertex-struct-vector>
     100000 <uint-vector>
     (parse-bunny-model) ;
 
diff --git a/extra/gpu/demos/bunny/deploy.factor b/extra/gpu/demos/bunny/deploy.factor
new file mode 100644 (file)
index 0000000..fe80da1
--- /dev/null
@@ -0,0 +1,14 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-name "gpu.demos.bunny" }
+    { deploy-word-defs? f }
+    { deploy-io 3 }
+    { "stop-after-last-window?" t }
+    { deploy-math? t }
+    { deploy-word-props? f }
+    { deploy-threads? t }
+    { deploy-c-types? f }
+    { deploy-reflection 2 }
+    { deploy-unicode? f }
+    { deploy-ui? t }
+}
index 12bc3430c30f221fe78ed5bbc3acc9bacf8f1630..efd71782d01550e353d9c22e94f0b27231d94a2a 100755 (executable)
@@ -3,8 +3,9 @@ USING: accessors alien.c-types arrays byte-arrays combinators
 destructors gpu gpu.buffers gpu.private gpu.textures
 gpu.textures.private images kernel locals math math.rectangles opengl
 opengl.framebuffers opengl.gl opengl.textures sequences
-specialized-arrays.int specialized-arrays.uint
-ui.gadgets.worlds variants ;
+specialized-arrays ui.gadgets.worlds variants ;
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: uint
 IN: gpu.framebuffers
 
 SINGLETON: system-framebuffer
index 171c9bb031e42ca682b63017582a86170049982e..f323c1ee3be852983a4480b66bab39665da5523f 100755 (executable)
@@ -2,8 +2,12 @@
 USING: alien alien.syntax byte-arrays classes gpu.buffers
 gpu.framebuffers gpu.shaders gpu.textures help.markup
 help.syntax images kernel math multiline sequences
-specialized-arrays.alien specialized-arrays.uint
-specialized-arrays.ulong strings ;
+specialized-arrays strings ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: ulong
+SPECIALIZED-ARRAY: void*
 IN: gpu.render
 
 HELP: <index-elements>
index 2f920645ed5a2213a4b5092613138ede0077552c..c0dca565512907e44cbadde45383e2b4422de932 100644 (file)
@@ -7,9 +7,12 @@ gpu.framebuffers.private gpu.shaders gpu.shaders.private gpu.state
 gpu.textures gpu.textures.private half-floats images kernel
 lexer locals math math.order math.parser namespaces opengl
 opengl.gl parser quotations sequences slots sorting
-specialized-arrays.alien specialized-arrays.float specialized-arrays.int
-specialized-arrays.uint strings ui.gadgets.worlds variants
+specialized-arrays strings ui.gadgets.worlds variants
 vocabs.parser words ;
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: void*
 IN: gpu.render
 
 UNION: ?integer integer POSTPONE: f ;
index a247158684841a142aa16bcdb204625e42847656..91bc760673cec2d37fe4ba7eb60fe6825705c5f1 100755 (executable)
@@ -1,15 +1,16 @@
 ! (c)2009 Joe Groff bsd license
-USING: accessors alien alien.c-types alien.strings
-arrays assocs byte-arrays classes.mixin classes.parser
-classes.singleton classes.struct combinators
-combinators.short-circuit definitions destructors
-generic.parser gpu gpu.buffers hashtables images
+USING: accessors alien alien.c-types alien.strings arrays assocs
+byte-arrays classes.mixin classes.parser classes.singleton
+classes.struct combinators combinators.short-circuit definitions
+destructors generic.parser gpu gpu.buffers hashtables images
 io.encodings.ascii io.files io.pathnames kernel lexer literals
 locals math math.parser memoize multiline namespaces opengl
 opengl.gl opengl.shaders parser quotations sequences
-specialized-arrays.alien specialized-arrays.int splitting
-strings tr ui.gadgets.worlds variants vectors vocabs vocabs.loader
-vocabs.parser words words.constant ;
+specialized-arrays splitting strings tr ui.gadgets.worlds
+variants vectors vocabs vocabs.loader vocabs.parser words
+words.constant ;
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: void*
 IN: gpu.shaders
 
 VARIANT: shader-kind
index 6027be74b5a0144619c4507fac560a113a3303e5..02d60467221bdd8de3a8fe0a0c85cfd785ebc759 100755 (executable)
@@ -1,7 +1,9 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types arrays byte-arrays combinators gpu
 kernel literals math math.rectangles opengl opengl.gl sequences
-variants specialized-arrays.int specialized-arrays.float ;
+variants specialized-arrays ;
+SPECIALIZED-ARRAY: int
+SPECIALIZED-ARRAY: float
 IN: gpu.state
 
 UNION: ?rect rect POSTPONE: f ;
index a2e6ffd44010854c6dc832c2f1f265fa16241403..8015ff9a9b7517e90e1b786b9cf8dd15807ecddd 100644 (file)
@@ -2,7 +2,8 @@
 USING: accessors alien.c-types arrays byte-arrays combinators
 destructors fry gpu gpu.buffers images kernel locals math
 opengl opengl.gl opengl.textures sequences
-specialized-arrays.float ui.gadgets.worlds variants ;
+specialized-arrays ui.gadgets.worlds variants ;
+SPECIALIZED-ARRAY: float
 IN: gpu.textures
 
 TUPLE: texture < gpu-object
index 512cea4a17cdf65f24549b999b1ce970dcbcff50..862c94d4b304e9212ec1ee031d12c79eefd91f9d 100644 (file)
@@ -1,6 +1,7 @@
 ! (c)2009 Joe Groff bsd license
 USING: gpu.buffers gpu.render gpu.shaders gpu.textures images kernel
-specialized-arrays.float ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: gpu.util
 
 CONSTANT: environment-cube-map-mv-matrices
index b0a3d8179a874d81bba9fd25cf06c383b9c22f20..9145434d90e688b70ddb9d8cacde1ef0ddd818ca 100644 (file)
@@ -4,7 +4,8 @@ game-input.scancodes game-loop game-worlds
 gpu.render gpu.state kernel literals
 locals math math.constants math.functions math.matrices
 math.order math.vectors opengl.gl sequences
-specialized-arrays.float ui ui.gadgets.worlds ;
+ui ui.gadgets.worlds specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: gpu.util.wasd
 
 UNIFORM-TUPLE: mvp-uniforms
index 19c4568b7ccc76da9bd79c50da995a5491c20e81..94638de3460b8dbd6fbdc7f42e485f40fde9c212 100644 (file)
@@ -1,6 +1,7 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors arrays destructors kernel math opengl
-opengl.gl sequences sequences.product specialized-arrays.float ;
+opengl.gl sequences sequences.product specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: grid-meshes
 
 TUPLE: grid-mesh dim buffer row-length ;
index 3eff29635c99f8c7aadaa49b8b13d0bd27ed6b87..cf3d7d3690198c85cbdaf442bf463d82cb3d731a 100644 (file)
@@ -1,4 +1,6 @@
-USING: alien.c-types alien.syntax half-floats kernel math tools.test ;
+USING: alien.c-types alien.syntax half-floats kernel math tools.test
+specialized-arrays ;
+SPECIALIZED-ARRAY: half
 IN: half-floats.tests
 
 [ HEX: 0000 ] [  0.0  half>bits ] unit-test
index d54c7af55fd0b26de8b3a154da5292a4383ed0f6..2c089e4330308d3496ede384de6bef67b6131660 100755 (executable)
@@ -1,6 +1,5 @@
 ! (c)2009 Joe Groff bsd license
-USING: accessors alien.c-types alien.syntax kernel math math.order
-specialized-arrays.functor ;
+USING: accessors alien.c-types alien.syntax kernel math math.order ;
 IN: half-floats
 
 : half>bits ( float -- bits )
@@ -36,6 +35,4 @@ C-STRUCT: half { "ushort" "(bits)" } ;
     [ *ushort bits>half ] >>boxer-quot
     drop
 
-"half" define-array
-
 >>
index 38aa291a3aff4afa9afdd7bfbabf70a65a4ac001..22474a75264efb18585a0514b26a84d31919419f 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2009 Tim Wawrzynczak, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences io io.encodings.binary io.files io.pathnames
-strings kernel math io.mmap io.mmap.uchar accessors
-combinators math.ranges unicode.categories byte-arrays
-io.encodings.string io.encodings.utf16 assocs math.parser
-combinators.short-circuit fry namespaces combinators.smart
-splitting io.encodings.ascii arrays io.files.info unicode.case
-io.directories.search literals math.functions continuations ;
+strings kernel math io.mmap accessors combinators math.ranges
+unicode.categories byte-arrays io.encodings.string
+io.encodings.utf16 assocs math.parser combinators.short-circuit
+fry namespaces combinators.smart splitting io.encodings.ascii
+arrays io.files.info unicode.case io.directories.search literals
+math.functions continuations ;
 IN: id3
 
 <PRIVATE
@@ -65,7 +65,7 @@ speed genre-name start-time end-time ;
 CONSTANT: id3v1-length 128
 CONSTANT: id3v1-offset 128
 CONSTANT: id3v1+-length 227
-CONSTANT: id3v1+-offset $[ 128 227 + ]
+: id3v1+-offset ( -- n ) id3v1-length id3v1+-length + ; inline
 
 : id3v1? ( seq -- ? )
     {
@@ -209,13 +209,12 @@ PRIVATE>
 
 : mp3>id3 ( path -- id3/f )
     [
-        [ <id3> ] dip
-        {
-            [ dup id3v1? [ read-v1-tags merge-id3v1 ] [ drop ] if ]
-            [ dup id3v1+? [ read-v1+-tags merge-id3v1 ] [ drop ] if ]
-            [ dup id3v2? [ read-v2-tags ] [ drop ] if ]
-        } cleave
-    ] with-mapped-uchar-file-reader ;
+        [ <id3> ] dip "uchar" <mapped-array>
+        [ dup id3v1? [ read-v1-tags merge-id3v1 ] [ drop ] if ]
+        [ dup id3v1+? [ read-v1+-tags merge-id3v1 ] [ drop ] if ]
+        [ dup id3v2? [ read-v2-tags ] [ drop ] if ]
+        tri
+    ] with-mapped-file-reader ;
 
 : find-id3-frame ( id3 name -- obj/f )
     swap frames>> at* [ data>> ] when ;
index 90341fed9262655105551045e552f7403e2e59a6..8706ac58341ed561b61dd93f57eaa98c054c2474 100755 (executable)
@@ -1,8 +1,11 @@
 ! Copyright (C) 2009 Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors grouping sequences combinators math
-byte-arrays fry specialized-arrays.uint specialized-arrays.ushort
-specialized-arrays.float images half-floats ;
+byte-arrays fry images half-floats specialized-arrays ;
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: ushort
+SPECIALIZED-ARRAY: float
+SPECIALIZED-ARRAY: half
 IN: images.normalization
 
 <PRIVATE
index a1d22c48dc548e715b3ba34e0427f6a74d84ff0e..1a03a2c9413fecfb786690d93bf79a04400e7882 100644 (file)
@@ -3,7 +3,8 @@
 USING: accessors alien.c-types jamshred.game jamshred.oint
 jamshred.player jamshred.tunnel kernel math math.constants
 math.functions math.vectors opengl opengl.gl opengl.glu
-opengl.demo-support sequences specialized-arrays.float ;
+opengl.demo-support sequences specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: jamshred.gl
 
 CONSTANT: min-vertices 6
index 3364179920dcc627dabe3702f3812a36c919ce93..536974952e255eb1bc17c3f9413d679968f6756d 100644 (file)
@@ -1,6 +1,10 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors colors.constants combinators jamshred.log jamshred.oint jamshred.sound jamshred.tunnel kernel locals math math.constants math.order math.ranges math.vectors math.matrices sequences shuffle specialized-arrays.float strings system ;
+USING: accessors colors.constants combinators jamshred.log
+jamshred.oint jamshred.sound jamshred.tunnel kernel locals math
+math.constants math.order math.ranges math.vectors math.matrices
+sequences shuffle specialized-arrays strings system ;
+SPECIALIZED-ARRAY: float
 IN: jamshred.player
 
 TUPLE: player < oint
index 8e2f1a6fab18b5841e73ddaaf9fd39443346d128..6f85389099c7c1f56637a09b5225f423593cfb44 100644 (file)
@@ -1,6 +1,8 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays jamshred.oint jamshred.tunnel kernel math.vectors sequences specialized-arrays.float tools.test ;
+USING: accessors arrays jamshred.oint jamshred.tunnel kernel
+math.vectors sequences specialized-arrays tools.test ;
+SPECIALIZED-ARRAY: float
 IN: jamshred.tunnel.tests
 
 [ 0 ] [ T{ segment f { 0 0 0 } f f f 0 }
index ac5be9df2e18b8630ed65dd01e95e6397ad9c6a0..2767444c8f930a377db801425669353080e02e7b 100644 (file)
@@ -3,8 +3,9 @@
 USING: accessors arrays colors combinators fry jamshred.oint
 kernel literals locals math math.constants math.matrices
 math.order math.quadratic math.ranges math.vectors random
-sequences specialized-arrays.float vectors ;
+sequences specialized-arrays vectors ;
 FROM: jamshred.oint => distance ;
+SPECIALIZED-ARRAY: float
 IN: jamshred.tunnel
 
 CONSTANT: n-segments 5000
index bb1b06bcf3023eaa165276d4462de6e44335dbab..87f39944d934b1fbc050d3ed600cfe1f77961478 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien arrays assocs compiler.units effects
 io.backend io.pathnames kernel llvm.core llvm.jit llvm.reader
-llvm.types make namespaces sequences specialized-arrays.alien
+llvm.types make namespaces sequences specialized-arrays
 vocabs words ;
-
+SPECIALIZED-ARRAY: void*
 IN: llvm.invoker
 
 ! get function name, ret type, param types and names
index a88c45c6cf7af9f489a34643d6d44185e0807ced..426e464b1bff3640c1174dad6bae92cf226ab199 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2009 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays combinators kernel llvm.core
-locals math.parser math multiline
-namespaces parser peg.ebnf sequences
-sequences.deep specialized-arrays.alien strings vocabs words ;
-
+USING: accessors arrays combinators kernel llvm.core locals
+math.parser math multiline namespaces parser peg.ebnf sequences
+sequences.deep specialized-arrays strings vocabs words ;
+SPECIALIZED-ARRAY: void*
 IN: llvm.types
 
 ! Type resolution strategy:
index ff77d3e915b970fe75eb33159a80941cf95e8e23..b8f2f1cb5f8dba3cc238815270cf1906c380616a 100644 (file)
@@ -1,7 +1,8 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors arrays grouping kernel locals math math.order
 math.ranges math.vectors math.vectors.homogeneous sequences
-specialized-arrays.float ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: float
 IN: nurbs
 
 TUPLE: nurbs-curve
index 6e9721b0fed32ca826cdd5207f193f14ceea26d9..81a6621eff5180d9c4fff499887b407df83ef5e8 100644 (file)
@@ -1,8 +1,10 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors arrays alien system combinators alien.syntax namespaces
-       alien.c-types sequences vocabs.loader shuffle
-       openal.backend specialized-arrays.uint alien.libraries generalizations ;
+USING: kernel accessors arrays alien system combinators
+alien.syntax namespaces alien.c-types sequences vocabs.loader
+shuffle openal.backend alien.libraries generalizations
+specialized-arrays ;
+SPECIALIZED-ARRAY: uint
 IN: openal
 
 << "alut" {
index 4c0ef6460745c129d84c43533a2691eda1825e35..71b05ac6421f2813af784a4a7012fffae3ea22ab 100644 (file)
@@ -1,6 +1,9 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types combinators kernel locals math math.ranges openal sequences sequences.merged specialized-arrays.uchar specialized-arrays.short ;
+USING: accessors alien.c-types combinators kernel locals math
+math.ranges openal sequences sequences.merged specialized-arrays ;
+SPECIALIZED-ARRAY: uchar
+SPECIALIZED-ARRAY: short
 IN: synth.buffers
 
 TUPLE: buffer sample-freq 8bit? id ;
index 8a943927c7174648c1713b9a6e8891afd1324488..5f83eb268b0fcd0c353f999adbd2a72643ccc9d1 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: unix alien alien.c-types kernel math sequences strings
 io.backend.unix splitting io.encodings.utf8 io.encodings.string
-specialized-arrays.char ;
+specialized-arrays ;
+SPECIALIZED-ARRAY: char
 IN: system-info.linux
 
 : (uname) ( buf -- int )
index 6576ca6d53b9e173d51e8bc1001bb06235a83130..07cbcc41b331e4d9fb8903edfc24b99be1878b1e 100755 (executable)
@@ -3,7 +3,8 @@
 USING: alien alien.c-types classes.struct accessors kernel
 math namespaces windows windows.kernel32 windows.advapi32 words
 combinators vocabs.loader system-info.backend system
-alien.strings windows.errors specialized-arrays.ushort ;
+alien.strings windows.errors specialized-arrays ;
+SPECIALIZED-ARRAY: ushort
 IN: system-info.windows
 
 : system-info ( -- SYSTEM_INFO )
index 4304ba343206ac53c048eba985549e189e79e0c6..95322e423a93bd0c92fb18743910638f89f91670 100644 (file)
@@ -4,11 +4,12 @@ game-input.scancodes grouping kernel literals locals
 math math.constants math.functions math.matrices math.order
 math.vectors opengl opengl.capabilities opengl.gl
 opengl.shaders opengl.textures opengl.textures.private
-sequences sequences.product specialized-arrays.float
+sequences sequences.product specialized-arrays
 terrain.generation terrain.shaders ui ui.gadgets
 ui.gadgets.worlds ui.pixel-formats game-worlds method-chains
 math.affine-transforms noise ui.gestures combinators.short-circuit
 destructors grid-meshes ;
+SPECIALIZED-ARRAY: float
 IN: terrain
 
 CONSTANT: FOV $[ 2.0 sqrt 1 + ]