Convert all uses of (integer-in 0 255) to `byte?'.

This commit is contained in:
Eli Barzilay 2012-07-22 12:59:52 -04:00
parent a6b20f01da
commit 18883681a2
14 changed files with 168 additions and 293 deletions

View File

@ -812,7 +812,7 @@ TODO
(user-break-parameterization #f)
(user-logger (make-logger))
;; user-exit-code (union #f (integer-in 0 255))
;; user-exit-code (union #f byte?)
;; #f indicates that exit wasn't called. Integer indicates exit code
(user-exit-code #f))

View File

@ -106,7 +106,6 @@
;; The maximum level height of an octree.
(define MAX-LEVEL 7)
(define byte/c (integer-in 0 255))
(define octet/c (integer-in 0 7))
@ -129,7 +128,7 @@
bluesum ; number
children ; (vectorof (or/c #f node))
next ; (or/c #f node)
palette-index) ; (or/c #f (integer-in 0 255))
palette-index) ; (or/c #f byte?)
#:mutable)
;; node-next is used to accelerate the search for a reduction candidate.
@ -355,7 +354,7 @@
([root node?]
[leaf-count natural-number/c]
[reduction-heads (vectorof (or/c node? false/c))]
[palette (vectorof (vector/c byte/c byte/c byte/c))])]
[palette (vectorof (vector/c byte? byte? byte?))])]
[struct node
([leaf? boolean?]
[npixels natural-number/c]
@ -364,11 +363,11 @@
[bluesum natural-number/c]
[children (vectorof (or/c false/c node?))]
[next (or/c node? false/c)]
[palette-index byte/c])]
[palette-index byte?])]
[new-octree (-> octree?)]
[octree-insert-color! (octree? byte/c byte/c byte/c . -> . any)]
[octree-insert-color! (octree? byte? byte? byte? . -> . any)]
[octree-lookup
(octree? byte/c byte/c byte/c . -> . (values byte/c byte/c byte/c))]
(octree? byte? byte? byte? . -> . (values byte? byte? byte?))]
[octree-reduce! (octree? . -> . any)]
[octree-finalize! (octree? . -> . any)]
[rgb->index (natural-number/c byte/c byte/c byte/c . -> . octet/c)])
[rgb->index (natural-number/c byte? byte? byte? . -> . octet/c)])

View File

@ -843,7 +843,7 @@ for b3, we have:
[argb->bitmap (argb? . -> . (or/c #f (is-a?/c bitmap%)))]
[argb? (any/c . -> . boolean?)]
[make-argb ((vectorof (integer-in 0 255)) exact-nonnegative-integer? exact-nonnegative-integer? . -> . argb?)]
[argb-vector (argb? . -> . (vectorof (integer-in 0 255)))]
[make-argb ((vectorof byte?) exact-nonnegative-integer? exact-nonnegative-integer? . -> . argb?)]
[argb-vector (argb? . -> . (vectorof byte?))]
[argb-width (argb? . -> . exact-nonnegative-integer?)]
[argb-height (argb? . -> . exact-nonnegative-integer?)])

View File

@ -107,23 +107,23 @@ exactly match alpha channels.}}
This snipclass is used for saved cache image snips.}
@defproc[(make-argb [vectorof (integer-in 0 255)]
@defproc[(make-argb [vectorof byte?]
[width exact-nonnegative-integer?]
[height exact-nonnegative-integer?])
argb?]{
Constructs a new argb value with the given width and height,
using the data in the vector. The vector has four entries
for each pixel, an alpha, red, green, and blue value.
The pixels are specified in row-major order, so that the
for each pixel, an alpha, red, green, and blue value.
The pixels are specified in row-major order, so that the
pixel at location (x,y) comes from vector entry (4*(x+(width*y))).
}
@defproc[(argb-vector [argb argb?]) (vectorof (integer-in 0 255))]{
@defproc[(argb-vector [argb argb?]) (vectorof byte?)]{
Extracts the vector from @racket[argb]. The resulting vector
has entries in row-major order, so that the data for the pixel
at (x,y) winds up in four vector entries beginning at
at (x,y) winds up in four vector entries beginning at
(4*(x+(width*y))).}
@defproc[(argb-width [argb argb?]) exact-nonnegative-integer?]{

View File

@ -57,9 +57,7 @@
real? real? real? real? real?))
(define make-color/c
(->* ((integer-in 0 255)
(integer-in 0 255)
(integer-in 0 255))
(->* (byte? byte? byte?)
((real-in 0 1))
(is-a?/c color%)))
@ -89,9 +87,9 @@
(define color%/c
(class/c
(alpha (->m (real-in 0 1)))
(red (->m (integer-in 0 255)))
(blue (->m (integer-in 0 255)))
(green (->m (integer-in 0 255)))
(red (->m byte?))
(blue (->m byte?))
(green (->m byte?))
(copy-from (->m (is-a?/c color%) (is-a?/c color%)))
(ok? (->m boolean?))
(set (->*m (byte? byte? byte?)
@ -132,10 +130,7 @@
(set-cap (->m pen-cap-style/c void?))
(set-color (case->m
(-> (or/c (is-a?/c color%) string?) void?)
(-> (integer-in 0 255)
(integer-in 0 255)
(integer-in 0 255)
void?)))
(-> byte? byte? byte? void?)))
(set-join (->m pen-join-style/c void?))
(set-stipple (->m (or/c (is-a?/c bitmap%) #f) void?))
(set-style (->m pen-style/c void?))
@ -158,10 +153,7 @@
(get-style (->m brush-style/c))
(set-color (case->m
(-> (or/c (is-a?/c color%) string?) void?)
(-> (integer-in 0 255)
(integer-in 0 255)
(integer-in 0 255)
void?)))
(-> byte? byte? byte? void?)))
(set-stipple (->*m ((or/c (is-a?/c bitmap%) #f))
((or/c transformation-vector/c #f))
void?))

View File

@ -70,7 +70,7 @@
(get-family (->m font-family/c))
(get-foreground-add (->m (is-a?/c add-color<%>)))
(get-foreground-mult (->m (is-a?/c mult-color<%>)))
(get-size-add (->m (integer-in 0 255)))
(get-size-add (->m byte?))
(get-size-in-pixels-off (->m boolean?))
(get-size-in-pixels-on (->m boolean?))
(get-size-mult (->m real?))
@ -117,7 +117,7 @@
(is-a?/c style-delta%)))
(set-face (->m (or/c string? false/c) void?))
(set-family (->m font-family/c void?))
(set-size-add (->m (integer-in 0 255) void?))
(set-size-add (->m byte? void?))
(set-size-in-pixels-off (->m any/c void?))
(set-size-in-pixels-on (->m any/c void?))
(set-size-mult (->m real? void?))

View File

@ -177,9 +177,7 @@ Returns @racket[#t] if the brush object is immutable.
void?]
[(set-color [color-name string?])
void?]
[(set-color [red (integer-in 0 255)]
[green (integer-in 0 255)]
[blue (integer-in 0 255)])
[(set-color [red byte?] [green byte?] [blue byte?])
void?])]{
Sets the brush's color. A brush cannot be modified if it was obtained

View File

@ -16,9 +16,7 @@ object using a color name, and see also @racket[make-color].
@defconstructor*/make[(()
([red (integer-in 0 255)]
[green (integer-in 0 255)]
[blue (integer-in 0 255)]
([red byte?] [green byte?] [blue byte?]
[alpha (real-in 0 1) 1.0])
([color-name string?]))]{
@ -29,62 +27,31 @@ Creates a new color with the given RGB values and alpha, or matching
}
@defmethod[(alpha)
(real-in 0 1)]{
@defmethod[(copy-from [src (is-a?/c color%)]) (is-a?/c color%)]{
Copies the RGB values of another color object to this one, returning
this object as the result.}
Returns the alpha component (i.e., opacity) of the color.
@defmethod[(is-immutable?) boolean?]{
Returns @racket[#t] if the color object is immutable.}
}
@defmethod[(ok?) boolean?]{
Returns @racket[#t] if the color object is valid.}
@defmethod[(blue)
(integer-in 0 255)]{
@defmethod[(red) byte?]{
Returns the red component of the color.}
Returns the blue component of the color.
@defmethod[(green) byte?]{
Returns the green component of the color.}
}
@defmethod[(blue) byte?]{
Returns the blue component of the color.}
@defmethod[(copy-from [src (is-a?/c color%)])
(is-a?/c color%)]{
@defmethod[(alpha) (real-in 0 1)]{
Returns the alpha component (i.e., opacity) of the color.}
Copies the RGB values of another color object to this one, returning
this object as the result.
}
@defmethod[(green)
(integer-in 0 255)]{
Returns the green component of the color.
}
@defmethod[(is-immutable?)
boolean?]{
Returns @racket[#t] if the color object is immutable.
}
@defmethod[(ok?)
boolean?]{
Returns @racket[#t] if the color object is valid.
}
@defmethod[(red)
(integer-in 0 255)]{
Returns the red component of the color.
}
@defmethod[(set [red (integer-in 0 255)]
[green (integer-in 0 255)]
[blue (integer-in 0 255)]
@defmethod[(set [red byte?] [green byte?] [blue byte?]
[alpha (real-in 0 1) 1.0])
void?]{
Sets the four (red, green, blue, and alpha) component values of the color.}
Sets the four (red, green, blue, and alpha) component values of the color.
}}
}

View File

@ -84,11 +84,8 @@ result brush is created via @method[brush-list% find-or-create-brush] of
@racket[the-brush-list].}
@defproc[(make-color
[red (integer-in 0 255)]
[green (integer-in 0 255)]
[blue (integer-in 0 255)]
[alpha (real-in 0 1) 1.0])
@defproc[(make-color [red byte?] [green byte?] [blue byte?]
[alpha (real-in 0 1) 1.0])
(is-a?/c color%)]{
Creates a @racket[color%] instance. This procedure provides a

View File

@ -244,9 +244,7 @@ A pen cannot be modified if it was obtained from a @racket[pen-list%]
void?]
[(set-color [color-name string?])
void?]
[(set-color [red (integer-in 0 255)]
[green (integer-in 0 255)]
[blue (integer-in 0 255)])
[(set-color [red byte?] [green byte?] [blue byte?])
void?])]{
Sets the pen color.

View File

@ -3,8 +3,8 @@
@defclass/title[style-delta% object% ()]{
A @racket[style-delta%] object encapsulates a style change. The changes expressible
by a delta include:
A @racket[style-delta%] object encapsulates a style change. The changes
expressible by a delta include:
@itemize[
@item{changing the font family}
@item{changing the font face}
@ -86,7 +86,8 @@ The possible values for @racket[underlined-on] and @racket[underlined-off] are:
@item{@racket[#t]}
]
The possible values for @racket[size-in-pixels-on] and @racket[size-in-pixels-off] are:
The possible values for @racket[size-in-pixels-on] and
@racket[size-in-pixels-off] are:
@itemize[
@item{@racket[#f] (acts like @racket['base])}
@item{@racket[#t]}
@ -127,35 +128,32 @@ The family and face settings in a style delta are interdependent:
]
@defconstructor*/make[(([change-command (or/c 'change-nothing
'change-normal
'change-toggle-underline
'change-toggle-size-in-pixels
'change-normal-color
'change-bold)
@defconstructor*/make[(([change-command (or/c 'change-nothing
'change-normal
'change-toggle-underline
'change-toggle-size-in-pixels
'change-normal-color
'change-bold)
'change-nothing])
([change-command (or/c 'change-family
'change-style
'change-toggle-style
'change-weight
'change-toggle-weight
'change-smoothing
([change-command (or/c 'change-family
'change-style
'change-toggle-style
'change-weight
'change-toggle-weight
'change-smoothing
'change-toggle-smoothing
'change-alignment)]
[v symbol])
([change-command (or/c 'change-size
'change-bigger
([change-command (or/c 'change-size
'change-bigger
'change-smaller)]
[v (integer-in 0 255)])
([change-command (or/c 'change-underline
[v byte?])
([change-command (or/c 'change-underline
'change-size-in-pixels)]
[v any/c]))]{
The initialization arguments are passed on to
The initialization arguments are passed on to
@method[style-delta% set-delta].
}
@ -170,37 +168,20 @@ Tries to collapse into a single delta the changes that would be made
}
@defmethod[(copy [delta (is-a?/c style-delta%)])
void?]{
@defmethod[(copy [delta (is-a?/c style-delta%)]) void?]{
Copies the given style delta's settings into this one.}
Copies the given style delta's settings into this one.
@defmethod[(equal? [delta (is-a?/c style-delta%)]) boolean?]{
Returns @racket[#t] if the given delta is equivalent to this one in
all contexts or @racket[#f] otherwise.}
}
@defmethod[(get-alignment-off) (or/c 'base 'top 'center 'bottom)]{
See @racket[style-delta%].}
@defmethod[(equal? [delta (is-a?/c style-delta%)])
boolean?]{
@defmethod[(get-alignment-on) (or/c 'base 'top 'center 'bottom)]{
See @racket[style-delta%].}
Returns @racket[#t] if the given delta is equivalent to this one in
all contexts or @racket[#f] otherwise.
}
@defmethod[(get-alignment-off)
(or/c 'base 'top 'center 'bottom)]{
See @racket[style-delta%].
}
@defmethod[(get-alignment-on)
(or/c 'base 'top 'center 'bottom)]{
See @racket[style-delta%].
}
@defmethod[(get-background-add)
(is-a?/c add-color<%>)]{
@defmethod[(get-background-add) (is-a?/c add-color<%>)]{
Gets the object additive color shift for the background (applied after
the multiplicative factor). Call this @racket[add-color<%>] object's
@ -248,13 +229,11 @@ Returns the delta's font family. The possible values are
@item{@indexed-racket['system] (used to draw control labels)}
]
See also
@method[style-delta% get-face].
See also @method[style-delta% get-face].
}
@defmethod[(get-foreground-add)
(is-a?/c add-color<%>)]{
@defmethod[(get-foreground-add) (is-a?/c add-color<%>)]{
Gets the additive color shift for the foreground (applied after the
multiplicative factor). Call this @racket[add-color<%>] object's
@ -272,120 +251,86 @@ Gets the multiplicative color shift for the foreground (applied before
}
@defmethod[(get-size-add)
(integer-in 0 255)]{
@defmethod[(get-size-add) byte?]{
Gets the additive font size shift (applied after the multiplicative factor).}
Gets the additive font size shift (applied after the multiplicative factor).
@defmethod[(get-size-in-pixels-off) boolean?]{
See @racket[style-delta%].}
}
@defmethod[(get-size-in-pixels-on) boolean?]{
See @racket[style-delta%].}
@defmethod[(get-size-in-pixels-off)
boolean?]{
See @racket[style-delta%].
}
@defmethod[(get-size-in-pixels-on)
boolean?]{
See @racket[style-delta%].
}
@defmethod[(get-size-mult)
real?]{
Gets the multiplicative font size shift (applied before the additive factor).
}
@defmethod[(get-size-mult) real?]{
Gets the multiplicative font size shift (applied before the additive factor).}
@defmethod[(get-smoothing-off)
(or/c 'base 'default 'partly-smoothed 'smoothed 'unsmoothed)]{
See @racket[style-delta%].
See @racket[style-delta%].
}
@defmethod[(get-smoothing-on)
(or/c 'base 'default 'partly-smoothed 'smoothed 'unsmoothed)]{See
@racket[style-delta%].
@racket[style-delta%].
}
@defmethod[(get-style-off)
(or/c 'base 'normal 'italic 'slant)]{See
@racket[style-delta%].
@racket[style-delta%].
}
@defmethod[(get-style-on)
(or/c 'base 'normal 'italic 'slant)]{See
@racket[style-delta%].
}
@defmethod[(get-style-on) (or/c 'base 'normal 'italic 'slant)]{
See @racket[style-delta%].}
@defmethod[(get-transparent-text-backing-off)
boolean?]{See
@racket[style-delta%].
}
@defmethod[(get-transparent-text-backing-off) boolean?]{
See @racket[style-delta%].}
@defmethod[(get-transparent-text-backing-on)
boolean?]{See
@racket[style-delta%].
}
@defmethod[(get-transparent-text-backing-on) boolean?]{
See @racket[style-delta%].}
@defmethod[(get-underlined-off)
boolean?]{See
@racket[style-delta%].
}
boolean?]{
See @racket[style-delta%].}
@defmethod[(get-underlined-on)
boolean?]{See
@racket[style-delta%].
}
boolean?]{
See @racket[style-delta%].}
@defmethod[(get-weight-off)
(or/c 'base 'normal 'bold 'light)]{See
@racket[style-delta%].
}
@defmethod[(get-weight-off) (or/c 'base 'normal 'bold 'light)]{
See @racket[style-delta%].}
@defmethod[(get-weight-on)
(or/c 'base 'normal 'bold 'light)]{See
@racket[style-delta%].
}
@defmethod[(get-weight-on) (or/c 'base 'normal 'bold 'light)]{
See @racket[style-delta%].}
@defmethod[(set-alignment-off [v (or/c 'base 'top 'center 'bottom)])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-alignment-off [v (or/c 'base 'top 'center 'bottom)]) void?]{
See @racket[style-delta%].}
@defmethod[(set-alignment-on [v (or/c 'base 'top 'center 'bottom)])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-alignment-on [v (or/c 'base 'top 'center 'bottom)]) void?]{
See @racket[style-delta%].}
@defmethod*[([(set-delta [change-command (or/c 'change-nothing
'change-normal
'change-toggle-underline
'change-toggle-size-in-pixels
'change-normal-color
'change-bold)
@defmethod*[([(set-delta [change-command (or/c 'change-nothing
'change-normal
'change-toggle-underline
'change-toggle-size-in-pixels
'change-normal-color
'change-bold)
'change-nothing])
(is-a?/c style-delta%)]
[(set-delta [change-command (or/c 'change-family
'change-style
'change-toggle-style
'change-weight
'change-toggle-weight
'change-smoothing
'change-toggle-smoothing
[(set-delta [change-command (or/c 'change-family
'change-style
'change-toggle-style
'change-weight
'change-toggle-weight
'change-smoothing
'change-toggle-smoothing
'change-alignment)]
[param symbol])
(is-a?/c style-delta%)]
[(set-delta [change-command (or/c 'change-size
'change-bigger
[(set-delta [change-command (or/c 'change-size
'change-bigger
'change-smaller)]
[param (integer-in 0 255)])
[param byte?])
(is-a?/c style-delta%)]
[(set-delta [change-command (or/c 'change-underline
[(set-delta [change-command (or/c 'change-underline
'change-size-in-pixels)]
[on? any/c])
(is-a?/c style-delta%)])]{
@ -455,7 +400,7 @@ For the case that a string color name is supplied, see
}
@defmethod[(set-delta-face [name string?]
[family (or/c 'base 'default 'decorative 'roman
[family (or/c 'base 'default 'decorative 'roman
'script 'swiss 'modern 'symbol 'system)
'default])
(is-a?/c style-delta%)]{
@ -493,7 +438,7 @@ For the case that a string color name is supplied, see
}
@defmethod[(set-family [v (or/c 'base 'default 'decorative 'roman 'script
@defmethod[(set-family [v (or/c 'base 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)])
void?]{
Sets the delta's font family. See
@ -501,72 +446,57 @@ Sets the delta's font family. See
}
@defmethod[(set-size-add [v (integer-in 0 255)])
void?]{Sets the additive font size shift (applied
after the multiplicative factor).
}
@defmethod[(set-size-add [v byte?]) void?]{
Sets the additive font size shift (applied
after the multiplicative factor).}
@defmethod[(set-size-in-pixels-off [v any/c])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-size-in-pixels-off [v any/c]) void?]{
See @racket[style-delta%].}
@defmethod[(set-size-in-pixels-on [v any/c])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-size-in-pixels-on [v any/c]) void?]{
See @racket[style-delta%].}
@defmethod[(set-size-mult [v real?])
void?]{Sets the multiplicative font size shift (applied
before the additive factor).
}
@defmethod[(set-size-mult [v real?]) void?]{
Sets the multiplicative font size shift (applied before the additive factor).}
@defmethod[(set-smoothing-off [v (or/c 'base 'default 'partly-smoothed 'smoothed 'unsmoothed)])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-smoothing-off [v (or/c 'base 'default 'partly-smoothed
'smoothed 'unsmoothed)])
void?]{
See @racket[style-delta%].}
@defmethod[(set-smoothing-on [v (or/c 'base 'default 'partly-smoothed 'smoothed 'unsmoothed)])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-smoothing-on [v (or/c 'base 'default 'partly-smoothed
'smoothed 'unsmoothed)])
void?]{
See @racket[style-delta%].}
@defmethod[(set-style-off [v (or/c 'base 'normal 'italic 'slant)])
void?]{See
@racket[style-delta%].
}
void?]{
See @racket[style-delta%].}
@defmethod[(set-style-on [v (or/c 'base 'normal 'italic 'slant)])
void?]{See
@racket[style-delta%].
}
void?]{
See @racket[style-delta%].}
@defmethod[(set-transparent-text-backing-off [v any/c])
void?]{See
@racket[style-delta%].
}
void?]{
See @racket[style-delta%].}
@defmethod[(set-transparent-text-backing-on [v any/c])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-transparent-text-backing-on [v any/c]) void?]{
See @racket[style-delta%].}
@defmethod[(set-underlined-off [v any/c])
void?]{See
@racket[style-delta%].
}
@defmethod[(set-underlined-off [v any/c]) void?]{
See @racket[style-delta%].}
@defmethod[(set-underlined-on [v any/c])
void?]{See
@racket[style-delta%].
}
void?]{
See @racket[style-delta%].}
@defmethod[(set-weight-off [v (or/c 'base 'normal 'bold 'light)])
void?]{See
@racket[style-delta%].
}
void?]{
See @racket[style-delta%].}
@defmethod[(set-weight-on [v (or/c 'base 'normal 'bold 'light)])
void?]{See
@racket[style-delta%].
}}
void?]{
See @racket[style-delta%].}
}

View File

@ -91,12 +91,8 @@ Returns the style's shift style if it is a join style. Otherwise, the
}
@defmethod[(get-size)
(integer-in 0 255)]{
Returns the style's font size.
}
@defmethod[(get-size) byte?]{
Returns the style's font size.}
@defmethod[(get-size-in-pixels)
boolean?]{

View File

@ -23,11 +23,11 @@ between @racket[1] and @racket[255] (which normally means
means ``success'').}
@defparam[executable-yield-handler proc ((integer-in 0 255) . -> . any)]{
@defparam[executable-yield-handler proc (byte? . -> . any)]{
A parameter that determines a procedure to be called as the Racket
process is about to exit normally. The procedure associated with this
parameter is not call when @racket[exit] (or, more precisely, the
parameter is not called when @racket[exit] (or, more precisely, the
default @tech{exit handler}) is used to exit early. The argument to
the handler is the status code that is returned to the system on exit.
The default executable-yield handler simply returns @|void-const|.

View File

@ -581,11 +581,9 @@ Selects a specific pen style for drawing, which applies to pen drawing
for @racket[pict] that does not already use a specific pen style.}
@defproc[(colorize [pict pict?] [color (or/c string?
(is-a?/c color%)
(list (integer-in 0 255)
(integer-in 0 255)
(integer-in 0 255)))])
@defproc[(colorize [pict pict?]
[color (or/c string? (is-a?/c color%)
(list byte? byte? byte?))])
pict?]{
Selects a specific color drawing, which applies to drawing in