Skip to content

Commit

Permalink
Universe: default on-new and on-msg; bundlize.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Van Horn committed Feb 4, 2012
1 parent 1a2c583 commit a8f113c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions class/universe.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
(send/apply w on-event args)
(default w)))]))


;; Any -> Bundle
(define (bundlize v)
(cond [(bundle? v) v]
[else (make-bundle v empty empty)]))


(define (universe* o)
Expand All @@ -28,19 +31,23 @@
(on-new
(if (method-in-interface? 'on-new i)
(λ (u iw)
(send u on-new iw))
(error "Must supply an on-new method.")))
(bundlize (send u on-new iw)))
(λ (u iw)
(make-bundle u empty empty))))

(on-msg
(if (method-in-interface? 'on-msg i)
(λ (u iw msg)
(send u on-msg iw msg))
(error "Must supply an on-msg method.")))
(bundlize (send u on-msg iw msg)))
(λ (u iw msg)
(make-bundle u empty empty))))

(on-tick
(m on-tick
(λ (u)
(make-bundle u empty empty)))
(if (method-in-interface? 'on-tick i)
(λ (u)
(bundlize (send u on-tick)))
(λ (u)
(make-bundle u empty empty)))
(if (method-in-interface? 'tick-rate i)
(send o tick-rate)
(if (method-in-interface? 'on-tick i)
Expand Down

0 comments on commit a8f113c

Please sign in to comment.