Remove unnecessary prettyprinter and debugger dependencies from UI
parent
e6ec0ff930
commit
f8bce98850
|
@ -0,0 +1,37 @@
|
|||
USING: arrays byte-arrays help.markup help.syntax kernel
|
||||
byte-vectors.private combinators ;
|
||||
IN: byte-vectors
|
||||
|
||||
ARTICLE: "byte-vectors" "Byte vectors"
|
||||
"A byte vector is a resizable mutable sequence of unsigned bytes. Byte vector words are found in the " { $vocab-link "byte-vectors" } " vocabulary."
|
||||
$nl
|
||||
"Byte vectors form a class:"
|
||||
{ $subsection byte-vector }
|
||||
{ $subsection byte-vector? }
|
||||
"Creating byte vectors:"
|
||||
{ $subsection >byte-vector }
|
||||
{ $subsection <byte-vector> }
|
||||
"Literal syntax:"
|
||||
{ $subsection POSTPONE: BV{ }
|
||||
"If you don't care about initial capacity, a more elegant way to create a new byte vector is to write:"
|
||||
{ $code "BV{ } clone" } ;
|
||||
|
||||
ABOUT: "byte-vectors"
|
||||
|
||||
HELP: byte-vector
|
||||
{ $description "The class of resizable byte vectors. See " { $link "byte-vectors" } " for information." } ;
|
||||
|
||||
HELP: <byte-vector>
|
||||
{ $values { "n" "a positive integer specifying initial capacity" } { "byte-vector" byte-vector } }
|
||||
{ $description "Creates a new byte vector that can hold " { $snippet "n" } " bytes before resizing." } ;
|
||||
|
||||
HELP: >byte-vector
|
||||
{ $values { "seq" "a sequence" } { "byte-vector" byte-vector } }
|
||||
{ $description "Outputs a freshly-allocated byte vector with the same elements as a given sequence." }
|
||||
{ $errors "Throws an error if the sequence contains elements other than integers." } ;
|
||||
|
||||
HELP: BV{
|
||||
{ $syntax "BV{ elements... }" }
|
||||
{ $values { "elements" "a list of bytes" } }
|
||||
{ $description "Marks the beginning of a literal byte vector. Literal byte vectors are terminated by " { $link POSTPONE: } } "." }
|
||||
{ $examples { $code "BV{ 1 2 3 12 }" } } ;
|
|
@ -0,0 +1,17 @@
|
|||
IN: byte-vectors.tests
|
||||
USING: tools.test byte-vectors vectors sequences kernel
|
||||
prettyprint ;
|
||||
|
||||
[ 0 ] [ 123 <byte-vector> length ] unit-test
|
||||
|
||||
: do-it
|
||||
123 [ over push ] each ;
|
||||
|
||||
[ t ] [
|
||||
3 <byte-vector> do-it
|
||||
3 <vector> do-it sequence=
|
||||
] unit-test
|
||||
|
||||
[ t ] [ BV{ } byte-vector? ] unit-test
|
||||
|
||||
[ "BV{ }" ] [ BV{ } unparse ] unit-test
|
|
@ -0,0 +1,51 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays kernel kernel.private math sequences
|
||||
sequences.private growable byte-arrays accessors parser
|
||||
prettyprint.backend ;
|
||||
IN: byte-vectors
|
||||
|
||||
TUPLE: byte-vector
|
||||
{ underlying byte-array }
|
||||
{ length array-capacity } ;
|
||||
|
||||
: <byte-vector> ( n -- byte-vector )
|
||||
<byte-array> 0 byte-vector boa ; inline
|
||||
|
||||
: >byte-vector ( seq -- byte-vector )
|
||||
T{ byte-vector f B{ } 0 } clone-like ;
|
||||
|
||||
M: byte-vector like
|
||||
drop dup byte-vector? [
|
||||
dup byte-array?
|
||||
[ dup length byte-vector boa ] [ >byte-vector ] if
|
||||
] unless ;
|
||||
|
||||
M: byte-vector new-sequence
|
||||
drop [ <byte-array> ] [ >fixnum ] bi byte-vector boa ;
|
||||
|
||||
M: byte-vector equal?
|
||||
over byte-vector? [ sequence= ] [ 2drop f ] if ;
|
||||
|
||||
M: byte-array like
|
||||
#! If we have an byte-array, we're done.
|
||||
#! If we have a byte-vector, and it's at full capacity,
|
||||
#! we're done. Otherwise, call resize-byte-array, which is a
|
||||
#! relatively fast primitive.
|
||||
drop dup byte-array? [
|
||||
dup byte-vector? [
|
||||
[ length ] [ underlying>> ] bi
|
||||
2dup length eq?
|
||||
[ nip ] [ resize-byte-array ] if
|
||||
] [ >byte-array ] if
|
||||
] unless ;
|
||||
|
||||
M: byte-array new-resizable drop <byte-vector> ;
|
||||
|
||||
: BV{ \ } [ >byte-vector ] parse-literal ; parsing
|
||||
|
||||
M: byte-vector pprint* pprint-object ;
|
||||
M: byte-vector pprint-delims drop \ BV{ \ } ;
|
||||
M: byte-vector >pprint-sequence ;
|
||||
|
||||
INSTANCE: byte-vector growable
|
|
@ -0,0 +1 @@
|
|||
Growable byte arrays
|
|
@ -0,0 +1 @@
|
|||
collections
|
|
@ -0,0 +1,34 @@
|
|||
USING: help.syntax help.markup io byte-arrays quotations ;
|
||||
IN: io.streams.byte-array
|
||||
|
||||
ABOUT: "io.streams.byte-array"
|
||||
|
||||
ARTICLE: "io.streams.byte-array" "Byte-array streams"
|
||||
"Byte array streams:"
|
||||
{ $subsection <byte-reader> }
|
||||
{ $subsection <byte-writer> }
|
||||
"Utility combinators:"
|
||||
{ $subsection with-byte-reader }
|
||||
{ $subsection with-byte-writer } ;
|
||||
|
||||
HELP: <byte-reader>
|
||||
{ $values { "byte-array" byte-array }
|
||||
{ "encoding" "an encoding descriptor" }
|
||||
{ "stream" "a new byte reader" } }
|
||||
{ $description "Creates an input stream reading from a byte array using an encoding." } ;
|
||||
|
||||
HELP: <byte-writer>
|
||||
{ $values { "encoding" "an encoding descriptor" }
|
||||
{ "stream" "a new byte writer" } }
|
||||
{ $description "Creates an output stream writing data to a byte array using an encoding." } ;
|
||||
|
||||
HELP: with-byte-reader
|
||||
{ $values { "encoding" "an encoding descriptor" }
|
||||
{ "quot" quotation } { "byte-array" byte-array } }
|
||||
{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream for reading from a byte array using an encoding." } ;
|
||||
|
||||
HELP: with-byte-writer
|
||||
{ $values { "encoding" "an encoding descriptor" }
|
||||
{ "quot" quotation }
|
||||
{ "byte-array" byte-array } }
|
||||
{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to an output stream writing data to a byte array using an encoding." } ;
|
|
@ -0,0 +1,9 @@
|
|||
USING: tools.test io.streams.byte-array io.encodings.binary
|
||||
io.encodings.utf8 io kernel arrays strings ;
|
||||
|
||||
[ B{ 1 2 3 } ] [ binary [ { 1 2 3 } write ] with-byte-writer ] unit-test
|
||||
[ B{ 1 2 3 } ] [ { 1 2 3 } binary [ 3 read ] with-byte-reader ] unit-test
|
||||
|
||||
[ B{ BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 BIN: 11101111 BIN: 10000000 BIN: 10111111 BIN: 11011111 BIN: 10000000 CHAR: x } ]
|
||||
[ { BIN: 101111111000000111111 BIN: 1111000000111111 BIN: 11111000000 CHAR: x } utf8 [ write ] with-byte-writer ] unit-test
|
||||
[ { BIN: 101111111000000111111 } t ] [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 } utf8 <byte-reader> contents dup >array swap string? ] unit-test
|
|
@ -0,0 +1,16 @@
|
|||
USING: byte-arrays byte-vectors kernel io.encodings io.streams.string
|
||||
sequences io namespaces io.encodings.private accessors ;
|
||||
IN: io.streams.byte-array
|
||||
|
||||
: <byte-writer> ( encoding -- stream )
|
||||
512 <byte-vector> swap <encoder> ;
|
||||
|
||||
: with-byte-writer ( encoding quot -- byte-array )
|
||||
[ <byte-writer> ] dip [ output-stream get ] compose with-output-stream*
|
||||
dup encoder? [ stream>> ] when >byte-array ; inline
|
||||
|
||||
: <byte-reader> ( byte-array encoding -- stream )
|
||||
[ >byte-vector dup reverse-here ] dip <decoder> ;
|
||||
|
||||
: with-byte-reader ( byte-array encoding quot -- )
|
||||
[ <byte-reader> ] dip with-input-stream* ; inline
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.accessors alien.c-types arrays io kernel libc
|
||||
math math.vectors namespaces opengl opengl.gl prettyprint assocs
|
||||
math math.vectors namespaces opengl opengl.gl assocs
|
||||
sequences io.files io.styles continuations freetype
|
||||
ui.gadgets.worlds ui.render ui.backend byte-arrays accessors
|
||||
locals specialized-arrays.direct.uchar ;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: arrays ui.gadgets.buttons ui.gadgets.borders
|
||||
ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers
|
||||
ui.gadgets.tracks ui.gadgets.theme ui.gadgets.frames
|
||||
ui.gadgets.grids io kernel math models namespaces prettyprint
|
||||
ui.gadgets.grids io kernel math models namespaces
|
||||
sequences sequences words classes.tuple ui.gadgets ui.render
|
||||
colors accessors ;
|
||||
IN: ui.gadgets.labelled
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays accessors definitions hashtables io kernel
|
||||
prettyprint sequences strings io.styles words help math models
|
||||
sequences strings io.styles words help math models
|
||||
namespaces quotations
|
||||
ui.gadgets ui.gadgets.borders ui.gadgets.buttons
|
||||
ui.gadgets.labels ui.gadgets.menus ui.gadgets.worlds
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: accessors arrays assocs continuations kernel math models
|
||||
namespaces opengl sequences io combinators fry math.vectors
|
||||
ui.gadgets ui.gestures ui.render ui.backend ui.gadgets.tracks
|
||||
debugger math.geometry.rect ;
|
||||
math.geometry.rect ;
|
||||
IN: ui.gadgets.worlds
|
||||
|
||||
TUPLE: world < track
|
||||
|
@ -76,7 +76,7 @@ C: <world-error> world-error
|
|||
SYMBOL: ui-error-hook
|
||||
|
||||
: ui-error ( error -- )
|
||||
ui-error-hook get [ call ] [ print-error ] if* ;
|
||||
ui-error-hook get [ call ] [ die ] if* ;
|
||||
|
||||
ui-error-hook global [ [ rethrow ] or ] change-at
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
! Copyright (C) 2006, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays assocs io kernel math models namespaces make
|
||||
prettyprint dlists deques sequences threads sequences words
|
||||
debugger ui.gadgets ui.gadgets.worlds ui.gadgets.tracks
|
||||
ui.gestures ui.backend ui.render continuations init combinators
|
||||
hashtables concurrency.flags sets accessors calendar ;
|
||||
dlists deques sequences threads sequences words ui.gadgets
|
||||
ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend
|
||||
ui.render continuations init combinators hashtables
|
||||
concurrency.flags sets accessors calendar ;
|
||||
IN: ui
|
||||
|
||||
! Assoc mapping aliens to gadgets
|
||||
|
|
|
@ -5,7 +5,7 @@ ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render
|
|||
assocs kernel math namespaces opengl sequences strings x11.xlib
|
||||
x11.events x11.xim x11.glx x11.clipboard x11.constants
|
||||
x11.windows io.encodings.string io.encodings.ascii
|
||||
io.encodings.utf8 combinators debugger command-line qualified
|
||||
io.encodings.utf8 combinators command-line qualified
|
||||
math.vectors classes.tuple opengl.gl threads math.geometry.rect
|
||||
environment ascii ;
|
||||
IN: ui.x11
|
||||
|
|
Loading…
Reference in New Issue