]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branches 'master' and 'cleanup' into cleanup
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Jan 2011 02:35:13 +0000 (18:35 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Jan 2011 02:35:13 +0000 (18:35 -0800)
110 files changed:
basis/alien/c-types/c-types-docs.factor
basis/alien/c-types/c-types-tests.factor
basis/alien/c-types/c-types.factor
basis/alien/data/data-docs.factor
basis/alien/data/data-tests.factor
basis/alien/data/data.factor
basis/alien/enums/enums-docs.factor
basis/alien/fortran/fortran-tests.factor
basis/alien/fortran/fortran.factor
basis/alien/syntax/syntax-docs.factor
basis/bit-sets/bit-sets-tests.factor
basis/bit-sets/bit-sets.factor
basis/calendar/unix/unix.factor
basis/checksums/md5/md5.factor
basis/compiler/tests/codegen.factor
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compression/zlib/zlib.factor
basis/concurrency/combinators/combinators-docs.factor
basis/concurrency/locks/locks-docs.factor
basis/concurrency/messaging/messaging-docs.factor
basis/core-foundation/numbers/numbers.factor
basis/core-graphics/core-graphics.factor
basis/cpu/x86/sse/sse.factor
basis/cpu/x86/x87/x87.factor
basis/db/db-docs.factor
basis/db/tuples/tuples-docs.factor
basis/endian/endian.factor
basis/eval/eval-docs.factor
basis/game/input/dinput/dinput.factor
basis/help/handbook/handbook.factor
basis/help/help-docs.factor
basis/hints/hints-docs.factor
basis/hints/hints.factor
basis/io/backend/unix/multiplexers/select/select.factor
basis/io/backend/unix/unix.factor
basis/io/directories/directories-docs.factor
basis/io/directories/search/search-docs.factor
basis/io/directories/unix/linux/linux.factor
basis/io/directories/unix/unix.factor
basis/io/files/info/unix/macosx/macosx.factor
basis/io/files/info/unix/unix-docs.factor
basis/io/files/windows/windows.factor [changed mode: 0644->0755]
basis/io/sockets/windows/windows.factor
basis/io/styles/styles-docs.factor
basis/literals/literals-docs.factor
basis/multiline/multiline-docs.factor
basis/opengl/shaders/shaders.factor
basis/random/random.factor
basis/random/sfmt/sfmt.factor
basis/specialized-arrays/specialized-arrays-docs.factor
basis/specialized-arrays/specialized-arrays-tests.factor
basis/stack-checker/known-words/known-words.factor
basis/system-info/macosx/macosx.factor
basis/system-info/windows/windows.factor
basis/tools/crossref/crossref-docs.factor
basis/tools/deploy/config/config-docs.factor
basis/ui/backend/windows/windows.factor
basis/ui/pixel-formats/pixel-formats-docs.factor
basis/unix/groups/groups.factor
basis/unix/types/linux/linux.factor
basis/urls/encoding/encoding-docs.factor
basis/windows/com/com-tests.factor
basis/windows/com/syntax/syntax.factor [changed mode: 0644->0755]
basis/windows/iphlpapi/iphlpapi.factor
basis/windows/registry/registry.factor
basis/x11/clipboard/clipboard.factor
basis/x11/windows/windows.factor
basis/x11/xim/xim.factor
basis/x11/xinput2/xinput2.factor
core/bootstrap/primitives.factor
core/classes/tuple/tuple-docs.factor
core/generic/generic-docs.factor
core/hash-sets/hash-sets.factor
core/io/encodings/utf16n/utf16n-tests.factor
core/io/pathnames/pathnames-docs.factor
core/math/floats/floats.factor
core/math/integers/integers-tests.factor
core/math/integers/integers.factor
core/math/math.factor
core/sequences/sequences-docs.factor
core/sets/sets-docs.factor
core/sets/sets-tests.factor
core/sets/sets.factor
core/syntax/syntax-docs.factor
core/vocabs/parser/parser-docs.factor
core/vocabs/vocabs-docs.factor
extra/alien/cxx/demangle/libstdcxx/libstdcxx.factor
extra/audio/engine/engine.factor
extra/audio/vorbis/vorbis.factor
extra/cuda/contexts/contexts.factor
extra/cuda/cuda.factor
extra/cuda/devices/devices.factor
extra/cuda/gl/gl.factor
extra/cuda/libraries/libraries.factor
extra/cuda/memory/memory.factor
extra/gpu/framebuffers/framebuffers.factor
extra/javascriptcore/javascriptcore.factor
extra/llvm/jit/jit.factor
extra/llvm/reader/reader.factor
extra/llvm/wrappers/wrappers.factor
extra/openal/alut/macosx/macosx.factor
extra/openal/alut/other/other.factor
extra/openal/openal.factor
extra/opencl/opencl.factor
extra/tokyo/assoc-functor/assoc-functor.factor
vm/bignum.cpp
vm/math.cpp
vm/math.hpp
vm/primitives.hpp
vm/vm.hpp

index 9c8d24d1e17fd5d02af6a8f1571921a83b4cdde5..e14a5cb5e10ca7bbc9c2b28abff040ec029e905a 100644 (file)
@@ -108,14 +108,6 @@ $nl
 "If this condition is not satisfied, " { $link "malloc" } " must be used instead."
 { $warning "Failure to comply with these requirements can lead to crashes, data corruption, and security exploits." } ;
 
-ARTICLE: "c-out-params" "Output parameters in C"
-"A frequently-occurring idiom in C code is the \"out parameter\". If a C function returns more than one value, the caller passes pointers of the correct type, and the C function writes its return values to those locations."
-$nl
-"To wrap Factor data for consumption by the FFI, we use a utility word that constructs a byte array of the correct size and converts the Factor object to a C value stored into that byte array:"
-{ $subsections <ref> }
-"You call the out parameter constructor with the required initial value, then pass the byte array to the C function, which receives a pointer to the start of the byte array's data area. The C function then returns, leaving the result in the byte array; you read it back using this word:"
-{ $subsections deref } ;
-
 ARTICLE: "c-types.primitives" "Primitive C types"
 "The following numerical types are defined in the " { $vocab-link "alien.c-types" } " vocabulary; a " { $snippet "u" } " prefix denotes an unsigned type:"
 { $table
index 93d76a8236cca53cbebb7bc1a7c4572b01c9b46e..661478e4bd0eb17437e0d0a01d9308bb75bef26e 100644 (file)
@@ -9,19 +9,6 @@ CONSTANT: xyz 123
 
 [ 492 ] [ { int xyz } heap-size ] unit-test
 
-[ -1 ] [ -1 char <ref> char deref ] unit-test
-[ -1 ] [ -1 short <ref> short deref ] unit-test
-[ -1 ] [ -1 int <ref> int deref ] unit-test
-
-! I don't care if this throws an error or works, but at least
-! it should be consistent between platforms
-[ -1 ] [ -1.0 int <ref> int deref ] unit-test
-[ -1 ] [ -1.0 long <ref> long deref ] unit-test
-[ -1 ] [ -1.0 longlong <ref> longlong deref ] unit-test
-[ 1 ] [ 1.0 uint <ref> uint deref ] unit-test
-[ 1 ] [ 1.0 ulong <ref> ulong deref ] unit-test
-[ 1 ] [ 1.0 ulonglong <ref> ulonglong deref ] unit-test
-
 UNION-STRUCT: foo
     { a int }
     { b int } ;
@@ -62,14 +49,6 @@ TYPEDEF: int* MyIntArray
 
 [ t ] [ void* c-type MyIntArray c-type = ] unit-test
 
-[
-    0 B{ 1 2 3 4 } <displaced-alien> void* <ref>
-] must-fail
-
-os windows? cpu x86.64? and [
-    [ -2147467259 ] [ 2147500037 long <ref> long deref ] unit-test
-] when
-
 [ 0 ] [ -10 uchar c-type-clamp ] unit-test
 [ 12 ] [ 12 uchar c-type-clamp ] unit-test
 [ -10 ] [ -10 char c-type-clamp ] unit-test
index 6821dae15f17b67461380d256948ffbde3055a79..19103ce3a8b55128b690b68f068b92919b49e587 100644 (file)
@@ -468,12 +468,3 @@ M: double-2-rep rep-component-type drop double ;
 : c-type-clamp ( value c-type -- value' )
     dup { float double } member-eq?
     [ drop ] [ c-type-interval clamp ] if ; inline
-
-: <ref> ( value c-type -- c-ptr )
-    [ heap-size <byte-array> ] keep
-    '[ 0 _ set-alien-value ] keep ; inline
-
-: deref ( c-ptr c-type -- value )
-    [ 0 ] dip alien-value ; inline
-
-: little-endian? ( -- ? ) 1 int <ref> char deref 1 = ; foldable
index 1bfaa007fc6d8db7cf9cda92753ed05053d4d29b..e860ff688948f554da1b4e20a7d949b3d1ec049d 100644 (file)
@@ -1,7 +1,7 @@
 USING: alien alien.c-types help.syntax help.markup libc
 kernel.private byte-arrays math strings hashtables alien.syntax
 alien.strings sequences io.encodings.string debugger destructors
-vocabs.loader classes.struct quotations ;
+vocabs.loader classes.struct quotations kernel ;
 IN: alien.data
 
 HELP: <c-array>
@@ -10,11 +10,6 @@ HELP: <c-array>
 { $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>
-{ $values { "type" "a C type" } { "array" byte-array } }
-{ $description "Creates a byte array suitable for holding a value with the given C type." }
-{ $errors "Throws an " { $link no-c-type } " error if the type does not exist." } ;
-
 HELP: memory>byte-array
 { $values { "alien" c-ptr } { "len" "a non-negative integer" } { "byte-array" byte-array } }
 { $description "Reads " { $snippet "len" } " bytes starting from " { $snippet "base" } " and stores them in a new byte array." } ;
@@ -125,6 +120,10 @@ ARTICLE: "c-pointers" "Passing pointers to C functions"
 { $warning
 "The Factor garbage collector can move byte arrays around, and code passing byte arrays, or objects backed by byte arrays, must obey important guidelines. See " { $link "byte-arrays-gc" } "." } ;
 
+ARTICLE: "c-boxes" "C value boxes"
+"Sometimes it is useful to create a byte array storing a single C value, like a struct with a single field. A pair of utility macros exist to make this more convenient:"
+{ $subsections <ref> deref } ;
+
 ARTICLE: "c-data" "Passing data between Factor and C"
 "Two defining characteristics of Factor are dynamic typing and automatic memory management, which are somewhat incompatible with the machine-level data model exposed by C. Factor's C library interface defines its own set of C data types, distinct from Factor language types, together with automatic conversion between Factor values and C types. For example, C integer types must be declared and are fixed-width, whereas Factor supports arbitrary-precision integers."
 $nl
@@ -135,13 +134,12 @@ $nl
     "malloc"
     "c-strings"
     "c-out-params"
+    "c-boxes"
 }
 "Important guidelines for passing data in byte arrays:"
 { $subsections "byte-arrays-gc" }
 "C-style enumerated types are supported:"
-{ $subsections "alien.enums" POSTPONE: ENUM: }
-"C types can be aliased for convenience and consistency with native library documentation:"
-{ $subsections POSTPONE: TYPEDEF: }
+{ $subsections "alien.enums" }
 "A utility for defining " { $link "destructors" } " for deallocating memory:"
 { $subsections "alien.destructors" }
 "C struct and union types can be defined with " { $link POSTPONE: STRUCT: } " and " { $link POSTPONE: UNION: } ". See " { $link "classes.struct" } " for details. For passing arrays to and from C, use the " { $link "specialized-arrays" } " vocabulary." ;
@@ -190,3 +188,20 @@ $nl
 { $subsections alien>string }
 "For example, if a C function returns a " { $link c-string } " but stipulates that the caller must deallocate the memory afterward, you must define the function as returning " { $snippet "char*" } " and call " { $link (free) } " yourself." ;
 
+HELP: <ref>
+{ $values { "value" object } { "c-type" "a C type" } { "c-ptr" c-ptr } }
+{ $description "Creates a new byte array to store a Factor object as a C value." }
+{ $examples
+    { $example "USING: alien.c-types alien.data prettyprint sequences ;" "123 int <ref> length ." "4" }
+} ;
+
+HELP: deref
+{ $values { "c-ptr" c-ptr } { "c-type" "a C type" } { "value" object } }
+{ $description "Loads a C value from a byte array." }
+{ $examples
+    { $example "USING: alien.c-types alien.data prettyprint sequences ;" "321 int <ref> int deref ." "321" }
+} ;
+
+ARTICLE: "c-out-params" "Output parameters in C"
+"A frequently-occurring idiom in C code is the \"out parameter\". If a C function returns more than one value, the caller passes pointers of the correct type, and the C function writes its return values to those locations."
+{ $subsection with-out-parameters } ;
index 20a6c26b84caadaba2be2406a773644d68772352..7d53c71815c79523baea390a5a3f0685aef58392 100644 (file)
@@ -1,9 +1,32 @@
-USING: alien alien.c-types alien.data alien.syntax
+USING: alien alien.data alien.syntax
 classes.struct kernel sequences specialized-arrays
-specialized-arrays.private tools.test compiler.units vocabs ;
+specialized-arrays.private tools.test compiler.units vocabs
+system ;
+QUALIFIED-WITH: alien.c-types c
 IN: alien.data.tests
 
-STRUCT: foo { a int } { b void* } { c bool } ;
+[ -1 ] [ -1 c:char <ref> c:char deref ] unit-test
+[ -1 ] [ -1 c:short <ref> c:short deref ] unit-test
+[ -1 ] [ -1 c:int <ref> c:int deref ] unit-test
+
+! I don't care if this throws an error or works, but at least
+! it should be consistent between platforms
+[ -1 ] [ -1.0 c:int <ref> c:int deref ] unit-test
+[ -1 ] [ -1.0 c:long <ref> c:long deref ] unit-test
+[ -1 ] [ -1.0 c:longlong <ref> c:longlong deref ] unit-test
+[ 1 ] [ 1.0 c:uint <ref> c:uint deref ] unit-test
+[ 1 ] [ 1.0 c:ulong <ref> c:ulong deref ] unit-test
+[ 1 ] [ 1.0 c:ulonglong <ref> c:ulonglong deref ] unit-test
+
+[
+    0 B{ 1 2 3 4 } <displaced-alien> c:void* <ref>
+] must-fail
+
+os windows? cpu x86.64? and [
+    [ -2147467259 ] [ 2147500037 c:long <ref> c:long deref ] unit-test
+] when
+
+STRUCT: foo { a c:int } { b c:void* } { c c:bool } ;
 
 SPECIALIZED-ARRAY: foo
 
index ab34bf5a4e7f645775db13874210032b6176e957..e17ed9dc3c511eda2e3fdbfc98b3ef47fbe7eef7 100644 (file)
@@ -7,6 +7,15 @@ stack-checker.dependencies combinators.short-circuit ;
 QUALIFIED: math
 IN: alien.data
 
+: <ref> ( value c-type -- c-ptr )
+    [ heap-size <byte-array> ] keep
+    '[ 0 _ set-alien-value ] keep ; inline
+
+: deref ( c-ptr c-type -- value )
+    [ 0 ] dip alien-value ; inline
+
+: little-endian? ( -- ? ) 1 int <ref> char deref 1 = ; foldable
+
 GENERIC: require-c-array ( c-type -- )
 
 M: array require-c-array first require-c-array ;
@@ -44,15 +53,6 @@ M: pointer <c-direct-array>
 : malloc-array ( n type -- array )
     [ heap-size calloc ] [ <c-direct-array> ] 2bi ; inline
 
-: (malloc-array) ( n type -- alien )
-    [ heap-size * malloc ] [ <c-direct-array> ] 2bi ; inline
-
-: <c-object> ( type -- array )
-    heap-size <byte-array> ; inline
-
-: (c-object) ( type -- array )
-    heap-size (byte-array) ; inline
-
 : malloc-byte-array ( byte-array -- alien )
     binary-object [ nip malloc dup ] 2keep memcpy ;
 
index 922aa260a8808dca077a09a8d638bea1c333d08f..0625b07799083a1f2d4b0d4ad7739aa9393d3145 100644 (file)
@@ -23,14 +23,6 @@ HELP: number>enum
 }
 { $description "Convert a number to an enum." } ;
 
-ARTICLE: "alien.enums" "Enumeration types"
-"The " { $vocab-link "alien.enums" } " vocab contains the implementation for " { $link POSTPONE: ENUM: } " C types, and provides words for converting between enum singletons and integers. It is possible to dispatch off of members of an enum."
-$nl
-"Defining enums at run-time:"
-{ $subsection define-enum }
-"Conversions between enums and integers:"
-{ $subsections enum>number number>enum } ;
-
 { POSTPONE: ENUM: define-enum enum>number number>enum } related-words
 
 ABOUT: "alien.enums"
index 38e0d5f27a41e1d24c5e3f3ab8328b4f85fd8491..ad2a60ddc47f968813b5eb927252ed6d241a25a8 100644 (file)
@@ -239,7 +239,7 @@ intel-unix-abi fortran-abi [
 
     [ [
         ! [<fortran-result>]
-        [ complex-float <c-object> ] 1 ndip
+        [ complex-float heap-size <byte-array> ] 1 ndip
         ! [fortran-args>c-args]
         { [ { [ ] } spread ] [ { [ drop ] } spread ] } 1 ncleave
         ! [fortran-invoke]
index 4b7142c4350160540b2b45219ad5cbf5a2ed4cec..f17e91b90ce4e907aab131668acb05778647fc1d 100755 (executable)
@@ -310,7 +310,7 @@ M: misc-type (fortran-result>)
 GENERIC: (<fortran-result>) ( type -- quot )
 
 M: fortran-type (<fortran-result>) 
-    (fortran-type>c-type) \ <c-object> [ ] 2sequence ;
+    (fortran-type>c-type) \ heap-size \ <byte-array> [ ] 3sequence ;
 
 M: character-type (<fortran-result>)
     fix-character-type dims>> product dup
@@ -427,8 +427,11 @@ MACRO: fortran-invoke ( return library function parameters -- )
     { [ 2drop nip set-fortran-abi ] [ (fortran-invoke) ] } 4 ncleave ;
 
 : parse-arglist ( parameters return -- types effect )
-    [ 2 group unzip [ "," ?tail drop ] map ]
-    [ [ { } ] [ 1array ] if-void ]
+    [
+        2 group
+        [ unzip [ "," ?tail drop ] map ]
+        [ [ first "!" head? ] filter [ second "," ?tail drop "'" append ] map ] bi
+    ] [ [ ] [ prefix ] if-void ]
     bi* <effect> ;
 
 :: define-fortran-function ( return library function parameters -- )
index c7ff228ab27679fd5ac5e3fb1571f60692b44c1e..8f60e7e0886688eb43b057fee7b3f1acf5ee9a4f 100644 (file)
@@ -123,3 +123,13 @@ HELP: C-GLOBAL:
 { $syntax "C-GLOBAL: type name" }
 { $values { "type" "a C type" } { "name" "a C global variable name" } }
 { $description "Defines a new word named " { $snippet "name" } " which accesses a global variable in the current library, set with " { $link POSTPONE: LIBRARY: } "." } ;
+
+ARTICLE: "alien.enums" "Enumeration types"
+"The " { $vocab-link "alien.enums" } " vocab contains the implementation for " { $link POSTPONE: ENUM: } " C types, and provides words for converting between enum singletons and integers. It is possible to dispatch off of members of an enum."
+$nl
+"Defining enums:"
+{ $subsection POSTPONE: ENUM: }
+"Defining enums at run-time:"
+{ $subsection define-enum }
+"Conversions between enums and integers:"
+{ $subsections enum>number number>enum } ;
index 0d4543f8f2fa3685873e6470dc70888ca291f8d3..379dc1befca4dde4237d7cd0e91a27e2dd1d9368 100644 (file)
@@ -64,3 +64,8 @@ IN: bit-sets.tests
 
 [ T{ bit-set f ?{ f } } T{ bit-set f ?{ t } } ]
 [ 1 <bit-set> dup clone 0 over adjoin ] unit-test
+
+[ 0 ] [ T{ bit-set f ?{ } } cardinality ] unit-test
+[ 0 ] [ T{ bit-set f ?{ f f f f } } cardinality ] unit-test
+[ 1 ] [ T{ bit-set f ?{ f t f f } } cardinality ] unit-test
+[ 2 ] [ T{ bit-set f ?{ f t f t } } cardinality ] unit-test
index aa74c2b9fbda35592b56ce12d22bd8e5550a96d1..97201256215263e5a87f30ddd81877ffa4101cd1 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors sequences byte-arrays bit-arrays math hints sets ;
+USING: kernel accessors sequences byte-arrays bit-arrays math
+math.bitwise hints sets ;
 IN: bit-sets
 
 TUPLE: bit-set { table bit-array read-only } ;
@@ -14,19 +15,21 @@ M: bit-set in?
     over integer? [ table>> ?nth ] [ 2drop f ] if ; inline
 
 M: bit-set adjoin
-    ! This is allowed to crash when the elt couldn't go in the set
+    ! This is allowed to throw an error when the elt couldn't
+    ! go in the set
     [ t ] 2dip table>> set-nth ;
 
 M: bit-set delete
-    ! This isn't allowed to crash if the elt wasn't in the set
+    ! This isn't allowed to throw an error if the elt wasn't
+    ! in the set
     over integer? [
         table>> 2dup bounds-check? [
             [ f ] 2dip set-nth
         ] [ 2drop ] if
     ] [ 2drop ] if ;
 
-! If you do binary set operations with a bitset, it's expected
-! that the other thing can also be represented as a bitset
+! If you do binary set operations with a bit-set, it's expected
+! that the other thing can also be represented as a bit-set
 ! of the same length.
 <PRIVATE
 
@@ -70,7 +73,8 @@ M: bit-set members
 <PRIVATE
 
 : bit-set-like ( set bit-set -- bit-set' )
-    ! This crashes if there are keys that can't be put in the bit set
+    ! Throws an error if there are keys that can't be put
+    ! in the bit set
     over bit-set? [ 2dup [ table>> length ] bi@ = ] [ f ] if
     [ drop ] [
         [ members ] dip table>> length <bit-set>
@@ -84,3 +88,6 @@ M: bit-set set-like
 
 M: bit-set clone
     table>> clone bit-set boa ;
+
+M: bit-set cardinality
+    table>> bit-count ;
index 58d280248f96d0b921514e3d191444d00ba83f89..f5b3afe9eef3da0722eae29f56c9613ebcf71436 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.syntax arrays calendar
-kernel math unix unix.time unix.types namespaces system
+USING: alien alien.c-types alien.data alien.syntax arrays
+calendar kernel math unix unix.time unix.types namespaces system
 accessors classes.struct ;
 IN: calendar.unix
 
index f83d0354f658ebc2f8b67134d4846870da5ab259..b2af09b7d59a710e4c7e9017eb4211d425276692 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2006, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types kernel io io.binary io.files io.streams.byte-array math
-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 literals hints ;
+USING: alien.c-types alien.data kernel io io.binary io.files
+io.streams.byte-array math 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 literals hints ;
 SPECIALIZED-ARRAY: uint
 IN: checksums.md5
 
index 4e822ba32c09529a43cf03038f696f3bb6fb51b6..f5555716f31d034ea1f492b07d66ac7a5b3c2bfe 100644 (file)
@@ -3,7 +3,7 @@ kernel.private math hashtables.private math.private namespaces
 sequences tools.test namespaces.private slots.private
 sequences.private byte-arrays alien alien.accessors layouts
 words definitions compiler.units io combinators vectors grouping
-make alien.c-types combinators.short-circuit math.order
+make alien.c-types alien.data combinators.short-circuit math.order
 math.libm math.parser math.functions alien.syntax memory
 stack-checker ;
 FROM: math => float ;
index aedab2b40c098439cb4d2a98f326f9ba674b273d..dfce70ae38107234aecacf686d9a33393dbef725 100644 (file)
@@ -1,11 +1,11 @@
 USING: tools.test kernel.private kernel arrays sequences
 math.private math generic words quotations alien alien.c-types
-strings sbufs sequences.private slots.private combinators
-definitions system layouts vectors math.partial-dispatch
-math.order math.functions accessors hashtables classes assocs
-io.encodings.utf8 io.encodings.ascii io.encodings fry slots
-sorting.private combinators.short-circuit grouping prettyprint
-generalizations
+alien.data strings sbufs sequences.private slots.private
+combinators definitions system layouts vectors
+math.partial-dispatch math.order math.functions accessors
+hashtables classes assocs io.encodings.utf8 io.encodings.ascii
+io.encodings fry slots sorting.private combinators.short-circuit
+grouping prettyprint generalizations
 compiler.tree
 compiler.tree.combinators
 compiler.tree.cleanup
@@ -521,8 +521,6 @@ cell-bits 32 = [
     ] cleaned-up-tree nodes>quot
 ] unit-test
 
-USING: alien alien.c-types ;
-
 [ t ] [
     [ int { } cdecl [ 2 2 + ] alien-callback ]
     { + } inlined?
index fc9f1f9693ad3ea8cf164b176551235711a6a06c..02a40defcf7170b1c42bd64e0baf49dc17c45805 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.syntax byte-arrays combinators
-kernel math math.functions sequences system accessors
-libc ;
+USING: alien alien.c-types alien.data alien.syntax byte-arrays
+combinators kernel math math.functions sequences system
+accessors libc ;
 QUALIFIED: compression.zlib.ffi
 IN: compression.zlib
 
index 57470209b6e9b53b58e7b88d675e918dafdb2223..c3389a1aec2f5fe104d2445a62ef81c0a4ccf133 100644 (file)
@@ -43,6 +43,6 @@ $nl
     parallel-spread\r
     parallel-napply\r
 }\r
-"The " { $vocab-link "concurrency.semaphores" } " vocabulary can be used in conjuction with the above combinators to limit the maximum number of concurrent operations." ;\r
+"The " { $vocab-link "concurrency.semaphores" } " vocabulary can be used in conjunction with the above combinators to limit the maximum number of concurrent operations." ;\r
 \r
 ABOUT: "concurrency.combinators"\r
index f600b01056a1a3cb0bf9e0a05d53d2bedd82dd97..4a331e8f19fde30c4dbd3df8b3ba8127d3876338 100644 (file)
@@ -60,7 +60,7 @@ ARTICLE: "concurrency.locks.rw" "Read-write locks"
 $nl\r
 "While this can be achieved with a simple " { $link "concurrency.locks.mutex" } ", performance will suffer, since in fact multiple threads can view the structure at the same time; serialization must only be enforced for writes."\r
 $nl\r
-"Read/write locks allow any number of threads to hold the read lock simulateneously, however attempting to acquire a write lock blocks until all other threads release read locks and write locks."\r
+"Read/write locks allow any number of threads to hold the read lock simultaneously, however attempting to acquire a write lock blocks until all other threads release read locks and write locks."\r
 $nl\r
 "Read/write locks are reentrant. A thread holding a write lock may acquire a read lock or a write lock without blocking. However a thread holding a read lock may not acquire a write lock recursively since that could break invariants assumed by the code executing with the read lock held."\r
 { $subsections\r
index 85870db4df8925bbc1c25ec26a7e419c615d2ab5..b2c0d656f4832261d06ab7ed4db1bad53ef04866 100644 (file)
@@ -1,35 +1,35 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.syntax help.markup 
+USING: help.syntax help.markup
 threads kernel arrays quotations strings ;
 IN: concurrency.messaging
 
 HELP: send
-{ $values { "message" object } 
-          { "thread" thread } 
+{ $values { "message" object }
+          { "thread" thread }
 }
-{ $description "Send the message to the thread by placing it in the threads mailbox. This is an asynchronous operation and will return immediately. The receving thread will act on the message the next time it retrieves that item from its mailbox (usually using the " { $link receive } " word. The message can be any Factor object. For destinations that are instances of remote-thread the message must be a serializable Factor type." } 
+{ $description "Send the message to the thread by placing it in the threads mailbox. This is an asynchronous operation and will return immediately. The receiving thread will act on the message the next time it retrieves that item from its mailbox (usually using the " { $link receive } " word. The message can be any Factor object. For destinations that are instances of remote-thread the message must be a serializable Factor type." }
 { $see-also receive receive-if } ;
 
 HELP: receive
-{ $values { "message" object } 
+{ $values { "message" object }
 }
-{ $description "Return a message from the current threads mailbox. If the box is empty, suspend the thread until another thread places an item in the mailbox (usually via the " { $link send } " word." } 
+{ $description "Return a message from the current threads mailbox. If the box is empty, suspend the thread until another thread places an item in the mailbox (usually via the " { $link send } " word." }
 { $see-also send receive-if } ;
 
 HELP: receive-if
-{ $values { "pred" "a predicate with stack effect " { $snippet "( obj -- ? )" } }  
-          { "message" object } 
+{ $values { "pred" "a predicate with stack effect " { $snippet "( obj -- ? )" } }
+          { "message" object }
 }
-{ $description "Return the first message from the current threads mailbox that satisfies the predicate. To satisfy the predicate, " { $snippet "pred" } " is called with the item on the stack and the predicate should leave a boolean indicating whether it was satisfied or not. If nothing in the mailbox satisfies the predicate then the thread will block until something does." } 
+{ $description "Return the first message from the current threads mailbox that satisfies the predicate. To satisfy the predicate, " { $snippet "pred" } " is called with the item on the stack and the predicate should leave a boolean indicating whether it was satisfied or not. If nothing in the mailbox satisfies the predicate then the thread will block until something does." }
 { $see-also send receive } ;
 
 HELP: spawn-linked
 { $values { "quot" quotation }
           { "name" string }
-          { "thread" thread } 
+          { "thread" thread }
 }
-{ $description "Start a thread which runs the given quotation. If that quotation throws an error which is not caught then the error will get propagated to the thread that spawned it. This can be used to set up 'supervisor' threads that restart child threads that crash due to uncaught errors.\n" } 
+{ $description "Start a thread which runs the given quotation. If that quotation throws an error which is not caught then the error will get propagated to the thread that spawned it. This can be used to set up 'supervisor' threads that restart child threads that crash due to uncaught errors.\n" }
 { $see-also spawn } ;
 
 ARTICLE: { "concurrency" "messaging" } "Sending and receiving messages"
@@ -65,15 +65,15 @@ ARTICLE: { "concurrency" "synchronous-sends" } "Synchronous sends"
 } ;
 
 ARTICLE: { "concurrency" "exceptions" } "Linked exceptions"
-"A thread can handle exceptions using the standard Factor exception handling mechanism. If an exception is uncaught the thread will terminate. For example:" 
-{ $code "[ 1 0 / \"This will not print\" print ] \"division-by-zero\" spawn" } 
+"A thread can handle exceptions using the standard Factor exception handling mechanism. If an exception is uncaught the thread will terminate. For example:"
+{ $code "[ 1 0 / \"This will not print\" print ] \"division-by-zero\" spawn" }
 "Processes can be linked so that a parent thread can receive the exception that caused the child thread to terminate. In this way 'supervisor' threads can be created that are notified when child threads terminate and possibly restart them."
 { $subsections spawn-linked }
 "This will create a unidirectional link, such that if an uncaught exception causes the child to terminate, the parent thread can catch it:"
 { $code "["
 "  [ 1 0 / \"This will not print\" print ] \"linked-division\" spawn-linked drop"
 "  receive"
-"] [ \"Exception caught.\" print ] recover" } 
+"] [ \"Exception caught.\" print ] recover" }
 "Exceptions are only raised in the parent when the parent does a " { $link receive } " or " { $link receive-if } ". This is because the exception is sent from the child to the parent as a message." ;
 
 ARTICLE: "concurrency.messaging" "Message-passing concurrency"
index 4d9f4e8d9f34d7e2309f9d36b5dccd8147b8351e..81440e20f6d207e6e81a25ebb489e9bddc5614e4 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax kernel math core-foundation ;
+USING: alien.c-types alien.data alien.syntax kernel math
+core-foundation ;
 FROM: math => float ;
 IN: core-foundation.numbers
 
index d921789cb053031773962c217343517f8dbd42d6..8463bf145ff2f6db508bf7c5b17173cc1c992798 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.destructors alien.syntax accessors
-destructors fry kernel math math.bitwise sequences libc colors
-images images.memory core-graphics.types core-foundation.utilities
-opengl.gl literals ;
+USING: alien alien.c-types alien.data alien.destructors
+alien.syntax accessors destructors fry kernel math math.bitwise
+sequences libc colors images images.memory core-graphics.types
+core-foundation.utilities opengl.gl literals ;
 IN: core-graphics
 
 TYPEDEF: int CGImageAlphaInfo
index b9541d6fa9a897ce3342aa989da61ba04c059ceb..0b71681d0d6929ad8197ef5ea85e0f362f5dc80d 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009, 2010 Joe Groff, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types arrays assocs combinators fry kernel locals
+USING: alien.data arrays assocs combinators fry kernel locals
 macros math math.vectors namespaces quotations sequences system
 compiler.cfg.comparisons compiler.cfg.intrinsics
 compiler.codegen.fixup cpu.architecture cpu.x86
index 0751877ca740df04682fa79cee0171f4551b2b3c..9ba707709bbea05a873843621cd3e1b95cfb8258 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators kernel locals system namespaces
-compiler.codegen.fixup compiler.constants
+USING: alien.c-types alien.data combinators kernel locals system
+namespaces compiler.codegen.fixup compiler.constants
 compiler.cfg.comparisons compiler.cfg.intrinsics
 cpu.architecture cpu.x86 cpu.x86.assembler
 cpu.x86.assembler.operands ;
index 66c9f32f7fcf39b383fc99933913e595d827d858..cf358fa4b2ecae9ffe1870cba702f1198f297853 100644 (file)
@@ -271,24 +271,21 @@ ARTICLE: "db-lowlevel-tutorial" "Low-level database tutorial"
 { $subsections sql-query }
 "Here's an example usage where we'll make a book table, insert some objects, and query them." $nl
 "First, let's set up a custom combinator for using our database. See " { $link "db-custom-database-combinators" } " for more details."
-{ $code """
-USING: db.sqlite db io.files io.files.temp ;
+{ $code """USING: db.sqlite db io.files io.files.temp ;
 : with-book-db ( quot -- )
-    "book.db" temp-file <sqlite-db> swap with-db ; inline" }
+    "book.db" temp-file <sqlite-db> swap with-db ; inline""" }
 "Now let's create the table manually:"
-{ $code " "create table books
+{ $code """"create table books
     (id integer primary key, title text, author text, date_published timestamp,
      edition integer, cover_price double, condition text)"
     [ sql-command ] with-book-db""" }
 "Time to insert some books:"
-{ $code """
-"insert into books
+{ $code """"insert into books
     (title, author, date_published, edition, cover_price, condition)
     values('Factor for Sheeple', 'Mister Stacky Pants', date('now'), 1, 13.37, 'mint')"
 [ sql-command ] with-book-db""" }
 "Now let's select the book:"
-{ $code """
-"select id, title, cover_price from books;" [ sql-query ] with-book-db""" }
+{ $code """"select id, title, cover_price from books;" [ sql-query ] with-book-db""" }
 "Notice that the result of this query is a Factor array containing the database rows as arrays of strings. We would have to convert the " { $snippet "cover_price" } " from a string to a number in order to use it in a calculation." $nl
 "In conclusion, this method of accessing a database is supported, but it is fairly low-level and generally specific to a single database. The " { $vocab-link "db.tuples" } " vocabulary is a good alternative to writing SQL by hand." ;
 
@@ -298,10 +295,9 @@ ARTICLE: "db-custom-database-combinators" "Custom database combinators"
 "Make a " { $snippet "with-" } " combinator to open and close a database so that resources are not leaked." $nl
 
 "SQLite example combinator:"
-{ $code """
-USING: db.sqlite db io.files io.files.temp ;
+{ $code """USING: db.sqlite db io.files io.files.temp ;
 : with-sqlite-db ( quot -- )
-    "my-database.db" temp-file <sqlite-db> swap with-db ; inline""" } 
+    "my-database.db" temp-file <sqlite-db> swap with-db ; inline""" }
 
 "PostgreSQL example combinator:"
 { $code """USING: db.postgresql db ;
index 3f77f9abaf6b51b6e5aa2f2f628125ee48147f85..8a9e6ba2b6035f8c3e1efb81fc95788acded2daa 100644 (file)
@@ -233,8 +233,7 @@ T{ book
     { date-published T{ timestamp { year 2009 } { month 3 } { day 3 } } }
     { edition 1 }
     { cover-price 13.37 }
-} book set
-""" }
+} book set""" }
 "Now we've created a book. Let's save it to the database."
 { $code """USING: db db.sqlite fry io.files.temp ;
 : with-book-tutorial ( quot -- )
@@ -243,8 +242,7 @@ T{ book
 [
     book recreate-table
     book get insert-tuple
-] with-book-tutorial
-""" }
+] with-book-tutorial""" }
 "Is it really there?"
 { $code """[
     T{ book { title "Factor for Sheeple" } } select-tuples .
index 502b13026511f574995db14e6222885dce802166..4f59f71f3a9066a3c5cba7d352cc19b49e3786f2 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types namespaces io.binary fry
+USING: alien.c-types alien.data namespaces io.binary fry
 kernel math grouping sequences math.bitwise ;
 IN: endian
 
index f3ee35d91c543959c44c2043acae11babb1c2841..e7e3c023030fb909f25becc62f0ef1a17aacbfb0 100644 (file)
@@ -50,7 +50,7 @@ $nl
 { $code
     """USING: eval listener vocabs.parser ;
 [
-    "cad-objects" use-vocab
+    "cad.objects" use-vocab
     (( -- seq )) (eval)
 ] with-interactive-vocabs"""
 }
index 2cd16bac1f94a81293fc0a7e925a2068fff9a186..fd9d992f138941cb575bb2fbf982d94bc66e2e0f 100755 (executable)
@@ -1,12 +1,12 @@
-USING: accessors alien alien.c-types alien.strings arrays assocs
-byte-arrays combinators combinators.short-circuit 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
+USING: accessors alien alien.c-types alien.data alien.strings
+arrays assocs byte-arrays combinators combinators.short-circuit
+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
 specialized-arrays ui.backend.windows vectors windows.com
 windows.directx.dinput windows.directx.dinput.constants
 windows.kernel32 windows.messages windows.ole32 windows.errors
-windows.user32 classes.struct alien.data ;
+windows.user32 classes.struct ;
 SPECIALIZED-ARRAY: DIDEVICEOBJECTDATA
 IN: game.input.dinput
 
index da5f2911f836cc436eed65a64b89ecf4ed1cec38..9c8464cae1316a8eb4a2c808d6e172c36f9f5ce6 100644 (file)
@@ -45,7 +45,7 @@ $nl
 $nl
 "Some generic words have " { $strong "Description" } " headings, and others have " { $strong "Contract" } " headings. A distinction is made between words which are not intended to be extended with user-defined methods, and those that are."
 { $heading "Vocabulary naming conventions" }
-"A vocabulary name ending in " { $snippet ".private" } " contains words which are either implementation details, unsafe, or both. For example, the " { $snippet "sequence.private" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } "). You should avoid using private words from the Factor library unless absolutely necessary. Similarly, your own code can place words in private vocabularies using " { $link POSTPONE: <PRIVATE } " if you do not want other people using them without good reason."
+"A vocabulary name ending in " { $snippet ".private" } " contains words which are either implementation details, unsafe, or both. For example, the " { $snippet "sequences.private" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } "). You should avoid using private words from the Factor library unless absolutely necessary. Similarly, your own code can place words in private vocabularies using " { $link POSTPONE: <PRIVATE } " if you do not want other people using them without good reason."
 { $heading "Word naming conventions" }
 "These conventions are not hard and fast, but are usually a good first step in understanding a word's behavior:"
 { $table
index e3bd50a6f2ddc399d004a7dcd9430ea694850c88..8e22aad21207c61de83699da9154adaa22ac0e22 100644 (file)
@@ -476,7 +476,8 @@ HELP: HELP:
 { $description "Defines documentation for a word." }
 { $examples
     { $code
-        ": foo 2 + ;"
+        "USING: help help.markup help.syntax math ;"
+        ": foo ( m -- n ) 2 + ;"
         "HELP: foo"
         "{ $values { \"m\" \"an integer\" } { \"n\" \"an integer\" } }"
         "{ $description \"Increments a value by 2.\" } ;"
index 46bdc698b73a59874c1884ba25626bfec96aa5fa..b5e7b377258e2740c63f3f5aaff908c10d120360 100644 (file)
@@ -24,20 +24,25 @@ HELP: HINTS:
 { $description "Defines specialization hints for a word or a method."
 $nl
 "Each sequence in the list will cause a specialized version of the word to be compiled. Classes are tested for using their predicate, and literals are tested using " { $link eq? } "." }
-{ $examples "The " { $link append } " word has a specializer for the very common case where two strings or two arrays are appended:"
-{ $code "HINTS: append { string string } { array array } ;" }
-"Specializers can also be defined on methods:"
-{ $code
-    "GENERIC: count-occurrences ( elt obj -- n )"
-    ""
-    "M: sequence count-occurrences [ = ] with count ;"
-    ""
-    "M: assoc count-occurrences"
-    "    swap [ = nip ] curry assoc-filter assoc-size ;"
-    ""
-    "HINTS: M\ sequence count-occurrences { object array } ;"
-    "HINTS: M\ assoc count-occurrences { object hashtable } ;"
-}
+{ $examples
+    "The " { $link append } " word has a specializer for the very common case where two strings or two arrays are appended:"
+    { $code
+        "USING: arrays hints sequences strings ;"
+        "HINTS: append { string string } { array array } ;"
+    }
+    "Specializers can also be defined on methods:"
+    { $code
+        "USING: assocs hashtables hints kernel sequences ;"
+        "GENERIC: count-occurrences ( elt obj -- n )"
+        ""
+        "M: sequence count-occurrences [ = ] with count ;"
+        ""
+        "M: assoc count-occurrences"
+        "    swap [ = nip ] curry assoc-filter assoc-size ;"
+        ""
+        "HINTS: M\\ sequence count-occurrences { object array } ;"
+        "HINTS: M\\ assoc count-occurrences { object hashtable } ;"
+    }
 } ;
 
 ABOUT: "hints"
index dc16cf8b246b4b7e99eb9db215f3721ad1516339..abfb3199a2989574f3a1fc0546cc9a7d942c5310 100644 (file)
@@ -3,9 +3,9 @@
 USING: accessors arrays assocs byte-arrays byte-vectors classes
 combinators definitions effects fry generic generic.single
 generic.standard hashtables io.binary io.encodings
-io.streams.string kernel kernel.private math
-math.integers.private math.parser namespaces parser sbufs
-sequences splitting splitting.private strings vectors words ;
+io.streams.string kernel kernel.private math math.parser
+namespaces parser sbufs sequences splitting splitting.private
+strings vectors words ;
 IN: hints
 
 GENERIC: specializer-predicate ( spec -- quot )
@@ -130,6 +130,4 @@ M\ hashtable at* { { fixnum object } { word object } } "specializer" set-word-pr
 
 M\ hashtable set-at { { object fixnum object } { object word object } } "specializer" set-word-prop
 
-\ bignum/f { { bignum bignum } { bignum fixnum } { fixnum bignum } { fixnum fixnum } } "specializer" set-word-prop
-
 \ encode-string { string object object } "specializer" set-word-prop
index 2cf406a941523e2d1e689ff14bf0071c425f9a29..3c1e5b06f786157f86c33392798fded2327d3685 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types kernel bit-arrays sequences assocs math
+USING: alien.data kernel bit-arrays sequences assocs math
 namespaces accessors math.order locals fry io.ports
 io.backend.unix io.backend.unix.multiplexers unix unix.ffi
 unix.time ;
index e84f1a8825d3f7aa5ba0510108d5fe2cd1d9ce71..22f0a339a90cb98ed9e215face6af0d63b8ee0c6 100755 (executable)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.syntax generic assocs kernel
-kernel.private math io.ports sequences strings sbufs threads
-unix unix.ffi vectors io.buffers io.backend io.encodings math.parser
-continuations system libc namespaces make io.timeouts
-io.encodings.utf8 destructors destructors.private accessors
-summary combinators locals unix.time unix.types fry
-io.backend.unix.multiplexers ;
+USING: alien alien.c-types alien.data alien.syntax generic
+assocs kernel kernel.private math io.ports sequences strings
+sbufs threads unix unix.ffi vectors io.buffers io.backend
+io.encodings math.parser continuations system libc namespaces
+make io.timeouts io.encodings.utf8 destructors
+destructors.private accessors summary combinators locals
+unix.time unix.types fry io.backend.unix.multiplexers ;
 QUALIFIED: io
 IN: io.backend.unix
 
index 3871f9be415753df2aeb2fc5e92ba44297a86399..6370fdb90d04255def2f25d79270c56c507183e0 100644 (file)
@@ -52,7 +52,7 @@ HELP: with-directory-files
 { $examples
     "Print all files in your home directory which are larger than a megabyte:"
     { $code
-        """USING: io.directoies io.files.info io.pathnames ;
+        """USING: io.directories io.files.info io.pathnames ;
 home [
     [
         dup link-info size>> 20 2^ >
index 4f7e0ba212c3b8005e8908c52eda4e9367ccaa47..de61aeaf0bc1541c751a86366fdef2a0eb3572b4 100644 (file)
@@ -64,7 +64,7 @@ HELP: find-by-extension
 }
 { $description "Searches a directory for all files with the given extension. File extension and filenames are converted to lower-case and compared using the " { $link tail? } " word. The file extension should contain the period." }
 { $examples
-    { $unchecked-example
+    { $code
         "USING: io.directories.search ;"
         "\"/\" \".mp3\" find-by-extension"
     }
@@ -77,7 +77,7 @@ HELP: find-by-extensions
 }
 { $description "Searches a directory for all files in the given list of extensions. File extensions and filenames are converted to lower-case and compared using the " { $link tail? } " word. File extensions should contain the period." }
 { $examples
-    { $unchecked-example
+    { $code
         "USING: io.directories.search ;"
         "\"/\" { \".jpg\" \".gif\" \".tiff\" \".png\" \".bmp\" } find-by-extensions"
     }
index a4d96c5b70e8aeccf819a26aa24285b43f811d30..3429d5beb2096f15be37a9f0b5248b11011d49ba 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types io.directories.unix kernel system unix
-classes.struct unix.ffi ;
+USING: alien.c-types alien.data io.directories.unix kernel
+system unix classes.struct unix.ffi ;
 IN: io.directories.unix.linux
 
 M: linux find-next-file ( DIR* -- dirent )
index a175599e015b646cfe1a8b1e100d1450a24797c5..d5dc0ab90575cd3357f5ebddbd05f44fc85d3ffd 100644 (file)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.strings combinators
-continuations destructors fry io io.backend io.backend.unix
-io.directories io.encodings.binary io.encodings.utf8 io.files
-io.pathnames io.files.types kernel math.bitwise sequences system
-unix unix.stat vocabs.loader classes.struct unix.ffi literals ;
+USING: accessors alien.c-types alien.data alien.strings
+combinators continuations destructors fry io io.backend
+io.backend.unix io.directories io.encodings.binary
+io.encodings.utf8 io.files io.pathnames io.files.types kernel
+math.bitwise sequences system unix unix.stat vocabs.loader
+classes.struct unix.ffi literals ;
 IN: io.directories.unix
 
 CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL }
index 445f16456483bbd6cf143d71732914591957b941..d0d4bb7c0575594b1e6e5290a7f2589498175d2d 100644 (file)
@@ -1,10 +1,10 @@
 ! 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 arrays unix.statfs.macosx unix.statvfs.macosx
-unix.getfsstat.macosx io.files.info.unix io.files.info
-classes.struct specialized-arrays ;
+USING: accessors alien.c-types alien.data alien.strings
+combinators 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
index 7b98788226bb53dc5dd7550d5f021425a2e2e448..c8fc965eca1e723b66f0e8070f067fd97664fd75 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes help.markup help.syntax io.streams.string
 strings math calendar io.files.info io.files.info.unix ;
-IN: io.files.unix
+IN: io.files.info.unix
 
 HELP: add-file-permissions
 { $values
@@ -102,16 +102,15 @@ HELP: set-file-permissions
      { "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } }
 { $description "Sets the file permissions for a given file with the supplied Unix permissions integer. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." }
 { $examples "Using the tradidional octal value:"
-    { $unchecked-example "USING: io.files.unix kernel ;"
+    { $code "USING: io.files.info.unix kernel ;"
         "\"resource:license.txt\" OCT: 755 set-file-permissions"
-        ""
     }
     "Higher-level, setting named bits:"
-    { $unchecked-example "USING: io.files.unix kernel math.bitwise ;"
+    { $code "USING: io.files.info.unix kernel literals ;"
     "\"resource:license.txt\""
-    "{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
-    "flags set-file-permissions"
-    "" }
+    "flags{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
+    "set-file-permissions"
+    }
 } ;
 
 HELP: set-file-times
old mode 100644 (file)
new mode 100755 (executable)
index 70fe03b..6a83fce
@@ -3,13 +3,13 @@
 USING: accessors alien alien.c-types alien.data alien.strings
 alien.syntax arrays assocs classes.struct combinators
 combinators.short-circuit continuations destructors environment
-io io.backend io.binary io.buffers
-io.encodings.utf16n io.files io.files.private io.files.types
-io.pathnames io.ports io.streams.c io.streams.null io.timeouts
-kernel libc literals locals make math math.bitwise namespaces
-sequences specialized-arrays system
-threads tr windows windows.errors windows.handles
-windows.kernel32 windows.shell32 windows.time windows.types ;
+io io.backend io.binary io.buffers io.encodings.utf16n io.files
+io.files.private io.files.types io.pathnames io.ports
+io.streams.c io.streams.null io.timeouts kernel libc literals
+locals make math math.bitwise namespaces sequences
+specialized-arrays system threads tr windows windows.errors
+windows.handles windows.kernel32 windows.shell32 windows.time
+windows.types ;
 SPECIALIZED-ARRAY: ushort
 IN: io.files.windows
 
@@ -52,7 +52,7 @@ C: <FileArgs> FileArgs
         [ handle>> handle>> ]
         [ buffer>> ]
         [ buffer>> buffer-length ]
-        [ drop DWORD <c-object> ]
+        [ drop 0 DWORD <ref> ]
         [ FileArgs-overlapped ]
     } cleave <FileArgs> ;
     
index ec00626b5151d19e5e0b54f9c5e3c53136a907a9..aea801615650313318eb388b57efdc7ad25d92fc 100755 (executable)
@@ -99,7 +99,7 @@ M: winnt WSASocket-flags ( -- DWORD )
     { void* }\r
     [\r
         void* heap-size\r
-        DWORD <c-object>\r
+        0 DWORD <ref>\r
         f\r
         f\r
         WSAIoctl SOCKET_ERROR = [\r
index 7750db8f1d46466b9bf4d3860d81c964a6a823de..98338639bb6f03a166ba65dc1fb79b2f36d453ba 100644 (file)
@@ -61,6 +61,7 @@ $nl
 "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
 { $examples
     { $code
+        "USING: io.styles prettyprint sequences ;"
         "{ { 1 2 } { 3 4 } }"
         "H{ { table-gap { 10 10 } } } ["
         "    [ [ [ [ . ] with-cell ] each ] with-row ] each"
@@ -201,12 +202,13 @@ HELP: bold-italic
 { $description "A value for the " { $link font-style } " character style denoting boldface italicized text." } ;
 
 HELP: foreground
-{ $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." } 
+{ $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." }
 { $examples
     { $code
+        "USING: colors.gray io.styles hashtables sequences kernel math ;"
         "10 iota ["
-            "    \"Hello world\\n\""
-            "    swap 10 / 1 <gray> foreground associate format"
+        "    \"Hello world\\n\""
+        "    swap 10 / 1 <gray> foreground associate format"
         "] each"
     }
 } ;
@@ -215,10 +217,11 @@ HELP: background
 { $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." }
 { $examples
     { $code
+        "USING: colors hashtables io io.styles kernel math sequences ;"
         "10 iota ["
-            "    \"Hello world\\n\""
-            "    swap 10 / 1 over - over 1 <rgba>"
-            "    background associate format nl"
+        "    \"Hello world\\n\""
+        "    swap 10 / 1 over - over 1 <rgba>"
+        "    background associate format nl"
         "] each"
     }
 } ;
@@ -227,14 +230,20 @@ HELP: font-name
 { $description "Character style. Font family named by a string." }
 { $examples
     "This example outputs some different font sizes:"
-    { $code "{ \"monospace\" \"serif\" \"sans-serif\" }\n[ dup font-name associate format nl ] each" }
+    { $code
+        "USING: hashtables io io.styles kernel sequences ;"
+        "{ \"monospace\" \"serif\" \"sans-serif\" }"
+        "[ dup font-name associate format nl ] each"
+    }
 } ;
 
 HELP: font-size
 { $description "Character style. Font size, an integer." }
 { $examples
     "This example outputs some different font sizes:"
-    { $code "{ 12 18 24 72 }"
+    { $code
+        "USING: hashtables io io.styles kernel sequences ;"
+        "{ 12 18 24 72 }"
         "[ \"Bigger\" swap font-size associate format nl ] each"
     }
 }  ;
@@ -243,28 +252,44 @@ HELP: font-style
 { $description "Character style. Font style, one of " { $link plain } ", " { $link bold } ", " { $link italic } ", or " { $link bold-italic } "." }
 { $examples
     "This example outputs text in all three styles:"
-    { $code "{ plain bold italic bold-italic }\n[ [ name>> ] keep font-style associate format nl ] each" }
+    { $code
+        "USING: accessors hashtables io io.styles kernel sequences ;"
+        "{ plain bold italic bold-italic }"
+        "[ [ name>> ] keep font-style associate format nl ] each"
+    }
 }  ;
 
 HELP: presented
 { $description "Character and paragraph style. An object associated with the text. In the Factor UI, this is shown as a clickable presentation of the object; left-clicking invokes a default command, and right-clicking shows a menu of commands." } ;
 
 HELP: page-color
-{ $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." } 
+{ $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." }
 { $examples
-    { $code "H{ { page-color T{ rgba f 1 0.8 0.5 1 } } }\n[ \"A background\" write ] with-nesting nl" }
+    { $code
+        "USING: colors io io.styles ;"
+        "H{ { page-color T{ rgba f 1 0.8 0.5 1 } } }"
+        "[ \"A background\" write ] with-nesting nl"
+    }
 } ;
 
 HELP: border-color
 { $description "Paragraph style. An instance of " { $link color } ". See " { $link "colors" } "." }
 { $examples
-    { $code "H{ { border-color T{ rgba f 1 0 0 1 } } }\n[ \"A border\" write ] with-nesting nl" }
+    { $code
+        "USING: colors io io.styles ;"
+        "H{ { border-color T{ rgba f 1 0 0 1 } } }"
+        "[ \"A border\" write ] with-nesting nl"
+    }
 } ;
 
 HELP: inset
-{ $description "Paragraph style. A pair of integers representing the number of pixels that the content should be inset from the border. The first number is the horizontal inset, and the second is the vertical inset." } 
+{ $description "Paragraph style. A pair of integers representing the number of pixels that the content should be inset from the border. The first number is the horizontal inset, and the second is the vertical inset." }
 { $examples
-    { $code "H{ { inset { 10 10 } } }\n[ \"Some inset text\" write ] with-nesting nl" }
+    { $code
+        "USING: io io.styles ;"
+        "H{ { inset { 10 10 } } }"
+        "[ \"Some inset text\" write ] with-nesting nl"
+    }
 } ;
 
 HELP: wrap-margin
@@ -284,7 +309,10 @@ HELP: input
 { $class-description "Class of input text presentations. Instances can be used passed to " { $link write-object } " to output a clickable piece of input. Input text presentations are created by calling " { $link <input> } "." }
 { $examples
     "This presentation class is used for the code examples you see in the online help:"
-    { $code "\"2 3 + .\" dup <input> write-object nl" }
+    { $code
+        "USING: io io.styles kernel ;"
+        "\"2 3 + .\" dup <input> write-object nl"
+    }
 } ;
 
 HELP: <input>
@@ -302,4 +330,4 @@ ARTICLE: "io.streams.plain" "Plain writer streams"
 { $link make-span-stream } ", "
 { $link make-block-stream } " and "
 { $link make-cell-stream } "."
-{ $subsections plain-writer } ;
\ No newline at end of file
+{ $subsections plain-writer } ;
index 6fcf8a5e07c807970d6b510e9fef5704f0c68384..52aa1cd717742fc0c3b614bd0a75d01047488163 100644 (file)
@@ -8,23 +8,22 @@ HELP: $
 { $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
 { $notes { $snippet "word" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." }
 { $examples
-
-    { $example """
-USING: kernel literals prettyprint ;
-IN: scratchpad
-
-CONSTANT: five 5
-{ $ five } .
-    """ "{ 5 }" }
-
-    { $example """
-USING: kernel literals prettyprint ;
-IN: scratchpad
-
-: seven-eleven ( -- a b ) 7 11 ;
-{ $ seven-eleven } .
-    """ "{ 7 11 }" }
-
+    { $example
+        "USING: kernel literals prettyprint ;"
+        "IN: scratchpad"
+        ""
+        "CONSTANT: five 5"
+        "{ $ five } ."
+        "{ 5 }"
+    }
+    { $example
+        "USING: kernel literals prettyprint ;"
+        "IN: scratchpad"
+        ""
+        ": seven-eleven ( -- a b ) 7 11 ;"
+        "{ $ seven-eleven } ."
+        "{ 7 11 }"
+    }
 } ;
 
 HELP: $[
@@ -32,15 +31,14 @@ HELP: $[
 { $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
 { $notes "Since " { $snippet "code" } " is " { $link call } "ed at parse time, it cannot reference any words defined in the same compilation unit." }
 { $examples
-
-    { $example """
-USING: kernel literals math prettyprint ;
-IN: scratchpad
-
-<< CONSTANT: five 5 >>
-{ $[ five dup 1 + dup 2 + ] } .
-    """ "{ 5 6 8 }" }
-
+    { $example
+        "USING: kernel literals math prettyprint ;"
+        "IN: scratchpad"
+        ""
+        "<< CONSTANT: five 5 >>"
+        "{ $[ five dup 1 + dup 2 + ] } ."
+        "{ 5 6 8 }"
+    }
 } ;
 
 HELP: ${
@@ -48,15 +46,14 @@ HELP: ${
 { $description "Outputs an array containing the results of executing " { $snippet "code" } " at parse time." }
 { $notes { $snippet "code" } "'s definition is looked up and " { $link call } "ed at parse time, so words that reference words in the current compilation unit cannot be used with " { $snippet "$" } "." }
 { $examples
-
-    { $example """
-USING: kernel literals math prettyprint ;
-IN: scratchpad
-
-CONSTANT: five 5
-CONSTANT: six 6
-${ five six 7 } .
-    """ "{ 5 6 7 }"
+    { $example
+        "USING: kernel literals math prettyprint ;"
+        "IN: scratchpad"
+        ""
+        "CONSTANT: five 5"
+        "CONSTANT: six 6"
+        "${ five six 7 } ."
+        "{ 5 6 7 }"
     }
 } ;
 
@@ -66,7 +63,8 @@ HELP: flags{
 { $values { "values" sequence } }
 { $description "Constructs a constant flag value from a sequence of integers or words that output integers. The resulting constant is computed at parse-time, which makes this word as efficient as using a literal integer." }
 { $examples
-    { $example "USING: literals kernel prettyprint ;"
+    { $example
+        "USING: literals kernel prettyprint ;"
         "IN: scratchpad"
         "CONSTANT: x HEX: 1"
         "flags{ HEX: 20 x BIN: 100 } .h"
@@ -77,13 +75,14 @@ HELP: flags{
 
 ARTICLE: "literals" "Interpolating code results into literal values"
 "The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
-{ $example """
-USE: literals
-IN: scratchpad
-
-CONSTANT: five 5
-{ $ five $[ five dup 1 + dup 2 + ] } .
-    """ "{ 5 5 6 8 }" }
+{ $example
+    "USING: kernel literals math prettyprint ;"
+    "IN: scratchpad"
+    ""
+    "<< CONSTANT: five 5 >>"
+    "{ $ five $[ five dup 1 + dup 2 + ] } ."
+    "{ 5 5 6 8 }"
+}
 { $subsections
     POSTPONE: $
     POSTPONE: $[
index 9e7c28e89f43fd1c9c5fec54c370413b3f1b1912..09f86197ba5f5c3cb2e00949941c755b9b670352 100644 (file)
@@ -17,7 +17,7 @@ HELP: /*
 HELP: HEREDOC:
 { $syntax "HEREDOC: marker\n...text...\nmarker" }
 { $values { "marker" "a word (token)" } { "text" "arbitrary text" } { "value" string } }
-{ $description "Returns a string delimited by an arbitrary user-defined token. This delimiter must be exactly the text beginning at the first non-blank character after " { $link POSTPONE: HEREDOC: } " until the end of the line containing " { $link POSTPONE: HEREDOC: } ". Text is captured until a line is found conatining exactly this delimter string." }
+{ $description "Returns a string delimited by an arbitrary user-defined token. This delimiter must be exactly the text beginning at the first non-blank character after " { $link POSTPONE: HEREDOC: } " until the end of the line containing " { $link POSTPONE: HEREDOC: } ". Text is captured until a line is found containing exactly this delimiter string." }
 { $warning "Whitespace is significant." }
 { $examples
     { $example "USING: multiline prettyprint ;"
index 30df656d4a4cd2edc7b6079283263c230b49b63b..1b7ac94f4d705608ad82db429acce81d66da4163 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel opengl.gl alien.c-types continuations namespaces
-assocs alien alien.data alien.strings libc opengl math sequences combinators
-macros arrays io.encodings.ascii fry specialized-arrays
-destructors accessors ;
+assocs alien alien.data alien.strings libc opengl math sequences
+combinators macros arrays io.encodings.ascii fry
+specialized-arrays destructors accessors ;
 SPECIALIZED-ARRAY: uint
 IN: opengl.shaders
 
index ae7c0ad1e38c7bc26873047408f4b17ca49d294c..bf99b47ba7f70504dac0c40462d19455ee014d67 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types arrays assocs byte-arrays
-byte-vectors combinators fry io.backend io.binary kernel locals
-math math.bitwise math.constants math.functions math.order
-math.ranges namespaces sequences sets summary system
+USING: accessors alien.c-types alien.data arrays assocs
+byte-arrays byte-vectors combinators fry io.backend io.binary
+kernel locals math math.bitwise math.constants math.functions
+math.order math.ranges namespaces sequences sets summary system
 vocabs.loader ;
 IN: random
 
index ccccaac7eaf53eef675dcbd18327da8cf2f9ba6e..2efe6f6facf96b70b3b32212bc0e7e019d1f141f 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types kernel locals math math.ranges
-math.bitwise math.vectors math.vectors.simd random
+USING: accessors alien.c-types alien.data kernel locals math
+math.ranges math.bitwise math.vectors math.vectors.simd random
 sequences specialized-arrays sequences.private classes.struct
 combinators.short-circuit fry ;
 SPECIALIZED-ARRAY: uint
index 722dff6d915c8cd0678dd2c78800682c35165663..99036ac01374a564ac5954f596ca7af137acda09 100644 (file)
@@ -41,7 +41,7 @@ ARTICLE: "specialized-array-words" "Specialized array words"
     { { $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)" } { "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 "malloc-T-array" } { "Constructor for arrays with elements of type " { $snippet "T" } " backed by newly-allocated, zeroed out, unmanaged memory; stack effect " { $snippet "( 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 "T-array-cast" } { "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 )" } } }
@@ -86,7 +86,7 @@ $nl
 }
 "Finally, sometimes a C library returns a pointer to an array in unmanaged memory, together with a length. In this case, a specialized array can be constructed to view this memory using " { $snippet "<direct-T-array>" } ":"
 { $code
-    "USING: alien.c-types classes.struct ;"
+    "USING: alien.c-types alien.data classes.struct ;"
     ""
     "STRUCT: device_info"
     "    { id int }"
index 02424a22fdc68cc9cd9c7b1a4ec521fa8c353177..e3770220e89e8f878cbd6b250c8fe894159f249c 100644 (file)
@@ -6,7 +6,8 @@ multiline eval words vocabs namespaces assocs prettyprint
 alien.data math.vectors definitions compiler.test ;
 FROM: specialized-arrays.private => specialized-array-vocab ;
 FROM: alien.c-types => int float bool char float ulonglong ushort uint
-heap-size little-endian? ;
+heap-size ;
+FROM: alien.data => little-endian? ;
 IN: specialized-arrays.tests
 
 SPECIALIZED-ARRAY: int
index 47e882f2277501705ddc2dfea87da23128876aca..43bff4e96a833b4e85aa0037036a90b43df17b19 100644 (file)
@@ -338,7 +338,6 @@ M: object infer-call* \ call bad-macro-input ;
 \ bignum> { bignum bignum } { object } define-primitive \ bignum> make-foldable
 \ bignum>= { bignum bignum } { object } define-primitive \ bignum>= make-foldable
 \ bignum>fixnum { bignum } { fixnum } define-primitive \ bignum>fixnum make-foldable
-\ bignum>float { bignum } { float } define-primitive \ bignum>float make-foldable
 \ bits>double { integer } { float } define-primitive \ bits>double make-foldable
 \ bits>float { integer } { float } define-primitive \ bits>float make-foldable
 \ both-fixnums? { object object } { object } define-primitive
index 11a89fc4bd069aca142663784f41062145aab12e..d4f22771284537671bf10c36310935325a1db45b 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.strings alien.syntax
+USING: alien alien.c-types alien.data alien.strings alien.syntax
 byte-arrays kernel namespaces sequences unix
 system-info.backend system io.encodings.utf8 ;
 IN: system-info.macosx
index 5ea68dbbad7e4aa1efbbf36a1cc9436b2dc5311c..4ff252bf25641cb91670e6d14023732f494e040d 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types alien.strings byte-arrays
-classes.struct combinators kernel math namespaces
-specialized-arrays system
-system-info.backend vocabs.loader windows windows.advapi32
-windows.errors windows.kernel32 words ;
+USING: accessors alien alien.c-types alien.data alien.strings
+byte-arrays classes.struct combinators kernel math namespaces
+specialized-arrays system system-info.backend vocabs.loader
+windows windows.advapi32 windows.errors windows.kernel32 words ;
 SPECIALIZED-ARRAY: ushort
 IN: system-info.windows
 
index e8c45ee4a0db23095232bf0559d31918004cec48..29b3d26d104f6dfe8c75142198697658462f8624 100644 (file)
@@ -28,7 +28,7 @@ HELP: uses
 { $notes "The sequence might include the definition itself, if it is a recursive word." }
 { $examples
     "We can ask the " { $link sq } " word to produce a list of words it calls:"
-    { $unchecked-example "\ sq uses ." "{ dup * }" }
+    { $unchecked-example "\\ sq uses ." "{ dup * }" }
 } ;
 
 HELP: crossref
index 0b06abc29a2bf2412827c3cdf9febdce16584086..2f525471040c6e2ac75e8995d35ca22e26b4044f 100644 (file)
@@ -40,13 +40,15 @@ HELP: deploy-c-types?
 $nl
 "Off by default."
 $nl
-"The optimizing compiler is able to fold away calls to various words which take a C type as an input if the C type is a literal string:"
+"The optimizing compiler is able to fold away calls to various words which take a C type as an input if the C type is a literal string, for example,"
 { $list
     { $link c-type }
     { $link heap-size }
-    { $link <c-object> }
     { $link <c-array> }
+    { $link <c-direct-array> }
     { $link malloc-array }
+    { $link <ref> }
+    { $link deref }
 }
 "If your program looks up C types dynamically or from words which do not have a stack effect, you must enable this flag, because in these situations the C type lookup code is not folded away and the word properties must be consulted at runtime." } ;
 
index 68a0a756a925f85c184d9bab1cfdcb4a4ad33faa..072924fa57d806a91b3accf1be5ef1857d52e2a9 100755 (executable)
@@ -1,19 +1,19 @@
 ! Copyright (C) 2005, 2006 Doug Coleman.
 ! Portions copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.strings arrays assocs ui
+USING: alien alien.data 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.dwmapi system-info.windows windows.kernel32
-windows.gdi32 windows.user32 windows.opengl32 windows.messages
-windows.types windows.offscreen windows 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
+vectors words windows.dwmapi system-info.windows
+windows.kernel32 windows.gdi32 windows.user32 windows.opengl32
+windows.messages windows.types windows.offscreen windows 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 colors
-specialized-arrays classes.struct alien.data ;
+specialized-arrays classes.struct ;
 FROM: namespaces => set ;
 SPECIALIZED-ARRAY: POINT
 QUALIFIED-WITH: alien.c-types c
@@ -60,14 +60,14 @@ PIXEL-FORMAT-ATTRIBUTE-TABLE: WGL_ARB { $ WGL_SUPPORT_OPENGL_ARB 1 } H{
     drop f ;
 
 : arb-make-pixel-format ( world attributes -- pf )
-    [ handle>> hDC>> ] dip >WGL_ARB-int-array f 1 { int int }
+    [ handle>> hDC>> ] dip >WGL_ARB-int-array f 1 { c:int c:int }
     [ wglChoosePixelFormatARB win32-error=0/f ] with-out-parameters drop ;
 
 : arb-pixel-format-attribute ( pixel-format attribute -- value )
     >WGL_ARB
     [ drop f ] [
         [ [ world>> handle>> hDC>> ] [ handle>> ] bi 0 1 ] dip
-        first int <ref> { int }
+        first c:int <ref> { c:int }
         [ wglGetPixelFormatAttribivARB win32-error=0/f ]
         with-out-parameters
     ] if-empty ;
@@ -96,7 +96,7 @@ CONSTANT: pfd-flag-map H{
 : >pfd ( attributes -- pfd )
     [ PIXELFORMATDESCRIPTOR <struct> ] dip
     {
-        [ drop PIXELFORMATDESCRIPTOR heap-size >>nSize ]
+        [ drop PIXELFORMATDESCRIPTOR c:heap-size >>nSize ]
         [ drop 1 >>nVersion ]
         [ >pfd-flags >>dwFlags ]
         [ drop PFD_TYPE_RGBA >>iPixelType ]
@@ -122,12 +122,12 @@ CONSTANT: pfd-flag-map H{
 
 : get-pfd ( pixel-format -- pfd )
     [ world>> handle>> hDC>> ] [ handle>> ] bi
-    PIXELFORMATDESCRIPTOR heap-size
+    PIXELFORMATDESCRIPTOR c:heap-size
     PIXELFORMATDESCRIPTOR <struct>
     [ DescribePixelFormat win32-error=0/f ] keep ;
 
 : pfd-flag? ( pfd flag -- ? )
-    [ dwFlags>> ] dip bitand c-bool> ;
+    [ dwFlags>> ] dip bitand c:c-bool> ;
 
 : (pfd-pixel-format-attribute) ( pfd attribute -- value )
     {
@@ -525,7 +525,7 @@ SYMBOL: nc-buttons
 : make-TRACKMOUSEEVENT ( hWnd -- alien )
     TRACKMOUSEEVENT <struct>
         swap >>hwndTrack
-        TRACKMOUSEEVENT heap-size >>cbSize ;
+        TRACKMOUSEEVENT c:heap-size >>cbSize ;
 
 : handle-wm-mousemove ( hWnd uMsg wParam lParam -- )
     2nip
@@ -614,7 +614,7 @@ SYMBOL: trace-messages?
 
 ! return 0 if you handle the message, else just let DefWindowProc return its val
 : ui-wndproc ( -- object )
-    uint { void* uint long long } stdcall [
+    c:uint { c:void* c:uint c:long c:long } stdcall [
         pick
 
         trace-messages? get-global
@@ -636,7 +636,7 @@ M: windows-ui-backend do-events
 :: register-window-class ( class-name-ptr -- )
     WNDCLASSEX <struct> f GetModuleHandle
     class-name-ptr pick GetClassInfoEx 0 = [
-        WNDCLASSEX heap-size >>cbSize
+        WNDCLASSEX c:heap-size >>cbSize
         flags{ CS_HREDRAW CS_VREDRAW CS_OWNDC } >>style
         ui-wndproc >>lpfnWndProc
         0 >>cbClsExtra
@@ -799,7 +799,7 @@ M: windows-ui-backend system-alert
 : fullscreen-RECT ( hwnd -- RECT )
     MONITOR_DEFAULTTONEAREST MonitorFromWindow
     MONITORINFOEX <struct>
-        MONITORINFOEX heap-size >>cbSize
+        MONITORINFOEX c:heap-size >>cbSize
     [ GetMonitorInfo win32-error=0/f ] keep rcMonitor>> ;
 
 : client-area>RECT ( hwnd -- RECT )
index c82990a79e877e6d55cbafaebecc38a25a0741c9..6537f34727a9bc13ca0faee09b7d40f1111df479 100644 (file)
@@ -45,8 +45,7 @@ ARTICLE: "ui.pixel-formats-attributes" "Pixel format attributes"
 }
 { $examples
 "The following " { $link world } " subclass will request a double-buffered window with minimum 24-bit color and depth buffers, and will throw an error if the requirements aren't met:"
-{ $code """
-USING: kernel ui.worlds ui.pixel-formats ;
+{ $code """USING: kernel ui.gadgets.worlds ui.pixel-formats ;
 IN: ui.pixel-formats.examples
 
 TUPLE: picky-depth-buffered-world < world ;
@@ -63,8 +62,7 @@ M: picky-depth-buffered-world check-world-pixel-format
     [ double-buffered pixel-format-attribute 0 = [ "Not double buffered!" throw ] when ]
     [ color-bits pixel-format-attribute 24 < [ "Not enough color bits!" throw ] when ]
     [ depth-bits pixel-format-attribute 24 < [ "Not enough depth bits!" throw ] when ]
-    tri ;
-""" } }
+    tri ;""" } }
 ;
 
 HELP: double-buffered
index 10564a85a6eaf11a59f21ac5d00fa8fe5d231400..c4632c590fa7745c5d7f87309684645b77e1b2e1 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types alien.strings assocs
-byte-arrays classes.struct combinators
+USING: accessors alien alien.c-types alien.data alien.strings
+assocs byte-arrays classes.struct combinators
 combinators.short-circuit continuations fry io.backend.unix
 io.encodings.utf8 kernel math math.parser namespaces sequences
 splitting strings unix unix.ffi unix.users unix.utilities ;
index 54307365bece79216300ec2688c148a9691d8878..7a09b0474aff9b2e48fadc814dd5dc37604207cf 100644 (file)
@@ -31,5 +31,3 @@ TYPEDEF: ulonglong __fsblkcnt64_t
 TYPEDEF: ulonglong __fsfilcnt64_t
 TYPEDEF: ulonglong ino64_t
 TYPEDEF: ulonglong off64_t
-
-: <time_t> ( n -- long ) long <ref> ;
index 39ce5c7bcac9c32eb42aa815d5adccead4454a1a..1f2b6e8e47f23d70d6b42ee764932400bc3da4c9 100644 (file)
@@ -1,4 +1,4 @@
-USING: strings help.markup help.syntax assocs ;
+USING: strings help.markup help.syntax assocs urls ;
 IN: urls.encoding
 
 HELP: url-decode
index 3f0dddab2920aedd733e6a70ef0b0c7d4725f8dd..f11c930c856d744074ee28039b26879ca586eac7 100644 (file)
@@ -1,7 +1,8 @@
 USING: kernel windows.com windows.com.syntax windows.ole32
-windows.types alien alien.syntax tools.test libc alien.c-types
-namespaces arrays continuations accessors math windows.com.wrapper
-windows.com.wrapper.private destructors effects compiler.units ;
+windows.types alien alien.data alien.syntax tools.test libc
+alien.c-types namespaces arrays continuations accessors math
+windows.com.wrapper windows.com.wrapper.private destructors
+effects compiler.units ;
 IN: windows.com.tests
 
 COM-INTERFACE: ISimple IUnknown {216fb341-0eb2-44b1-8edb-60b76e353abc}
old mode 100644 (file)
new mode 100755 (executable)
index f6380cb..2710599
@@ -1,6 +1,6 @@
-USING: alien alien.c-types alien.accessors alien.parser
-effects kernel windows.ole32 parser lexer splitting grouping
-sequences namespaces assocs quotations generalizations
+USING: alien alien.c-types alien.data alien.accessors
+alien.parser effects kernel windows.ole32 parser lexer splitting
+grouping sequences namespaces assocs quotations generalizations
 accessors words macros alien.syntax fry arrays layouts math
 classes.struct windows.kernel32 locals ;
 FROM: alien.parser.private => parse-pointers return-type-name ;
index b6b69d10b4e0c59cd95d80ad20056c7a054c2649..9beb3bd9a6fec2925289272c9b37d8aa8291ce12 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types alien.syntax
+USING: accessors alien alien.c-types alien.data alien.syntax
 classes.struct io.encodings.string io.encodings.utf8 kernel
 make sequences windows.errors windows.types ;
 IN: windows.iphlpapi
index 50b61dcf89568a55e48824c14fdf315384791c83..1d6a302b2aabebae806b6d47f4923bcba00a7428 100644 (file)
@@ -13,7 +13,7 @@ samDesired lpSecurityAttributes phkResult lpdwDisposition ;
 CONSTANT: registry-value-max-length 16384
 
 :: open-key ( key subkey mode -- hkey )
-    key subkey 0 mode HKEY <c-object>
+    key subkey 0 mode 0 HKEY <ref>
     [
         RegOpenKeyEx dup ERROR_SUCCESS = [
             drop
@@ -21,16 +21,16 @@ CONSTANT: registry-value-max-length 16384
             [ key subkey mode ] dip n>win32-error-string
             open-key-failed
         ] if
-    ] keep uint deref ;
+    ] keep HKEY deref ;
 
 :: create-key* ( hKey lpSubKey lpClass dwOptions samDesired lpSecurityAttributes -- hkey new? )
-    hKey lpSubKey 0 lpClass dwOptions samDesired lpSecurityAttributes
-    HKEY <c-object>
-    DWORD <c-object>
     f :> ret!
+    hKey lpSubKey 0 lpClass dwOptions samDesired lpSecurityAttributes
+    0 HKEY <ref>
+    0 DWORD <ref>
     [ RegCreateKeyEx ret! ] 2keep
-    [ uint deref ]
-    [ uint deref REG_CREATED_NEW_KEY = ] bi*
+    [ HKEY deref ]
+    [ DWORD deref REG_CREATED_NEW_KEY = ] bi*
     ret ERROR_SUCCESS = [
         [
             hKey lpSubKey 0 lpClass dwOptions samDesired
@@ -103,9 +103,9 @@ TUPLE: registry-enum-key ;
         registry-value-max-length TCHAR <c-array> dup :> registry-value
         registry-value length dup :> registry-value-length
         f
-        DWORD <c-object> dup :> type
-        f ! BYTE <c-object> dup :> data
-        f ! BYTE <c-object> dup :> buffer
+        0 DWORD <ref> dup :> type
+        f ! 0 BYTE <ref> dup :> data
+        f ! 0 BYTE <ref> dup :> buffer
         RegEnumKeyEx dup ERROR_SUCCESS = [
             
         ] [
@@ -118,13 +118,13 @@ TUPLE: registry-enum-key ;
     dup TCHAR <c-array> dup :> class-buffer
     swap int <ref> dup :> class-buffer-length
     f
-    DWORD <c-object> dup :> sub-keys
-    DWORD <c-object> dup :> longest-subkey
-    DWORD <c-object> dup :> longest-class-string
-    DWORD <c-object> dup :> #values
-    DWORD <c-object> dup :> max-value
-    DWORD <c-object> dup :> max-value-data
-    DWORD <c-object> dup :> security-descriptor
+    0 DWORD <ref> dup :> sub-keys
+    0 DWORD <ref> dup :> longest-subkey
+    0 DWORD <ref> dup :> longest-class-string
+    0 DWORD <ref> dup :> #values
+    0 DWORD <ref> dup :> max-value
+    0 DWORD <ref> dup :> max-value-data
+    0 DWORD <ref> dup :> security-descriptor
     FILETIME <struct> dup :> last-write-time
     RegQueryInfoKey :> ret
     ret ERROR_SUCCESS = [
index 49a9f8903956f6e521f7e6e1aa20b48d95ee1641..319ca4671421d1be7ea8bd5cda39d71698eb0ccb 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2010 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.strings classes.struct
-io.encodings.utf8 kernel namespaces sequences
+USING: accessors alien.c-types alien.data alien.strings
+classes.struct io.encodings.utf8 kernel namespaces sequences
 specialized-arrays x11 x11.constants x11.xlib ;
 SPECIALIZED-ARRAY: int
 IN: x11.clipboard
index cd1ef0217ff58776a3d7b8042e1c1d1e68202455..72c0670482d96de5cd0d3fd11b43cba6a3a6e5fc 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2005, 2010 Eduardo Cavazos, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types kernel math math.bitwise
-math.vectors namespaces sequences arrays fry classes.struct
-literals x11 x11.xlib x11.constants x11.events x11.glx ;
+USING: accessors alien.c-types alien.data kernel math
+math.bitwise math.vectors namespaces sequences arrays fry
+classes.struct literals x11 x11.xlib x11.constants x11.events
+x11.glx ;
 IN: x11.windows
 
 CONSTANT: create-window-mask
index acae3cf89162586e010f7f8c6797f64cfcab2e86..b9248bac05c584fcb630dd89f69ff3311843d37f 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2007, 2008 Slava Pestov
 ! 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
+USING: alien alien.c-types alien.data alien.strings arrays
+byte-arrays hashtables io io.encodings.string kernel math
+namespaces sequences strings continuations x11 x11.xlib
 specialized-arrays accessors io.encodings.utf16n ;
 SPECIALIZED-ARRAY: uint
 IN: x11.xim
index 1a6b0e3cf25d77d9fbcf5bdf2e79817f108f198b..5e38d70cb6e8f0e5d5a2339f884f1f5b26bd85d2 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Niklas Waern.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators kernel namespaces x11
-x11.constants x11.xinput2.ffi ;
+USING: alien.c-types alien.data combinators kernel namespaces
+x11 x11.constants x11.xinput2.ffi ;
 IN: x11.xinput2
 
 : (xi2-available?) ( display -- ? )
index 8e3af26932377db2c1a3cf7bfae6f083d0b75e8e..90b48c6a375db455fb447dfddf3c4929c5e65e73 100755 (executable)
@@ -491,7 +491,6 @@ tuple
     { "bignum>" "math.private" "primitive_bignum_greater" (( x y -- ? )) }
     { "bignum>=" "math.private" "primitive_bignum_greatereq" (( x y -- ? )) }
     { "bignum>fixnum" "math.private" "primitive_bignum_to_fixnum" (( x -- y )) }
-    { "bignum>float" "math.private" "primitive_bignum_to_float" (( x -- y )) }
     { "fixnum-shift" "math.private" "primitive_fixnum_shift" (( x y -- z )) }
     { "fixnum/i" "math.private" "primitive_fixnum_divint" (( x y -- z )) }
     { "fixnum/mod" "math.private" "primitive_fixnum_divmod" (( x y -- z w )) }
index 037ecf8715f98f18923fcf04d1caeaf06e275549..7443e02cc5cef07fe05b4abb1ce2278704eb0f5d 100644 (file)
@@ -190,7 +190,7 @@ $nl
 { $subsections
     "tuple-inheritance-example"
     "tuple-inheritance-anti-example"
-} 
+}
 "Declaring a tuple class final prohibits other classes from subclassing it:"
 { $subsections POSTPONE: final }
 { $see-also "call-next-method" "parametrized-constructors" "unions" "mixins" } ;
@@ -215,12 +215,14 @@ ARTICLE: "tuple-examples" "Tuple examples"
 { $table
     { "Reader" "Writer" "Setter" "Changer" }
     { { $snippet "name>>" } { $snippet "name<<" } { $snippet ">>name" } { $snippet "change-name" } }
+    { { $snippet "position>>" } { $snippet "position<<" } { $snippet ">>position" } { $snippet "change-position" } }
     { { $snippet "salary>>" } { $snippet "salary<<" } { $snippet ">>salary" } { $snippet "change-salary" } }
-    { { $snippet "position>>" } { $snippet "position<<" } { $snippet ">>position" } { $snippet "change-position" }   }
 }
 "We can define a constructor which makes an empty employee:"
-{ $code ": <employee> ( -- employee )"
-    "    employee new ;" }
+{ $code
+    ": <employee> ( -- employee )"
+    "    employee new ;"
+}
 "Or we may wish the default constructor to always give employees a starting salary:"
 { $code
     ": <employee> ( -- employee )"
index 8d4f1f61a5fe94295c56b511d612f938b66a7a2a..c9673a95b8fec75f071f2226cebaecb5f50e97dd 100644 (file)
@@ -129,7 +129,7 @@ HELP: define-generic
 HELP: M\
 { $syntax "M\\ class generic" }
 { $class-description "Pushes a method on the stack." }
-{ $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets ui.gadgets.editors ;" "M\\ editor draw-gadget* edit" } } ;
+{ $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets.editors ui.render ;" "M\\ editor draw-gadget* edit" } } ;
 
 HELP: method
 { $values { "class" class } { "generic" generic } { "method/f" { $maybe method } } }
index ac198a2ca2023a3ce4813a991fc125b3c7f9e12d..028c324f6a8164669df4f53dfa7a8de54fb76207 100644 (file)
@@ -19,6 +19,7 @@ M: hash-set members table>> keys ; inline
 M: hash-set set-like drop dup hash-set? [ members <hash-set> ] unless ;
 M: hash-set clone table>> clone hash-set boa ;
 M: hash-set null? table>> assoc-empty? ;
+M: hash-set cardinality table>> assoc-size ;
 
 M: sequence fast-set <hash-set> ;
 M: f fast-set drop H{ } clone hash-set boa ;
index 9f3f35ff2a7136f01ab3256eee86f100e025d970..96c4c29265b50ac31ea84a4cfcb7a29f6d356ba1 100644 (file)
@@ -1,4 +1,4 @@
-USING: accessors alien.c-types kernel
+USING: accessors alien.c-types alien.data kernel
 io.encodings.utf16 io.streams.byte-array tools.test ;
 IN: io.encodings.utf16n
 
index cc637b59c353f89345eabf994557d8747933e23a..a3b933897877b8f483ec18f66e18a2454b595fb8 100644 (file)
@@ -106,7 +106,7 @@ HELP: absolute-path
     { "path" "a pathname string" }
     { "path'" "a pathname string" }
 }
-{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " or " { $snippet "voacb:" } " prefix, if present (see " { $link "io.pathnames.special" } ")." }
+{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " or " { $snippet "vocab:" } " prefix, if present (see " { $link "io.pathnames.special" } ")." }
 { $notes "This word is exaclty the same as " { $link normalize-path } ", except on Windows NT platforms, where it does not prepend the Unicode path prefix. Most code should call " { $link normalize-path } " instead." } ;
 
 HELP: resolve-symlinks
index 45fce36ee6f5f23e645d0bd5c607769cbc0c337a..49e5ec30ccb3ff8cb747ff5c326f380cc8a1ca6c 100644 (file)
@@ -7,9 +7,6 @@ IN: math.floats.private
 : float-min ( x y -- z ) [ float< ] most ; foldable
 : float-max ( x y -- z ) [ float> ] most ; foldable
 
-M: fixnum >float fixnum>float ; inline
-M: bignum >float bignum>float ; inline
-
 M: float >fixnum float>fixnum ; inline
 M: float >bignum float>bignum ; inline
 M: float >float ; inline
index 85cd63463c582b238b61f124d4de63837d8d4ca0..178bb544c119ee4b90956f3d55df6d0061bbad98 100644 (file)
@@ -240,3 +240,12 @@ unit-test
 
 [ 17 ] [ 17 >bignum 5 max ] unit-test
 [ 5 ] [ 17 >bignum 5 min ] unit-test
+
+[ 1 ] [ 1 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784 /f double>bits ] unit-test
+[ 12 ] [ 3 50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696 /f double>bits ] unit-test
+[ 123 ] [ 123 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784 /f double>bits ] unit-test
+[ 1234 ] [ 617 101201126653655309176247673359458653524778324882071059178450679013715169783997673445980191850718562247593538932158405955694904368692896738433506699970369254960758712138283180682233453871046608170619883839236372534281003741712346349309051677824579778170405028256179384776166707307615251266093163754323003131653853870546747392 /f double>bits ] unit-test
+[ 1/0. ] [ 2048 2^ 1 /f ] unit-test
+[ -1/0. ] [ 2048 2^ -1 /f ] unit-test
+[ -1/0. ] [ 2048 2^ neg 1 /f ] unit-test
+[ 1/0. ] [ 2048 2^ neg -1 /f ] unit-test
index 22fe01f1ab743dd37060b1994554207736e6dca1..940ffa65ac291287acff3abfe482903b5f33436d 100644 (file)
@@ -14,6 +14,7 @@ M: integer denominator drop 1 ; inline
 M: fixnum >fixnum ; inline
 M: fixnum >bignum fixnum>bignum ; inline
 M: fixnum >integer ; inline
+M: fixnum >float fixnum>float ; inline
 
 M: fixnum hashcode* nip ; inline
 M: fixnum equal? over bignum? [ >bignum bignum= ] [ 2drop f ] if ; inline
@@ -37,16 +38,6 @@ M: fixnum - fixnum- ; inline
 M: fixnum * fixnum* ; inline
 M: fixnum /i fixnum/i ; inline
 
-DEFER: bignum/f
-CONSTANT: bignum/f-threshold HEX: 20,0000,0000,0000
-
-: fixnum/f ( m n -- m/n )
-    [ >float ] bi@ float/f ; inline
-
-M: fixnum /f
-    2dup [ abs bignum/f-threshold >= ] either?
-    [ bignum/f ] [ fixnum/f ] if ; inline
-
 M: fixnum mod fixnum-mod ; inline
 
 M: fixnum /mod fixnum/mod ; inline
@@ -130,15 +121,16 @@ M: bignum (log2) bignum-log2 ; inline
     [ /mod ] dip ; inline
 
 ! Third step: post-scaling
-: unscaled-float ( mantissa -- n )
-    52 2^ 1 - bitand 1022 52 shift bitor bits>double ; inline
-
 : scale-float ( mantissa scale -- float' )
-    dup 0 < [ neg 2^ recip ] [ 2^ ] if * ; inline
+    {
+        { [ dup 1024 > ] [ 2drop 1/0. ] }
+        { [ dup -1023 < ] [ 1021 + shift bits>double ] }
+        [ [ 52 2^ 1 - bitand ] dip 1022 + 52 shift bitor bits>double ]
+    } cond ; inline
 
 : post-scale ( mantissa scale -- n )
     [ 2/ ] dip over log2 52 > [ [ 2/ ] [ 1 + ] bi* ] when
-    [ unscaled-float ] dip scale-float ; inline
+    scale-float ; inline
 
 : round-to-nearest ( fraction-and-guard rem -- fraction-and-guard' )
     over odd?
@@ -157,7 +149,21 @@ M: bignum (log2) bignum-log2 ; inline
     ] if ; inline
 
 : bignum/f ( m n -- f )
-    [ [ abs ] bi@ /f-abs ] [ [ 0 < ] bi@ xor ] 2bi [ neg ] when ;
+    [ [ abs ] bi@ /f-abs ] [ [ 0 < ] bi@ xor ] 2bi [ neg ] when ; inline
+
+M: bignum /f ( m n -- f ) { bignum bignum } declare bignum/f ;
+
+CONSTANT: bignum/f-threshold HEX: 20,0000,0000,0000
+
+: fixnum/f ( m n -- m/n )
+    [ >float ] bi@ float/f ; inline
+
+M: fixnum /f
+    { fixnum fixnum } declare
+    2dup [ abs bignum/f-threshold >= ] either?
+    [ bignum/f ] [ fixnum/f ] if ; inline
+
+: bignum>float ( bignum -- float )
+    { bignum } declare 1 >bignum bignum/f ;
 
-M: bignum /f ( m n -- f )
-    bignum/f ;
+M: bignum >float bignum>float ; inline
index bc7658feba439629e44aa846561f907db80bd75e..e8f2813a959418d2408c37b5d2815a7edae7b8e0 100644 (file)
@@ -59,11 +59,7 @@ PRIVATE>
 ERROR: log2-expects-positive x ;
 
 : log2 ( x -- n )
-    dup 0 <= [
-        log2-expects-positive
-    ] [
-        (log2)
-    ] if ; inline
+    dup 0 <= [ log2-expects-positive ] [ (log2) ] if ; inline
 
 : zero? ( x -- ? ) 0 number= ; inline
 : 2/ ( x -- y ) -1 shift ; inline
@@ -74,8 +70,8 @@ ERROR: log2-expects-positive x ;
 : ?1+ ( x -- y ) [ 1 + ] [ 0 ] if* ; inline
 : rem ( x y -- z ) abs [ mod ] [ + ] [ mod ] tri ; foldable
 : 2^ ( n -- 2^n ) 1 swap shift ; inline
-: even? ( n -- ? ) 1 bitand zero? ;
-: odd? ( n -- ? ) 1 bitand 1 number= ;
+: even? ( n -- ? ) 1 bitand zero? ; inline
+: odd? ( n -- ? ) 1 bitand 1 number= ; inline
 
 : if-zero ( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b )
     [ dup zero? ] [ [ drop ] prepose ] [ ] tri* if ; inline
index ed0f4b16b072fecbbf9ff55d4cfd17f2d281a76d..29067a133e19c7dfd7b8215c67c4ac9da727e6ef 100644 (file)
@@ -15,7 +15,7 @@ HELP: length
 HELP: set-length
 { $values { "n" "a non-negative integer" } { "seq" "a resizable sequence" } }
 { $contract "Resizes a sequence. The initial contents of the new area is undefined." }
-{ $errors "Throws a " { $link no-method  } " error if the sequence is not resizable, and a " { $link bounds-error } " if the new length is negative." }
+{ $errors "Throws a " { $link no-method } " error if the sequence is not resizable, and a " { $link bounds-error } " if the new length is negative." }
 { $side-effects "seq" } ;
 
 HELP: lengthen
@@ -45,7 +45,7 @@ HELP: nths
      { "indices" sequence } { "seq" sequence }
      { "seq'" sequence } }
 { $description "Outputs a sequence of elements from the input sequence indexed by the indices." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint sequences ;"
                "{ 0 2 } { \"a\" \"b\" \"c\" } nths ."
                "{ \"a\" \"c\" }"
@@ -248,7 +248,7 @@ HELP: array-nth
 { $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types or array bounds, and improper use can corrupt memory. User code must use " { $link nth } " instead." } ;
 
 HELP: set-array-nth
-{ $values { "elt" object } { "n" "a non-negative fixnum" } { "array" "an array" }  }
+{ $values { "elt" object } { "n" "a non-negative fixnum" } { "array" "an array" } }
 { $description "Low-level array element mutator." }
 { $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types or array bounds, and improper use can corrupt memory. User code must use " { $link set-nth } " instead." } ;
 
@@ -430,7 +430,7 @@ HELP: all?
 
 HELP: push-if
 { $values { "elt" object } { "quot" { $quotation "( ..a elt -- ..b ? )" } } { "accum" "a resizable mutable sequence" } }
-{ $description "Adds the element at the end of the sequence if the quotation yields a true value." } 
+{ $description "Adds the element at the end of the sequence if the quotation yields a true value." }
 { $notes "This word is a factor of " { $link filter } "." } ;
 
 HELP: filter
@@ -557,7 +557,7 @@ HELP: append!
 HELP: prefix
 { $values { "seq" sequence } { "elt" object } { "newseq" sequence } }
 { $description "Outputs a new sequence obtained by adding " { $snippet "elt" } " at the beginning of " { $snippet "seq" } "." }
-{ $errors "Throws an error if the type of " { $snippet "elt" } " is not permitted in sequences of the same class as " { $snippet "seq1" } "." } 
+{ $errors "Throws an error if the type of " { $snippet "elt" } " is not permitted in sequences of the same class as " { $snippet "seq1" } "." }
 { $examples
 { $example "USING: prettyprint sequences ;" "{ 1 2 3 } 0 prefix ." "{ 0 1 2 3 }" }
 } ;
@@ -713,7 +713,7 @@ HELP: append
 { $values { "seq1" sequence } { "seq2" sequence } { "newseq" sequence } }
 { $description "Outputs a new sequence of the same type as " { $snippet "seq1" } " consisting of the elements of " { $snippet "seq1" } " followed by " { $snippet "seq2" } "." }
 { $errors "Throws an error if " { $snippet "seq2" } " contains elements not permitted in sequences of the same class as " { $snippet "seq1" } "." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint sequences ;"
         "{ 1 2 } B{ 3 4 } append ."
         "{ 1 2 3 4 }"
@@ -728,7 +728,7 @@ HELP: append-as
 { $values { "seq1" sequence } { "seq2" sequence } { "exemplar" sequence } { "newseq" sequence } }
 { $description "Outputs a new sequence of the same type as " { $snippet "exemplar" } " consisting of the elements of " { $snippet "seq1" } " followed by " { $snippet "seq2" } "." }
 { $errors "Throws an error if " { $snippet "seq1" } " or " { $snippet "seq2" } " contain elements not permitted in sequences of the same class as " { $snippet "exemplar" } "." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint sequences ;"
         "{ 1 2 } B{ 3 4 } B{ } append-as ."
         "B{ 1 2 3 4 }"
@@ -992,7 +992,7 @@ HELP: selector
 { $values
      { "quot" { $quotation "( ... elt -- ... ? )" } }
      { "selector" { $quotation "( ... elt -- ... )" } } { "accum" vector } }
-{ $description "Creates a new vector to accumulate the values which return true for a predicate.  Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." }
+{ $description "Creates a new vector to accumulate the values which return true for a predicate. Returns a new quotation which accepts an object to be tested and stored in the collector if the test yields true. The collector is left on the stack for convenience." }
 { $example "! Find all the even numbers:" "USING: prettyprint sequences math kernel ;"
            "10 iota [ even? ] selector [ each ] dip ."
            "V{ 0 2 4 6 8 }"
@@ -1004,7 +1004,7 @@ HELP: trim-head
      { "seq" sequence } { "quot" quotation }
      { "newseq" sequence } }
 { $description "Removes elements starting from the left side of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a new sequence." }
-{ $example "" "USING: prettyprint math sequences ;"
+{ $example "USING: prettyprint math sequences ;"
            "{ 0 0 1 2 3 0 0 } [ zero? ] trim-head ."
            "{ 1 2 3 0 0 }"
 } ;
@@ -1014,7 +1014,7 @@ HELP: trim-head-slice
      { "seq" sequence } { "quot" quotation }
      { "slice" slice } }
 { $description "Removes elements starting from the left side of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a slice" }
-{ $example "" "USING: prettyprint math sequences ;"
+{ $example "USING: prettyprint math sequences ;"
            "{ 0 0 1 2 3 0 0 } [ zero? ] trim-head-slice ."
            "T{ slice { from 2 } { to 7 } { seq { 0 0 1 2 3 0 0 } } }"
 } ;
@@ -1024,7 +1024,7 @@ HELP: trim-tail
      { "seq" sequence } { "quot" quotation }
      { "newseq" sequence } }
 { $description "Removes elements starting from the right side of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a new sequence." }
-{ $example "" "USING: prettyprint math sequences ;"
+{ $example "USING: prettyprint math sequences ;"
            "{ 0 0 1 2 3 0 0 } [ zero? ] trim-tail ."
            "{ 0 0 1 2 3 }"
 } ;
@@ -1034,7 +1034,7 @@ HELP: trim-tail-slice
      { "seq" sequence } { "quot" quotation }
      { "slice" slice } }
 { $description "Removes elements starting from the right side of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a slice." }
-{ $example "" "USING: prettyprint math sequences ;"
+{ $example "USING: prettyprint math sequences ;"
            "{ 0 0 1 2 3 0 0 } [ zero? ] trim-tail-slice ."
            "T{ slice { from 0 } { to 5 } { seq { 0 0 1 2 3 0 0 } } }"
 } ;
@@ -1044,7 +1044,7 @@ HELP: trim
      { "seq" sequence } { "quot" quotation }
      { "newseq" sequence } }
 { $description "Removes elements starting from the left and right sides of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a new sequence." }
-{ $example "" "USING: prettyprint math sequences ;"
+{ $example "USING: prettyprint math sequences ;"
            "{ 0 0 1 2 3 0 0 } [ zero? ] trim ."
            "{ 1 2 3 }"
 } ;
@@ -1054,7 +1054,7 @@ HELP: trim-slice
      { "seq" sequence } { "quot" quotation }
      { "slice" slice } }
 { $description "Removes elements starting from the left and right sides of a sequence if they match a predicate. Once an element does not match, the test stops and the rest of the sequence is left on the stack as a slice." }
-{ $example "" "USING: prettyprint math sequences ;"
+{ $example "USING: prettyprint math sequences ;"
            "{ 0 0 1 2 3 0 0 } [ zero? ] trim-slice ."
            "T{ slice { from 2 } { to 5 } { seq { 0 0 1 2 3 0 0 } } }"
 } ;
@@ -1065,8 +1065,8 @@ HELP: sift
 { $values
      { "seq" sequence }
      { "newseq" sequence } }
- { $description "Outputs a new sequence with all instance of " { $link f  } " removed." }
- { $examples 
+ { $description "Outputs a new sequence with all instance of " { $link f } " removed." }
+ { $examples
     { $example "USING: prettyprint sequences ;"
         "{ \"a\" 3 { } f } sift ."
         "{ \"a\" 3 { } }"
@@ -1078,7 +1078,7 @@ HELP: harvest
      { "seq" sequence }
      { "newseq" sequence } }
 { $description "Outputs a new sequence with all empty sequences removed." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint sequences ;"
                "{ { } { 2 3 } { 5 } { } } harvest ."
                "{ { 2 3 } { 5 } }"
@@ -1091,9 +1091,9 @@ HELP: set-first
 { $values
      { "first" object } { "seq" sequence } }
 { $description "Sets the first element of a sequence." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint kernel sequences ;"
-        "{ 1 2 3 4  } 5 over set-first ."
+        "{ 1 2 3 4 } 5 over set-first ."
         "{ 5 2 3 4 }"
     }
 } ;
@@ -1102,9 +1102,9 @@ HELP: set-second
 { $values
      { "second" object } { "seq" sequence } }
 { $description "Sets the second element of a sequence." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint kernel sequences ;"
-        "{ 1 2 3 4  } 5 over set-second ."
+        "{ 1 2 3 4 } 5 over set-second ."
         "{ 1 5 3 4 }"
     }
 } ;
@@ -1113,9 +1113,9 @@ HELP: set-third
 { $values
      { "third" object } { "seq" sequence } }
 { $description "Sets the third element of a sequence." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint kernel sequences ;"
-        "{ 1 2 3 4  } 5 over set-third ."
+        "{ 1 2 3 4 } 5 over set-third ."
         "{ 1 2 5 4 }"
     }
 } ;
@@ -1124,9 +1124,9 @@ HELP: set-fourth
 { $values
      { "fourth" object } { "seq" sequence } }
 { $description "Sets the fourth element of a sequence." }
-{ $examples 
+{ $examples
     { $example "USING: prettyprint kernel sequences ;"
-        "{ 1 2 3 4  } 5 over set-fourth ."
+        "{ 1 2 3 4 } 5 over set-fourth ."
         "{ 1 2 3 5 }"
     }
 } ;
@@ -1138,7 +1138,7 @@ HELP: replicate
      { "len" integer } { "quot" { $quotation "( ... -- ... newelt )" } }
      { "newseq" sequence } }
      { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new array." }
-{ $examples 
+{ $examples
     { $unchecked-example "USING: kernel prettyprint random sequences ;"
         "5 [ 100 random ] replicate ."
         "{ 52 10 45 81 30 }"
@@ -1150,7 +1150,7 @@ HELP: replicate-as
      { "len" integer } { "quot" { $quotation "( ... -- ... newelt )" } } { "exemplar" sequence }
      { "newseq" sequence } }
  { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." }
-{ $examples 
+{ $examples
     { $unchecked-example "USING: prettyprint kernel sequences ;"
         "5 [ 100 random ] B{ } replicate-as ."
         "B{ 44 8 2 33 18 }"
@@ -1163,8 +1163,8 @@ HELP: partition
 { $values
      { "seq" sequence } { "quot" quotation }
      { "trueseq" sequence } { "falseseq" sequence } }
-     { $description "Calls a predicate quotation on each element of the input sequence.  If the test yields true, the element is added to " { $snippet "trueseq" } "; if false, it's added to " { $snippet "falseseq" } "." }
-{ $examples 
+     { $description "Calls a predicate quotation on each element of the input sequence. If the test yields true, the element is added to " { $snippet "trueseq" } "; if false, it's added to " { $snippet "falseseq" } "." }
+{ $examples
     { $example "USING: prettyprint kernel math sequences ;"
         "{ 1 2 3 4 5 } [ even? ] partition [ . ] bi@"
         "{ 2 4 }\n{ 1 3 5 }"
@@ -1343,10 +1343,9 @@ HELP: assert-sequence=
 { $description "Throws an error if all the elements of two sequences, taken pairwise, are not equal." }
 { $notes "The sequences need not be of the same type." }
 { $examples
-  { $example
+  { $code
     "USING: prettyprint sequences ;"
     "{ 1 2 3 } V{ 1 2 3 } assert-sequence="
-    ""
   }
 } ;
 
index bf2b6904c3dba4c5ffb2e9a51df33a2557148772..5197e57ad0cf8c89e9ded298790b6d823ead58b5 100644 (file)
@@ -18,6 +18,8 @@ ARTICLE: "set-operations" "Operations on sets"
 { $subsections in? }
 "All sets can be represented as a sequence, without duplicates, of their members:"
 { $subsections members }
+"To get the number of elements in a set:"
+{ $subsections cardinality }
 "Sets can have members added or removed destructively:"
 { $subsections
     adjoin
@@ -184,3 +186,7 @@ HELP: without
 HELP: null?
 { $values { "set" set } { "?" "a boolean" } }
 { $description "Tests whether the given set is empty. This outputs " { $snippet "t" } " when given a null set of any type." } ;
+
+HELP: cardinality
+{ $values { "set" set } { "n" "a non-negative integer" } }
+{ $description "Returns the number of elements in the set. All sets support this operation." } ;
index 9a48acc4cfc0ef64bb85720f2e3d98a69fc2288a..899a43af4f7299ab0363c0cd824f3bd2afb5c0d9 100644 (file)
@@ -3,7 +3,7 @@
 USING: sets tools.test kernel prettyprint hash-sets sorting ;
 IN: sets.tests
 
-[ { } ] [ { } { } intersect  ] unit-test
+[ { } ] [ { } { } intersect ] unit-test
 [ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test
 [ { 2 3 } ] [ { 1 2 2 3 } { 2 3 3 4 } intersect ] unit-test
 
@@ -11,7 +11,7 @@ IN: sets.tests
 [ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test
 [ { 1 } ] [ { 1 1 2 3 } { 2 3 4 4 } diff ] unit-test
 
-[ { } ] [ { } { } within  ] unit-test
+[ { } ] [ { } { } within ] unit-test
 [ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } within ] unit-test
 [ { 2 2 3 } ] [ { 1 2 2 3 } { 2 3 3 4 } within ] unit-test
 
@@ -64,3 +64,9 @@ IN: sets.tests
 
 [ t ] [ f null? ] unit-test
 [ f ] [ { 4 } null? ] unit-test
+
+[ 0 ] [ f cardinality ] unit-test
+[ 0 ] [ { } cardinality ] unit-test
+[ 1 ] [ { 1 } cardinality ] unit-test
+[ 1 ] [ HS{ 1 } cardinality ] unit-test
+[ 3 ] [ HS{ 1 2 3 } cardinality ] unit-test
index 9c1870aa2e57634feee580262f0813bf65771b93..ae15908e4cb594aed40ae53e3122bff54322ce3a 100644 (file)
@@ -22,12 +22,17 @@ GENERIC: set= ( set1 set2 -- ? )
 GENERIC: duplicates ( set -- seq )
 GENERIC: all-unique? ( set -- ? )
 GENERIC: null? ( set -- ? )
+GENERIC: cardinality ( set -- n )
+
+M: f cardinality drop 0 ;
 
 ! Defaults for some methods.
 ! Override them for efficiency
 
 M: set null? members null? ; inline
 
+M: set cardinality members length ;
+
 M: set set-like drop ; inline
 
 M: set union
@@ -54,7 +59,7 @@ M: set intersects?
 
 M: set subset?
     sequence/tester all? ;
-    
+
 M: set set=
     2dup subset? [ swap subset? ] [ 2drop f ] if ;
 
@@ -94,10 +99,13 @@ M: sequence set-like
 
 M: sequence members
     [ pruned ] keep like ;
-  
+
 M: sequence null?
     empty? ; inline
 
+M: sequence cardinality
+    length ;
+
 : combine ( sets -- set )
     [ f ]
     [ [ [ members ] map concat ] [ first ] bi set-like ]
index 512e2de61a896500faba02096b13a82639262422..18434166b9933004b231dd34f948dc2923ee877b 100644 (file)
@@ -195,7 +195,7 @@ ARTICLE: "syntax-hash-sets" "Hash set syntax"
 
 ARTICLE: "syntax-tuples" "Tuple syntax"
 { $subsections POSTPONE: T{ }
-"Tuples are documented in " { $link "tuples" } "."  ;
+"Tuples are documented in " { $link "tuples" } "." ;
 
 ARTICLE: "syntax-quots" "Quotation syntax"
 { $subsections
@@ -340,37 +340,37 @@ $nl
 HELP: {
 { $syntax "{ elements... }" }
 { $values { "elements" "a list of objects" } }
-{ $description "Marks the beginning of a literal array. Literal arrays are terminated by " { $link POSTPONE: } } "." } 
+{ $description "Marks the beginning of a literal array. Literal arrays are terminated by " { $link POSTPONE: } } "." }
 { $examples { $code "{ 1 2 3 }" } } ;
 
 HELP: V{
 { $syntax "V{ elements... }" }
 { $values { "elements" "a list of objects" } }
-{ $description "Marks the beginning of a literal vector. Literal vectors are terminated by " { $link POSTPONE: } } "." } 
+{ $description "Marks the beginning of a literal vector. Literal vectors are terminated by " { $link POSTPONE: } } "." }
 { $examples { $code "V{ 1 2 3 }" } } ;
 
 HELP: B{
 { $syntax "B{ elements... }" }
 { $values { "elements" "a list of integers" } }
-{ $description "Marks the beginning of a literal byte array. Literal byte arrays are terminated by " { $link POSTPONE: } } "." } 
+{ $description "Marks the beginning of a literal byte array. Literal byte arrays are terminated by " { $link POSTPONE: } } "." }
 { $examples { $code "B{ 1 2 3 }" } } ;
 
 HELP: H{
 { $syntax "H{ { key value }... }" }
 { $values { "key" "an object" } { "value" "an object" } }
-{ $description "Marks the beginning of a literal hashtable, given as a list of two-element arrays holding key/value pairs. Literal hashtables are terminated by " { $link POSTPONE: } } "." } 
+{ $description "Marks the beginning of a literal hashtable, given as a list of two-element arrays holding key/value pairs. Literal hashtables are terminated by " { $link POSTPONE: } } "." }
 { $examples { $code "H{ { \"tuna\" \"fish\" } { \"jalapeno\" \"vegetable\" } }" } } ;
 
 HELP: HS{
 { $syntax "HS{ members ... }" }
 { $values { "members" "a list of objects" } }
-{ $description "Marks the beginning of a literal hash set, given as a list of its members. Literal hashtables are terminated by " { $link POSTPONE: } } "." } 
+{ $description "Marks the beginning of a literal hash set, given as a list of its members. Literal hashtables are terminated by " { $link POSTPONE: } } "." }
 { $examples { $code "HS{ 3 \"foo\" }" } } ;
 
 HELP: C{
 { $syntax "C{ real-part imaginary-part }" }
 { $values { "real-part" "a real number" } { "imaginary-part" "a real number" } }
-{ $description "Parses a complex number given in rectangular form as a pair of real numbers. Literal complex numbers are terminated by " { $link POSTPONE: } } "." }  ;
+{ $description "Parses a complex number given in rectangular form as a pair of real numbers. Literal complex numbers are terminated by " { $link POSTPONE: } } "." } ;
 
 HELP: T{
 { $syntax "T{ class }" "T{ class f slot-values... }" "T{ class { slot-name slot-value } ... }" }
@@ -453,7 +453,7 @@ HELP: SINGLETON:
 { $examples
     { $example "USING: classes.singleton kernel io ;" "IN: singleton-demo" "USE: prettyprint SINGLETON: foo\nGENERIC: bar ( obj -- )\nM: foo bar drop \"a foo!\" print ;\nfoo bar" "a foo!" }
 } ;
-    
+
 HELP: SINGLETONS:
 { $syntax "SINGLETONS: words... ;" }
 { $values { "words" "a sequence of new words to define" } }
@@ -533,13 +533,14 @@ HELP: QUALIFIED:
 { $examples { $example
     "USING: prettyprint ;"
     "QUALIFIED: math"
-    "1 2 math:+ ." "3"
+    "1 2 math:+ ."
+    "3"
 } } ;
 
 HELP: QUALIFIED-WITH:
 { $syntax "QUALIFIED-WITH: vocab word-prefix" }
 { $description "Like " { $link POSTPONE: QUALIFIED: } " but uses " { $snippet "word-prefix" } " as prefix." }
-{ $examples { $code
+{ $examples { $example
     "USING: prettyprint ;"
     "QUALIFIED-WITH: math m"
     "1 2 m:+ ."
@@ -559,7 +560,7 @@ HELP: FROM:
 
 HELP: EXCLUDE:
 { $syntax "EXCLUDE: vocab => words ... ;" }
-{ $description "Adds all words except for " { $snippet "words" } " from " { $snippet "vocab" } "  to the search path." }
+{ $description "Adds all words except for " { $snippet "words" } " from " { $snippet "vocab" } " to the search path." }
 { $examples { $code
     "EXCLUDE: math.parser => bin> hex> ;" "! imports everything but bin> and hex>" } } ;
 
@@ -727,7 +728,7 @@ HELP: HOOK:
         "TUPLE: air-transport ;"
         "HOOK: deliver transport ( destination -- )"
         "M: land-transport deliver \"Land delivery to \" write print ;"
-        "M: air-transport deliver \"Air delivery to \"  write print ;"
+        "M: air-transport deliver \"Air delivery to \" write print ;"
         "T{ air-transport } transport set"
         "\"New York City\" deliver"
         "Air delivery to New York City"
index 66900978a84b20d3cf6448bb5cefac933044094e..9f60f790479de189f247d7d9e1b18c972ad05d91 100644 (file)
@@ -1,7 +1,7 @@
 USING: help.markup help.syntax parser strings words assocs vocabs ;
 IN: vocabs.parser
 
-ARTICLE: "word-search-errors"  "Word lookup errors"
+ARTICLE: "word-search-errors" "Word lookup errors"
 "If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies."
 $nl
 "If " { $link auto-use? } " mode is off, a restartable error is thrown with a restart for each vocabulary in question, together with a restart which defers the word in the current vocabulary, as if " { $link POSTPONE: DEFER: } " was used."
@@ -142,7 +142,7 @@ HELP: add-words-from
 
 HELP: add-words-excluding
 { $values { "vocab" "a vocabulary specifier" } { "words" "a sequence of word names" } }
-{ $description "Adds all words except for " { $snippet "words" } " from " { $snippet "vocab" } "  to the manifest." }
+{ $description "Adds all words except for " { $snippet "words" } " from " { $snippet "vocab" } " to the manifest." }
 { $notes "This word is used to implement " { $link POSTPONE: EXCLUDE: } "." } ;
 
 HELP: add-renamed-word
index 3f8a71e76cf0b293277fcf46f127fb37aba5e695..b2cb422178ed41ca42839a5e748429bc86bfad49 100644 (file)
@@ -77,7 +77,7 @@ HELP: forget-vocab
 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
 
 HELP: load-vocab-hook
-{ $var-description { $quotation "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functinality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
+{ $var-description { $quotation "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
 
 HELP: words-named
 { $values { "str" string } { "seq" "a sequence of words" } }
index 522c33bbf11a61e991919daafe6717603e7fb0d6..ae727ac3707bc5e057fde42b02a0b92889b484f9 100644 (file)
@@ -1,7 +1,7 @@
 ! (c)2010 Joe Groff bsd license
-USING: alien alien.c-types alien.libraries alien.strings
-alien.syntax combinators destructors io.encodings.ascii kernel
-libc locals sequences system ;
+USING: alien alien.c-types alien.data alien.libraries
+alien.strings alien.syntax combinators destructors
+io.encodings.ascii kernel libc locals sequences system ;
 IN: alien.cxx.demangle.libstdcxx
 
 FUNCTION: char* __cxa_demangle ( char* mangled_name, char* output_buffer, size_t* length, int* status ) ;
index 3fcfbdfa9f0f83d74449985a63b95f9d3b104cc3..9932953822e9d7037c89ec0159a55aba30cefc02 100644 (file)
@@ -1,8 +1,8 @@
 ! (c)2009 Joe Groff bsd license
-USING: accessors alien audio classes.struct fry calendar timers
-combinators combinators.short-circuit destructors generalizations
-kernel literals locals math openal sequences
-sequences.generalizations specialized-arrays strings ;
+USING: accessors alien alien.data audio classes.struct fry
+calendar timers combinators combinators.short-circuit
+destructors generalizations kernel literals locals math openal
+sequences sequences.generalizations specialized-arrays strings ;
 QUALIFIED-WITH: alien.c-types c
 SPECIALIZED-ARRAYS: c:float c:uchar c:uint ;
 IN: audio.engine
@@ -122,7 +122,7 @@ ERROR: audio-context-not-available device-name ;
 
 :: flush-source ( al-source -- )
     al-source alSourceStop
-    0 c:uint c:<ref> :> dummy-buffer
+    0 c:uint <ref> :> dummy-buffer
     al-source AL_BUFFERS_PROCESSED get-source-param [
         al-source 1 dummy-buffer alSourceUnqueueBuffers
     ] times
@@ -161,7 +161,7 @@ ERROR: audio-context-not-available device-name ;
             audio-clip t >>done? drop
         ] [
             al-buffer audio-clip openal-format data size audio-clip sample-rate>> alBufferData
-            al-source 1 al-buffer c:uint c:<ref> alSourceQueueBuffers
+            al-source 1 al-buffer c:uint <ref> alSourceQueueBuffers
         ] if
     ] unless ;
 
@@ -190,10 +190,10 @@ M: static-audio-clip (update-audio-clip)
 
 M:: streaming-audio-clip (update-audio-clip) ( audio-clip -- )
     audio-clip al-source>> :> al-source
-    0 c:uint c:<ref> :> buffer
+    0 c:uint <ref> :> buffer
     al-source AL_BUFFERS_PROCESSED get-source-param [
         al-source 1 buffer alSourceUnqueueBuffers
-        audio-clip buffer c:uint c:deref queue-clip-buffer
+        audio-clip buffer c:uint deref queue-clip-buffer
     ] times ;
 
 : update-audio-clip ( audio-clip -- )
@@ -256,7 +256,7 @@ M: audio-engine dispose*
     audio-engine get-available-source :> al-source
 
     al-source [
-        1 0 c:uint c:<ref> [ alGenBuffers ] keep c:uint c:deref :> al-buffer
+        1 0 c:uint <ref> [ alGenBuffers ] keep c:uint deref :> al-buffer
         al-buffer audio { [ openal-format ] [ data>> ] [ size>> ] [ sample-rate>> ] } cleave
             alBufferData
 
@@ -301,7 +301,7 @@ M: audio-clip dispose*
 
 M: static-audio-clip dispose*
     [ call-next-method ]
-    [ [ 1 ] dip al-buffer>> c:uint c:<ref> alDeleteBuffers ] bi ;
+    [ [ 1 ] dip al-buffer>> c:uint <ref> alDeleteBuffers ] bi ;
 
 M: streaming-audio-clip dispose*
     [ call-next-method ]
index 7e69aea7b4256cdb18d4397cdbbf72d4deb849f1..2ae957812e8c53cf0cfd71cdc96a9592c0f8a08e 100644 (file)
@@ -1,9 +1,9 @@
 ! (c)2007, 2010 Chris Double, Joe Groff bsd license
-USING: accessors alien alien.c-types audio.engine byte-arrays
-classes.struct combinators destructors fry io io.files
-io.encodings.binary kernel libc locals make math math.order
-math.parser ogg ogg.vorbis sequences specialized-arrays
-specialized-vectors ;
+USING: accessors alien alien.c-types alien.data audio.engine
+byte-arrays classes.struct combinators destructors fry io
+io.files io.encodings.binary kernel libc locals make math
+math.order math.parser ogg ogg.vorbis sequences
+specialized-arrays specialized-vectors ;
 FROM: alien.c-types => float short void* ;
 SPECIALIZED-ARRAYS: float void* ;
 SPECIALIZED-VECTOR: short
index 714eaab94c60e7d8ba36f30e4db30f85054e2b9e..5218f7b23eed1f6665cdfdce0b6a88559fe20fa3 100644 (file)
@@ -9,14 +9,14 @@ IN: cuda.contexts
 
 : create-context ( device flags -- context )
     swap
-    [ CUcontext <c-object> ] 2dip
-    [ cuCtxCreate cuda-error ] 3keep 2drop void* deref ; inline
+    [ { CUcontext } ] 2dip
+    '[ _ _ cuCtxCreate cuda-error ] with-out-parameters ; inline
 
 : sync-context ( -- )
     cuCtxSynchronize cuda-error ; inline
 
 : context-device ( -- n )
-    CUdevice <c-object> [ cuCtxGetDevice cuda-error ] keep int deref ; inline
+    { CUdevice } [ cuCtxGetDevice cuda-error ] with-out-parameters ; inline
 
 : destroy-context ( context -- ) cuCtxDestroy cuda-error ; inline
 
index 566622eb029e0dee065983dcbbd0c2b45e7c800c..c86fbacc69f0349935dd2a2cd969be5a193fc9f5 100644 (file)
@@ -16,7 +16,7 @@ TUPLE: cuda-error code ;
     dup CUDA_SUCCESS = [ drop ] [ \ cuda-error boa throw ] if ;
 
 : cuda-version ( -- n )
-    c:int <c-object> [ cuDriverGetVersion cuda-error ] keep c:int c:deref ;
+    { c:int } [ cuDriverGetVersion cuda-error ] with-out-parameters ;
 
 : init-cuda ( -- )
     0 cuInit cuda-error ; inline
index 07e066a4397e34231568a644971fbfe0384ab2d2..079234b2ee26dd858a2f3b16ba66a478c972b09e 100644 (file)
@@ -8,11 +8,10 @@ prettyprint sequences ;
 IN: cuda.devices
 
 : #cuda-devices ( -- n )
-    int <c-object> [ cuDeviceGetCount cuda-error ] keep int deref ;
+    { int } [ cuDeviceGetCount cuda-error ] with-out-parameters ;
 
 : n>cuda-device ( n -- device )
-    [ CUdevice <c-object> ] dip [ cuDeviceGet cuda-error ] 2keep
-    drop int deref ;
+    [ { CUdevice } ] dip '[ _ cuDeviceGet cuda-error ] with-out-parameters ;
 
 : enumerate-cuda-devices ( -- devices )
     #cuda-devices iota [ n>cuda-device ] map ;
@@ -33,19 +32,17 @@ IN: cuda.devices
     [ 2drop utf8 alien>string ] 3bi ;
 
 : cuda-device-capability ( n -- pair )
-    [ int <c-object> int <c-object> ] dip
-    [ cuDeviceComputeCapability cuda-error ]
-    [ drop [ int deref ] bi@ ] 3bi 2array ;
+    [ { int int } ] dip
+    '[ _ cuDeviceComputeCapability cuda-error ] with-out-parameters
+    2array ;
 
 : cuda-device-memory ( n -- bytes )
-    [ uint <c-object> ] dip
-    [ cuDeviceTotalMem cuda-error ]
-    [ drop uint deref ] 2bi ;
+    [ { uint } ] dip
+    '[ _ cuDeviceTotalMem cuda-error ] with-out-parameters ;
 
 : cuda-device-attribute ( attribute n -- n )
-    [ int <c-object> ] 2dip
-    [ cuDeviceGetAttribute cuda-error ]
-    [ 2drop int deref ] 3bi ;
+    [ { int } ] 2dip
+    '[ _ _ cuDeviceGetAttribute cuda-error ] with-out-parameters ;
 
 : cuda-device. ( n -- )
     {
index 78e108ae7a28bc41abf2fcf1f4debe8b81be6b39..e4e093c1e95146c298422b29d425353efdca70e8 100644 (file)
@@ -6,25 +6,25 @@ IN: cuda.gl
 
 : create-gl-cuda-context ( device flags -- context )
     swap
-    [ CUcontext <c-object> ] 2dip
-    [ cuGLCtxCreate cuda-error ] 3keep 2drop void* deref ; inline
+    [ { CUcontext } ] 2dip
+    '[ _ _ cuGLCtxCreate cuda-error ] with-out-parameters ; inline
 
 : with-gl-cuda-context ( device flags quot -- )
     [ set-up-cuda-context create-gl-cuda-context ] dip (with-cuda-context) ; inline 
 
 : gl-buffer>resource ( gl-buffer flags -- resource )
     enum>number
-    [ CUgraphicsResource <c-object> ] 2dip
-    [ cuGraphicsGLRegisterBuffer cuda-error ] 3keep 2drop void* deref ; inline
+    [ { CUgraphicsResource } ] 2dip
+    '[ _ _ cuGraphicsGLRegisterBuffer cuda-error ] with-out-parameters ; inline
 
 : buffer>resource ( buffer flags -- resource )
     [ handle>> ] dip gl-buffer>resource ; inline
 
 : map-resource ( resource -- device-ptr size )
     [ 1 swap void* <ref> f cuGraphicsMapResources cuda-error ] [
-        [ CUdeviceptr <c-object> uint <c-object> ] dip
-        [ cuGraphicsResourceGetMappedPointer cuda-error ] 3keep drop
-        [ uint deref ] [ uint deref ] bi*
+        [ { CUdeviceptr uint } ] dip
+        '[ _ cuGraphicsResourceGetMappedPointer cuda-error ]
+        with-out-parameters
     ] bi ; inline
 
 : unmap-resource ( resource -- )
index bd5d867fbb60623f2688880bd5204be625044180..faf50bb39b049a94df86ef3b5b1f3c4b99c80d50 100644 (file)
@@ -74,8 +74,8 @@ M: sequence grid-dim
 PRIVATE>
 
 : load-module ( path -- module )
-    [ CUmodule <c-object> ] dip
-    [ cuModuleLoad cuda-error ] 2keep drop c:void* c:deref ;
+    [ { CUmodule } ] dip
+    '[ _ cuModuleLoad cuda-error ] with-out-parameters ;
 
 : unload-module ( module -- )
     cuModuleUnload cuda-error ;
@@ -151,8 +151,8 @@ MACRO: cuda-arguments ( c-types abi -- quot: ( args... function -- ) )
     [ [ 0 cuda-param-size ] ] swap '[ _ [cuda-arguments] ] if-empty ;
 
 : get-function-ptr ( module string -- function )
-    [ CUfunction <c-object> ] 2dip
-    [ cuModuleGetFunction cuda-error ] 3keep 2drop c:void* c:deref ;
+    [ { CUfunction } ] 2dip
+    '[ _ _ cuModuleGetFunction cuda-error ] with-out-parameters ;
 
 : cached-module ( module-name -- alien )
     lookup-cuda-library
@@ -170,9 +170,9 @@ MACRO: cuda-invoke ( module-name function-name arguments -- )
     ] ;
 
 : cuda-global* ( module-name symbol-name -- device-ptr size )
-    [ CUdeviceptr <c-object> c:uint <c-object> ] 2dip
+    [ { CUdeviceptr { c:uint initial: 0 } } ] 2dip
     [ cached-module ] dip 
-    '[ _ _ cuModuleGetGlobal cuda-error ] 2keep [ c:uint c:deref ] bi@ ; inline
+    '[ _ _ cuModuleGetGlobal cuda-error ] with-out-parameters ; inline
 
 : cuda-global ( module-name symbol-name -- device-ptr )
     cuda-global* drop ; inline
index 41a1cac7ff60dfea40ca7c9700781ba184f4d208..2369851292af4dfb8a6492cc7cba06d21775740e 100644 (file)
@@ -8,9 +8,8 @@ QUALIFIED-WITH: alien.c-types c
 IN: cuda.memory
 
 : cuda-malloc ( n -- ptr )
-    [ CUdeviceptr <c-object> ] dip
-    '[ _ cuMemAlloc cuda-error ] keep
-    c:int c:deref ; inline
+    [ { CUdeviceptr } ] dip
+    '[ _ cuMemAlloc cuda-error ] with-out-parameters ; inline
 
 : cuda-malloc-type ( n type -- ptr )
     c:heap-size * cuda-malloc ; inline
index 6f469a3c8bb7346b15785b51110c0be51e266b33..9a594c1cd072d13e19940b020f22a0860f746fa9 100644 (file)
@@ -1,8 +1,8 @@
 ! (c)2009 Joe Groff bsd license
-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
+USING: accessors alien.c-types alien.data 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 typed ui.gadgets.worlds variants ;
 SPECIALIZED-ARRAY: int
 SPECIALIZED-ARRAY: uint
index 6dff17a43323c2e32fcf098266d0e177bb5cc528..e3465a324ba3087aaffead9dce9eac660fa2f312 100644 (file)
@@ -37,8 +37,8 @@ SYMBOL: js-context
 
 : eval-js ( string -- result-string )
     [ js-context get dup ] dip
-    JSStringCreateWithUTF8CString f f 0 JSValueRef <c-object>
-    [ JSEvaluateScript ] keep void* deref
+    JSStringCreateWithUTF8CString f f 0
+    { { void* initial: f } } [ JSEvaluateScript ] with-out-parameters
     dup [ nip JSValueRef>string javascriptcore-error ] [ drop JSValueRef>string ] if ;
 
 : eval-js-standalone ( string -- result-string )
index 2c4c0a509fd6ea2b329c543195564211018e1a6d..eb3bebe819f2a5e51686434ad15bb00e83adbd84 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.syntax assocs destructors
-kernel llvm.core llvm.engine llvm.wrappers namespaces ;
+USING: accessors alien.c-types alien.data alien.syntax assocs
+destructors kernel llvm.core llvm.engine llvm.wrappers
+namespaces ;
 
 IN: llvm.jit
 
index 176e89b9946e83b12943d92b8561f463572503ce..90cf36f955bbf0c38f8eeb53b54363b00b9dadcc 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.syntax destructors kernel
-llvm.core llvm.engine llvm.jit llvm.wrappers ;
+USING: accessors alien.c-types alien.data alien.syntax
+destructors kernel llvm.core llvm.engine llvm.jit llvm.wrappers
+;
 
 IN: llvm.reader
 
index 24df1d5a12ea7356bb96a8be313d006ddd775634..27c8a0592a3575d5ee0c0b0fe8c18569d00f9d5d 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.strings
+USING: accessors alien.c-types alien.data alien.strings
 io.encodings.utf8 destructors kernel
 llvm.core llvm.engine ;
 
index 5380930dd17a29e6965909fcd99ce213387633fa..ccc4238533ba7b3ed020cf31608db937734f0586 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types kernel alien alien.syntax shuffle
+USING: alien.c-types alien.data kernel alien alien.syntax shuffle
 openal openal.alut.backend namespaces system generalizations ;
 IN: openal.alut.macosx
 
index 42e6172c9fd4f1c72867f0c6507d4391c9379534..8b446c3f5c26c76d7bf10409886eca2952b50b85 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax combinators generalizations
-kernel openal openal.alut.backend ;
+USING: alien.c-types alien.data alien.syntax combinators
+generalizations kernel openal openal.alut.backend ;
 IN: openal.alut.other
 
 LIBRARY: alut
index b1baa46d30af8e89d59b6bbb3466e6dde848db62..8f2d77b1e41f1ff75d5d227f959992211d1e545b 100755 (executable)
@@ -1,10 +1,11 @@
 ! 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
+alien.syntax namespaces sequences vocabs.loader
 shuffle alien.libraries generalizations
-specialized-arrays alien.destructors ;
-FROM: alien.c-types => float short ;
+specialized-arrays alien.destructors alien.data ;
+FROM: alien.c-types => char double float int short uchar uint
+ushort void ;
 SPECIALIZED-ARRAY: uint
 IN: openal
 
index 0fa5db978411706f4c4110a4bcf722a8090e7f1f..01ceb4e88f35d4d51354502b773b7d37f20d9d0c 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2010 Erik Charlebois.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types arrays byte-arrays combinators
-combinators.smart destructors io.encodings.ascii io.encodings.string
-kernel libc locals math namespaces opencl.ffi sequences shuffle
-specialized-arrays variants ;
+USING: accessors alien alien.c-types alien.data arrays
+byte-arrays combinators combinators.smart destructors
+io.encodings.ascii io.encodings.string kernel libc locals math
+namespaces opencl.ffi sequences shuffle specialized-arrays
+variants ;
 IN: opencl
 SPECIALIZED-ARRAYS: void* char size_t ;
 
index a7e53394bb70724c8876f69a7c3ba63b09c3b63b..acc1d7999f18b12f29dbaeef24667259bf684a86 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Bruno Deferrari
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types arrays assocs destructors fry functors
-kernel locals sequences serialize tokyo.alien.tcutil tokyo.utils vectors ;
+USING: accessors alien.c-types alien.data arrays assocs
+destructors fry functors kernel locals sequences serialize
+tokyo.alien.tcutil tokyo.utils vectors ;
 IN: tokyo.assoc-functor
 
 FUNCTOR: define-tokyo-assoc-api ( T N -- )
index 47896340cd8ce45dfaa686d5b9a1f4eeadb2e0b4..adcfa6f4da4655943615233b5da092bb350d7b20 100755 (executable)
@@ -381,25 +381,11 @@ FOO_TO_BIGNUM(ulong_long,u64,s64,u64)
                }                                                       \
        }
 
-BIGNUM_TO_FOO(cell,cell,fixnum,cell);
-BIGNUM_TO_FOO(fixnum,fixnum,fixnum,cell);
+BIGNUM_TO_FOO(cell,cell,fixnum,cell)
+BIGNUM_TO_FOO(fixnum,fixnum,fixnum,cell)
 BIGNUM_TO_FOO(long_long,s64,s64,u64)
 BIGNUM_TO_FOO(ulong_long,u64,s64,u64)
 
-double factor_vm::bignum_to_double(bignum * bignum)
-{
-       if (BIGNUM_ZERO_P (bignum))
-               return (0);
-       {
-               double accumulator = 0;
-               bignum_digit_type * start = (BIGNUM_START_PTR (bignum));
-               bignum_digit_type * scan = (start + (BIGNUM_LENGTH (bignum)));
-               while (start < scan)
-                       accumulator = ((accumulator * BIGNUM_RADIX) + (*--scan));
-               return ((BIGNUM_NEGATIVE_P (bignum)) ? (-accumulator) : accumulator);
-       }
-}
-
 #define DTB_WRITE_DIGIT(factor)                                                \
 {                                                                      \
        significand *= (factor);                                        \
index 67cab3570dc756378a7a0a122c23ce692e32dc9a..4bc918ad66ab29d81fe82a2cacbba08f57050d82 100755 (executable)
@@ -255,11 +255,6 @@ void factor_vm::primitive_fixnum_to_float()
        ctx->replace(allot_float(fixnum_to_float(ctx->peek())));
 }
 
-void factor_vm::primitive_bignum_to_float()
-{
-       ctx->replace(allot_float(bignum_to_float(ctx->peek())));
-}
-
 void factor_vm::primitive_format_float()
 {
        byte_array *array = allot_byte_array(100);
index ffe60dced5f0f0e0c04e198dedea7588d1a10ff0..62c007be8df605cf522ab14a65804e4ad3319fe0 100644 (file)
@@ -33,11 +33,6 @@ inline bignum *factor_vm::float_to_bignum(cell tagged)
        return double_to_bignum(untag_float(tagged));
 }
 
-inline double factor_vm::bignum_to_float(cell tagged)
-{
-       return bignum_to_double(untag<bignum>(tagged));
-}
-
 inline double factor_vm::untag_float(cell tagged)
 {
        return untag<boxed_float>(tagged)->n;
index ce40ca0a7e97de642cf8a94f96663e49d4a5f6a7..573f91b072ba71757170727a5fb94bb554eaff5b 100644 (file)
@@ -27,7 +27,6 @@ namespace factor
        _(bignum_shift) \
        _(bignum_subtract) \
        _(bignum_to_fixnum) \
-       _(bignum_to_float) \
        _(bignum_xor) \
        _(bits_double) \
        _(bits_float) \
index f940bd593734bf6167c30f0e4f14e8589e80c803..38eb5033d77060239706363b600a83e34db4a581 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -192,7 +192,6 @@ struct factor_vm
        fixnum bignum_to_fixnum(bignum * bignum);
        s64 bignum_to_long_long(bignum * bignum);
        u64 bignum_to_ulong_long(bignum * bignum);
-       double bignum_to_double(bignum * bignum);
        bignum *double_to_bignum(double x);
        int bignum_equal_p_unsigned(bignum * x, bignum * y);
        enum bignum_comparison bignum_compare_unsigned(bignum * x, bignum * y);
@@ -457,7 +456,6 @@ struct factor_vm
        inline cell unbox_array_size();
        cell unbox_array_size_slow();
        void primitive_fixnum_to_float();
-       void primitive_bignum_to_float();
        void primitive_format_float();
        void primitive_float_eq();
        void primitive_float_add();
@@ -487,7 +485,6 @@ struct factor_vm
        inline cell from_unsigned_cell(cell x);
        inline cell allot_float(double n);
        inline bignum *float_to_bignum(cell tagged);
-       inline double bignum_to_float(cell tagged);
        inline double untag_float(cell tagged);
        inline double untag_float_check(cell tagged);
        inline fixnum float_to_fixnum(cell tagged);