]> gitweb.factorcode.org Git - factor.git/commitdiff
specialized-arrays.direct is no more; instead, every specialized-array.<foo> vocabula...
authorSlava Pestov <slava@factorcode.org>
Sat, 5 Sep 2009 03:01:55 +0000 (22:01 -0500)
committerSlava Pestov <slava@factorcode.org>
Sat, 5 Sep 2009 03:01:55 +0000 (22:01 -0500)
58 files changed:
basis/alien/arrays/arrays-docs.factor [changed mode: 0644->0755]
basis/alien/arrays/arrays.factor
basis/alien/c-types/c-types-docs.factor [changed mode: 0644->0755]
basis/alien/c-types/c-types.factor
basis/classes/struct/struct-tests.factor [changed mode: 0644->0755]
basis/classes/struct/struct.factor [changed mode: 0644->0755]
basis/cocoa/enumeration/enumeration.factor [changed mode: 0644->0755]
basis/cocoa/messages/messages.factor [changed mode: 0644->0755]
basis/core-foundation/fsevents/fsevents.factor [changed mode: 0644->0755]
basis/environment/winnt/winnt.factor [changed mode: 0644->0755]
basis/io/files/info/unix/macosx/macosx.factor [changed mode: 0644->0755]
basis/io/mmap/alien/alien.factor [changed mode: 0644->0755]
basis/io/mmap/bool/bool.factor [changed mode: 0644->0755]
basis/io/mmap/char/char.factor [changed mode: 0644->0755]
basis/io/mmap/double/double.factor [changed mode: 0644->0755]
basis/io/mmap/float/float.factor [changed mode: 0644->0755]
basis/io/mmap/int/int.factor [changed mode: 0644->0755]
basis/io/mmap/long/long.factor [changed mode: 0644->0755]
basis/io/mmap/longlong/longlong.factor [changed mode: 0644->0755]
basis/io/mmap/short/short.factor [changed mode: 0644->0755]
basis/io/mmap/uchar/uchar.factor [changed mode: 0644->0755]
basis/io/mmap/uint/uint.factor [changed mode: 0644->0755]
basis/io/mmap/ulong/ulong.factor [changed mode: 0644->0755]
basis/io/mmap/ulonglong/ulonglong.factor [changed mode: 0644->0755]
basis/io/mmap/ushort/ushort.factor [changed mode: 0644->0755]
basis/math/blas/matrices/matrices.factor
basis/math/blas/vectors/vectors.factor
basis/specialized-arrays/direct/alien/alien.factor [deleted file]
basis/specialized-arrays/direct/bool/bool.factor [deleted file]
basis/specialized-arrays/direct/char/char.factor [deleted file]
basis/specialized-arrays/direct/complex-double/complex-double.factor [deleted file]
basis/specialized-arrays/direct/complex-float/complex-float.factor [deleted file]
basis/specialized-arrays/direct/direct-docs.factor [deleted file]
basis/specialized-arrays/direct/direct-tests.factor [deleted file]
basis/specialized-arrays/direct/direct.factor [deleted file]
basis/specialized-arrays/direct/double/double.factor [deleted file]
basis/specialized-arrays/direct/float/float.factor [deleted file]
basis/specialized-arrays/direct/functor/functor.factor [deleted file]
basis/specialized-arrays/direct/functor/summary.txt [deleted file]
basis/specialized-arrays/direct/int/int.factor [deleted file]
basis/specialized-arrays/direct/long/long.factor [deleted file]
basis/specialized-arrays/direct/longlong/longlong.factor [deleted file]
basis/specialized-arrays/direct/short/short.factor [deleted file]
basis/specialized-arrays/direct/uchar/uchar.factor [deleted file]
basis/specialized-arrays/direct/uint/uint.factor [deleted file]
basis/specialized-arrays/direct/ulong/ulong.factor [deleted file]
basis/specialized-arrays/direct/ulonglong/ulonglong.factor [deleted file]
basis/specialized-arrays/direct/ushort/ushort.factor [deleted file]
basis/specialized-arrays/functor/functor.factor [changed mode: 0644->0755]
basis/specialized-arrays/prettyprint/prettyprint.factor [new file with mode: 0755]
basis/specialized-arrays/specialized-arrays-docs.factor [changed mode: 0644->0755]
basis/specialized-arrays/specialized-arrays-tests.factor [changed mode: 0644->0755]
basis/specialized-arrays/specialized-arrays.factor [changed mode: 0644->0755]
basis/windows/dragdrop-listener/dragdrop-listener.factor [changed mode: 0644->0755]
basis/windows/errors/errors.factor [changed mode: 0644->0755]
basis/windows/ole32/ole32.factor
extra/half-floats/half-floats.factor [changed mode: 0644->0755]
extra/images/normalization/normalization.factor

old mode 100644 (file)
new mode 100755 (executable)
index bf01209..db4a7bf
@@ -6,7 +6,7 @@ ARTICLE: "c-arrays" "C arrays"
 $nl\r
 "C type specifiers for array types are documented in " { $link "c-types-specs" } "."\r
 $nl\r
 $nl\r
 "C type specifiers for array types are documented in " { $link "c-types-specs" } "."\r
 $nl\r
-"Specialized sequences are provided for accessing memory as an array of primitive type values. These sequences are implemented in the " { $vocab-link "specialized-arrays" } " and " { $vocab-link "specialized-arrays.direct" } " vocabulary sets. They can also be loaded and constructed through their primitive C types:"\r
-{ $subsection require-c-arrays }\r
+"Specialized sequences are provided for accessing memory as an array of primitive type values. These sequences are implemented in the " { $vocab-link "specialized-arrays" } " vocabulary set. They can also be loaded and constructed through their primitive C types:"\r
+{ $subsection require-c-array }\r
 { $subsection <c-array> }\r
 { $subsection <c-direct-array> } ;\r
 { $subsection <c-array> }\r
 { $subsection <c-direct-array> } ;\r
index 98994c753eb3d8ecd2a13ca70d71e6830f97f0d9..64827ec139cc567f2ee13b6dee7d683e2dc5350f 100755 (executable)
@@ -35,7 +35,7 @@ M: array stack-size drop "void*" stack-size ;
 M: array c-type-boxer-quot
     unclip
     [ array-length ]
 M: array c-type-boxer-quot
     unclip
     [ array-length ]
-    [ [ require-c-arrays ] keep ] bi*
+    [ [ require-c-array ] keep ] bi*
     [ <c-direct-array> ] 2curry ;
 
 M: array c-type-unboxer-quot drop [ >c-ptr ] ;
     [ <c-direct-array> ] 2curry ;
 
 M: array c-type-unboxer-quot drop [ >c-ptr ] ;
old mode 100644 (file)
new mode 100755 (executable)
index ac9a959..3a7c3a7
@@ -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." }
 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-arrays } " 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, 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." }
 { $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>
 { $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> } "." }
 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 direct 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-arrays } " word. See the " { $vocab-link "specialized-arrays.direct" } " vocabulary set for details on the underlying sequence type constructed." }
+{ $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." }
 { $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." } ;
 
 { $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." } ;
 
@@ -130,15 +130,15 @@ HELP: malloc-string
     }
 } ;
 
     }
 } ;
 
-HELP: require-c-arrays
+HELP: require-c-array
 { $values { "c-type" "a C type" } }
 { $values { "c-type" "a C type" } }
-{ $description { $link require } "s any unloaded vocabularies needed to construct a specialized array or direct 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" } " and " { $vocab-link "specialized-arrays.direct" } " vocabulary sets for details on the underlying sequence types loaded." } ;
+{ $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." } ;
 
 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" } "." }
 
 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 direct 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-arrays } " word. See the " { $vocab-link "specialized-arrays.direct" } " vocabulary set for details on the underlying sequence type constructed." } ;
+{ $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." } ;
 
 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."
 
 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 ac0bbf68b3c489e45e821cbd247597470f46d5f4..86e695831cb419d4ba5a31119ebd318148b83415 100755 (executable)
@@ -25,9 +25,7 @@ align
 array-class
 array-constructor
 (array)-constructor
 array-class
 array-constructor
 (array)-constructor
-direct-array-class
-direct-array-constructor
-sequence-mixin-class ;
+direct-array-constructor ;
 
 TUPLE: c-type < abstract-c-type
 boxer
 
 TUPLE: c-type < abstract-c-type
 boxer
@@ -89,21 +87,19 @@ M: string heap-size c-type heap-size ;
 
 M: abstract-c-type heap-size size>> ;
 
 
 M: abstract-c-type heap-size size>> ;
 
-GENERIC: require-c-arrays ( c-type -- )
+GENERIC: require-c-array ( c-type -- )
 
 
-M: object require-c-arrays
+M: object require-c-array
     drop ;
 
     drop ;
 
-M: c-type require-c-arrays
-    [ array-class>> ?require-word ]
-    [ sequence-mixin-class>> ?require-word ]
-    [ direct-array-class>> ?require-word ] tri ;
+M: c-type require-c-array
+    array-class>> ?require-word ;
 
 
-M: string require-c-arrays
-    c-type require-c-arrays ;
+M: string require-c-array
+    c-type require-c-array ;
 
 
-M: array require-c-arrays
-    first c-type require-c-arrays ;
+M: array require-c-array
+    first c-type require-c-array ;
 
 ERROR: specialized-array-vocab-not-loaded vocab word ;
 
 
 ERROR: specialized-array-vocab-not-loaded vocab word ;
 
@@ -370,14 +366,6 @@ M: long-long-type box-return ( type -- )
         ]
         [
             [ "specialized-arrays." prepend ]
         ]
         [
             [ "specialized-arrays." prepend ]
-            [ "-sequence" append ] bi* ?lookup >>sequence-mixin-class
-        ]
-        [
-            [ "specialized-arrays.direct." prepend ]
-            [ "direct-" "-array" surround ] bi* ?lookup >>direct-array-class
-        ]
-        [
-            [ "specialized-arrays.direct." prepend ]
             [ "<direct-" "-array>" surround ] bi* ?lookup >>direct-array-constructor
         ]
     } 2cleave ;
             [ "<direct-" "-array>" surround ] bi* ?lookup >>direct-array-constructor
         ]
     } 2cleave ;
old mode 100644 (file)
new mode 100755 (executable)
index 9387d93..f359b5f
@@ -5,9 +5,8 @@ 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
 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.direct.int specialized-arrays.ushort
-struct-arrays system tools.test ;
+prettyprint.config see sequences specialized-arrays.char int
+specialized-arrays.ushort struct-arrays system tools.test ;
 IN: classes.struct.tests
 
 <<
 IN: classes.struct.tests
 
 <<
old mode 100644 (file)
new mode 100755 (executable)
index b2bd07a..09d80e5
@@ -6,7 +6,7 @@ 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
 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.direct.uchar ;
+words compiler.tree.propagation.transforms specialized-arrays.uchar ;
 FROM: slots => reader-word writer-word ;
 IN: classes.struct
 
 FROM: slots => reader-word writer-word ;
 IN: classes.struct
 
@@ -20,8 +20,7 @@ TUPLE: struct
 TUPLE: struct-slot-spec < slot-spec
     c-type ;
 
 TUPLE: struct-slot-spec < slot-spec
     c-type ;
 
-PREDICATE: struct-class < tuple-class
-    { [ \ struct subclass-of? ] [ all-slots length 1 = ] } 1&& ;
+PREDICATE: struct-class < tuple-class \ struct subclass-of? ;
 
 : struct-slots ( struct-class -- slots )
     "struct-slots" word-prop ;
 
 : struct-slots ( struct-class -- slots )
     "struct-slots" word-prop ;
@@ -126,10 +125,6 @@ M: struct-class writer-quot
     [ \ struct-slot-values ] [ struct-slot-values-quot ] bi
     define-inline-method ;
 
     [ \ struct-slot-values ] [ struct-slot-values-quot ] bi
     define-inline-method ;
 
-: (define-byte-length-method) ( class -- )
-    [ \ byte-length ] [ heap-size \ drop swap [ ] 2sequence ] bi
-    define-inline-method ;
-
 : clone-underlying ( struct -- byte-array )
     [ >c-ptr ] [ byte-length ] bi memory>byte-array ; inline
 
 : clone-underlying ( struct -- byte-array )
     [ >c-ptr ] [ byte-length ] bi memory>byte-array ; inline
 
@@ -203,6 +198,9 @@ M: struct-class c-type-unboxer-quot
 M: struct-class heap-size
     "struct-size" word-prop ;
 
 M: struct-class heap-size
     "struct-size" word-prop ;
 
+M: struct byte-length
+    class "struct-size" word-prop ; foldable
+
 ! class definition
 
 <PRIVATE
 ! class definition
 
 <PRIVATE
@@ -218,9 +216,8 @@ M: struct-class heap-size
 
 : (struct-methods) ( class -- )
     [ (define-struct-slot-values-method) ]
 
 : (struct-methods) ( class -- )
     [ (define-struct-slot-values-method) ]
-    [ (define-byte-length-method) ]
     [ (define-clone-method) ]
     [ (define-clone-method) ]
-    tri ;
+    bi ;
 
 : (struct-word-props) ( class slots size align -- )
     [
 
 : (struct-word-props) ( class slots size align -- )
     [
old mode 100644 (file)
new mode 100755 (executable)
index 5f93134..caa8333
@@ -4,7 +4,7 @@ USING: accessors kernel classes.struct cocoa cocoa.types alien.c-types
 locals math sequences vectors fry libc destructors ;
 IN: cocoa.enumeration
 
 locals math sequences vectors fry libc destructors ;
 IN: cocoa.enumeration
 
-<< "id" require-c-arrays >>
+<< "id" require-c-array >>
 
 CONSTANT: NS-EACH-BUFFER-SIZE 16
 
 
 CONSTANT: NS-EACH-BUFFER-SIZE 16
 
old mode 100644 (file)
new mode 100755 (executable)
index 26672dd..7342451
@@ -5,7 +5,7 @@ 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
 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.direct.alien ;
+generalizations specialized-arrays.alien ;
 IN: cocoa.messages
 
 : make-sender ( method function -- quot )
 IN: cocoa.messages
 
 : make-sender ( method function -- quot )
old mode 100644 (file)
new mode 100755 (executable)
index 4b2cce9..7eba7d1
@@ -3,8 +3,8 @@
 USING: alien alien.c-types alien.strings alien.syntax kernel
 math sequences namespaces make assocs init accessors
 continuations combinators io.encodings.utf8 destructors locals
 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.direct.alien classes.struct
-specialized-arrays.direct.int specialized-arrays.direct.longlong
+arrays specialized-arrays.alien classes.struct
+specialized-arrays.int specialized-arrays.longlong
 core-foundation core-foundation.run-loop core-foundation.strings
 core-foundation.time ;
 IN: core-foundation.fsevents
 core-foundation core-foundation.run-loop core-foundation.strings
 core-foundation.time ;
 IN: core-foundation.fsevents
old mode 100644 (file)
new mode 100755 (executable)
index afe4425..518a7d5
@@ -6,7 +6,7 @@ alien.c-types sequences windows.errors io.streams.memory
 io.encodings io ;
 IN: environment.winnt
 
 io.encodings io ;
 IN: environment.winnt
 
-<< "TCHAR" require-c-arrays >>
+<< "TCHAR" require-c-array >>
 
 M: winnt os-env ( key -- value )
     MAX_UNICODE_PATH "TCHAR" <c-array>
 
 M: winnt os-env ( key -- value )
     MAX_UNICODE_PATH "TCHAR" <c-array>
old mode 100644 (file)
new mode 100755 (executable)
index bd40f39..9ce235e
@@ -2,7 +2,7 @@
 ! 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
 ! 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.direct.uint arrays
+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 ;
 IN: io.files.info.unix.macosx
 unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx
 io.files.info.unix io.files.info classes.struct struct-arrays ;
 IN: io.files.info.unix.macosx
old mode 100644 (file)
new mode 100755 (executable)
index 4b0a532..bf72148
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.alien ;
+USING: io.mmap.functor specialized-arrays.alien ;
 IN: io.mmap.alien
 
 << "void*" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.alien
 
 << "void*" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index a2b596f..5352bbf
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.bool ;
+USING: io.mmap.functor specialized-arrays.bool ;
 IN: io.mmap.bool
 
 << "bool" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.bool
 
 << "bool" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 453e7e9..fc5f14f
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.char ;
+USING: io.mmap.functor specialized-arrays.char ;
 IN: io.mmap.char
 
 << "char" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.char
 
 << "char" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 919c006..708286b
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.double ;
+USING: io.mmap.functor specialized-arrays.double ;
 IN: io.mmap.double
 
 << "double" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.double
 
 << "double" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 33cf16c..71685a4
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.float ;
+USING: io.mmap.functor specialized-arrays.float ;
 IN: io.mmap.float
 
 << "float" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.float
 
 << "float" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 400e81e..1f6bd2a
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.int ;
+USING: io.mmap.functor specialized-arrays.int ;
 IN: io.mmap.int
 
 << "int" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.int
 
 << "int" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 190dd28..70a9c46
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.long ;
+USING: io.mmap.functor specialized-arrays.long ;
 IN: io.mmap.long
 
 << "long" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.long
 
 << "long" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 4d0a2aa..426f872
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.longlong ;
+USING: io.mmap.functor specialized-arrays.longlong ;
 IN: io.mmap.longlong
 
 << "longlong" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.longlong
 
 << "longlong" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index add5815..c19d70d
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.short ;
+USING: io.mmap.functor specialized-arrays.short ;
 IN: io.mmap.short
 
 << "short" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.short
 
 << "short" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index d30fb60..03b6cd4
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.uchar ;
+USING: io.mmap.functor specialized-arrays.uchar ;
 IN: io.mmap.uchar
 
 << "uchar" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.uchar
 
 << "uchar" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 926a0f4..a379349
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.uint ;
+USING: io.mmap.functor specialized-arrays.uint ;
 IN: io.mmap.uint
 
 << "uint" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.uint
 
 << "uint" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 80f70b3..dfdae5d
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.ulong ;
+USING: io.mmap.functor specialized-arrays.ulong ;
 IN: io.mmap.ulong
 
 << "ulong" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.ulong
 
 << "ulong" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 91f481c..1d6bd0e
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.ulonglong ;
+USING: io.mmap.functor specialized-arrays.ulonglong ;
 IN: io.mmap.ulonglong
 
 << "ulonglong" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.ulonglong
 
 << "ulonglong" define-mapped-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 6d5ac01..fc63313
@@ -1,4 +1,4 @@
-USING: io.mmap.functor specialized-arrays.direct.ushort ;
+USING: io.mmap.functor specialized-arrays.ushort ;
 IN: io.mmap.ushort
 
 << "ushort" define-mapped-array >>
\ No newline at end of file
 IN: io.mmap.ushort
 
 << "ushort" define-mapped-array >>
\ No newline at end of file
index a7ee79f210cb9bbf5c70333601eb8b6295d14628..c315021ed4765cbb441c45b82a29ececc9a60905 100755 (executable)
@@ -3,9 +3,7 @@ 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
 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.direct.float specialized-arrays.direct.double
 specialized-arrays.float specialized-arrays.double
 specialized-arrays.float specialized-arrays.double
-specialized-arrays.direct.complex-float specialized-arrays.direct.complex-double
 specialized-arrays.complex-float specialized-arrays.complex-double
 parser prettyprint.backend prettyprint.custom ascii ;
 IN: math.blas.matrices
 specialized-arrays.complex-float specialized-arrays.complex-double
 parser prettyprint.backend prettyprint.custom ascii ;
 IN: math.blas.matrices
index dd80b50f90885261e03ce2719700a3c3e68fbfc7..2b573ab6edc6c10bb5af6c3bd9f836b195e54399 100755 (executable)
@@ -3,10 +3,7 @@ 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
 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.direct.float specialized-arrays.direct.double
-specialized-arrays.complex-float specialized-arrays.complex-double
-specialized-arrays.direct.complex-float
-specialized-arrays.direct.complex-double ;
+specialized-arrays.complex-float specialized-arrays.complex-double ;
 IN: math.blas.vectors
 
 TUPLE: blas-vector-base underlying length inc ;
 IN: math.blas.vectors
 
 TUPLE: blas-vector-base underlying length inc ;
diff --git a/basis/specialized-arrays/direct/alien/alien.factor b/basis/specialized-arrays/direct/alien/alien.factor
deleted file mode 100644 (file)
index 3949c40..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.alien specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.alien
-
-<< "void*" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/bool/bool.factor b/basis/specialized-arrays/direct/bool/bool.factor
deleted file mode 100644 (file)
index 689fcc3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.bool specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.bool
-
-<< "bool" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/char/char.factor b/basis/specialized-arrays/direct/char/char.factor
deleted file mode 100644 (file)
index cca3a62..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.char specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.char
-
-<< "char" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/complex-double/complex-double.factor b/basis/specialized-arrays/direct/complex-double/complex-double.factor
deleted file mode 100644 (file)
index ae8d2b5..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.complex-double specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.complex-double
-
-<< "complex-double" define-direct-array >>
diff --git a/basis/specialized-arrays/direct/complex-float/complex-float.factor b/basis/specialized-arrays/direct/complex-float/complex-float.factor
deleted file mode 100644 (file)
index 8971196..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.complex-float specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.complex-float
-
-<< "complex-float" define-direct-array >>
diff --git a/basis/specialized-arrays/direct/direct-docs.factor b/basis/specialized-arrays/direct/direct-docs.factor
deleted file mode 100644 (file)
index e2638c4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-USING: help.markup help.syntax byte-arrays alien ;
-IN: specialized-arrays.direct
-
-ARTICLE: "specialized-arrays.direct" "Direct-mapped specialized arrays"
-"The " { $vocab-link "specialized-arrays.direct" } " vocabulary implements fixed-length sequence types for storing machine values in unmanaged C memory."
-$nl
-"For each primitive C type " { $snippet "T" } ", a set of words are defined:"
-{ $table
-    { { $snippet "direct-T-array" } { "The class of direct arrays with elements of type " { $snippet "T" } } }
-    { { $snippet "<direct-T-array>" } { "Constructor for arrays with elements of type " { $snippet "T" } "; stack effect " { $snippet "( alien len -- array )" } } }
-}
-"Each direct array has a " { $slot "underlying" } " slot holding an " { $link simple-alien } " pointer to the raw data. This data can be passed to C functions."
-$nl
-"The primitive C types for which direct 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 "void*" }
-    { $snippet "bool" }
-}
-"Direct arrays are generated with a functor in the " { $vocab-link "specialized-arrays.direct.functor" } " vocabulary." ;
-
-ABOUT: "specialized-arrays.direct"
diff --git a/basis/specialized-arrays/direct/direct-tests.factor b/basis/specialized-arrays/direct/direct-tests.factor
deleted file mode 100644 (file)
index 2a48b5d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-IN: specialized-arrays.direct.tests
-USING: specialized-arrays.direct.ushort tools.test
-specialized-arrays.ushort alien.syntax sequences ;
-
-[ ushort-array{ 0 0 0 } ] [
-    3 ALIEN: 123 100 <direct-ushort-array> new-sequence
-] unit-test
diff --git a/basis/specialized-arrays/direct/direct.factor b/basis/specialized-arrays/direct/direct.factor
deleted file mode 100644 (file)
index 7c15c66..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-IN: specialized-arrays.direct
diff --git a/basis/specialized-arrays/direct/double/double.factor b/basis/specialized-arrays/direct/double/double.factor
deleted file mode 100644 (file)
index c3089b3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.double specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.double
-
-<< "double" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/float/float.factor b/basis/specialized-arrays/direct/float/float.factor
deleted file mode 100644 (file)
index 94caa95..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.float specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.float
-
-<< "float" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/functor/functor.factor b/basis/specialized-arrays/direct/functor/functor.factor
deleted file mode 100755 (executable)
index 5731fd8..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: functors sequences sequences.private kernel words classes
-math alien alien.c-types byte-arrays accessors
-specialized-arrays parser
-prettyprint.backend prettyprint.custom prettyprint.sections ;
-IN: specialized-arrays.direct.functor
-
-<PRIVATE
-
-: pprint-direct-array ( direct-array tag -- )
-    [ [ underlying>> ] [ length>> ] bi [ pprint* ] bi@ ] pprint-prefix ;
-
-PRIVATE>
-
-FUNCTOR: define-direct-array ( T -- )
-
-A'      IS ${T}-array
-S       IS ${T}-sequence
->A'     IS >${T}-array
-<A'>    IS <${A'}>
-A'{     IS ${A'}{
-
-A       DEFINES-CLASS direct-${T}-array
-<A>     DEFINES <${A}>
-A'@      DEFINES ${A'}@
-
-NTH     [ T dup c-type-getter-boxer array-accessor ]
-SET-NTH [ T dup c-setter array-accessor ]
-
-WHERE
-
-TUPLE: A
-{ underlying c-ptr read-only }
-{ length fixnum read-only } ;
-
-: <A> ( alien len -- direct-array ) A boa ; inline
-M: A length length>> ; inline
-M: A nth-unsafe underlying>> NTH call ; inline
-M: A set-nth-unsafe underlying>> SET-NTH call ; inline
-M: A like drop dup A instance? [ >A' ] unless ; inline
-M: A new-sequence drop <A'> ; inline
-
-M: A byte-length length>> T heap-size * ; inline
-
-SYNTAX: A'@ 
-    scan-object scan-object <A> parsed ;
-
-M: A pprint-delims drop \ A'{ \ } ;
-
-M: A >pprint-sequence ;
-
-M: A pprint*
-    [ pprint-object ]
-    [ \ A'@ pprint-direct-array ]
-    pprint-c-object ;
-
-INSTANCE: A sequence
-INSTANCE: A S
-
-T c-type
-    \ A >>direct-array-class
-    \ <A> >>direct-array-constructor
-    drop
-
-;FUNCTOR
diff --git a/basis/specialized-arrays/direct/functor/summary.txt b/basis/specialized-arrays/direct/functor/summary.txt
deleted file mode 100644 (file)
index 79df0a5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Code generation for direct specialized arrays
diff --git a/basis/specialized-arrays/direct/int/int.factor b/basis/specialized-arrays/direct/int/int.factor
deleted file mode 100644 (file)
index c204e27..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.int specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.int
-
-<< "int" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/long/long.factor b/basis/specialized-arrays/direct/long/long.factor
deleted file mode 100644 (file)
index 33c52bb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.long specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.long
-
-<< "long" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/longlong/longlong.factor b/basis/specialized-arrays/direct/longlong/longlong.factor
deleted file mode 100644 (file)
index f132000..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.longlong specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.longlong
-
-<< "longlong" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/short/short.factor b/basis/specialized-arrays/direct/short/short.factor
deleted file mode 100644 (file)
index f837beb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.short specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.short
-
-<< "short" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/uchar/uchar.factor b/basis/specialized-arrays/direct/uchar/uchar.factor
deleted file mode 100644 (file)
index 3440979..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.uchar specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.uchar
-
-<< "uchar" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/uint/uint.factor b/basis/specialized-arrays/direct/uint/uint.factor
deleted file mode 100644 (file)
index 22f7ba3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.uint specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.uint
-
-<< "uint" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/ulong/ulong.factor b/basis/specialized-arrays/direct/ulong/ulong.factor
deleted file mode 100644 (file)
index 8a568ab..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.ulong specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.ulong
-
-<< "ulong" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/ulonglong/ulonglong.factor b/basis/specialized-arrays/direct/ulonglong/ulonglong.factor
deleted file mode 100644 (file)
index 10fa178..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.ulonglong specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.ulonglong
-
-<< "ulonglong" define-direct-array >>
\ No newline at end of file
diff --git a/basis/specialized-arrays/direct/ushort/ushort.factor b/basis/specialized-arrays/direct/ushort/ushort.factor
deleted file mode 100644 (file)
index 6bd34c7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-USING: specialized-arrays.ushort specialized-arrays.direct.functor ;
-IN: specialized-arrays.direct.ushort
-
-<< "ushort" define-direct-array >>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index df1c938..45539b7
@@ -1,8 +1,8 @@
-! Copyright (C) 2008 Slava Pestov.
+! 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
 ! 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.c-types byte-arrays accessors summary alien specialized-arrays ;
 IN: specialized-arrays.functor
 
 ERROR: bad-byte-array-length byte-array type ;
 IN: specialized-arrays.functor
 
 ERROR: bad-byte-array-length byte-array type ;
@@ -22,9 +22,12 @@ A            DEFINES-CLASS ${T}-array
 S            DEFINES-CLASS ${T}-sequence
 <A>          DEFINES <${A}>
 (A)          DEFINES (${A})
 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}
 byte-array>A DEFINES byte-array>${A}
+
 A{           DEFINES ${A}{
 A{           DEFINES ${A}{
+A@           DEFINES ${A}@
 
 NTH          [ T dup c-type-getter-boxer array-accessor ]
 SET-NTH      [ T dup c-setter array-accessor ]
 
 NTH          [ T dup c-type-getter-boxer array-accessor ]
 SET-NTH      [ T dup c-setter array-accessor ]
@@ -34,18 +37,20 @@ WHERE
 MIXIN: S
 
 TUPLE: A
 MIXIN: S
 
 TUPLE: A
-{ length array-capacity read-only }
-{ underlying byte-array read-only } ;
+{ underlying c-ptr read-only }
+{ length array-capacity read-only } ;
+
+: <direct-A> ( alien len -- specialized-array ) A boa ; inline
 
 
-: <A> ( n -- specialized-array ) dup T <underlying> A boa ; inline
+: <A> ( n -- specialized-array ) [ T <underlying> ] keep <direct-A> ; inline
 
 
-: (A) ( n -- specialized-array ) dup T (underlying) A boa ; 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
 
 : byte-array>A ( byte-array -- specialized-array )
     dup length T heap-size /mod 0 = [ drop T bad-byte-array-length ] unless
-    swap A boa ; inline
+    <direct-A> ; inline
 
 
-M: A clone [ length>> ] [ underlying>> clone ] bi A boa ; inline
+M: A clone [ underlying>> clone ] [ length>> ] bi <direct-A> ; inline
 
 M: A length length>> ; inline
 
 
 M: A length length>> ; inline
 
@@ -62,24 +67,20 @@ M: A new-sequence drop (A) ; inline
 M: A equal? over A instance? [ sequence= ] [ 2drop f ] if ;
 
 M: A resize
 M: A equal? over A instance? [ sequence= ] [ 2drop f ] if ;
 
 M: A resize
-    [ drop ] [
+    [
         [ T heap-size * ] [ underlying>> ] bi*
         resize-byte-array
         [ T heap-size * ] [ underlying>> ] bi*
         resize-byte-array
-    ] 2bi
-    A boa ; inline
+    ] [ drop ] 2bi
+    <direct-A> ; inline
 
 M: A byte-length underlying>> length ; inline
 
 M: A byte-length underlying>> length ; inline
-
 M: A pprint-delims drop \ A{ \ } ;
 M: A pprint-delims drop \ A{ \ } ;
-
 M: A >pprint-sequence ;
 
 M: A >pprint-sequence ;
 
-M: A pprint* pprint-object ;
-
 SYNTAX: A{ \ } [ >A ] parse-literal ;
 SYNTAX: A{ \ } [ >A ] parse-literal ;
+SYNTAX: A@ scan-object scan-object <direct-A> parsed ;
 
 
-INSTANCE: A sequence
-INSTANCE: A S
+INSTANCE: A specialized-array
 
 A T c-type-boxed-class specialize-vector-words
 
 
 A T c-type-boxed-class specialize-vector-words
 
@@ -87,7 +88,7 @@ T c-type
     \ A >>array-class
     \ <A> >>array-constructor
     \ (A) >>(array)-constructor
     \ A >>array-class
     \ <A> >>array-constructor
     \ (A) >>(array)-constructor
-    \ S >>sequence-mixin-class
+    \ <direct-A> >>direct-array-constructor
     drop
 
 ;FUNCTOR
     drop
 
 ;FUNCTOR
diff --git a/basis/specialized-arrays/prettyprint/prettyprint.factor b/basis/specialized-arrays/prettyprint/prettyprint.factor
new file mode 100755 (executable)
index 0000000..4d6416a
--- /dev/null
@@ -0,0 +1,14 @@
+! Copyright (C) 2009 Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel prettyprint.backend
+prettyprint.sections prettyprint.custom
+specialized-arrays ;
+IN: specialized-arrays.prettyprint
+
+: pprint-direct-array ( direct-array -- )
+    dup direct-array-syntax
+    [ [ underlying>> ] [ length>> ] bi [ pprint* ] bi@ ] pprint-prefix ;
+
+M: specialized-array pprint*
+    [ pprint-object ] [ pprint-direct-array ] pprint-c-object ;
+
old mode 100644 (file)
new mode 100755 (executable)
index 9015ccc..e064545
@@ -8,8 +8,9 @@ $nl
 { $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 )" } } }
 { $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 ">T-array" } { "Converts a sequence into a specialized array of type " { $snippet "T" } "; stack effect " { $snippet "( seq -- array )" } } }
+    { { $snippet "<direct-T-array>" } { "Constructor for arrays with elements of type " { $snippet "T" } "; 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 "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."
     { { $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."
old mode 100644 (file)
new mode 100755 (executable)
index 1e470b6..21fc417
@@ -2,8 +2,7 @@ IN: specialized-arrays.tests
 USING: tools.test specialized-arrays sequences
 specialized-arrays.int specialized-arrays.bool
 specialized-arrays.ushort alien.c-types accessors kernel
 USING: tools.test specialized-arrays sequences
 specialized-arrays.int specialized-arrays.bool
 specialized-arrays.ushort alien.c-types accessors kernel
-specialized-arrays.direct.int specialized-arrays.char
-specialized-arrays.uint arrays combinators ;
+specialized-arrays.char specialized-arrays.uint arrays combinators ;
 
 [ t ] [ { 1 2 3 } >int-array int-array? ] unit-test
 
 
 [ t ] [ { 1 2 3 } >int-array int-array? ] unit-test
 
@@ -27,4 +26,8 @@ specialized-arrays.uint arrays combinators ;
 
 [ { 3 1 3 3 7 } ] [
     int-array{ 3 1 3 3 7 } malloc-byte-array 5 <direct-int-array> >array
 
 [ { 3 1 3 3 7 } ] [
     int-array{ 3 1 3 3 7 } malloc-byte-array 5 <direct-int-array> >array
+] unit-test
+
+[ ushort-array{ 0 0 0 } ] [
+    3 ALIEN: 123 100 <direct-ushort-array> new-sequence
 ] unit-test
\ No newline at end of file
 ] unit-test
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 631d28d..f3b75af
@@ -1,3 +1,13 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 ! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences vocabs vocabs.loader ;
 IN: specialized-arrays
 IN: specialized-arrays
+
+MIXIN: specialized-array
+INSTANCE: specialized-array sequence
+
+GENERIC: direct-array-syntax ( obj -- word )
+
+"prettyprint" vocab [
+    "specialized-arrays.prettyprint" require
+] when
old mode 100644 (file)
new mode 100755 (executable)
index 91dfddb..bd65123
@@ -5,7 +5,7 @@ prettyprint namespaces ui.tools.listener ui.tools.workspace
 alien.c-types alien sequences math ;\r
 IN: windows.dragdrop-listener\r
 \r
 alien.c-types alien sequences math ;\r
 IN: windows.dragdrop-listener\r
 \r
-<< "WCHAR" require-c-arrays >>\r
+<< "WCHAR" require-c-array >>\r
 \r
 : filenames-from-hdrop ( hdrop -- filenames )\r
     dup HEX: FFFFFFFF f 0 DragQueryFile ! get count of files\r
 \r
 : filenames-from-hdrop ( hdrop -- filenames )\r
     dup HEX: FFFFFFFF f 0 DragQueryFile ! get count of files\r
old mode 100644 (file)
new mode 100755 (executable)
index 5a1bf74..d2ee337
@@ -4,7 +4,7 @@ io.encodings.string io.encodings.utf16n alien.strings
 arrays literals ;
 IN: windows.errors
 
 arrays literals ;
 IN: windows.errors
 
-<< "TCHAR" require-c-arrays >>
+<< "TCHAR" require-c-array >>
 
 CONSTANT: ERROR_SUCCESS                               0
 CONSTANT: ERROR_INVALID_FUNCTION                      1
 
 CONSTANT: ERROR_SUCCESS                               0
 CONSTANT: ERROR_INVALID_FUNCTION                      1
@@ -698,7 +698,7 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK   HEX: 000000FF
 : make-lang-id ( lang1 lang2 -- n )
     10 shift bitor ; inline
 
 : make-lang-id ( lang1 lang2 -- n )
     10 shift bitor ; inline
 
-<< "TCHAR" require-c-arrays >>
+<< "TCHAR" require-c-array >>
 
 ERROR: error-message-failed id ;
 :: n>win32-error-string ( id -- string )
 
 ERROR: error-message-failed id ;
 :: n>win32-error-string ( id -- string )
index 0942123504116a86576ac414a74f90e654c161a6..c7ccf38e432504c10e9696d8cf31914aa95bca67 100755 (executable)
@@ -1,7 +1,7 @@
 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
 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.direct.uchar
+combinators locals specialized-arrays.uchar
 literals splitting grouping classes.struct combinators.smart ;
 IN: windows.ole32
 
 literals splitting grouping classes.struct combinators.smart ;
 IN: windows.ole32
 
old mode 100644 (file)
new mode 100755 (executable)
index 53f6c6c..d54c7af
@@ -1,6 +1,6 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types alien.syntax kernel math math.order
 ! (c)2009 Joe Groff bsd license
 USING: accessors alien.c-types alien.syntax kernel math math.order
-specialized-arrays.direct.functor specialized-arrays.functor ;
+specialized-arrays.functor ;
 IN: half-floats
 
 : half>bits ( float -- bits )
 IN: half-floats
 
 : half>bits ( float -- bits )
@@ -37,6 +37,5 @@ C-STRUCT: half { "ushort" "(bits)" } ;
     drop
 
 "half" define-array
     drop
 
 "half" define-array
-"half" define-direct-array
 
 >>
 
 >>
index 0f4877055a6cbe40828a403e35cab11684d007ef..e318044b81ea4ba301e393e725965c99e445d71b 100755 (executable)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2009 Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
 ! Copyright (C) 2009 Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors grouping sequences combinators
-math specialized-arrays.direct.uint byte-arrays fry
-specialized-arrays.direct.ushort specialized-arrays.uint
-specialized-arrays.ushort specialized-arrays.float images
-half-floats ;
+USING: kernel accessors grouping sequences combinators math
+byte-arrays fry specialized-arrays.direct.ushort
+specialized-arrays.uint specialized-arrays.ushort
+specialized-arrays.float images half-floats ;
 IN: images.normalization
 
 <PRIVATE
 IN: images.normalization
 
 <PRIVATE