"));
34 | }
35 |
36 | @Test public void testNestedChildren() {
37 | List worldList = new Pair(Symbol.makeInstance("world"),
38 | new Pair(Empty.EMPTY,
39 | Empty.EMPTY));
40 | assertEquals(new Pair(Symbol.makeInstance("hello"),
41 | new Pair(Empty.EMPTY,
42 | new Pair(worldList,
43 | Empty.EMPTY))),
44 | parser.parseString(""));
45 | }
46 |
47 |
48 | @Test public void testText() {
49 | assertEquals(new Pair(Symbol.makeInstance("p"),
50 | new Pair(Empty.EMPTY,
51 | new Pair("this is a test",
52 | Empty.EMPTY))),
53 | parser.parseString("this is a test
"));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/approx-equal.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname approx-equal) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | ;; Simple text example.
6 | (define WIDTH 320)
7 | (define HEIGHT 480)
8 |
9 | (define t1 (text (cond [(=~ 3 4 0.5)
10 | "blah"]
11 | [else
12 | "yes"])
13 | 10
14 | "black"))
15 | (define t2 (text (cond [(=~ 3 4 1.0)
16 | "yes"]
17 | [else
18 | "blah"])
19 | 10
20 | "black"))
21 |
22 | ;; we expect to see "yes, yes" on this
23 | (define (draw-scene y)
24 | (place-image t2 0 30
25 | (place-image t1
26 | 0 0
27 | (empty-scene WIDTH HEIGHT))))
28 |
29 | (big-bang WIDTH HEIGHT
30 | 0
31 | (on-redraw draw-scene))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/bubble.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname bubble) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 |
6 | (define-struct world (pitch roll))
7 | (define initial-world (make-world 0 0))
8 |
9 | (define width 320)
10 | (define height 480)
11 |
12 |
13 | (define (render-world a-world)
14 | (place-image (circle 20 "solid" "blue")
15 | (- (quotient width 2)
16 | (* (/ (world-roll a-world) 90)
17 | (quotient width 2)))
18 | (+ (* (/ (world-pitch a-world) 90)
19 | (quotient height 2))
20 | (quotient height 2))
21 | (empty-scene width height)))
22 |
23 | (define (handle-orientation-change world new-azimuth new-pitch new-roll)
24 | (make-world new-pitch new-roll))
25 |
26 |
27 | (big-bang width height initial-world
28 | (on-redraw render-world)
29 | (on-tilt handle-orientation-change))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/button-with-picture.ss:
--------------------------------------------------------------------------------
1 | #lang moby
2 |
3 | ;; The world consists of a number.
4 |
5 | ;; We have two images, a plus and a minus image, that we'll plop onto our buttons.
6 | (define PLUS (js-img "http://boredzo.org/buttonicons/plus-8.png"))
7 | (define MINUS (js-img "http://boredzo.org/buttonicons/minus-8.png"))
8 |
9 | ;; plus-press: world -> world
10 | (define (plus-press w)
11 | (add1 w))
12 |
13 | ;; minus-press: world -> world
14 | (define (minus-press w)
15 | (sub1 w))
16 |
17 | ;; draw: world -> dom-sexp
18 | (define (draw w)
19 | (list (js-div '((id "main")))
20 | (list (js-text (format "World contains: ~a" w)))
21 | (list (js-button plus-press)
22 | (list PLUS))
23 | (list (js-button minus-press)
24 | (list MINUS))))
25 |
26 | ;; draw-css: world -> css-sexp
27 | ;; Let all text drawn in the main div have a font size of 30px.
28 | (define (draw-css w)
29 | '(("main" ("font-size" "30px"))))
30 |
31 | (js-big-bang 0
32 | (on-draw draw draw-css))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/falling-ball-pair.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname falling-ball-pair) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | ;; Simple falling ball example, with structures.
6 |
7 | ;; A world is a coord representing the x,y position of the red ball.
8 |
9 | (define WIDTH 320)
10 | (define HEIGHT 480)
11 | (define RADIUS 5)
12 |
13 | (define-struct coord (x y))
14 |
15 | (define (tick w)
16 | (make-coord (+ (coord-x w) 5)
17 | (+ (coord-y w) 5)))
18 |
19 | (define (hits-floor? w)
20 | (>= (coord-y w) HEIGHT))
21 |
22 | (define (draw-scene w)
23 | (place-image (circle RADIUS "solid" "red")
24 | (coord-x w)
25 | (coord-y w)
26 | (empty-scene WIDTH HEIGHT)))
27 |
28 | (big-bang WIDTH HEIGHT (make-coord 0 0)
29 | (on-tick 1/15 tick)
30 | (on-redraw draw-scene)
31 | (stop-when hits-floor?))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/falling-ball-posn.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname falling-ball-posn) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | ;; Simple falling ball example, with posns.
6 |
7 | ;; A world is a posn representing the x,y position of the red ball.
8 |
9 | (define WIDTH 320)
10 | (define HEIGHT 480)
11 | (define RADIUS 5)
12 |
13 | (define (tick w)
14 | (make-posn (+ (posn-x w) 5)
15 | (+ (posn-y w) 5)))
16 |
17 | (define (hits-floor? w)
18 | (>= (posn-y w) HEIGHT))
19 |
20 | (define (draw-scene w)
21 | (place-image (circle RADIUS "solid" "red")
22 | (posn-x w)
23 | (posn-y w)
24 | (empty-scene WIDTH HEIGHT)))
25 |
26 | (big-bang WIDTH HEIGHT (make-posn 0 0)
27 | (on-tick 1/15 tick)
28 | (on-redraw draw-scene)
29 | (stop-when hits-floor?))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/falling-ball.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname falling-ball) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | ;; Simple falling ball example. Red ball falls down.
6 |
7 | ;; A world is a number representing the y position of the red ball.
8 |
9 | (define WIDTH 320)
10 | (define HEIGHT 480)
11 | (define RADIUS 5)
12 |
13 | (define (tick y)
14 | (+ y 5))
15 |
16 | (define (hits-floor? y)
17 | (>= y (- HEIGHT RADIUS)))
18 |
19 | (check-expect (hits-floor? 0) false)
20 | (check-expect (hits-floor? HEIGHT) true)
21 |
22 | (define (draw-scene y)
23 | (place-image (circle RADIUS "solid" "red") (/ WIDTH 2) y
24 | (empty-scene WIDTH HEIGHT)))
25 |
26 | (big-bang WIDTH HEIGHT
27 | 10
28 | (on-tick 1/15 tick)
29 | (on-redraw draw-scene)
30 | (stop-when hits-floor?))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/gui-world-box-group.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname gui-world-box-group) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "gui-world.ss" "gui-world"))
5 |
6 | (big-bang 0 (box-group "hello" "world"))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/gui-world-checkbox.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname gui-world-checkbox) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "gui-world.ss" "gui-world"))
5 |
6 | (define (world-update w b)
7 | b)
8 |
9 | (define (world-value w)
10 | w)
11 |
12 | (define (description w)
13 | (cond
14 | [w "This is true"]
15 | [else
16 | "this is false"]))
17 |
18 | (define (flip w)
19 | (not w))
20 |
21 | (big-bang true (row (checkbox "Click me" world-value world-update)
22 | (message description)
23 | (button "Reverse" flip)
24 | ))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/gui-world-drop-down.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname gui-world-drop-down) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "gui-world.ss" "gui-world"))
5 |
6 | (define initial-world "black")
7 |
8 | ;; current-choice: world -> string
9 | (define (current-choice w)
10 | w)
11 |
12 | ;; choices: world -> (listof string)
13 | (define (choices w)
14 | (list "red" "green" "blue" "black" "white"))
15 |
16 | ;; update-choice: world string -> world
17 | (define (update-choice w new-choice)
18 | new-choice)
19 |
20 | ;; status: world -> string
21 | (define (status w)
22 | (string-append "The current world is: " w))
23 |
24 | (big-bang initial-world
25 | (col
26 | (drop-down current-choice choices update-choice)
27 | (message status)))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/gui-world-hello-world.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname gui-world-hello-world) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "gui-world.ss" "gui-world"))
5 |
6 | ;; the world is a number
7 | (define initial-world 0)
8 |
9 | ;; world-message: world -> string
10 | (define (world-message a-world)
11 | (number->string a-world))
12 |
13 | ;; on-button-pressed: world -> world
14 | (define (on-button-pressed a-world)
15 | (add1 a-world))
16 |
17 | ;; view: gui
18 | (define view
19 | (col (row "hello" (col "*world*"
20 | (row "goodbye"
21 | (message "world"))))
22 | (message world-message)
23 | (button world-message on-button-pressed)))
24 |
25 |
26 | (big-bang initial-world view)
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/gui-world-location.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname gui-world-location) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "gui-world.ss" "gui-world"))
5 | ;; Location, using the on-location-changed hook.
6 |
7 |
8 | (define-struct world (latitude longitude))
9 | (define initial-world (make-world 0 0))
10 |
11 |
12 | ;; lat-msg: world -> string
13 | (define (lat-msg w)
14 | (number->string (world-latitude w)))
15 |
16 |
17 | ;; long-msg: world -> string
18 | (define (long-msg w)
19 | (number->string (world-longitude w)))
20 |
21 |
22 | ;; The gui shows the latitude and longitude.
23 | (define view
24 | (col
25 | (row "Latitude: " (message lat-msg))
26 | (row "Longitude: " (message long-msg))))
27 |
28 |
29 | ;; handle-location-change: world number number -> world
30 | (define (handle-location-change a-world a-latitude a-longitude)
31 | (make-world a-latitude
32 | a-longitude))
33 |
34 |
35 | (big-bang initial-world view
36 | (on-location-change handle-location-change))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/gui-world-text-field.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname gui-world-text-field) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "gui-world.ss" "gui-world"))
5 |
6 | (define initial-world "hello")
7 |
8 | (define (content w)
9 | w)
10 |
11 | (define (update-content w new-w)
12 | new-w)
13 |
14 | (define (show-content w)
15 | (string-append "The world contains: " w))
16 |
17 | (big-bang initial-world (col (text-field content update-content)
18 | (message show-content)))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/hello-world.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname hello-world) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | ;; Simple text example.
6 | (define WIDTH 320)
7 | (define HEIGHT 480)
8 |
9 |
10 | (define (draw-scene y)
11 | (place-image (text "hello world" 10 "red")
12 | 0 0
13 | (empty-scene WIDTH HEIGHT)))
14 |
15 | (big-bang WIDTH HEIGHT 0
16 | (on-redraw draw-scene))
17 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/image-question.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname image-question) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | ;; Simple text example.
5 | (define WIDTH 320)
6 | (define HEIGHT 480)
7 |
8 | (define t1 (text (cond [(image? 42)
9 | "blah"]
10 | [else
11 | "yes"])
12 | 10
13 | "black"))
14 | (define t2 (text (cond [(image? (circle 20 "solid" "red"))
15 | "yes"]
16 | [else
17 | "blah"])
18 | 10
19 | "black"))
20 |
21 | ;; we expect to see "yes, yes" on this
22 | (define (draw-scene y)
23 | (place-image t2 0 30
24 | (place-image t1
25 | 0 0
26 | (empty-scene WIDTH HEIGHT))))
27 |
28 | (big-bang WIDTH HEIGHT 0
29 | (on-redraw draw-scene))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/info.ss:
--------------------------------------------------------------------------------
1 | #lang setup/infotab
2 | (define compile-omit-paths 'all)
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/jsworld/jsworld-fading.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname jsworld-fading) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (require (lib "moby.ss" "moby" "stub"))
6 |
7 | (define (tick w)
8 | (add1 w))
9 |
10 |
11 | (define hello-div (js-div))
12 | (define separator-div (js-div))
13 | (define hello-text-1 (js-text "hello"))
14 | (define hello-text-2 (js-text "world"))
15 |
16 |
17 | (define (get-color r g b)
18 | (string-append "#" (hex r)
19 | (hex g) (hex b)))
20 |
21 | (define (hex-digit n)
22 | (string (list-ref (string->list "0123456789ABCDEF") n)))
23 |
24 | (define (hex n)
25 | (string-append
26 | (hex-digit (quotient n 16))
27 | (hex-digit (modulo n 16))))
28 |
29 |
30 | ;; redraw: world -> sexp
31 | (define (redraw w)
32 | (list hello-div (list hello-text-1)
33 | (list separator-div)
34 | (list hello-text-2)))
35 |
36 |
37 | (define (redraw-css w)
38 | (local ((define n (floor (abs (* (sin (/ w 10)) 255)))))
39 | (list (list hello-div (list "color"
40 | (get-color n n n))))))
41 |
42 |
43 |
44 | (js-big-bang 0
45 | '()
46 | (on-draw redraw redraw-css)
47 | (on-tick (/ 1 10) tick))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/jsworld/location.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname location) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | ;; The world is a latitude and longitude.
5 | (define-struct world (lat long))
6 |
7 | (define initial-world (make-world 0 0))
8 |
9 |
10 | ;; update: world number number -> world
11 | ;; Update the world to the latest latitude and longitude reading.
12 | (define (update w lat long)
13 | (make-world lat long))
14 |
15 |
16 | ;; world->string: world -> string
17 | (define (world->string w)
18 | (string-append "("
19 | (number->string (world-lat w))
20 | ", "
21 | (number->string (world-long w))
22 | ")"))
23 |
24 |
25 | ;; draw: world -> DOM-sexp
26 | (define (draw w)
27 | (list (js-p '(("id" "aPara")))
28 | (list (js-text "(latitude, longitude) = "))
29 | (list (js-text (world->string w)))))
30 |
31 |
32 | ;; draw-css: world -> CSS-sexp
33 | ;; Style the paragraph so its internal text is large.
34 | (define (draw-css w)
35 | '(("aPara" ("font-size" "30px"))))
36 |
37 |
38 | (js-big-bang initial-world
39 | '()
40 | (on-draw draw draw-css)
41 | (on-location-change update))
42 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/jsworld/maps-mashup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | Test
49 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/jsworld/simple-button.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname simple-button) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | (require (lib "moby.ss" "moby" "stub"))
5 |
6 | ;; button example. Pressing the button will send an alert and adjust the button's text.
7 |
8 | ;; The world is a number.
9 |
10 |
11 | ;; on-press: world -> world
12 | (define (on-press w)
13 | (add1 w))
14 |
15 |
16 | ;; ring: world -> effect
17 | (define (ring w)
18 | (make-effect:beep))
19 |
20 |
21 |
22 | ;; draw: world -> (sexpof dom)
23 | (define (draw w)
24 | (local [(define a-button (js-button* on-press ring
25 | (list (list "id" "aButton"))))
26 | (define a-para (js-p (list (list "id" "aPara"))))
27 | (define a-button-text (js-text (number->string w) (list (list "id" "aText"))))]
28 | (list a-button (list a-para (list a-button-text)))))
29 |
30 |
31 |
32 | ;; draw-css: world -> (sexpof css)
33 | (define (draw-css w)
34 | (list (list "aButton"
35 | (list "background-color" "lightblue"))
36 | (list "aPara"
37 | (list "font-size" "30pt"))))
38 |
39 |
40 | (js-big-bang 0
41 | '()
42 | (on-draw draw draw-css))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/line.ss:
--------------------------------------------------------------------------------
1 | #lang s-exp "../../moby-lang.ss"
2 |
3 |
4 | (place-image (line 100 0 'black) 50 150 (empty-scene 200 200))
5 | (place-image (line -100 0 'black) 50 150 (empty-scene 200 200))
6 |
7 | (check-expect 101 (image-width (line 100 -50 'black)))
8 | (check-expect 101 (image-width (line -100 -50 'black)))
9 | (check-expect 51 (image-height (line -100 -50 'black)))
10 |
11 | (image-width (line -100 -50 'black))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/local.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-intermediate-reader.ss" "lang")((modname local) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | ;; Simple text example.
5 | (define WIDTH 320)
6 | (define HEIGHT 480)
7 |
8 | (define (f x)
9 | 42)
10 |
11 | (define some-value
12 | (+ (f 2)
13 | (local [(define (f x y)
14 | (* x y))]
15 | (f 3 3))))
16 | ;; We expect some value to be 42 + 9 = 51.
17 |
18 |
19 |
20 | (define (draw-scene y)
21 | (place-image (text (if (= some-value 51) "yes" "no") 10 "red")
22 | 0 0
23 | (empty-scene WIDTH HEIGHT)))
24 |
25 | (big-bang WIDTH HEIGHT 0
26 | (on-redraw draw-scene))
27 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/location-2.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname location-2) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 |
6 | (define width 320)
7 | (define height 480)
8 |
9 | (define-struct world (latitude longitude))
10 |
11 | (define initial-world (make-world 0 0))
12 |
13 |
14 | (define (render-world a-world)
15 | (place-image
16 | (text (number->string (world-longitude a-world)) 20 "blue")
17 | 0
18 | 50
19 | (place-image
20 | (text (number->string (world-latitude a-world)) 20 "red")
21 | 0
22 | 0
23 | (empty-scene width height))))
24 |
25 |
26 | (define (handle-location-change a-world a-latitude a-longitude)
27 | (make-world a-latitude
28 | a-longitude))
29 |
30 |
31 | (big-bang width height initial-world
32 | (on-redraw render-world)
33 | (on-location-change handle-location-change))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/location.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname location) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (define width 320)
6 | (define height 480)
7 |
8 | (define-struct world (latitude longitude))
9 |
10 | (define initial-world (make-world 0 0))
11 |
12 |
13 | (define (render-world a-world)
14 | (place-image
15 | (text (number->string (world-longitude a-world)) 20 "blue")
16 | 0
17 | 50
18 | (place-image
19 | (text (number->string (world-latitude a-world)) 20 "red")
20 | 0
21 | 0
22 | (empty-scene width height))))
23 |
24 |
25 | (define (tick a-world)
26 | (make-world (get-latitude)
27 | (get-longitude)))
28 |
29 |
30 | (big-bang width height initial-world
31 | (on-redraw render-world)
32 | (on-tick 1 tick))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/move-ball.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname move-ball) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | ;; Movable circle with posns.
5 |
6 | ;; A world is a posn representing the x,y position of the red ball.
7 |
8 | (define WIDTH 320)
9 | (define HEIGHT 480)
10 | (define RADIUS 5)
11 |
12 | (define (tick w) w)
13 |
14 | (define (move-ball w k)
15 | (cond
16 | [(key=? k 'up)
17 | (make-posn (posn-x w) (- (posn-y w) 5))]
18 | [(key=? k 'down)
19 | (make-posn (posn-x w) (+ (posn-y w) 5))]
20 | [(key=? k 'left)
21 | (make-posn (- (posn-x w) 5) (posn-y w))]
22 | [(key=? k 'right)
23 | (make-posn (+ (posn-x w) 5) (posn-y w))]
24 | [else
25 | w]))
26 |
27 |
28 | (define (draw-scene w)
29 | (place-image (circle RADIUS "solid" "red")
30 | (posn-x w)
31 | (posn-y w)
32 | (empty-scene WIDTH HEIGHT)))
33 |
34 |
35 | (big-bang WIDTH HEIGHT (make-posn (/ WIDTH 2) (/ HEIGHT 2))
36 | (on-tick 1 tick)
37 | (on-redraw draw-scene)
38 | (on-key move-ball))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/net.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname net) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (define (content w)
6 | w)
7 |
8 | (define (ignore-change w n)
9 | w)
10 |
11 | (define (refresh w)
12 | (get-url "http://ip.hashcollision.org/"))
13 |
14 | (define view
15 | (col
16 | (text-field content ignore-change)
17 | (button "Refresh!" refresh)))
18 |
19 | (big-bang (get-url "http://ip.hashcollision.org/")
20 | view)
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/pick-playlist.ss:
--------------------------------------------------------------------------------
1 | #lang s-exp "../moby-lang.ss"
2 |
3 | (define (update-playlist w playlist)
4 | playlist)
5 |
6 | (define (draw w)
7 | (list (js-div)
8 | (list (js-text (format "Current playlist: ~s"
9 | w)))
10 |
11 | (list (js-button*
12 | (lambda (w)
13 | w)
14 | (lambda (w)
15 | (make-effect:pick-playlist update-playlist)))
16 | (list (js-text "Pick playlist")))
17 |
18 |
19 | (list (js-button* identity play) (list (js-text "Play")))
20 | (list (js-button* identity pause) (list (js-text "Pause")))
21 | (list (js-button* identity stop) (list (js-text "Stop")))))
22 |
23 |
24 | (define (play w)
25 | (cond
26 | [(boolean? w)
27 | empty]
28 | [else
29 | (make-effect:play-sound w)]))
30 |
31 |
32 | (define (pause w)
33 | (cond
34 | [(boolean? w)
35 | empty]
36 | [else
37 | (make-effect:pause-sound w)]))
38 |
39 | (define (stop w)
40 | (cond
41 | [(boolean? w)
42 | empty]
43 | [else
44 | (make-effect:stop-sound w)]))
45 |
46 |
47 |
48 | (define (draw-css w)
49 | '())
50 |
51 |
52 | (js-big-bang false
53 | (on-draw draw draw-css))
54 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/pinholes.ss:
--------------------------------------------------------------------------------
1 | #lang s-exp "../../moby-lang.ss"
2 | (define x 50)
3 | (define y 50)
4 |
5 | (define (draw-world a-world)
6 | #;(place-image (circle x "solid" "green")
7 | 100
8 | y
9 | (empty-scene 100 100))
10 |
11 | (place-image (circle x "solid" "red")
12 | x
13 | y
14 | (place-image (circle x "solid" "green")
15 | 100
16 | y
17 | (empty-scene 320 480))))
18 |
19 |
20 | (js-big-bang false
21 | (on-redraw draw-world))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/rectangles.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname rectangles) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (define WIDTH 320)
6 | (define HEIGHT 480)
7 |
8 | (define (draw-world a-world)
9 | (place-image (nw:rectangle 100 10 "solid" "red")
10 | 0
11 | 0
12 | (place-image
13 | (nw:rectangle 100 10 "solid" "green")
14 | 0
15 | 20
16 | (empty-scene WIDTH HEIGHT))))
17 |
18 |
19 | (big-bang WIDTH HEIGHT false
20 | (on-redraw draw-world))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/shake-for-music.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname shake-for-music) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 |
6 | (define WIDTH 320)
7 | (define HEIGHT 480)
8 |
9 | (define file-path "file:///android_asset/audio/Sweet Child.mp3")
10 | (define initial-world false)
11 |
12 | (define (swap w)
13 | (not w))
14 |
15 | (define (play w)
16 | (if w
17 | (make-effect:play-sound file-path)
18 | (make-effect:pause-sound file-path)))
19 |
20 | (big-bang WIDTH HEIGHT initial-world
21 | (on-shake* swap play))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/simple-bootstrap-game.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname simple-bootstrap-game) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (define WIDTH 320)
6 | (define HEIGHT 480)
7 |
8 | (define TITLE "My Simple Game")
9 | (define background (empty-scene WIDTH HEIGHT))
10 |
11 | (define (update-target-x x)
12 | (add1 x))
13 |
14 | (define (update-target-y y)
15 | (sub1 y))
16 |
17 | (define (update-player x key)
18 | (cond
19 | [(string=? key "left")
20 | (- x 10)]
21 | [(string=? key "right")
22 | (+ x 10)]
23 | [else x]))
24 |
25 | (define (update-object y)
26 | (- y 20))
27 |
28 | (define target (circle 20 "solid" "green"))
29 |
30 | (define player (rectangle 30 40 "solid" "blue"))
31 |
32 | (define object (circle 10 "solid" "black"))
33 |
34 | (define (offscreen? x y)
35 | (or (< x 0)
36 | (> x WIDTH)
37 | (< y 0)
38 | (> y HEIGHT)))
39 |
40 |
41 |
42 | (start TITLE background update-target-x update-target-y update-player update-object target player object offscreen?)
43 |
44 |
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/sms.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname sms) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (define WIDTH 320)
6 | (define HEIGHT 480)
7 |
8 | (define the-world 42)
9 |
10 | (send-text-message "5556"
11 | "This is a test; hello world"
12 | the-world)
13 |
14 | (big-bang WIDTH HEIGHT the-world)
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/struct-question.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname struct-question) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | ;; Simple text example.
5 | (define WIDTH 320)
6 | (define HEIGHT 480)
7 |
8 | (define t1 (text (cond [(struct? 42)
9 | "blah"]
10 | [else
11 | "yes"])
12 | 10
13 | "black"))
14 | (define t2 (text (cond [(struct? (make-posn 1 2))
15 | "yes"]
16 | [else
17 | "blah"])
18 | 10
19 | "black"))
20 |
21 | ;; we expect to see "yes, yes" on this
22 | (define (draw-scene y)
23 | (place-image t2 0 30
24 | (place-image t1
25 | 0 0
26 | (empty-scene WIDTH HEIGHT))))
27 |
28 | (big-bang WIDTH HEIGHT 0
29 | (on-redraw draw-scene))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/tilt.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname tilt) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 |
6 | (define width 320)
7 | (define height 480)
8 |
9 | (define-struct world (a p r))
10 | (define initial-world (make-world 0 0 0))
11 |
12 |
13 | (define (render-world a-world)
14 | (place-image
15 | (text (string-append (number->string (world-a a-world))
16 | " "
17 | (number->string (world-p a-world))
18 | " "
19 | (number->string (world-r a-world)))
20 | 20
21 | "blue")
22 | 0
23 | 50
24 | (empty-scene width height)))
25 |
26 | (define (handle-orientation-change a-world new-a new-p new-r)
27 | (make-world new-a new-p new-r))
28 |
29 | (big-bang width height initial-world
30 | (on-redraw render-world)
31 | (on-tilt handle-orientation-change))
--------------------------------------------------------------------------------
/sandbox/old-src/test/sample-moby-programs/upside-down.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname upside-down) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 |
5 | (define width 320)
6 | (define height 480)
7 |
8 | ;; The world is a boolean, which is true if we've been
9 | ;; flipped upside down.
10 | (define initial-world false)
11 |
12 | (define (render-world a-world)
13 | (place-image
14 | (text (cond [a-world
15 | "upside down"]
16 | [else
17 | "right side up"])
18 | 20
19 | "blue")
20 | 0
21 | 50
22 | (empty-scene width height)))
23 |
24 |
25 | (define (handle-orientation-change a-world azimuth pitch roll)
26 | (or (> (abs pitch) 120)
27 | (> (abs roll) 120)))
28 |
29 | (big-bang width height initial-world
30 | (on-redraw render-world)
31 | (on-tilt handle-orientation-change))
--------------------------------------------------------------------------------
/sandbox/old-src/test/test-harness.ss:
--------------------------------------------------------------------------------
1 | #lang s-exp "../moby-lang.ss"
2 | (define number-of-tests 0)
3 | (define number-of-skipped-tests 0)
4 | (define number-of-errors 0)
5 |
6 | (define error-messages empty)
7 |
8 | (define (add-error-message! msg)
9 | (set! error-messages (append error-messages (list msg))))
10 |
11 |
12 | (define (test expect fun args)
13 | (begin
14 | (set! number-of-tests (add1 number-of-tests))
15 | (let ([res (if (procedure? fun)
16 | (apply fun args)
17 | (car args))])
18 | (let ([ok? (equal? expect res)])
19 | (cond [(not ok?)
20 | (begin
21 | (add-error-message! (format "expected ~s, got ~s, on ~s"
22 | expect
23 | res
24 | (cons fun args)))
25 | (set! number-of-errors (add1 number-of-errors))
26 | (list false expect fun args))]
27 | [else
28 | (list ok? expect fun args)])))))
29 |
30 |
31 | ;; Just a note to myself about which tests need to be fixed.
32 | (define (skip f)
33 | (begin
34 | (set! number-of-skipped-tests (add1 number-of-skipped-tests))))
--------------------------------------------------------------------------------
/sandbox/old-src/tool.ss:
--------------------------------------------------------------------------------
1 | #lang scheme/base
2 | (require scheme/class
3 | drscheme/tool
4 | string-constants/string-constant
5 | scheme/unit)
6 |
7 | ;; Moby hooks.
8 | (provide tool@)
9 |
10 |
11 | (define-unit tool@
12 | (import drscheme:tool^)
13 | (export drscheme:tool-exports^)
14 |
15 | (define (phase1)
16 | (void))
17 |
18 | (define (phase2)
19 | (void)))
--------------------------------------------------------------------------------
/sandbox/schanzer/Archive.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/schanzer/Archive.zip
--------------------------------------------------------------------------------
/sandbox/timing/measure-throw-time.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/sandbox/tones/C-tone.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/tones/C-tone.wav
--------------------------------------------------------------------------------
/sandbox/tones/D-tone.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/tones/D-tone.wav
--------------------------------------------------------------------------------
/sandbox/tones/E-tone.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/tones/E-tone.wav
--------------------------------------------------------------------------------
/sandbox/tones/G-tone.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/tones/G-tone.wav
--------------------------------------------------------------------------------
/sandbox/tsrj/simple-location.ss:
--------------------------------------------------------------------------------
1 | ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 | ;; about the language level of this file in a form that our tools can easily process.
3 | #reader(lib "htdp-beginner-reader.ss" "lang")((modname simple-location) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
4 | ;; Shows the current GPS location.
5 |
6 | ;; The world is a latitude and longitude.
7 | (define-struct world (lat long))
8 |
9 | ;; The initial world is set to (0, 0).
10 | (define initial-world (make-world 0 0))
11 |
12 |
13 | ;; update: world number number -> world
14 | ;; Update the world to the latest latitude and longitude reading.
15 | (define (update w lat long)
16 | (make-world lat long))
17 |
18 |
19 | ;; world->string: world -> string
20 | ;; Produces a string description of the world.
21 | (define (world->string w)
22 | (string-append "("
23 | (number->string (world-lat w))
24 | ", "
25 | (number->string (world-long w))
26 | ")"))
27 |
28 |
29 | ;; draw: world -> DOM-sexp
30 | (define (draw w)
31 | (list (js-p '(("id" "aPara")))
32 | (list (js-text "(latitude, longitude) = "))
33 | (list (js-text (world->string w)))))
34 |
35 |
36 | ;; draw-css: world -> CSS-sexp
37 | ;; Style the paragraph so its internal text is large.
38 | (define (draw-css w)
39 | '(("aPara" ("font-size" "30px"))))
40 |
41 |
42 | (js-big-bang initial-world
43 | '()
44 | (on-draw draw draw-css)
45 | (on-location-change update))
46 |
--------------------------------------------------------------------------------
/src/android/android-packager.ss:
--------------------------------------------------------------------------------
1 | #lang scheme/base
2 |
3 | (require scheme/contract
4 | (prefix-in local: "local-android-packager.ss")
5 | (prefix-in remote: "server-side-packager/client-side-packager.ss")
6 | "../config.ss")
7 |
8 |
9 |
10 | ;; local-android-ready?: -> boolean
11 | ;; Produces true if we can do local android packaging.
12 | (define (local-android-ready?)
13 | (and (file-exists? (current-ant-bin-path))
14 | (directory-exists? (current-android-sdk-path))))
15 |
16 |
17 | ;; build-android-package: string path -> bytes
18 | ;; Either tries to use the local android packager; if the
19 | ;; resources aren't available,
20 | ;; then tries to use the web service.
21 | (define (build-android-package program-name program-path)
22 | (cond
23 | [(local-android-ready?)
24 | (local:build-android-package program-name program-path)]
25 | [else
26 | (remote:build-android-package program-name program-path)]))
27 |
28 |
29 | (provide/contract
30 | [build-android-package (string? path? . -> . bytes?)])
--------------------------------------------------------------------------------
/src/android/android-permission.rkt:
--------------------------------------------------------------------------------
1 | #lang racket/base
2 |
3 | (require racket/list
4 | racket/contract)
5 |
6 | ;; permission->android-permissions: string (-> X)-> (or/c (listof string) X)
7 | ;; Given a permission, translates to the permissions associated with the Google Android platform.
8 | (define (permission->android-permissions a-permission on-fail)
9 | (define mapping '(["PERMISSION:LOCATION" "android.permission.ACCESS_COARSE_LOCATION"
10 | "android.permission.ACCESS_FINE_LOCATION"]
11 | ["PERMISSION:SEND-SMS" "android.permission.SEND_SMS"]
12 | ["PERMISSION:RECEIVE-SMS" "android.permission.RECEIVE_SMS"]
13 | ["PERMISSION:TILT"]
14 | ["PERMISSION:SHAKE"]
15 | ["PERMISSION:INTERNET" "android.permission.INTERNET"]
16 | ["PERMISSION:TELEPHONY" "android.permission.ACCESS_COARSE_UPDATES"]
17 | ["PERMISSION:WAKE-LOCK" "android.permission.WAKE_LOCK"]
18 | ["PERMISSION:VIBRATE" "android.permission.VIBRATE"]
19 | ["PERMISSION:FFI"]))
20 | (cond [(assoc a-permission mapping)
21 | =>
22 | (lambda (entry) (rest entry))]
23 | [else
24 | (on-fail)]))
25 |
26 | (provide/contract [permission->android-permissions (string? (-> any/c)
27 | . -> .
28 | (or/c any/c (listof string?)))])
--------------------------------------------------------------------------------
/src/android/helpers.ss:
--------------------------------------------------------------------------------
1 | #lang scheme/base
2 |
3 | (require scheme/contract)
4 |
5 | (require file/gzip)
6 |
7 | (define (gzip-bytes bytes)
8 | (let ([op (open-output-bytes)])
9 | (gzip-through-ports (open-input-bytes bytes) op #f 0)
10 | (get-output-bytes op)))
11 |
12 | (define (gunzip-bytes bytes)
13 | (let ([op (open-output-bytes)])
14 | (deflate (open-input-bytes bytes) op)
15 | (get-output-bytes op)))
16 |
17 |
18 | ;; gzip-string: string -> string
19 | (define (gzip-string a-string)
20 | (format "~s" (gzip-bytes (string->bytes/utf-8 a-string))))
21 |
22 | ;; gunzip-string: string -> string
23 | (define (gunzip-string a-string)
24 | (bytes->string/utf-8 (gunzip-bytes (read (open-input-string a-string)))))
25 |
26 |
27 |
28 |
29 | (provide/contract [gzip-bytes (bytes? . -> . bytes?)]
30 | [gunzip-bytes (bytes? . -> . bytes?)]
31 | [gzip-string (string? . -> . string?)]
32 | [gunzip-string (string? . -> . string?)])
--------------------------------------------------------------------------------
/src/android/server-side-packager/htdocs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Android packager
6 | This service should be accessed programmatically.
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/android/server-side-packager/logger.ss:
--------------------------------------------------------------------------------
1 | #lang racket/base
2 |
3 | (require racket/contract
4 | racket/path)
5 | ;; Logger module; record programs that have been sent to us.
6 |
7 |
8 | (define-struct logger (semaphore logfile-path))
9 |
10 |
11 | ;; -make-logger: path-string -> logger
12 | ;; Creates a new logger.
13 | (define (-make-logger logfile-path)
14 | (make-logger (make-semaphore 1)
15 | (normalize-path logfile-path)))
16 |
17 |
18 | ;; logger-add!: logger string bytes any -> void
19 | ;; Write a new entry into the log.
20 | (define (logger-add! a-logger client-ip asset-zip-bytes other-attributes)
21 | (call-with-semaphore
22 | (logger-semaphore a-logger)
23 | (lambda ()
24 | (call-with-output-file (logger-logfile-path a-logger)
25 | (lambda (op)
26 | (write `((time ,(current-inexact-milliseconds))
27 | (client-ip ,client-ip)
28 | (asset-zip-bytes ,asset-zip-bytes)
29 | (other-attributes ,other-attributes))
30 | op)
31 | (newline op))
32 | #:exists 'append))))
33 |
34 |
35 |
36 |
37 | (provide/contract
38 | [logger? (any/c . -> . boolean?)]
39 | [rename -make-logger make-logger (path-string? . -> . logger?)]
40 | [logger-add! (logger? string? bytes? any/c . -> . any)])
--------------------------------------------------------------------------------
/src/config.rkt:
--------------------------------------------------------------------------------
1 | #lang racket/base
2 |
3 | (require racket/contract)
4 |
5 |
6 | (provide/contract [current-ant-bin-path parameter?]
7 | [current-android-sdk-path parameter?])
8 |
9 | ;; These parameters may need to be adjusted.
10 |
11 | ;; current-ant-bin-path: (parameterof file-path)
12 | ;; Where the Apache Ant binary is installed.
13 | (define current-ant-bin-path (make-parameter
14 | (cond
15 | [(find-executable-path "ant")
16 | => (lambda (a-path)
17 | a-path)]
18 | [else
19 | (build-path "/usr/bin/ant")])))
20 |
21 | ;; current-android-sdk-path: (parameterof directory-path)
22 | ;; Where the Google Android SDK is installed.
23 | (define current-android-sdk-path (make-parameter
24 | (cond
25 | [(find-executable-path "android")
26 | => (lambda (a-path)
27 | (simplify-path
28 | (build-path a-path ".." "..")))]
29 | [else
30 | (build-path "/usr/local/android")])))
--------------------------------------------------------------------------------
/support/closure-compiler.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/support/closure-compiler.jar
--------------------------------------------------------------------------------
/support/icons/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/support/icons/icon.png
--------------------------------------------------------------------------------
/support/js.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/support/js.jar
--------------------------------------------------------------------------------
/support/js/css/choose.css:
--------------------------------------------------------------------------------
1 | body{
2 | width: 100%;
3 | min-width: 650px;
4 | height: 100%;
5 | padding: 0px;
6 | margin: 0px;
7 | background: #f5deb3;
8 | text-align: center;
9 | }
10 |
11 | h1, h2{
12 | text-align: center;
13 | width: 100%;
14 | background: #f5deb3;
15 | }
16 |
17 | h1{font-size: 60px;}
18 | h2{font-size: 20px;}
19 |
20 | img{background: none;
21 | vertical-align: middle;
22 | }
23 | #splash{
24 | position: absolute;
25 | width: 100%;
26 | min-width: 650px;
27 | text-align: center;
28 | top: 150px;
29 | }
30 | #login{
31 | display: none;
32 | width: 280px;
33 | height: 275px;
34 | background-image: url(images/halfscr-blue.gif);
35 | border: solid 5px black;
36 | -moz-border-radius: 160px;
37 | }
38 |
39 | #footer{
40 | position: fixed;
41 | width: 100%;
42 | bottom: 0px;
43 | height: 20px;
44 | color: white;
45 | background: black;
46 | text-align: center;
47 | margin: 0px;
48 | padding: 0px;
49 | }
50 |
51 | a{
52 | display: inline-block;
53 | width: 25%;
54 | margin: 30px;
55 | padding: 0px;
56 | color: white;
57 | clear: none;
58 | text-decoration: none;
59 | }
60 |
61 | .big {
62 | font-size: 30px;
63 | }
64 |
65 | .programName {
66 | font-size: 30px;
67 | font-family: Serif;
68 | font-style: italic;
69 | }
70 |
71 | a:hover{
72 | background: #546DAF;
73 | text-decoration: none;
74 | }
75 |
76 | .linkbutton{
77 | margin: 50px 50px;
78 | vertical-align: middle;
79 | border: solid 1px black;
80 | background: lightsteelblue;
81 | font-size: 1em;
82 | width: 180px;
83 | }
84 | .linkbutton:hover{
85 | background: gray;
86 | }
87 |
--------------------------------------------------------------------------------
/support/js/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/support/phonegap-fork/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .*.sw?
3 | tmp/
4 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/build.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked in Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # The name of your application package as defined in the manifest.
7 | # Used by the 'uninstall' rule.
8 | #application-package=com.example.myproject
9 |
10 | # The name of the source folder.
11 | #source-folder=src
12 |
13 | # The name of the output folder.
14 | #out-folder=bin
15 |
16 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-3
12 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DroidGap
4 | file:///android_asset/index.html
5 |
6 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/AccelTuple.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 | /* License (MIT)
3 | * Copyright (c) 2008 Nitobi
4 | * website: http://phonegap.com
5 | * Permission is hereby granted, free of charge, to any person obtaining
6 | * a copy of this software and associated documentation files (the
7 | * “Software”), to deal in the Software without restriction, including
8 | * without limitation the rights to use, copy, modify, merge, publish,
9 | * distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so, subject to
11 | * the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | public class AccelTuple {
26 | public long accelX;
27 | public long accelY;
28 | public long accelZ;
29 | }
30 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/ArgTable.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 | import java.util.HashMap;
4 |
5 | public class ArgTable {
6 |
7 | private HashMap args;
8 |
9 | public ArgTable() {
10 | args = new HashMap();
11 | }
12 |
13 | public Object get(String key) {
14 | return args.remove(key);
15 | }
16 |
17 | public void put(String key, Object val) {
18 | args.put(key, val);
19 | }
20 |
21 | public void clearCache() {
22 | args.clear();
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/CellInfo.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 | // A small structure for saving cell strength info.
4 |
5 | public class CellInfo {
6 | private int id;
7 | private int strength;
8 |
9 | public CellInfo(int id, int strength) {
10 | this.id = id;
11 | this.strength = strength;
12 | }
13 |
14 | public int getId() { return this.id; }
15 | public int getStrength() { return this.strength; }
16 | }
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/ConsoleOutput.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 | import android.content.Context;
4 | import android.webkit.WebView;
5 | import android.util.Log;
6 |
7 | /**
8 | * class designed to allow phonegap to print to the console
9 | * using the print and println methods.
10 | */
11 | public class ConsoleOutput {
12 |
13 | WebView mAppView;
14 | Context mCtx;
15 |
16 | public ConsoleOutput(Context ctx, WebView appView)
17 | {
18 | mCtx = ctx;
19 | mAppView = appView;
20 | }
21 |
22 | public void print(String msg) {
23 | System.out.print(msg);
24 | }
25 |
26 | public void println(String msg) {
27 | System.out.println(msg);
28 | }
29 |
30 | public void logd(String tag, String msg) {
31 | Log.d(tag, msg);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/GeoTuple.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 | /* License (MIT)
3 | * Copyright (c) 2008 Nitobi
4 | * website: http://phonegap.com
5 | * Permission is hereby granted, free of charge, to any person obtaining
6 | * a copy of this software and associated documentation files (the
7 | * “Software”), to deal in the Software without restriction, including
8 | * without limitation the rights to use, copy, modify, merge, publish,
9 | * distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so, subject to
11 | * the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 |
26 | public class GeoTuple {
27 |
28 | public double lat;
29 | public double lng;
30 | public double ele;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/LifecycleService.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 |
4 | public interface LifecycleService {
5 | void onPause();
6 | void onResume();
7 | void onStop();
8 | void onRestart();
9 | void onDestroy();
10 | }
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/Network.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 |
4 | import java.io.BufferedReader;
5 | import java.io.BufferedWriter;
6 | import java.io.IOException;
7 | import java.io.InputStreamReader;
8 | import java.io.StringWriter;
9 | import java.io.Reader;
10 | import java.io.Writer;
11 | import java.net.MalformedURLException;
12 | import java.net.URL;
13 | import java.net.URLEncoder;
14 | import java.net.URLConnection;
15 |
16 |
17 |
18 | public class Network {
19 | public String getUrl(String urlString) {
20 | try {
21 | URL url = new URL(urlString);
22 | URLConnection conn = url.openConnection();
23 | BufferedReader in = new BufferedReader
24 | (new InputStreamReader(conn.getInputStream()));
25 | StringWriter w = new StringWriter();
26 | BufferedWriter writer = new BufferedWriter(w);
27 | copyReaderToWriter(in, writer);
28 | in.close();
29 | writer.close();
30 | return w.getBuffer().toString();
31 | } catch (Throwable e) {
32 | e.printStackTrace();
33 | return new String("");
34 | }
35 | }
36 |
37 |
38 | private void copyReaderToWriter(Reader r, Writer w) throws IOException {
39 | int b;
40 | while (true) {
41 | b = r.read();
42 | if (b == -1) {
43 | break;
44 | }
45 | w.write(b);
46 | }
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/NoSuchToneException.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 | class NoSuchToneException extends RuntimeException {
4 |
5 | // public NoSuchToneException() {
6 | // super();
7 | // }
8 |
9 | public NoSuchToneException(int tone) {
10 | super("The tone " + tone + " does not exist.");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/Telephony.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 |
4 | import android.content.Context;
5 | import android.telephony.TelephonyManager;
6 | import android.telephony.NeighboringCellInfo;
7 |
8 | import java.util.List;
9 | import java.util.ArrayList;
10 |
11 | public class Telephony {
12 | private Context ctx;
13 |
14 | public Telephony(Context ctx) {
15 | this.ctx = ctx;
16 | }
17 |
18 | public List getSignalStrengths() {
19 | System.out.println("Trying to get signal strengths!");
20 | TelephonyManager mgr = (TelephonyManager)
21 | ctx.getSystemService(Context.TELEPHONY_SERVICE);
22 | List infos =
23 | mgr.getNeighboringCellInfo();
24 | System.out.println("I see infos: " + infos);
25 | List result = new ArrayList();
26 | for(NeighboringCellInfo info : infos) {
27 | System.out.println(info.getCid() + "> " + info.getRssi());
28 | result.add(new CellInfo(info.getCid(),
29 | info.getRssi()));
30 | }
31 | return result;
32 | }
33 | }
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/src/com/phonegap/demo/ToneHandler.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 | import android.media.AudioManager;
4 | import android.media.ToneGenerator;
5 |
6 | public class ToneHandler {
7 |
8 | private ToneGenerator generator;
9 | private Integer nowPlaying = null;
10 |
11 | private static final int[] TONE_VALUES =
12 | {ToneGenerator.TONE_DTMF_1, ToneGenerator.TONE_DTMF_2, ToneGenerator.TONE_DTMF_3, ToneGenerator.TONE_DTMF_A,
13 | ToneGenerator.TONE_DTMF_4, ToneGenerator.TONE_DTMF_5, ToneGenerator.TONE_DTMF_6, ToneGenerator.TONE_DTMF_B,
14 | ToneGenerator.TONE_DTMF_7, ToneGenerator.TONE_DTMF_8, ToneGenerator.TONE_DTMF_9, ToneGenerator.TONE_DTMF_C,
15 | ToneGenerator.TONE_DTMF_S, ToneGenerator.TONE_DTMF_0, ToneGenerator.TONE_DTMF_P, ToneGenerator.TONE_DTMF_D};
16 |
17 | public ToneHandler() {
18 | generator = new ToneGenerator(AudioManager.STREAM_RING, ToneGenerator.MAX_VOLUME);
19 | }
20 |
21 | public void playDTMF(int tone) {
22 | // if already playing the specified tone, then do nothing
23 | if (nowPlaying != null && tone == nowPlaying.intValue()) {
24 | return;
25 | }
26 |
27 | if (tone >= 0 && tone < TONE_VALUES.length) {
28 | generator.startTone(TONE_VALUES[tone]);
29 | nowPlaying = tone;
30 | }
31 | else {
32 | throw new NoSuchToneException(tone);
33 | }
34 | }
35 |
36 | public void stopDTMF() {
37 | nowPlaying = null;
38 | generator.stopTone();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/tests/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
13 |
18 |
21 |
22 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/tests/build.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked in Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # The name of your application package as defined in the manifest.
7 | # Used by the 'uninstall' rule.
8 | #application-package=com.example.myproject
9 |
10 | # The name of the source folder.
11 | #source-folder=src
12 |
13 | # The name of the output folder.
14 | #out-folder=bin
15 |
16 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/tests/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-3
12 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/tests/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked in Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk-location=/pro/plt/android/android-sdk-linux_x86-1.5_r2
11 |
--------------------------------------------------------------------------------
/support/phonegap-fork/android-1.5/tests/src/com/phonegap/demo/DroidGapTest.java:
--------------------------------------------------------------------------------
1 | package com.phonegap.demo;
2 |
3 | import android.test.ActivityInstrumentationTestCase;
4 |
5 | /**
6 | * This is a simple framework for a test of an Application. See
7 | * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
8 | * how to write and extend Application tests.
9 | *
10 | * To run this test, you can type:
11 | * adb shell am instrument -w \
12 | * -e class com.phonegap.demo.DroidGapTest \
13 | * com.phonegap.demo.tests/android.test.InstrumentationTestRunner
14 | */
15 | public class DroidGapTest extends ActivityInstrumentationTestCase {
16 |
17 | public DroidGapTest() {
18 | super("com.phonegap.demo", DroidGap.class);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------