updated many unions to or/c's

svn: r2061

original commit: fddb1fa862b6e0e8e71f011dcdda5309e64635e1
This commit is contained in:
Robby Findler 2006-01-31 19:17:33 +00:00
parent 7fbb670b32
commit 70a100e7f7
7 changed files with 86 additions and 87 deletions

View File

@ -228,7 +228,7 @@
"default preferences.") "default preferences.")
(preferences:add-panel (preferences:add-panel
((union string? (cons/c string? (listof string?))) ((or/c string? (cons/c string? (listof string?)))
((is-a?/c area-container-window<%>) ((is-a?/c area-container-window<%>)
. ->d . . ->d .
(λ (parent) (λ (parent)
@ -494,13 +494,13 @@
(opt-> (opt->
() ()
(string? (string?
(union false/c path?) (or/c false/c path?)
boolean? boolean?
string? string?
(union false/c byte-regexp?) (or/c false/c byte-regexp?)
string? string?
(union (is-a?/c top-level-window<%>) false/c)) (or/c (is-a?/c top-level-window<%>) false/c))
(union false/c path?)) (or/c false/c path?))
(() (()
((name "Untitled") ((name "Untitled")
(directory #f) (directory #f)
@ -518,12 +518,12 @@
(finder:common-get-file (finder:common-get-file
(opt-> (opt->
() ()
((union path? false/c) ((or/c path? false/c)
string? string?
(union byte-regexp? false/c) (or/c byte-regexp? false/c)
string? string?
(union false/c (is-a?/c top-level-window<%>))) (or/c false/c (is-a?/c top-level-window<%>)))
(union path? false/c)) (or/c path? false/c))
(() (()
((directory #f) ((directory #f)
(prompt "Select File") (prompt "Select File")
@ -540,13 +540,13 @@
(opt-> (opt->
() ()
(string? (string?
(union false/c path?) (or/c false/c path?)
boolean? boolean?
string? string?
(union false/c byte-regexp?) (or/c false/c byte-regexp?)
string? string?
(union (is-a?/c top-level-window<%>) false/c)) (or/c (is-a?/c top-level-window<%>) false/c))
(union false/c path?)) (or/c false/c path?))
(() (()
((name "Untitled") ((name "Untitled")
(directory #f) (directory #f)
@ -564,12 +564,12 @@
(finder:std-get-file (finder:std-get-file
(opt-> (opt->
() ()
((union path? false/c) ((or/c path? false/c)
string? string?
(union byte-regexp? false/c) (or/c byte-regexp? false/c)
string? string?
(union false/c (is-a?/c top-level-window<%>))) (or/c false/c (is-a?/c top-level-window<%>)))
(union path? false/c)) (or/c path? false/c))
(() (()
((directory #f) ((directory #f)
(prompt "Select File") (prompt "Select File")
@ -586,13 +586,13 @@
(opt-> (opt->
() ()
(string? (string?
(union false/c path?) (or/c false/c path?)
boolean? boolean?
string? string?
(union false/c byte-regexp?) (or/c false/c byte-regexp?)
string? string?
(union (is-a?/c top-level-window<%>) false/c)) (or/c (is-a?/c top-level-window<%>) false/c))
(union false/c path?)) (or/c false/c path?))
(() (()
((name "Untitled") ((name "Untitled")
(directory #f) (directory #f)
@ -614,12 +614,12 @@
(finder:get-file (finder:get-file
(opt-> (opt->
() ()
((union path? false/c) ((or/c path? false/c)
string? string?
(union byte-regexp? string? false/c) (or/c byte-regexp? string? false/c)
string? string?
(union false/c (is-a?/c top-level-window<%>))) (or/c false/c (is-a?/c top-level-window<%>)))
(union path? false/c)) (or/c path? false/c))
(() (()
((directory #f) ((directory #f)
(prompt "Select File") (prompt "Select File")
@ -639,12 +639,12 @@
(finder:common-get-file-list (finder:common-get-file-list
(opt-> (opt->
() ()
((union false/c path?) ((or/c false/c path?)
string? string?
(union false/c byte-regexp?) (or/c false/c byte-regexp?)
string? string?
(union false/c (is-a?/c top-level-window<%>))) (or/c false/c (is-a?/c top-level-window<%>)))
(union (listof path?) false/c)) (or/c (listof path?) false/c))
(() (()
((directory #f) ((directory #f)
(prompt "Select File") (prompt "Select File")
@ -699,7 +699,7 @@
(handler) (handler)
"Extracts the name from a handler.") "Extracts the name from a handler.")
(handler:handler-extension (handler:handler-extension
(handler:handler? . -> . (union (path? . -> . boolean?) (listof string?))) (handler:handler? . -> . (or/c (path? . -> . boolean?) (listof string?)))
(handler) (handler)
"Extracts the extension from a handler.") "Extracts the extension from a handler.")
(handler:handler-handler (handler:handler-handler
@ -708,8 +708,8 @@
"Extracs the handler's handling function") "Extracs the handler's handling function")
(handler:insert-format-handler (handler:insert-format-handler
(string? (string?
(union string? (listof string?) (path? . -> . boolean?)) (or/c string? (listof string?) (path? . -> . boolean?))
(path? . -> . (union false/c (is-a?/c frame:editor<%>))) (path? . -> . (or/c false/c (is-a?/c frame:editor<%>)))
. -> . . -> .
void?) void?)
(name pred handler) (name pred handler)
@ -744,9 +744,9 @@
(handler:edit-file (handler:edit-file
(opt-> (opt->
((union path? false/c)) ((or/c path? false/c))
((-> (is-a?/c frame:editor<%>))) ((-> (is-a?/c frame:editor<%>)))
(union false/c (is-a?/c frame:editor<%>))) (or/c false/c (is-a?/c frame:editor<%>)))
((filename) ((filename)
((make-default (λ () ((handler:current-create-new-window) filename))))) ((make-default (λ () ((handler:current-create-new-window) filename)))))
"This function creates a frame or re-uses an existing frame to edit a file. " "This function creates a frame or re-uses an existing frame to edit a file. "
@ -790,8 +790,8 @@
(handler:current-create-new-window (handler:current-create-new-window
(case-> (case->
(((union false/c path?) . -> . (is-a?/c frame%)) . -> . void) (((or/c false/c path?) . -> . (is-a?/c frame%)) . -> . void)
(-> ((union false/c string?) . -> . (is-a?/c frame%)))) (-> ((or/c false/c string?) . -> . (is-a?/c frame%))))
((new-window-handler) ()) ((new-window-handler) ())
"This is a parameter that controls how the framework" "This is a parameter that controls how the framework"
"creates new application windows." "creates new application windows."
@ -805,7 +805,7 @@
"\\end{schemedisplay}") "\\end{schemedisplay}")
(handler:open-file (handler:open-file
(-> (union false/c (is-a?/c frame:basic<%>))) (-> (or/c false/c (is-a?/c frame:basic<%>)))
() ()
"This function queries the user for a filename and opens the file for" "This function queries the user for a filename and opens the file for"
"editing. It uses " "editing. It uses "
@ -1298,7 +1298,7 @@
(scheme:text-balanced? (scheme:text-balanced?
(opt-> (opt->
((is-a?/c text%)) ((is-a?/c text%))
(number? (union false/c number?)) (number? (or/c false/c number?))
boolean?) boolean?)
((text) ((text)
((start 0) (end #f))) ((start 0) (end #f)))
@ -1516,7 +1516,7 @@
"Builds a printed representation for a style-delta.") "Builds a printed representation for a style-delta.")
(color-prefs:unmarshall-style (color-prefs:unmarshall-style
(-> printable/c (union false/c (is-a?/c style-delta%))) (-> printable/c (or/c false/c (is-a?/c style-delta%)))
(marshalled-style-delta) (marshalled-style-delta)
"Builds a style delta from its printed representation." "Builds a style delta from its printed representation."
"Returns \\scheme|#f| if the printed form cannot be parsed.") "Returns \\scheme|#f| if the printed form cannot be parsed.")

View File

@ -150,9 +150,9 @@
(string? (string?
string?) string?)
(boolean? (boolean?
(union false/c (or/c false/c
(is-a?/c frame%) (is-a?/c frame%)
(is-a?/c dialog%))) (is-a?/c dialog%)))
(symbols 'continue 'save 'cancel)) (symbols 'continue 'save 'cancel))
((filename action) ((filename action)
((can-save-now? #f) ((can-save-now? #f)
@ -175,7 +175,7 @@
string?) string?)
(string? (string?
any/c any/c
(union false/c (is-a?/c frame%) (is-a?/c dialog%)) (or/c false/c (is-a?/c frame%) (is-a?/c dialog%))
(symbols 'app 'caution 'stop)) (symbols 'app 'caution 'stop))
any/c) any/c)
((message true-choice false-choice) ((message true-choice false-choice)

View File

@ -80,7 +80,7 @@
;; ((frame-has? p) f) = ;; ((frame-has? p) f) =
;; f is a frame and it has a child (in it or a subpanel) that responds #t to p ;; f is a frame and it has a child (in it or a subpanel) that responds #t to p
(test:button-push (test:button-push
((union (λ (str) ((or/c (λ (str)
(and (string? str) (and (string? str)
(test:top-level-focus-window-has? (test:top-level-focus-window-has?
(λ (c) (λ (c)
@ -104,7 +104,7 @@
"active frame. Otherwise, it pushes the button argument.") "active frame. Otherwise, it pushes the button argument.")
(test:set-radio-box! (test:set-radio-box!
((union string? (is-a?/c radio-box%)) (union string? number?) . -> . void?) ((or/c string? (is-a?/c radio-box%)) (or/c string? number?) . -> . void?)
(radio-box state) (radio-box state)
"Sets the radio-box to \\var{state}. If \\var{state} is a" "Sets the radio-box to \\var{state}. If \\var{state} is a"
"string, this function finds the choice with that label and" "string, this function finds the choice with that label and"
@ -122,7 +122,7 @@
"Finds a \\iscmclass{radio-box} that has a label \\var{entry}" "Finds a \\iscmclass{radio-box} that has a label \\var{entry}"
"and sets the radio-box to \\var{entry}.") "and sets the radio-box to \\var{entry}.")
(test:set-check-box! (test:set-check-box!
((union string? (is-a?/c check-box%)) boolean? . -> . void?) ((or/c string? (is-a?/c check-box%)) boolean? . -> . void?)
(check-box state) (check-box state)
"Clears the \\iscmclass{check-box} item if \\var{state} is \\rawscm{\\#f}, and sets it" "Clears the \\iscmclass{check-box} item if \\var{state} is \\rawscm{\\#f}, and sets it"
"otherwise." "otherwise."
@ -132,7 +132,7 @@
"otherwise it uses \\var{check-box} itself.") "otherwise it uses \\var{check-box} itself.")
(test:set-choice! (test:set-choice!
((union string? (is-a?/c choice%)) string? . -> . void?) ((or/c string? (is-a?/c choice%)) string? . -> . void?)
(choice str) (choice str)
"Selects \\var{choice}'s item \\var{str}. If \\var{choice} is a string," "Selects \\var{choice}'s item \\var{str}. If \\var{choice} is a string,"
"this function searches for a \\iscmclass{choice} with a label matching" "this function searches for a \\iscmclass{choice} with a label matching"
@ -140,7 +140,7 @@
(test:keystroke (test:keystroke
(opt-> (opt->
((union char? symbol?)) ((or/c char? symbol?))
((listof (symbols 'alt 'control 'meta 'shift 'noalt 'nocontrol 'nometea 'noshift))) ((listof (symbols 'alt 'control 'meta 'shift 'noalt 'nocontrol 'nometea 'noshift)))
void?) void?)
((key) ((key)

View File

@ -7,12 +7,12 @@
(provide/contract (provide/contract
[make-bitmap-label (opt-> [make-bitmap-label (opt->
(string? (string?
(union path-string? (or/c path-string?
(is-a?/c bitmap%))) (is-a?/c bitmap%)))
((is-a?/c font%)) ((is-a?/c font%))
(is-a?/c bitmap%))] (is-a?/c bitmap%))]
[bitmap-label-maker (string? [bitmap-label-maker (string?
(union path-string? (or/c path-string?
(is-a?/c bitmap%)) (is-a?/c bitmap%))
. -> . . -> .
(any/c . -> . (is-a?/c bitmap%)))]) (any/c . -> . (is-a?/c bitmap%)))])

View File

@ -34,54 +34,54 @@
void?) void?)
((is-a?/c graph-snip<%>) ((is-a?/c graph-snip<%>)
(is-a?/c graph-snip<%>) (is-a?/c graph-snip<%>)
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
. -> . . -> .
void?) void?)
((is-a?/c graph-snip<%>) ((is-a?/c graph-snip<%>)
(is-a?/c graph-snip<%>) (is-a?/c graph-snip<%>)
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c string?) (or/c false/c string?)
. -> . . -> .
void?) void?)
((is-a?/c graph-snip<%>) ((is-a?/c graph-snip<%>)
(is-a?/c graph-snip<%>) (is-a?/c graph-snip<%>)
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
number? number?
number? number?
. -> . . -> .
void?) void?)
((is-a?/c graph-snip<%>) ((is-a?/c graph-snip<%>)
(is-a?/c graph-snip<%>) (is-a?/c graph-snip<%>)
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
number? number?
number? number?
(union false/c string?) (or/c false/c string?)
. -> . . -> .
void?))) void?)))
(add-links/text-colors (add-links/text-colors
((is-a?/c graph-snip<%>) ((is-a?/c graph-snip<%>)
(is-a?/c graph-snip<%>) (is-a?/c graph-snip<%>)
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c pen%)) (or/c false/c (is-a?/c pen%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c (is-a?/c brush%)) (or/c false/c (is-a?/c brush%))
(union false/c (is-a?/c color%)) (or/c false/c (is-a?/c color%))
(union false/c (is-a?/c color%)) (or/c false/c (is-a?/c color%))
number? number?
number? number?
(union false/c string?) (or/c false/c string?)
. -> . . -> .
void?))) void?)))
@ -351,7 +351,7 @@
(let* ([parents-and-children (append (get-all-parents snip) (let* ([parents-and-children (append (get-all-parents snip)
(get-all-children snip))] (get-all-children snip))]
[rects (eliminate-redundancies (get-rectangles snip parents-and-children))] [rects (eliminate-redundancies (get-rectangles snip parents-and-children))]
[union (union-rects rects)] [or/c (or/c-rects rects)]
[text-height (call-with-values [text-height (call-with-values
(λ () (send dc get-text-extent "Label" #f #f 0)) (λ () (send dc get-text-extent "Label" #f #f 0))
(λ (w h a s) h))] (λ (w h a s) h))]
@ -366,9 +366,9 @@
(rect-top rect)) (rect-top rect))
text-height)))]) text-height)))])
(cond (cond
[(< (rect-area union) [(< (rect-area or/c)
(apply + (map (lambda (x) (rect-area x)) rects))) (apply + (map (lambda (x) (rect-area x)) rects)))
(invalidate-rect union)] (invalidate-rect or/c)]
[else [else
(for-each invalidate-rect rects)])))) (for-each invalidate-rect rects)]))))
@ -414,7 +414,7 @@
sy sy
(+ (+ sx sw) self-offset) (+ (+ sx sw) self-offset)
(+ (+ sy sh) self-offset h))) (+ (+ sy sh) self-offset h)))
(union-rects (list main-snip-rect (or/c-rects (list main-snip-rect
(snip->rect c/p))))]) (snip->rect c/p))))])
(cons rect (loop (cdr c/p-snips))))])))) (cons rect (loop (cdr c/p-snips))))]))))
@ -432,7 +432,7 @@
(- (rect-bottom rect) (- (rect-bottom rect)
(rect-top rect)))) (rect-top rect))))
(define/private (union-rects rects) (define/private (or/c-rects rects)
(cond (cond
[(null? rects) (make-rect 0 0 0 0)] [(null? rects) (make-rect 0 0 0 0)]
[else [else
@ -928,7 +928,7 @@
(and (< (min p1x p2x) x (max p1x p2x)) (and (< (min p1x p2x) x (max p1x p2x))
(< (min p1y p2y) y (max p1y p2y)))) (< (min p1y p2y) y (max p1y p2y))))
;; find-intersection : number^8 -> (values (union #f number) (union #f number)) ;; find-intersection : number^8 -> (values (or/c #f number) (or/c #f number))
;; calculates the intersection between two line segments, ;; calculates the intersection between two line segments,
;; described as pairs of points. Returns #f if they do not intersect ;; described as pairs of points. Returns #f if they do not intersect
(define (find-intersection x1 y1 x2 y2 x3 y3 x4 y4) (define (find-intersection x1 y1 x2 y2 x3 y3 x4 y4)
@ -975,7 +975,7 @@
(values int-x int-y) (values int-x int-y)
(values #f #f))))) (values #f #f)))))
;; find-mb : number number number number -> (values (union #f number) (union #f number)) ;; find-mb : number number number number -> (values (or/c #f number) (or/c #f number))
;; finds the "m" and "b" constants that describe the ;; finds the "m" and "b" constants that describe the
;; lines from (x1, y1) to (x2, y2) ;; lines from (x1, y1) to (x2, y2)
(define (find-mb x1 y1 x2 y2) (define (find-mb x1 y1 x2 y2)

View File

@ -11,7 +11,7 @@
(provide/contract (provide/contract
(pasteboard-root ((is-a?/c aligned-pasteboard<%>) . -> . (is-a?/c aligned-pasteboard<%>))) (pasteboard-root ((is-a?/c aligned-pasteboard<%>) . -> . (is-a?/c aligned-pasteboard<%>)))
(pasteboard-parent (pasteboard-parent
((is-a?/c pasteboard%) . -> . (union (is-a?/c editor-canvas%) (is-a?/c editor-snip%) false/c)))) ((is-a?/c pasteboard%) . -> . (or/c (is-a?/c editor-canvas%) (is-a?/c editor-snip%) false/c))))
;; gets the top most aligned pasteboard in the tree of pasteboards and containers ;; gets the top most aligned pasteboard in the tree of pasteboards and containers
(define (pasteboard-root pasteboard) (define (pasteboard-root pasteboard)
@ -35,5 +35,4 @@
(send admin get-snip)] (send admin get-snip)]
[(is-a? admin editor-admin%) [(is-a? admin editor-admin%)
(send pasteboard get-canvas)] (send pasteboard get-canvas)]
[else false]))) [else false]))))
)

View File

@ -11,7 +11,7 @@
;; a snip ;; a snip
(define snip? (is-a?/c snip%)) (define snip? (is-a?/c snip%))
;; a snip to act as the varying argument to a recursive functions ;; a snip to act as the varying argument to a recursive functions
(define linked-snip? (union snip? false/c)) (define linked-snip? (or/c snip? false/c))
;; a function to act on snips being mapped ;; a function to act on snips being mapped
(define snip-visitor? any/c #;((snip?) (listof any/c) . ->* . (void))) (define snip-visitor? any/c #;((snip?) (listof any/c) . ->* . (void)))
;; the rest of the lists passed to a snip mapping function ;; the rest of the lists passed to a snip mapping function
@ -24,7 +24,7 @@
(snip-height (snip? . -> . number?)) (snip-height (snip? . -> . number?))
(snip-min-width (snip? . -> . number?)) (snip-min-width (snip? . -> . number?))
(snip-min-height (snip? . -> . number?)) (snip-min-height (snip? . -> . number?))
(snip-parent (snip? . -> . (union editor? false/c))) (snip-parent (snip? . -> . (or/c editor? false/c)))
(fold-snip ((snip? any/c . -> . any/c) any/c linked-snip? . -> . any/c)) (fold-snip ((snip? any/c . -> . any/c) any/c linked-snip? . -> . any/c))
(for-each-snip any/c #;((snip-visitor? linked-snip?) rest-lists? . ->* . (void))) (for-each-snip any/c #;((snip-visitor? linked-snip?) rest-lists? . ->* . (void)))
(map-snip any/c #;((snip-visitor? linked-snip?) rest-lists? . ->* . ((listof any/c)))) (map-snip any/c #;((snip-visitor? linked-snip?) rest-lists? . ->* . ((listof any/c))))