]> gitweb.factorcode.org Git - factor.git/commitdiff
endian: replaces io.binary and io.binary.fast.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 30 Dec 2021 05:21:44 +0000 (21:21 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 30 Dec 2021 05:25:15 +0000 (21:25 -0800)
92 files changed:
basis/bit-arrays/bit-arrays.factor
basis/bitstreams/bitstreams.factor
basis/bootstrap/image/image.factor
basis/cbor/cbor.factor
basis/checksums/common/common.factor
basis/checksums/crc16/crc16.factor
basis/checksums/fletcher/fletcher.factor
basis/checksums/internet/internet.factor
basis/checksums/metrohash/metrohash.factor
basis/checksums/murmur/murmur.factor
basis/checksums/sha/sha.factor
basis/checksums/superfast/superfast.factor
basis/checksums/wyhash/wyhash.factor
basis/checksums/xxhash/xxhash.factor
basis/compiler/cfg/value-numbering/simd/simd.factor
basis/compression/inflate/inflate.factor
basis/cpu/ppc/assembler/assembler.factor
basis/cpu/x86/assembler/assembler.factor
basis/cpu/x86/features/features-tests.factor
basis/dns/dns.factor
basis/endian/endian-tests.factor
basis/endian/endian.factor
basis/furnace/auth/auth.factor
basis/hints/hints.factor
basis/io/encodings/euc/euc.factor
basis/io/encodings/gb18030/gb18030.factor
basis/io/encodings/iso2022/iso2022.factor
basis/io/encodings/shift-jis/shift-jis.factor
basis/io/encodings/utf32/utf32.factor
basis/io/files/windows/windows.factor
basis/io/sockets/secure/openssl/openssl.factor
basis/io/sockets/sockets.factor
basis/math/bitwise/bitwise-docs.factor
basis/math/bitwise/bitwise-tests.factor
basis/math/bitwise/bitwise.factor
basis/msgpack/msgpack.factor
basis/random/random.factor
basis/serialize/serialize.factor
basis/system-info/macosx/macosx.factor
basis/uuid/uuid.factor
basis/windows/processes/processes.factor
core/checksums/crc32/crc32.factor
core/io/binary/authors.txt [deleted file]
core/io/binary/binary-docs.factor [deleted file]
core/io/binary/binary-tests.factor [deleted file]
core/io/binary/binary.factor [deleted file]
core/io/binary/summary.txt [deleted file]
core/io/encodings/utf16/utf16.factor
extra/asn1/asn1.factor
extra/audio/aiff/aiff.factor
extra/audio/wav/wav.factor
extra/base24/base24-tests.factor
extra/base24/base24.factor
extra/base32/base32.factor
extra/base36/base36.factor
extra/base58/base58.factor
extra/base62/base62.factor
extra/base85/base85.factor
extra/benchmark/cuckoo-filters/cuckoo-filters.factor
extra/benchmark/udp-echo0/udp-echo0.factor
extra/bittorrent/bittorrent.factor
extra/bson/reader/reader.factor
extra/bson/writer/writer.factor
extra/compiler/cfg/gvn/simd/simd.factor
extra/dbf/dbf.factor
extra/fastcgi/fastcgi.factor
extra/git/git.factor
extra/icfp/2006/2006.factor
extra/images/bitmap/bitmap.factor
extra/images/gif/gif.factor
extra/images/jpeg/jpeg.factor
extra/images/png/png.factor
extra/images/tga/tga.factor
extra/images/tiff/tiff.factor
extra/io/binary/fast/authors.txt [deleted file]
extra/io/binary/fast/fast-tests.factor [deleted file]
extra/io/binary/fast/fast.factor [deleted file]
extra/key-logger/key-logger.factor
extra/libusb/libusb.factor
extra/macho/macho.factor
extra/midi/midi.factor
extra/mongodb/operations/operations.factor
extra/protocols/tftp/tftp.factor
extra/shapefiles/shapefiles.factor
extra/terminfo/terminfo.factor
extra/tinyvg/tinyvg.factor
extra/totp/totp.factor
extra/tzinfo/tzinfo.factor
extra/ulid/ulid-tests.factor
extra/ulid/ulid.factor
extra/windows/fullscreen/fullscreen.factor
extra/windows/version/version.factor

index 2bb4727d134f7f579b9cf06bc3f92226656918b4..c71dc243d8f11c6b9402b0f09cee5077e02f66cb 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2011 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.accessors byte-arrays io.binary
+USING: accessors alien alien.accessors byte-arrays endian
 kernel kernel.private math math.bitwise parser sequences
 sequences.private vocabs.loader ;
 IN: bit-arrays
index 6b699cea0d1f256eb7e14f1028cf56da4c1c2b4b..fb917f97945d3d4c339d9be4e969a3c7f4bd6026 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors byte-arrays byte-vectors
-combinators.short-circuit io.binary kernel math math.bitwise
+combinators.short-circuit endian kernel math math.bitwise
 sequences sequences.private ;
 IN: bitstreams
 
index 2e2ef09153e39415c38beda3872d3b9d7d7388c7..6bf93c7636f067ff99b62835242b2751d6598e2e 100644 (file)
@@ -4,12 +4,12 @@ USING: accessors arrays assocs byte-arrays classes
 classes.builtin classes.private classes.tuple
 classes.tuple.private combinators combinators.short-circuit
 combinators.smart command-line compiler.codegen.relocation
-compiler.units generic generic.single.private grouping
-hashtables hashtables.private io io.binary io.encodings.binary
-io.files io.pathnames kernel kernel.private layouts make math
-math.order namespaces namespaces.private parser parser.notes
-prettyprint quotations sequences sequences.private source-files
-splitting strings system vectors vocabs words ;
+compiler.units endian generic generic.single.private grouping
+hashtables hashtables.private io io.encodings.binary io.files
+io.pathnames kernel kernel.private layouts make math
+math.bitwise math.order namespaces namespaces.private parser
+parser.notes prettyprint quotations sequences sequences.private
+source-files splitting strings system vectors vocabs words ;
 IN: bootstrap.image
 
 : arch-name ( os cpu -- arch )
index 2ec03417579042dece8c9467639c56b46c9ba7f9..adcc651cf8d2f81e8f82dc32c6417ee0672c2d86 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license
 
 USING: accessors arrays assocs base64 byte-arrays calendar
-calendar.format calendar.parser combinators io io.binary
+calendar.format calendar.parser combinators endian io
 io.encodings.binary io.encodings.string io.encodings.utf8
 io.streams.byte-array io.streams.string kernel math math.bitwise
 math.floats.half present sequences strings urls ;
index 511910ec6edfcd7c8da5a469952a5e7b52d08af9..bfd8554d750da2b16cb9cc63f0df4da67e90c151 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays byte-vectors checksums grouping
-io.binary kernel locals make math sequences ;
+USING: accessors byte-arrays byte-vectors checksums endian
+grouping kernel locals make math sequences ;
 IN: checksums.common
 
 : calculate-pad-length ( length -- length' )
index 415a4090a4a3b00ee4fec99639ea36e31faf3832..0097b07c940bb4a58697ec0cb83574597be5de75 100644 (file)
@@ -1,7 +1,6 @@
 ! Copyright (C) 2016 Alexander Ilin.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: checksums io.binary kernel math sequences
-sequences.private ;
+USING: checksums endian kernel math sequences sequences.private ;
 IN: checksums.crc16
 
 CONSTANT: crc16-polynomial 0xa001
@@ -16,7 +15,7 @@ CONSTANT: crc16-table V{ }
 
 : (crc16) ( crc ch -- crc )
     dupd bitxor
-    mask-byte crc16-table nth-unsafe
+    0xff bitand crc16-table nth-unsafe
     swap -8 shift bitxor ; inline
 
 SINGLETON: crc16
index 257912d8a8179b94dc27aa214bbc8590b5de04b3..bbe2de10274da973e61e965f7bec1071d8d02474 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2013 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: checksums grouping io.binary kernel locals math sequences
+USING: checksums endian grouping kernel locals math sequences
 ;
 
 IN: checksums.fletcher
index 926e184fe59db604db224fd65c956f2c10911523..41ff7a904fdd7113cef1822d92c1f608f80957c7 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: checksums grouping io.binary kernel math sequences ;
+USING: checksums endian grouping kernel math sequences ;
 
 IN: checksums.internet
 
index ad9b6dcaac0de0b6e5a22d3a0e3ca24b85d9c050..d9f2620c344c14126d7ecf5728cf059e11902ba8 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2018 John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data byte-arrays checksums
-combinators grouping io.binary kernel locals math math.bitwise
+combinators endian grouping kernel locals math math.bitwise
 sequences specialized-arrays ;
 SPECIALIZED-ARRAY: uint64_t
 SPECIALIZED-ARRAY: uint32_t
index d18b1318a58b8629b4186a8bf50f46e91f0a6b3c..4a0955442c1dccddddd364ffead019649ec3f935 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: accessors alien alien.c-types alien.data byte-arrays
-checksums fry grouping io.binary kernel math math.bitwise
+checksums endian fry grouping kernel math math.bitwise
 math.ranges sequences ;
 
 IN: checksums.murmur
index f87a32d250ac8ca2003ff2ee99f0acaf32045a05..43a3847ab1d6aeadb08771e84c4cc0a306ba06b3 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types arrays checksums checksums.common
-combinators combinators.smart fry grouping io.binary kernel
+combinators combinators.smart endian fry grouping kernel
 kernel.private literals locals math math.bitwise math.ranges
 sequences sequences.generalizations sequences.private
 specialized-arrays ;
index c3b1545c50ed15e2b44719479df10e4ceb1336dd..e9491a0fb4dda6d7acb25d479e658e0889e13119 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: accessors alien alien.c-types alien.data byte-arrays
-checksums combinators fry grouping io.binary kernel math
+checksums combinators endian fry grouping kernel math
 math.bitwise math.ranges sequences sequences.private ;
 
 IN: checksums.superfast
index 00492f98ecf7a1cf9532bd46b0d60b1d819afe94..2035a9b7e826c2d0cbb1368cf20034a0c2e16e1d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license
 
 USING: accessors alien.c-types alien.data byte-arrays checksums
-grouping io.binary kernel literals math math.bitwise math.order
+endian grouping kernel literals math math.bitwise math.order
 sequences sequences.generalizations sequences.private
 specialized-arrays ;
 SPECIALIZED-ARRAY: uint64_t
index 1437eb81d94c2eb536e22bb9e3ee7c9c844cb14f..021cf34f74c16a5cfb40db6368d90d20512ff4a5 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: accessors alien alien.c-types alien.data byte-arrays
-checksums combinators generalizations grouping io.binary kernel
+checksums combinators endian generalizations grouping kernel
 locals math math.bitwise math.ranges sequences
 specialized-arrays ;
 SPECIALIZED-ARRAY: uint64_t
index adff45b5e550bc10908fd361e028eadd10b4d184..298e0b31e02f5f7126515eeeb02d7222ada65230 100644 (file)
@@ -5,7 +5,7 @@ combinators.short-circuit compiler.cfg.instructions
 compiler.cfg.utilities compiler.cfg.value-numbering.graph
 compiler.cfg.value-numbering.math
 compiler.cfg.value-numbering.rewrite cpu.architecture
-generalizations grouping io.binary kernel locals make math
+endian generalizations grouping kernel locals make math
 sequences ;
 IN: compiler.cfg.value-numbering.simd
 
index fe17d230832cd01a558784da9f3e473d64c82a97..c6f22b912b4bb6ead18281113f0495b156403510 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009, 2020 Marc Fauconneau, Abtin Molavi, Jacob Fischer.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs byte-vectors combinators
-combinators.smart compression.huffman fry hashtables io.binary
+combinators.smart compression.huffman endian fry hashtables
 kernel literals locals math math.bitwise math.order math.ranges
 sequences sorting memoize combinators.short-circuit byte-arrays ;
 QUALIFIED-WITH: bitstreams bs
index 6f083373d59b091e610b5991e3333129448e05b2..137032d17aae027c57cb908bb4a17d6525094d99 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2011 Erik Charlebois.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces words math math.order locals math.bitwise io.binary make ;
+USING: kernel namespaces words math math.order locals
+math.bitwise endian make ;
 IN: cpu.ppc.assembler
 
 ! This vocabulary implements the V2.06B Power ISA found at http://www.power.org.
index 46baef612180a4e23baaa5ae62ca2e4c1c637afd..4ea7e4eb08427a20b2545687450a7b3fe3d798db 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays io.binary kernel combinators
+USING: arrays endian kernel combinators
 combinators.short-circuit math math.bitwise locals namespaces
 make sequences words system layouts math.order accessors
 cpu.x86.assembler.operands cpu.x86.assembler.operands.private ;
index 63582ec1bf724a5b21f4be4cc3b31afb357a4f32..b5a33637ee0bc989a52148c2c337408609797184 100644 (file)
@@ -1,5 +1,5 @@
 USING: cpu.x86.features tools.test kernel sequences math math.order
-strings system io.binary ;
+strings system endian ;
 IN: cpu.x86.features.tests
 
 [ t ] [ sse-version 0 42 between? ] unit-test
index 6bb3204b32141b1e0196d8ed89a3a30f93f58515..d31e5d830b739a426998f154791d595a5965936d 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.enums alien.syntax arrays calendar
-combinators combinators.smart constructors destructors grouping
-io io.binary io.encodings.binary io.encodings.string
+combinators combinators.smart constructors destructors endian
+grouping io io.encodings.binary io.encodings.string
 io.encodings.utf8 io.sockets io.sockets.private
 io.streams.byte-array io.timeouts kernel make math math.bitwise
 math.parser namespaces random sequences slots.syntax splitting
index f0650cc8fd2b721cb13124e5701abfa4dfa35d4a..1b1889da9f9b1915aa409de4752e7988a0bdc3c4 100644 (file)
@@ -1,6 +1,46 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: endian kernel namespaces tools.test ;
+USING: classes endian endian.private kernel math namespaces tools.test ;
 
 { t } [ [ endianness get big-endian = ] with-big-endian ] unit-test
 { t } [ [ endianness get little-endian = ] with-little-endian ] unit-test
+
+{ 0x0102 } [ B{ 01 02 } 2be> ] unit-test
+{ 0x01020304 } [ B{ 01 02 03 04 } 4be> ] unit-test
+{ 0x0102030405060708 } [ B{ 01 02 03 04 05 06 07 08 } 8be> ] unit-test
+
+{ 0x0102 } [ B{ 02 01 } 2le> ] unit-test
+{ 0x01020304 } [ B{ 04 03 02 01 } 4le> ] unit-test
+{ 0x0102030405060708 } [ B{ 08 07 06 05 04 03 02 01 } 8le> ] unit-test
+
+{ 0x7a2c793b2ff08554 } [
+    B{ 0x54 0x85 0xf0 0x2f 0x3b 0x79 0x2c 0x7a } le>
+] unit-test
+
+{ 0x988a259c3433f237 } [
+    B{ 0x37 0xf2 0x33 0x34 0x9c 0x25 0x8a 0x98 } le>
+] unit-test
+
+{ 0x03020100 } [ B{ 0 1 2 3 } le> ] unit-test
+{ 0x00010203 } [ B{ 0 1 2 3 } be> ] unit-test
+
+{ 0x332211 } [
+    B{ 0x11 0x22 0x33 } le>
+] unit-test
+
+{ 0x04030201 } [ B{ 1 2 3 4 } signed-le> ] unit-test
+{ 0x01020304 } [ B{ 1 2 3 4 } signed-be> ] unit-test
+
+{ -12 } [ B{ 0xf4 0xff 0xff 0xff } signed-le> ] unit-test
+{ -12 } [ B{ 0xff 0xff 0xff 0xf4 } signed-be> ] unit-test
+
+{ B{ 0 0 4 0xd2 } } [ 1234 4 >be ] unit-test
+{ B{ 0 0 0 0 0 0 4 0xd2 } } [ 1234 8 >be ] unit-test
+{ B{ 0xd2 4 0 0 } } [ 1234 4 >le ] unit-test
+{ B{ 0xd2 4 0 0 0 0 0 0 } } [ 1234 8 >le ] unit-test
+
+{ 1234 } [ 1234 4 >be be> ] unit-test
+{ 1234 } [ 1234 4 >le le> ] unit-test
+
+{ fixnum } [ B{ 0 0 0 0 0 0 0 0 0 0 } be> class-of ] unit-test
+
index ba949b3aaa683de4e0b71fd076e5b15c764ecd00..90c6e281471424c1cc14c5797ac7e4753596f0d6 100644 (file)
@@ -1,7 +1,13 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.data grouping io.binary kernel
+
+USING: alien.c-types alien.data byte-arrays combinators
+combinators.smart endian kernel math math.ranges sequences
+sequences.generalizations ;
+
+USING: alien.c-types alien.data grouping kernel
 math.bitwise namespaces sequences ;
+
 IN: endian
 
 SINGLETONS: big-endian little-endian ;
@@ -9,12 +15,160 @@ SINGLETONS: big-endian little-endian ;
 : compute-native-endianness ( -- class )
     1 int <ref> char deref 0 = big-endian little-endian ? ; foldable
 
+<PRIVATE
+
+: slow-be> ( seq -- x ) 0 [ [ 8 shift ] dip + ] reduce ;
+
+: slow-le> ( seq -- x ) 0 [ 8 * shift + ] reduce-index ;
+
+ERROR: bad-length bytes n ;
+
+: check-length ( bytes n -- bytes n )
+    2dup [ length ] dip > [ bad-length ] when ; inline
+
+<<
+: be-range ( n -- range )
+    1 - 8 * 0 -8 <range> ; inline
+
+: le-range ( n -- range )
+    1 - 8 * 0 swap 8 <range> ; inline
+
+: reassemble-bytes ( range -- quot )
+    [ [ [ ] ] [ '[ _ shift ] ] if-zero ] map
+    '[ [ _ spread ] [ bitor ] reduce-outputs ] ; inline
+
+MACRO: reassemble-be ( n -- quot ) be-range reassemble-bytes ;
+
+MACRO: reassemble-le ( n -- quot ) le-range reassemble-bytes ;
+>>
+
+:: n-be> ( bytes n -- x )
+    bytes n check-length drop n firstn-unsafe n reassemble-be ; inline
+
+:: n-le> ( bytes n -- x )
+    bytes n check-length drop n firstn-unsafe n reassemble-le ; inline
+
+! HINTS: n-be> { byte-array object } ;
+! HINTS: n-le> { byte-array object } ;
+
+! { >le >be } [
+!     { { fixnum fixnum } { bignum fixnum } }
+!     set-specializer
+! ] each
+
+! { le> be> } [
+!     { byte-array } set-specializer
+! ] each
+
+: if-endian ( endian bytes-quot seq-quot -- )
+    [
+        compute-native-endianness =
+        [ dup byte-array? ] [ f ] if
+    ] 2dip if ; inline
+
+: 2be> ( bytes -- x )
+    big-endian [ uint16_t deref ] [ 2 n-be> ] if-endian ;
+
+: 4be> ( bytes -- x )
+    big-endian [ uint32_t deref ] [ 4 n-be> ] if-endian ;
+
+: 8be> ( bytes -- x )
+    big-endian [ uint64_t deref ] [ 8 n-be> ] if-endian ;
+
+: 2le> ( bytes -- x )
+    little-endian [ uint16_t deref ] [ 2 n-le> ] if-endian ;
+
+: 4le> ( bytes -- x )
+    little-endian [ uint32_t deref ] [ 4 n-le> ] if-endian ;
+
+: 8le> ( bytes -- x )
+    little-endian [ uint64_t deref ] [ 8 n-le> ] if-endian ;
+
+PRIVATE>
+
+: be> ( bytes -- x )
+    dup length {
+        { 2 [ 2be> ] }
+        { 4 [ 4be> ] }
+        { 8 [ 8be> ] }
+        [ drop slow-be> ]
+    } case ;
+
+: le> ( bytes -- x )
+    dup length {
+        { 2 [ 2le> ] }
+        { 4 [ 4le> ] }
+        { 8 [ 8le> ] }
+        [ drop slow-le> ]
+    } case ;
+
+<PRIVATE
+
+: signed> ( x seq -- n )
+    length 8 * 2dup 1 - bit? [ 2^ - ] [ drop ] if ; inline
+
+: slow-signed-le> ( bytes -- x ) [ le> ] [ signed> ] bi ;
+
+: slow-signed-be> ( bytes -- x ) [ be> ] [ signed> ] bi ;
+
+PRIVATE>
+
+: signed-be> ( bytes -- x )
+    big-endian [
+        dup length {
+            { 2 [ int16_t deref ] }
+            { 4 [ int32_t deref ] }
+            { 8 [ int64_t deref ] }
+            [ drop slow-signed-be> ]
+        } case
+    ] [ slow-signed-be> ] if-endian ;
+
+: signed-le> ( bytes -- x )
+    little-endian [
+        dup length {
+            { 2 [ int16_t deref ] }
+            { 4 [ int32_t deref ] }
+            { 8 [ int64_t deref ] }
+            [ drop slow-signed-le> ]
+        } case
+    ] [ slow-signed-le> ] if-endian ;
+
+: nth-byte ( x n -- b ) -8 * shift 0xff bitand ; inline
+
+<PRIVATE
+
+: map-bytes ( x seq -- byte-array )
+    [ nth-byte ] with B{ } map-as ; inline
+
+: >slow-be ( x n -- byte-array ) <iota> <reversed> map-bytes ;
+
+: >slow-le ( x n -- byte-array ) <iota> map-bytes ;
+
+PRIVATE>
+
+: >le ( x n -- bytes )
+    compute-native-endianness little-endian = [
+        {
+            { 2 [ int16_t <ref> ] }
+            { 4 [ int32_t <ref> ] }
+            { 8 [ int64_t <ref> ] }
+            [ >slow-le ]
+        } case
+    ] [ >slow-le ] if ;
+
+: >be ( x n -- bytes )
+    compute-native-endianness big-endian = [
+        {
+            { 2 [ int16_t <ref> ] }
+            { 4 [ int32_t <ref> ] }
+            { 8 [ int64_t <ref> ] }
+            [ >slow-be ]
+        } case
+    ] [ >slow-be ] if ;
+
 SYMBOL: native-endianness
 native-endianness [ compute-native-endianness ] initialize
 
-SYMBOL: endianness
-endianness [ native-endianness get-global ] initialize
-
 HOOK: >native-endian native-endianness ( obj n -- bytes )
 
 M: big-endian >native-endian >be ;
@@ -27,6 +181,9 @@ M: big-endian unsigned-native-endian> be> ;
 
 M: little-endian unsigned-native-endian> le> ;
 
+SYMBOL: endianness
+endianness [ native-endianness get-global ] initialize
+
 : signed-native-endian> ( obj n -- n' )
     [ unsigned-native-endian> ] dip >signed ;
 
@@ -48,8 +205,11 @@ M: big-endian unsigned-endian> be> ;
 
 M: little-endian unsigned-endian> le> ;
 
-: signed-endian> ( obj n -- bytes )
-    [ unsigned-endian> ] dip >signed ;
+HOOK: signed-endian> endianness ( obj -- bytes )
+
+M: big-endian signed-endian> signed-be> ;
+
+M: little-endian signed-endian> signed-le> ;
 
 : with-endianness ( endian quot -- )
     [ endianness ] dip with-variable ; inline
@@ -74,3 +234,4 @@ M: little-endian unsigned-endian> le> ;
             '[ le> _ >be ] map
         ] if concat
     ] if ; inline
+
index e2930f461b4a2710ea82e0a7094456d8789e2ccc..12997c4fba3ebc60135c5cc8cd66487b282fa37f 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (c) 2008, 2010 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs namespaces kernel sequences sets
-destructors combinators fry logging io.encodings.utf8
-io.encodings.string io.binary io.sockets.secure random checksums
+destructors combinators endian fry logging io.encodings.utf8
+io.encodings.string io.sockets.secure random checksums
 checksums.sha urls
 html.forms
 http.server
index 9a372d5630e8cbe158b5878d11c4c6d5f21fa1dd..8e1c67c43e3255e1fe4d54272f7569e954e28b71 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs byte-arrays byte-vectors classes
 combinators definitions fry generic generic.single
-generic.standard hashtables io.binary kernel kernel.private math
+generic.standard hashtables kernel kernel.private math
 math.parser parser sbufs sequences sequences.private splitting
 strings vectors words ;
 IN: hints
@@ -123,15 +123,6 @@ set-specializer
 
 \ assoc-stack { vector } set-specializer
 
-{ >le >be } [
-    { { fixnum fixnum } { bignum fixnum } }
-    set-specializer
-] each
-
-{ le> be> } [
-    { byte-array } set-specializer
-] each
-
 \ base> { string fixnum } set-specializer
 
 M\ hashtable at*
index 1d65e146acffff9541f7b66591c8e6ae276a867d..88878d18beb85fd5c4d98ef315f72222620a25ac 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2009 Daniel Ehrenberg, Jonghyouk Yun.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel io.encodings accessors assocs sequences biassocs generic
-math.order simple-flat-file io io.binary byte-arrays locals combinators
-words classes.singleton fry classes.parser parser quotations ;
+USING: accessors assocs biassocs byte-arrays classes.parser
+classes.singleton combinators endian generic io io.encodings
+kernel math.bitwise math.order parser sequences simple-flat-file
+words ;
 IN: io.encodings.euc
 
 TUPLE: euc { table biassoc read-only } ;
index 760dc75dbd773250dd4231f14ddf9956fd7d6709..82cf141621ae1f2433c19a9e82631235f6ee6163 100644 (file)
@@ -3,7 +3,7 @@
 USING: xml xml.data kernel io io.encodings interval-maps splitting fry
 math.parser sequences combinators assocs locals accessors math arrays
 byte-arrays ascii io.files biassocs math.order namespaces
-combinators.short-circuit io.binary io.encodings.iana ;
+combinators.short-circuit endian io.encodings.iana ;
 FROM: io.encodings.ascii => ascii ;
 IN: io.encodings.gb18030
 
index 9419293d16c0af3edac86491b5c2ba9071f72156..8c52beaed6c5e786afe69357893191034ad91921 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs biassocs byte-arrays combinators
-combinators.short-circuit io io.binary io.encodings kernel
-literals locals math namespaces sequences simple-flat-file ;
+combinators.short-circuit endian io io.encodings kernel
+literals math math.bitwise namespaces sequences simple-flat-file ;
 IN: io.encodings.iso2022
 
 SINGLETON: iso2022
index 5e9307d8e7a02d6db1ff62feb06c8c9f84807086..f44deec096434de82416ca6e33b9e36d9f92309b 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel io io.files combinators.short-circuit
-math.order assocs io.encodings io.binary fry strings math
-io.encodings.ascii arrays byte-arrays accessors splitting
-math.parser biassocs io.encodings.iana namespaces
-locals multiline combinators simple-flat-file ;
+USING: accessors arrays assocs byte-arrays
+combinators.short-circuit endian io io.encodings
+io.encodings.iana kernel math.bitwise math.order namespaces
+simple-flat-file ;
 IN: io.encodings.shift-jis
 
 SINGLETON: shift-jis
index ba0938e1c0136d45c6d58fc0a391b35d893c4577..249dcea48ca386f90daac441e553bacedd25758d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: math kernel io.encodings combinators io io.encodings.utf16
-sequences io.binary io.encodings.iana ;
+USING: combinators endian math io io.encodings
+io.encodings.iana io.encodings.utf16 kernel sequences ;
 IN: io.encodings.utf32
 
 SINGLETON: utf32be
index 7f9bdfb960bcb06d408b0ef8ca921fa913aa405c..ad18263548f158bde52cf3f1f9bcd45d7f6820da 100644 (file)
@@ -2,13 +2,14 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.strings
 alien.syntax arrays ascii assocs classes.struct combinators
-combinators.short-circuit continuations destructors environment io
-io.backend io.binary io.buffers io.files io.files.private
-io.files.types io.pathnames io.pathnames.private io.ports io.streams.c
-io.streams.null io.timeouts kernel libc literals locals math math.bitwise
-namespaces sequences specialized-arrays system threads tr vectors windows
-windows.errors windows.handles windows.kernel32 windows.shell32
-windows.time windows.types windows.winsock splitting ;
+combinators.short-circuit continuations destructors environment
+io io.backend io.buffers io.files io.files.private
+io.files.types io.pathnames io.pathnames.private io.ports
+io.streams.c io.streams.null io.timeouts kernel libc literals
+locals math math.bitwise namespaces sequences specialized-arrays
+system threads tr vectors windows windows.errors windows.handles
+windows.kernel32 windows.shell32 windows.time windows.types
+windows.winsock splitting ;
 SPECIALIZED-ARRAY: ushort
 IN: io.files.windows
 
index d15015d20795ad96487c02b9c3f4020b9bba2772..7fe0d61293ad9347a231867b4c52e68610cf354d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.enums
 alien.strings assocs byte-arrays classes.struct combinators
-combinators.short-circuit destructors io io.backend io.binary
+combinators.short-circuit destructors endian io io.backend
 io.buffers io.encodings.latin1 io.encodings.string
 io.encodings.utf8 io.files io.pathnames io.ports io.sockets
 io.sockets.secure io.timeouts kernel libc math math.functions
index b9b06158dc8687162801e9733b7d0afa03fca1bd..da1d5c5205a1c3086faa114b41b4242973c8ad02 100644 (file)
@@ -3,8 +3,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data alien.strings arrays
 byte-arrays classes classes.struct combinators
-combinators.short-circuit continuations destructors fry
-grouping init io.backend io.binary io.encodings.ascii
+combinators.short-circuit continuations destructors endian fry
+grouping init io.backend io.encodings.ascii
 io.encodings.binary io.pathnames io.ports io.streams.duplex
 kernel locals math math.parser memoize namespaces present
 sequences sequences.private splitting strings summary system
index aaf9f9d489bd5b23231f06d79f7854dae1875701..cc3c33a49bd96e2b6536eae0767419dd1740eb66 100644 (file)
@@ -494,6 +494,18 @@ HELP: wrap
     }
 } ;
 
+HELP: d>w/w
+{ $values { "d" "a 64-bit integer" } { "w1" "a 32-bit integer" } { "w2" "a 32-bit integer" } }
+{ $description "Outputs two integers, the least followed by the most significant 32 bits of the input." } ;
+
+HELP: w>h/h
+{ $values { "w" "a 32-bit integer" } { "h1" "a 16-bit integer" } { "h2" "a 16-bit integer" } }
+{ $description "Outputs two integers, the least followed by the most significant 16 bits of the input." } ;
+
+HELP: h>b/b
+{ $values { "h" "a 16-bit integer" } { "b1" "an 8-bit integer" } { "b2" "an 8-bit integer" } }
+{ $description "Outputs two integers, the least followed by the most significant 8 bits of the input." } ;
+
 ARTICLE: "math-bitfields" "Constructing bit fields"
 "Some applications, such as binary communication protocols and assemblers, need to construct integers from elaborate bit field specifications. Hand-coding this using " { $link shift } " and " { $link bitor } " results in repetitive code. A higher-level facility exists to factor out this repetition:"
 { $subsections bitfield } ;
@@ -552,6 +564,12 @@ $nl
     W-
     W*
 }
+"Words for taking larger integers apart into smaller integers:"
+{ $subsections
+    d>w/w
+    w>h/h
+    h>b/b
+}
 "Converting a number to the nearest even/odd/signed:"
 { $subsections
     >even
index 7613b478760e80e4bc9ee2d6ba548537e3b83c65..79567c725c406d85fe117c91fc36a6f3c6b3d000 100644 (file)
@@ -116,3 +116,7 @@ SPECIALIZED-ARRAY: uint-4
 { 3 } [ 0b101 bit-length ] unit-test
 { 3 } [ 0b110 bit-length ] unit-test
 { 3 } [ 0b111 bit-length ] unit-test
+
+{ 0x56780000 0x12340000 } [ 0x1234000056780000 d>w/w ] unit-test
+{ 0x5678 0x1234 } [ 0x12345678 w>h/h ] unit-test
+{ 0x34 0x12 } [ 0x1234 h>b/b ] unit-test
index 4589f19065e347a71316d8da4f1576be3dbee357..ffed471cd6639c53154e5ddd8ecc37bc6b9c9b8e 100644 (file)
@@ -150,3 +150,12 @@ M: object bit-count
 : even-parity? ( obj -- ? ) bit-count even? ;
 
 : odd-parity? ( obj -- ? ) bit-count odd? ;
+
+: d>w/w ( d -- w1 w2 )
+    [ 0xffffffff bitand ] [ -32 shift 0xffffffff bitand ] bi ;
+
+: w>h/h ( w -- h1 h2 )
+    [ 0xffff bitand ] [ -16 shift 0xffff bitand ] bi ;
+
+: h>b/b ( h -- b1 b2 )
+    [ 0xff bitand ] [ -8 shift 0xff bitand ] bi ;
index 021a96c3bb5e1895755b013f611ed080366d98e2..6e8b715aed504474f2ffc71253d15dcec695363b 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2013 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: arrays assocs byte-arrays combinators grouping hashtables
-io io.binary io.encodings io.encodings.binary
+USING: arrays assocs byte-arrays combinators endian grouping
+hashtables io io.encodings io.encodings.binary
 io.encodings.string io.encodings.utf8 io.streams.byte-array
 io.streams.string kernel math math.bitwise math.order namespaces
 sequences strings ;
index 0040ee77fb8ffca2be7b34dd6fe399d909861e39..b71291df92faafc8ff10b117b9baca6e236d9148 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.data arrays assocs byte-arrays
-byte-vectors combinators combinators.short-circuit fry
-hashtables hashtables.private hash-sets hints io.backend
-io.binary kernel locals math math.bitwise math.constants
-math.functions math.order math.ranges namespaces sequences
-sequences.private sets summary system typed vocabs ;
+byte-vectors combinators combinators.short-circuit endian fry
+hashtables hashtables.private hash-sets hints io.backend kernel
+locals math math.bitwise math.constants math.functions
+math.order math.ranges namespaces sequences sequences.private
+sets summary system typed vocabs ;
 QUALIFIED-WITH: alien.c-types c
 QUALIFIED-WITH: sets sets
 IN: random
index 2e5e33d137112fdd29fdeccde49a50aecb58718b..b28f38f89c7da341f62a14640208049ec453368d 100644 (file)
@@ -7,7 +7,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 USING: accessors arrays assocs byte-arrays classes classes.tuple
-combinators hashtables hashtables.identity io io.binary
+combinators endian hashtables hashtables.identity io
 io.encodings.binary io.encodings.string io.encodings.utf8
 io.streams.byte-array kernel locals math namespaces prettyprint
 quotations sequences sequences.private strings vocabs words ;
index b7a76f33a8ddc72672c8a3c028d2468b1ac3f8d6..6dfd4cfabb8161cb319888c60d9d77f3d9ad1386 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman, John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types alien.data alien.strings alien.syntax
-arrays assocs byte-arrays core-foundation io.binary
+arrays assocs byte-arrays core-foundation endian
 io.encodings.utf8 kernel libc sequences specialized-arrays
 splitting system system-info unix.users ;
 SPECIALIZED-ARRAY: int
index b96434627b6f4ad3bbb959028ebd6576b8ed59ab..cb72219a797e2981cf9dbd536822aa6641e64d92 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 USING: byte-arrays calendar checksums checksums.md5
-checksums.sha io.binary kernel math math.parser math.ranges
+checksums.sha endian kernel math math.parser math.ranges
 random sequences strings system unicode ;
 IN: uuid
 
index b904003e1addc2e8be6afa428eab5cfc32ac7d1d..a803eca9f969dfee22efde8e7349defe01a009cb 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2021 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data arrays
-classes.struct destructors io.binary kernel literals sequences
+classes.struct destructors endian kernel literals sequences
 strings windows windows.errors windows.handles windows.kernel32
 windows.types ;
 IN: windows.processes
@@ -122,4 +122,4 @@ IN: windows.processes
     le> head >string ;
 
 : get-my-process-image-name ( -- string )
-    GetCurrentProcess get-process-image-name ;
\ No newline at end of file
+    GetCurrentProcess get-process-image-name ;
index f6f6870041649d54e588e64c2c9aa19c5b0ff881..d646a0440d31f07f35f33d756eb14454eba2c31a 100644 (file)
@@ -1,7 +1,6 @@
 ! Copyright (C) 2006 Doug Coleman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: checksums io.binary kernel math sequences
-sequences.private ;
+USING: checksums kernel math sequences sequences.private ;
 IN: checksums.crc32
 
 CONSTANT: crc32-polynomial 0xedb88320
@@ -16,7 +15,7 @@ CONSTANT: crc32-table V{ }
 
 : (crc32) ( crc ch -- crc )
     dupd bitxor
-    mask-byte crc32-table nth-unsafe
+    0xff bitand crc32-table nth-unsafe
     swap -8 shift bitxor ; inline
 
 SINGLETON: crc32
@@ -26,8 +25,13 @@ INSTANCE: crc32 checksum
 : init-crc32 ( input checksum -- x y input )
     drop [ 0xffffffff dup ] dip ; inline
 
+<PRIVATE
+: 4>be ( n -- byte-array ) ! duplicated from io.binary, but in core
+    { -24 -16 -8 0 } [ shift 0xff bitand ] with B{ } map-as ;
+PRIVATE>
+
 : finish-crc32 ( x y -- bytes )
-    bitxor 4 >be ; inline
+    bitxor 4>be ; inline
 
 M: crc32 checksum-bytes
     init-crc32
diff --git a/core/io/binary/authors.txt b/core/io/binary/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/core/io/binary/binary-docs.factor b/core/io/binary/binary-docs.factor
deleted file mode 100644 (file)
index 078b0df..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-USING: help.markup help.syntax io math byte-arrays ;
-IN: io.binary
-
-ARTICLE: "stream-binary" "Working with binary data"
-"Stream words on binary streams only read and write byte arrays. Packed binary integers can be read and written by converting to and from sequences of bytes. Floating point numbers can be read and written by converting them into a their bitwise integer representation (" { $link "floats" } ")."
-$nl
-"There are two ways to order the bytes making up an integer; " { $emphasis "little endian" } " byte order outputs the least significant byte first, and the most significant byte last, whereas " { $emphasis "big endian" } " is the other way around."
-$nl
-"Consider the hexadecimal integer " { $snippet "0xcafebabe" } ". Little endian byte order yields the following sequence of bytes:"
-{ $table
-    { "Byte:" "1" "2" "3" "4" }
-    { "Value:" { $snippet "be" } { $snippet "ba" } { $snippet "fe" } { $snippet "ca" } }
-}
-"Compare this with big endian byte order:"
-{ $table
-    { "Byte:" "1" "2" "3" "4" }
-    { "Value:" { $snippet "ca" } { $snippet "fe" } { $snippet "ba" } { $snippet "be" } }
-}
-"Two words convert a sequence of bytes into an integer:"
-{ $subsections
-    be>
-    le>
-}
-"Two words convert an integer into a sequence of bytes:"
-{ $subsections
-    >be
-    >le
-}
-"Words for taking larger integers apart into smaller integers:"
-{ $subsections
-    d>w/w
-    w>h/h
-    h>b/b
-} ;
-
-ABOUT: "stream-binary"
-
-HELP: be>
-{ $values { "seq" { $sequence "bytes" } } { "x" "a non-negative integer" } }
-{ $description "Converts a sequence of bytes in big endian order into an unsigned integer." } ;
-
-HELP: le>
-{ $values { "seq" { $sequence "bytes" } } { "x" "a non-negative integer" } }
-{ $description "Converts a sequence of bytes in little endian order into an unsigned integer." } ;
-
-HELP: nth-byte
-{ $values { "x" integer } { "n" "a non-negative integer" } { "b" "a byte" } }
-{ $description "Outputs the " { $snippet "n" } "th least significant byte of the sign-extended 2's complement representation of " { $snippet "x" } "." } ;
-
-HELP: >le
-{ $values { "x" integer } { "n" "a non-negative integer" } { "byte-array" byte-array } }
-{ $description "Converts an integer " { $snippet "x" } " into a string of " { $snippet "n" } " bytes in little endian order. Truncation will occur if the integer is not in the range " { $snippet "[-2^(8n),2^(8n))" } "." } ;
-
-HELP: >be
-{ $values { "x" integer } { "n" "a non-negative integer" } { "byte-array" byte-array } }
-{ $description "Converts an integer " { $snippet "x" } " into a string of " { $snippet "n" } " bytes in big endian order. Truncation will occur if the integer is not in the range " { $snippet "[-2^(8n),2^(8n))" } "." } ;
-
-HELP: mask-byte
-{ $values { "x" integer } { "y" "a non-negative integer" } }
-{ $description "Masks off the least significant 8 bits of an integer." } ;
-
-HELP: d>w/w
-{ $values { "d" "a 64-bit integer" } { "w1" "a 32-bit integer" } { "w2" "a 32-bit integer" } }
-{ $description "Outputs two integers, the least followed by the most significant 32 bits of the input." } ;
-
-HELP: w>h/h
-{ $values { "w" "a 32-bit integer" } { "h1" "a 16-bit integer" } { "h2" "a 16-bit integer" } }
-{ $description "Outputs two integers, the least followed by the most significant 16 bits of the input." } ;
-
-HELP: h>b/b
-{ $values { "h" "a 16-bit integer" } { "b1" "an 8-bit integer" } { "b2" "an 8-bit integer" } }
-{ $description "Outputs two integers, the least followed by the most significant 8 bits of the input." } ;
diff --git a/core/io/binary/binary-tests.factor b/core/io/binary/binary-tests.factor
deleted file mode 100644 (file)
index a06d684..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-USING: io.binary tools.test classes math ;
-IN: io.binary.tests
-
-{ 0x03020100 } [ B{ 0 1 2 3 } le> ] unit-test
-{ 0x00010203 } [ B{ 0 1 2 3 } be> ] unit-test
-
-{ 0x332211 } [
-    B{ 0x11 0x22 0x33 } le>
-] unit-test
-
-{ 0x04030201 } [ B{ 1 2 3 4 } signed-le> ] unit-test
-{ 0x01020304 } [ B{ 1 2 3 4 } signed-be> ] unit-test
-
-{ -12 } [ B{ 0xf4 0xff 0xff 0xff } signed-le> ] unit-test
-{ -12 } [ B{ 0xff 0xff 0xff 0xf4 } signed-be> ] unit-test
-
-{ 0x7a2c793b2ff08554 } [
-    B{ 0x54 0x85 0xf0 0x2f 0x3b 0x79 0x2c 0x7a } le>
-] unit-test
-
-{ 0x988a259c3433f237 } [
-    B{ 0x37 0xf2 0x33 0x34 0x9c 0x25 0x8a 0x98 } le>
-] unit-test
-
-{ B{ 0 0 4 0xd2 } } [ 1234 4 >be ] unit-test
-{ B{ 0 0 0 0 0 0 4 0xd2 } } [ 1234 8 >be ] unit-test
-{ B{ 0xd2 4 0 0 } } [ 1234 4 >le ] unit-test
-{ B{ 0xd2 4 0 0 0 0 0 0 } } [ 1234 8 >le ] unit-test
-
-{ 1234 } [ 1234 4 >be be> ] unit-test
-{ 1234 } [ 1234 4 >le le> ] unit-test
-
-{ fixnum } [ B{ 0 0 0 0 0 0 0 0 0 0 } be> class-of ] unit-test
-
-{ 0x56780000 0x12340000 } [ 0x1234000056780000 d>w/w ] unit-test
-{ 0x5678 0x1234 } [ 0x12345678 w>h/h ] unit-test
-{ 0x34 0x12 } [ 0x1234 h>b/b ] unit-test
diff --git a/core/io/binary/binary.factor b/core/io/binary/binary.factor
deleted file mode 100644 (file)
index b85e931..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-! Copyright (C) 2003, 2007 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math sequences ;
-IN: io.binary
-
-: le> ( seq -- x ) 0 [ 8 * shift + ] reduce-index ;
-
-: be> ( seq -- x ) 0 [ [ 8 shift ] dip + ] reduce ;
-
-: mask-byte ( x -- y ) 0xff bitand ; inline
-
-: nth-byte ( x n -- b ) -8 * shift mask-byte ; inline
-
-<PRIVATE
-
-: map-bytes ( x seq -- byte-array )
-    [ nth-byte ] with B{ } map-as ; inline
-
-PRIVATE>
-
-: >le ( x n -- byte-array ) <iota> map-bytes ;
-
-: >be ( x n -- byte-array ) <iota> <reversed> map-bytes ;
-
-: d>w/w ( d -- w1 w2 )
-    [ 0xffffffff bitand ] [ -32 shift 0xffffffff bitand ] bi ;
-
-: w>h/h ( w -- h1 h2 )
-    [ 0xffff bitand ] [ -16 shift 0xffff bitand ] bi ;
-
-: h>b/b ( h -- b1 b2 )
-    [ mask-byte ] [ -8 shift mask-byte ] bi ;
-
-<PRIVATE
-
-: signed> ( x seq -- n )
-    length 8 * 2dup 1 - bit? [ 2^ - ] [ drop ] if ; inline
-
-PRIVATE>
-
-: signed-le> ( bytes -- x ) [ le> ] [ signed> ] bi ;
-
-: signed-be> ( bytes -- x ) [ be> ] [ signed> ] bi ;
diff --git a/core/io/binary/summary.txt b/core/io/binary/summary.txt
deleted file mode 100644 (file)
index 14d76d4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Utilities for reading and writing little and big endian data
index 254f668c903d648360a8d19be9d680d9244c84f0..d8896529094fb686cb6939dd7fabf46e164a55b4 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2006, 2009 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays combinators io io.binary
-io.encodings kernel math math.private namespaces sbufs
-sequences sequences.private splitting strings strings.private
-vectors ;
+USING: accessors byte-arrays combinators io io.encodings kernel
+math math.private namespaces sbufs sequences sequences.private
+splitting strings strings.private vectors ;
 IN: io.encodings.utf16
 
 SINGLETON: utf16be
@@ -80,12 +79,15 @@ M: utf16le decode-char
     [ B{ } 2sequence ] dip stream-write ; inline
     ! [ stream-write1 ] curry bi@ ; inline
 
+: split>b/b ( h -- b1 b2 ) ! duplicate from math.bitwise:h>b/b
+    [ 0xff bitand ] [ -8 shift 0xff bitand ] bi ;
+
 : char>utf16be ( char stream -- )
     over 0xFFFF > [
         [ 0x10000 - ] dip
         [ [ encode-first ] dip stream-write2 ]
         [ [ encode-second ] dip stream-write2 ] 2bi
-    ] [ [ h>b/b swap ] dip stream-write2 ] if ; inline
+    ] [ [ split>b/b swap ] dip stream-write2 ] if ; inline
 
 M: utf16be encode-char
     drop char>utf16be ;
@@ -95,7 +97,7 @@ M: utf16be encode-char
         [ 0x10000 - ] dip
         [ [ encode-first swap ] dip stream-write2 ]
         [ [ encode-second swap ] dip stream-write2 ] 2bi
-    ] [ [ h>b/b ] dip stream-write2 ] if ; inline
+    ] [ [ split>b/b ] dip stream-write2 ] if ; inline
 
 M: utf16le encode-char
     drop char>utf16le ;
index ad86a8877d4b2e9e056d328abea96920e0268fb2..9dad150214c2a5be975754b0661f2c6d06e01758 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: arrays asn1.ldap assocs byte-arrays combinators
-continuations io io.binary io.streams.string kernel math
+continuations endian io io.streams.string kernel math
 math.parser namespaces make pack strings sequences accessors ;
 
 IN: asn1
index 3fd5dbdacf845bc64f2aee3f9df9f0d985e8b144..e0c3c4fa43fac6d1bd0d7c6d148c2f832df031fe 100644 (file)
@@ -2,9 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data audio
 audio.chunked-file classes.struct combinators
-combinators.short-circuit endian io io.binary
-io.encodings.binary io.files kernel locals math sequences
-audio.loader ;
+combinators.short-circuit endian io io.encodings.binary
+io.files kernel locals math sequences audio.loader ;
 IN: audio.aiff
 
 CONSTANT: FORM-MAGIC "FORM"
index fe062df9cf2fe8d54dca429530b854822dea59c9..2aacaae0b12e2c95087745345b07d72ff829e755 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types alien.syntax audio combinators endian
-combinators.short-circuit io io.binary io.encodings.binary
+combinators.short-circuit endian io io.encodings.binary
 io.files io.streams.byte-array kernel locals math
 sequences alien alien.data classes.struct accessors
 audio.chunked-file audio.loader ;
index ba213ccc1a98d7d6c094905592cb3304094699bb..54e28120be382777b0e26377f10a068a720ac90b 100644 (file)
@@ -1,4 +1,4 @@
-USING: base24 grouping io.binary kernel math.parser sequences
+USING: base24 endian grouping kernel math.parser sequences
 tools.test ;
 
 IN: base24.tests
index 434866c01499274bd7106b4c7a42ef1fcc607710..902917226080b86db40ed140b58ee6726d761124 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2020 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: ascii assocs base64.private byte-arrays grouping
-io.binary kernel kernel.private literals math sequences ;
+USING: ascii assocs base64.private byte-arrays endian grouping
+kernel kernel.private literals math sequences ;
 
 IN: base24
 
index 90c362f48f4831428ac9cb67e4f0f82d398d69c4..3bace0d75f9403031a0b232fa10b2a2ed97aa276 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2019 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
-USING: base64.private byte-arrays combinators fry io io.binary
+USING: base64.private byte-arrays combinators endian fry io
 io.encodings.binary io.streams.byte-array kernel kernel.private
 literals math namespaces sequences ;
 IN: base32
index e937e053f92b2b05c03e2acb01ed73b0133d420c..3d11cd619ea7e98f15d5ca394a56e82a8b301f3a 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: base64.private byte-arrays checksums checksums.sha
-io.binary kernel kernel.private literals math math.functions
+endian kernel kernel.private literals math math.functions
 sequences ;
 
 IN: base36
index a3601a7856d98c671d6fa496eb6f2d5bcd333c4e..db5153866f96608d602f08f1f65f83ce5e2924ff 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: base64.private byte-arrays checksums checksums.sha
-io.binary kernel kernel.private literals math sequences ;
+endian kernel kernel.private literals math sequences ;
 
 IN: base58
 
index 40c29cacb0ef4bd18354066234aeff652a98767d..9cc6d037210430c8561bf8abe4c2caa59eb528b1 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: base64.private byte-arrays checksums checksums.sha
-io.binary kernel kernel.private literals math sequences ;
+endian kernel kernel.private literals math sequences ;
 
 IN: base62
 
index bbf98e13c2018ecc5579bda6d9b75ac74008db1f..44d3d9289d29e53fa74f3b2f6d74b545e0c69349 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2013 John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: base64.private byte-arrays combinators io io.binary
+USING: base64.private byte-arrays combinators endian io
 io.encodings.binary io.streams.byte-array kernel kernel.private
 literals math namespaces sequences ;
 IN: base85
index 95e92d95c76498212b51371df4f4595cb2c4dee3..16c668e1bf775a19b3ffdd0857f6caaa22977f43 100644 (file)
@@ -1,4 +1,4 @@
-USING: cuckoo-filters fry io.binary kernel math sequences ;
+USING: cuckoo-filters endian fry kernel math sequences ;
 IN: benchmark.cuckoo-filters
 
 : insert-data ( cuckoo-filter -- cuckoo-filter )
index 9338245b62caa708b807ab3a3c1eac72ff93e413..f4fa7c242a57fdf7467560014de5c0234c14c86a 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2011 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors destructors fry io.binary io.sockets kernel
+USING: accessors destructors endian fry io.sockets kernel
 sequences ;
 
 IN: benchmark.udp-echo0
index 70e4158e7b7ccec9b0dd6a338b63e9dc45b47b24..a4416cb475ac1e43ec9ad063369575eb26336c4d 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2020 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 USING: accessors arrays assocs bencode byte-arrays byte-vectors
-calendar checksums checksums.sha combinators destructors fry
-grouping http.client io io.binary io.encodings.binary io.files
+calendar checksums checksums.sha combinators destructors endian
+fry grouping http.client io io.encodings.binary io.files
 io.pathnames io.sockets io.streams.byte-array io.streams.duplex
 kernel literals locals make math math.bitwise math.functions
 math.order math.parser math.ranges multiline namespaces
index 62e76eb42cfb8a6f42db4b25ccd1fc466e054b9a..c6ab3d4e88cb865bb90d2a2896221b82a4689420 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Sascha Matzke.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs bson.constants byte-arrays calendar
-combinators combinators.short-circuit io io.binary io.encodings
+combinators combinators.short-circuit endian io io.encodings
 io.encodings.binary io.encodings.utf8 io.files
 io.streams.byte-array kernel locals math namespaces sequences
 sequences.extras serialize strings typed vectors ;
index 3d5bfeda94519e17ac4db393e8833fa9ebf63f53..7a9b398144f5ad701049149786e4463f84d42eb7 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.accessors arrays assocs bson.constants
 byte-arrays byte-vectors calendar combinators
-combinators.short-circuit dlists fry hashtables io io.binary
-io.encodings io.encodings.utf8 io.streams.byte-array kernel
+combinators.short-circuit dlists endian fry hashtables
+io io.encodings io.encodings.utf8 io.streams.byte-array kernel
 linked-assocs literals math math.parser namespaces quotations
 sequences serialize strings typed vectors words ;
 IN: bson.writer
index 667d750f267323af14410258e2ad83b0d327b16e..04cfd571b78b4c5a0d514897c2b1682e4a2b7fad 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors combinators combinators.short-circuit arrays
 fry kernel layouts math namespaces sequences cpu.architecture
-math.bitwise math.order classes generalizations
-locals make alien.c-types io.binary grouping
+math.bitwise math.order classes endian generalizations
+locals make alien.c-types grouping
 math.vectors.simd.intrinsics
 compiler.cfg
 compiler.cfg.registers
index e7f3e60d314d85032d0cbf9f83106e04b673b1aa..3d61947c7e14937cf66fc076164648931ed769f5 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license
 
 USING: accessors alien.c-types alien.endian alien.strings assocs
-calendar calendar.parser classes.struct combinators fry io
-io.binary io.encodings.8-bit io.encodings.ascii
+calendar calendar.parser classes.struct combinators endian fry
+io io.encodings.8-bit io.encodings.ascii
 io.encodings.binary io.encodings.string io.files
 io.streams.byte-array kernel math math.parser namespaces
 sequences splitting strings ;
index 271451ca38dae8fa641862c5c1eac8133d9538be..1a64f3c24a28278694c76248ffec9d1e791daa2c 100644 (file)
@@ -14,8 +14,8 @@
 !     * REMOTE_ADDR
 
 USING: accessors alien.enums alien.syntax assocs combinators
-combinators.smart formatting http http.server
-http.server.responses io io.binary io.directories
+combinators.smart endian formatting http http.server
+http.server.responses io io.directories
 io.encodings.binary io.files io.servers io.sockets
 io.streams.byte-array kernel locals math namespaces pack
 prettyprint sequences sequences.deep strings threads
index 9cbe8d439a18763c336965f5fba8da5a0bf5d025..18727a588b08e082bada4e34aef8069a7c2fb24a 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs assocs.extras calendar
 calendar.format checksums checksums.sha combinators
-combinators.smart compression.zlib constructors grouping io
-io.binary io.directories io.encodings.binary io.encodings.string
+combinators.smart compression.zlib constructors endian grouping
+io io.directories io.encodings.binary io.encodings.string
 io.encodings.utf8 io.files io.files.info io.pathnames
 io.streams.byte-array io.streams.peek kernel math math.bitwise
 math.parser namespaces random sequences sequences.extras
index e50fa596176977e96ced055ca245a37135b28de4..7e14378c4e9e6f0f72ef27f65bc55edddbb694ee 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Gavin Harrison
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math sequences kernel.private namespaces arrays io
-io.files splitting grouping io.binary math.functions vectors
+io.files splitting grouping math.functions vectors endian
 quotations combinators io.encodings.binary ;
 IN: icfp.2006
 
index 8c9de5005b72058b3dedc77ef66778ab19f7583e..546749d2de39002040651a0247fa979f06365b87 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2007, 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data arrays byte-arrays
-combinators compression.run-length fry grouping images
-images.loader images.normalization io io.binary
+combinators compression.run-length endian fry grouping images
+images.loader images.normalization io
 io.encodings.latin1 io.encodings.string io.streams.throwing
 kernel math math.bitwise sequences specialized-arrays summary ;
 QUALIFIED-WITH: bitstreams b
index 13e0cc1ac6b432358839755e40481418bb9bddad..0fd010675d52e40f5b50e1c58b0f2edcfde60822 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyrigt (C) 2009 Doug Coleman, Keith Lazuka
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays combinators compression.lzw
-constructors destructors grouping images images.loader io
-io.binary io.buffers io.encodings.string io.encodings.utf8
+constructors destructors endian grouping images images.loader
+io io.buffers io.encodings.string io.encodings.utf8
 kernel make math math.bitwise namespaces sequences ;
 IN: images.gif
 
index 9422bfe8e607ef209de953f2b921ff22eb4e5a81..87897898a2f06cf9d8258a068997e4f134ec51e2 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Marc Fauconneau.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays byte-arrays combinators
-compression.huffman fry grouping images images.loader
-images.processing io io.binary io.encodings.binary
+compression.huffman endian fry grouping images images.loader
+images.processing io io.encodings.binary
 io.streams.byte-array io.streams.limited io.streams.throwing
 kernel locals math math.bitwise math.blas.matrices
 math.blas.vectors math.constants math.functions math.matrices
index d6d4e5639d4033497e18d5d806b4399a7091983e..ec3ebfae5c12217de71b67604164beeec9d7b8b1 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs checksums checksums.crc32
-combinators compression.inflate fry grouping images
-images.loader io io.binary io.encodings.ascii
+combinators compression.inflate endian fry grouping images
+images.loader io io.encodings.ascii
 io.encodings.binary io.encodings.latin1 io.encodings.string
 io.streams.byte-array io.streams.throwing kernel locals math
 math.bitwise math.functions sequences sorting ;
index 1cbf8441d41d7bb590d244cf7446b8c0c71db479..b592851db06dabfbc99260edc891389dca39f9d3 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2010 Erik Charlebois
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors images images.loader io io.binary kernel
+USING: accessors endian images images.loader io kernel
 locals math sequences io.encodings.ascii io.encodings.string
 calendar math.ranges math.parser colors arrays hashtables
 ui.pixel-formats combinators continuations io.streams.throwing ;
index 2fab7c147cd018307849e4867bf275caa707410e..7bdbf34327743dd087fc44c04e71ef3df84eb257 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs byte-arrays combinators
 combinators.short-circuit compression.lzw endian fry grouping
-images images.loader io io.binary io.encodings.ascii
+images images.loader io io.encodings.ascii
 io.encodings.string io.encodings.utf8 io.streams.throwing kernel
 math math.bitwise math.vectors pack sequences ;
 IN: images.tiff
diff --git a/extra/io/binary/fast/authors.txt b/extra/io/binary/fast/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/io/binary/fast/fast-tests.factor b/extra/io/binary/fast/fast-tests.factor
deleted file mode 100644 (file)
index 66c98b0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-! Copyright (C) 2011 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test io.binary.fast ;
-
-{ 0x0102 } [ B{ 01 02 } 2be> ] unit-test
-{ 0x01020304 } [ B{ 01 02 03 04 } 4be> ] unit-test
-{ 0x0102030405060708 } [ B{ 01 02 03 04 05 06 07 08 } 8be> ] unit-test
-
-{ 0x0102 } [ B{ 02 01 } 2le> ] unit-test
-{ 0x01020304 } [ B{ 04 03 02 01 } 4le> ] unit-test
-{ 0x0102030405060708 } [ B{ 08 07 06 05 04 03 02 01 } 8le> ] unit-test
-
-{ 0x04030201 } [ B{ 1 2 3 4 } signed-le> ] unit-test
-{ 0x01020304 } [ B{ 1 2 3 4 } signed-be> ] unit-test
-
-{ -12 } [ B{ 0xf4 0xff 0xff 0xff } signed-le> ] unit-test
-{ -12 } [ B{ 0xff 0xff 0xff 0xf4 } signed-be> ] unit-test
diff --git a/extra/io/binary/fast/fast.factor b/extra/io/binary/fast/fast.factor
deleted file mode 100644 (file)
index 64206a7..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-! Copyright (C) 2011 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.data byte-arrays combinators
-combinators.smart endian fry hints kernel locals macros math
-math.ranges sequences sequences.generalizations ;
-RENAME: be> io.binary => slow-be>
-RENAME: le> io.binary => slow-le>
-RENAME: signed-be> io.binary => slow-signed-be>
-RENAME: signed-le> io.binary => slow-signed-le>
-RENAME: >be io.binary => >slow-be
-RENAME: >le io.binary => >slow-le
-IN: io.binary.fast
-
-ERROR: bad-length bytes n ;
-
-: check-length ( bytes n -- bytes n )
-    2dup [ length ] dip > [ bad-length ] when ; inline
-
-<<
-: be-range ( n -- range )
-    1 - 8 * 0 -8 <range> ; inline
-
-: le-range ( n -- range )
-    1 - 8 * 0 swap 8 <range> ; inline
-
-: reassemble-bytes ( range -- quot )
-    [ [ [ ] ] [ '[ _ shift ] ] if-zero ] map
-    '[ [ _ spread ] [ bitor ] reduce-outputs ] ; inline
-
-MACRO: reassemble-be ( n -- quot ) be-range reassemble-bytes ;
-
-MACRO: reassemble-le ( n -- quot ) le-range reassemble-bytes ;
->>
-
-:: n-be> ( bytes n -- x )
-    bytes n check-length drop n firstn-unsafe n reassemble-be ; inline
-
-:: n-le> ( bytes n -- x )
-    bytes n check-length drop n firstn-unsafe n reassemble-le ; inline
-
-HINTS: n-be> { byte-array object } ;
-HINTS: n-le> { byte-array object } ;
-
-<PRIVATE
-: if-endian ( endian bytes-quot seq-quot -- )
-    [
-        compute-native-endianness =
-        [ dup byte-array? ] [ f ] if
-    ] 2dip if ; inline
-PRIVATE>
-
-: 2be> ( bytes -- x )
-    big-endian [ uint16_t deref ] [ 2 n-be> ] if-endian ;
-
-: 4be> ( bytes -- x )
-    big-endian [ uint32_t deref ] [ 4 n-be> ] if-endian ;
-
-: 8be> ( bytes -- x )
-    big-endian [ uint64_t deref ] [ 8 n-be> ] if-endian ;
-
-: be> ( bytes -- x )
-    dup length {
-        { 2 [ 2be> ] }
-        { 4 [ 4be> ] }
-        { 8 [ 8be> ] }
-        [ drop slow-be> ]
-    } case ;
-
-: signed-be> ( bytes -- x )
-    compute-native-endianness big-endian = [
-        dup byte-array? [
-            dup length {
-                { 2 [ int16_t deref ] }
-                { 4 [ int32_t deref ] }
-                { 8 [ int64_t deref ] }
-                [ drop slow-signed-be> ]
-            } case
-        ] [ slow-signed-be> ] if
-    ] [ slow-signed-be> ] if ;
-
-: 2le> ( bytes -- x )
-    little-endian [ uint16_t deref ] [ 2 n-le> ] if-endian ;
-
-: 4le> ( bytes -- x )
-    little-endian [ uint32_t deref ] [ 4 n-le> ] if-endian ;
-
-: 8le> ( bytes -- x )
-    little-endian [ uint64_t deref ] [ 8 n-le> ] if-endian ;
-
-: le> ( bytes -- x )
-    dup length {
-        { 2 [ 2le> ] }
-        { 4 [ 4le> ] }
-        { 8 [ 8le> ] }
-        [ drop slow-le> ]
-    } case ;
-
-: signed-le> ( bytes -- x )
-    compute-native-endianness little-endian = [
-        dup byte-array? [
-            dup length {
-                { 2 [ int16_t deref ] }
-                { 4 [ int32_t deref ] }
-                { 8 [ int64_t deref ] }
-                [ drop slow-signed-le> ]
-            } case
-        ] [ slow-signed-le> ] if
-    ] [ slow-signed-le> ] if ;
-
-: >le ( x n -- bytes )
-    compute-native-endianness little-endian = [
-        {
-            { 2 [ int16_t <ref> ] }
-            { 4 [ int32_t <ref> ] }
-            { 8 [ int64_t <ref> ] }
-            [ >slow-le ]
-        } case
-    ] [ >slow-le ] if ;
-
-: >be ( x n -- bytes )
-    compute-native-endianness big-endian = [
-        {
-            { 2 [ int16_t <ref> ] }
-            { 4 [ int32_t <ref> ] }
-            { 8 [ int64_t <ref> ] }
-            [ >slow-be ]
-        } case
-    ] [ >slow-be ] if ;
index 75a1f0e7178679e14d587765ba2a1275a1fa7cf9..eb662315eef7b10110d6c29c341c3c8908fc977f 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors timers bit-arrays calendar game.input io
-io.binary io.encodings.binary io.files kernel literals math
-namespaces system threads ;
+USING: accessors timers bit-arrays calendar endian game.input io
+io.encodings.binary io.files kernel literals math namespaces
+system threads ;
 IN: key-logger
 
 CONSTANT: frequency $[ 1/30 seconds ]
index b7d60d7fbcffb57c2d8772548a50c397f7c16f0b..888e6c3b89c1fa433ad5075a096924aaf4ae0a45 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Erik Charlebois.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.libraries
-alien.syntax classes.struct combinators endian io.binary
+alien.syntax classes.struct combinators endian
 kernel locals math sequences specialized-arrays
 system unix.time unix.types ;
 FROM: alien.c-types => short ;
index 83064ae9232e32b45978eadcb6df932645ae36ec..f404317123fcc93e04e37b31b631ee51e192dcef 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors alien alien.c-types alien.data alien.strings
 alien.syntax classes classes.struct combinators
 combinators.short-circuit io.encodings.ascii io.encodings.string
 kernel literals make math sequences specialized-arrays typed
-fry io.mmap formatting locals splitting io.binary arrays ;
+fry io.mmap formatting locals splitting endian arrays ;
 FROM: alien.c-types => short ;
 IN: macho
 
index 4a199111eed094051c2f15a5ca35d0b16cfc4cf9..adc5cf76930b7dc4199839f7b1d044530dff0e41 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2015 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors assocs byte-arrays combinators fry io io.binary
+USING: accessors assocs byte-arrays combinators endian fry io
 io.encodings.binary io.encodings.string io.encodings.utf8
 io.files io.streams.byte-array io.streams.peek kernel literals
 make math sequences sequences.generalizations ;
index 7aaea3d6af37c48ce00d3dc30a1823f05e012dfb..8e5fe548e4d72866e9270bd0502ded3394d79a86 100644 (file)
@@ -1,7 +1,9 @@
 USING: accessors assocs bson.reader bson.writer byte-arrays
-byte-vectors combinators formatting fry io io.binary io.encodings.private
-io.encodings.binary io.encodings.string io.encodings.utf8 io.encodings.utf8.private io.files
-kernel locals math mongodb.msg namespaces sequences uuid bson.writer.private ;
+byte-vectors combinators formatting endian fry io
+io.encodings.private io.encodings.binary io.encodings.string
+io.encodings.utf8 io.encodings.utf8.private io.files kernel
+locals math mongodb.msg namespaces sequences uuid
+bson.writer.private ;
 
 FROM: mongodb.connection => connection-buffer ;
 FROM: alien => byte-length ;
index cebd82aeb87e41c7c8c69ffb2873844e16af18fc..ae9a8eb639d955d03f26a9af0265a16c36dbadcd 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2019 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs combinators
-combinators.short-circuit continuations destructors fry io
-io.binary io.directories io.encodings.binary io.encodings.latin1
+combinators.short-circuit continuations destructors endian fry
+io io.directories io.encodings.binary io.encodings.latin1
 io.encodings.string io.encodings.utf8 io.files io.files.info
 io.sockets kernel math math.parser namespaces pack prettyprint
 random sequences sequences.extras splitting strings ;
index 62a2ab59a2d156bd180d839e5f5496112febd867..de5b3ae11c24d39bf7f5ac02f38cc147c9752653 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2018 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors byte-arrays classes combinators io
-io.binary.fast io.encodings.binary io.files
-io.streams.byte-array kernel locals math math.order
-math.statistics sequences sequences.extras sets ;
+USING: accessors byte-arrays classes combinators endian io
+io.encodings.binary io.files io.streams.byte-array kernel locals
+math math.order math.statistics sequences sequences.extras sets
 
 IN: shapefiles
 
index f2c6ff57d1c7865d8e372c7f2181dc728e3af25b..f756ab9b1b593b8ad70743e9f1e39717fc406308 100644 (file)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2013 John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license.
 
-USING: accessors assocs combinators formatting fry grouping hashtables
-io io.binary io.directories io.encodings.binary io.files
-io.files.types io.pathnames kernel math math.parser memoize pack
-sequences sequences.generalizations splitting strings system ;
+USING: accessors assocs combinators formatting endian fry
+grouping hashtables io io.directories io.encodings.binary
+io.files io.files.types io.pathnames kernel math math.parser
+memoize pack sequences sequences.generalizations splitting
+strings system ;
 
 IN: terminfo
 
index 95f41a81ce51cacabaff37e982e44410901c6df2..9407b937f8034b6bd1cf985f1178c18c6b609005 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2021 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors colors combinators generalizations io io.binary
+USING: accessors colors combinators endian generalizations io
 io.encodings.binary io.files io.streams.byte-array kernel math
 math.bitwise namespaces sequences ;
 
index 28c172263ea35dcea30110a683c33203dabf7494..ab5c2efee44f05885a11d6ea8fc1db81af8c65ec 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2018, 2020 Alexander Ilin.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: base32 calendar checksums.hmac checksums.sha io.binary
+USING: base32 calendar checksums.hmac checksums.sha endian
 kernel math math.bitwise math.parser namespaces sequences
 strings unicode ;
 IN: totp
index 998353eab4bccb8e85a8a25179a0ca83342013c0..84a62e8d4fa200b7ce724df40e68f5f9792c4587 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license
 
 USING: accessors alien.c-types alien.data alien.endian arrays
-assocs calendar classes.struct combinators hashtables io
-io.binary io.encodings.binary io.files kernel locals math
-math.order sequences strings ;
+assocs calendar classes.struct combinators endian hashtables io
+io.encodings.binary io.files kernel locals math math.order
+sequences strings ;
 
 IN: tzinfo
 
index a30e734e9766c48b580d43458d4cae6d8936d8a5..cd4ff69e1da8d5819f9a7dbf182cc5363cb2e3cf 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2019 Alexander Ilin.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors io.binary kernel math namespaces sequences
+USING: accessors endian kernel math namespaces sequences
 strings tools.test ulid ulid.private ;
 IN: ulid.tests
 
index d9f82d07990907971d4d0b6920e201eaff0b69d9..28ad1ac6c710e1cf87fba82babfdf055191187a2 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2018, 2019 Alexander Ilin.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: ascii binary-search calendar io.binary kernel make math
+USING: ascii binary-search calendar endian kernel make math
 math.bitwise math.order namespaces random sequences splitting
 summary system tr ;
 
index dec93893d68538bf1eb280a37937ae162c9db4e0..ff06dcade5fd1043ce06c8b66672b8a860ad2cd8 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data classes.struct
-io.binary kernel literals locals make math math.bitwise
+endian kernel literals locals make math math.bitwise
 sequences slots.syntax ui.backend.windows ui.gadgets.worlds
 windows.errors windows.gdi32 windows.shcore windows.types
 windows.user32 ;
@@ -143,4 +143,4 @@ ERROR: unsupported-resolution triple ;
 
 : get-desktop-scale-factor ( -- n )
     desktop-hmonitor 0 DEVICE_SCALE_FACTOR <ref>
-    [ GetScaleFactorForMonitor win32-error=0/f ] keep le> ;
\ No newline at end of file
+    [ GetScaleFactorForMonitor win32-error=0/f ] keep le> ;
index cda71866d5a60f8deb577ec54b71ed15c5043149..70b2d3d32000daaeda6f9a3fdcdfdd53793cf6d6 100644 (file)
@@ -1,6 +1,6 @@
 USING:
     alien alien.data alien.libraries alien.syntax
-    destructors formatting io.binary kernel libc locals
+    destructors endian formatting kernel libc locals
     math math.bitwise
     sequences windows.types
 ;