├── .gitmodules ├── .project ├── README ├── doc ├── acknowledgements.txt ├── base-language.txt ├── contributors.txt ├── core-lang.txt ├── dom-data-types.txt ├── images │ └── hello.png ├── internal │ ├── DESIGN │ ├── TODO │ ├── android-functionality.txt │ ├── android-notes.txt │ ├── bsl-todo.txt │ ├── bugs.txt │ ├── extending.txt │ ├── gui-world-todo.txt │ ├── image-ss-todo.txt │ ├── imperative-effects-2.txt │ ├── imperative-effects.txt │ ├── j2me-android-gui-differences.txt │ ├── moby-application-proposals.txt │ ├── sound-design.txt │ └── wescheme-model-requirements.txt └── known-permissions.txt ├── examples ├── falling-ball.rkt ├── make-falling-ball.rkt ├── make-mood-ring.rkt ├── make-sensors.rkt ├── mood-ring.rkt └── sensors.rkt ├── info.ss ├── js-vm ├── base.rkt ├── bump-to.rkt ├── ffi │ └── ffi.rkt ├── js-impl.rkt ├── jsworld │ └── jsworld.rkt ├── main.rkt ├── permissions │ └── require-permission.rkt ├── private │ ├── compile-moby-module.rkt │ ├── log-port.rkt │ ├── misc.rkt │ ├── module-record.rkt │ ├── notification-window.rkt │ ├── write-module-records.rkt │ └── write-runtime.rkt └── wescheme.rkt ├── lang ├── moby.rkt └── reader.rkt ├── main.rkt ├── make-planet-archive.sh ├── manual.scrbl ├── phone ├── in-phone.rkt ├── internet.rkt ├── location.rkt ├── mock-location-setup.js ├── mock-location-setup.rkt ├── mock-tilt-setup.js ├── mock-tilt-setup.rkt ├── sms.rkt └── tilt.rkt ├── sandbox ├── adder │ ├── build.xml │ └── src │ │ └── Adder.java ├── arview │ ├── AndroidManifest.xml │ ├── bin │ │ ├── ARView-debug.apk │ │ ├── ARView.ap_ │ │ └── classes.dex │ ├── build.xml │ ├── default.properties │ ├── res │ │ └── values │ │ │ └── strings.xml │ └── src │ │ └── edu │ │ └── brown │ │ └── cs │ │ └── squirrel │ │ └── arview │ │ ├── ARView.java │ │ ├── ARViewView.java │ │ └── R.java ├── bootstrap-game.ss ├── cheney │ ├── Sketch │ │ ├── AndroidManifest.xml │ │ ├── build.xml │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── icon.png │ │ │ ├── layout │ │ │ │ ├── midpform.xml │ │ │ │ ├── midpgauge.xml │ │ │ │ ├── midplist.xml │ │ │ │ ├── midplistitem.xml │ │ │ │ ├── midpstringitem.xml │ │ │ │ └── splash.xml │ │ │ └── values │ │ │ │ └── strings.xml │ │ └── src │ │ │ ├── j2ab │ │ │ └── android │ │ │ │ └── app │ │ │ │ └── J2ABMIDletActivity.java │ │ │ ├── jad.properties │ │ │ ├── java │ │ │ ├── j2ab │ │ │ │ └── android │ │ │ │ │ ├── io │ │ │ │ │ ├── AndroidURLConnection.java │ │ │ │ │ ├── LogOutputStream.java │ │ │ │ │ └── file │ │ │ │ │ │ └── AndroidFileConnection.java │ │ │ │ │ ├── lcdui │ │ │ │ │ └── Toolkit.java │ │ │ │ │ └── pim │ │ │ │ │ ├── AndroidContactList.java │ │ │ │ │ ├── AndroidPIMItem.java │ │ │ │ │ ├── AndroidPIMList.java │ │ │ │ │ └── PreloadingAndroidPIMItem.java │ │ │ └── javax │ │ │ │ └── microedition │ │ │ │ ├── io │ │ │ │ ├── Connection.java │ │ │ │ ├── ConnectionNotFoundException.java │ │ │ │ ├── Connector.java │ │ │ │ ├── HttpConnection.java │ │ │ │ ├── InputConnection.java │ │ │ │ ├── OutputConnection.java │ │ │ │ ├── StreamConnection.java │ │ │ │ └── file │ │ │ │ │ ├── FileConnection.java │ │ │ │ │ ├── FileSystemListener.java │ │ │ │ │ └── FileSystemRegistry.java │ │ │ │ ├── lcdui │ │ │ │ ├── Alert.java │ │ │ │ ├── AlertType.java │ │ │ │ ├── Canvas.java │ │ │ │ ├── Command.java │ │ │ │ ├── CommandListener.java │ │ │ │ ├── Display.java │ │ │ │ ├── Displayable.java │ │ │ │ ├── Font.java │ │ │ │ ├── Form.java │ │ │ │ ├── Gauge.java │ │ │ │ ├── Graphics.java │ │ │ │ ├── Image.java │ │ │ │ ├── Item.java │ │ │ │ ├── ItemStateListener.java │ │ │ │ ├── List.java │ │ │ │ ├── Screen.java │ │ │ │ ├── StringItem.java │ │ │ │ ├── TextBox.java │ │ │ │ └── TextField.java │ │ │ │ ├── media │ │ │ │ ├── Control.java │ │ │ │ ├── Controllable.java │ │ │ │ ├── Manager.java │ │ │ │ ├── MediaException.java │ │ │ │ ├── Player.java │ │ │ │ ├── PlayerListener.java │ │ │ │ ├── TonePlayer.java │ │ │ │ └── control │ │ │ │ │ ├── ToneControl.java │ │ │ │ │ └── VolumeControl.java │ │ │ │ ├── midlet │ │ │ │ ├── MIDlet.java │ │ │ │ └── MIDletStateChangeException.java │ │ │ │ ├── pim │ │ │ │ ├── Contact.java │ │ │ │ ├── ContactList.java │ │ │ │ ├── PIM.java │ │ │ │ ├── PIMException.java │ │ │ │ ├── PIMItem.java │ │ │ │ └── PIMList.java │ │ │ │ └── rms │ │ │ │ ├── InvalidRecordIDException.java │ │ │ │ ├── RecordComparator.java │ │ │ │ ├── RecordEnumeration.java │ │ │ │ ├── RecordFilter.java │ │ │ │ ├── RecordStore.java │ │ │ │ ├── RecordStoreException.java │ │ │ │ ├── RecordStoreNotFoundException.java │ │ │ │ └── RecordStoreNotOpenException.java │ │ │ ├── net │ │ │ └── dclausen │ │ │ │ └── microfloat │ │ │ │ ├── BitUtils.java │ │ │ │ ├── MicroDouble.java │ │ │ │ └── MicroFloat.java │ │ │ ├── org │ │ │ └── plt │ │ │ │ ├── Kernel.java │ │ │ │ ├── Sketch │ │ │ │ ├── R.java │ │ │ │ └── Sketch.java │ │ │ │ ├── WorldKernel.java │ │ │ │ ├── checker │ │ │ │ ├── ArgumentChecker.java │ │ │ │ ├── PropertyChecker.java │ │ │ │ ├── RelationChecker.java │ │ │ │ └── SchemeException.java │ │ │ │ ├── gui │ │ │ │ ├── BasicPicture.java │ │ │ │ ├── CirclePicture.java │ │ │ │ ├── Color.java │ │ │ │ ├── DrawPicture.java │ │ │ │ ├── FilePicture.java │ │ │ │ ├── Graphics.java │ │ │ │ ├── GraphicsAdapter.java │ │ │ │ ├── NwRectanglePicture.java │ │ │ │ ├── Picture.java │ │ │ │ ├── PictureList.java │ │ │ │ ├── PictureVisitor.java │ │ │ │ ├── RectanglePicture.java │ │ │ │ ├── Scene.java │ │ │ │ └── TextPicture.java │ │ │ │ ├── guiworld │ │ │ │ ├── BoxGroup.java │ │ │ │ ├── Button.java │ │ │ │ ├── Canvas.java │ │ │ │ ├── CheckBox.java │ │ │ │ ├── Col.java │ │ │ │ ├── DropDown.java │ │ │ │ ├── Gui.java │ │ │ │ ├── GuiRenderer.java │ │ │ │ ├── GuiVisitor.java │ │ │ │ ├── GuiWorld.java │ │ │ │ ├── Message.java │ │ │ │ ├── Row.java │ │ │ │ ├── Slider.java │ │ │ │ └── TextField.java │ │ │ │ ├── lib │ │ │ │ ├── Location.java │ │ │ │ ├── LocationService.java │ │ │ │ ├── Net.java │ │ │ │ ├── NetworkService.java │ │ │ │ ├── Parser.java │ │ │ │ ├── Sms.java │ │ │ │ ├── SmsService.java │ │ │ │ ├── Tilt.java │ │ │ │ └── TiltService.java │ │ │ │ ├── parser │ │ │ │ └── XmlParser.java │ │ │ │ ├── platform │ │ │ │ ├── AndroidPlatform.java │ │ │ │ ├── J2MEPlatform.java │ │ │ │ ├── Platform.java │ │ │ │ └── PlatformI.java │ │ │ │ ├── types │ │ │ │ ├── Bignum.java │ │ │ │ ├── Callable.java │ │ │ │ ├── Complex.java │ │ │ │ ├── Empty.java │ │ │ │ ├── EofObject.java │ │ │ │ ├── FloatPoint.java │ │ │ │ ├── List.java │ │ │ │ ├── Logic.java │ │ │ │ ├── Number.java │ │ │ │ ├── NumberTower.java │ │ │ │ ├── Pair.java │ │ │ │ ├── Posn.java │ │ │ │ ├── Rational.java │ │ │ │ ├── Struct.java │ │ │ │ ├── Symbol.java │ │ │ │ └── VoidObject.java │ │ │ │ └── world │ │ │ │ ├── AccelerationChangeListener.java │ │ │ │ ├── Bootstrap.java │ │ │ │ ├── LocationChangeListener.java │ │ │ │ ├── MessageListener.java │ │ │ │ ├── OrientationChangeListener.java │ │ │ │ ├── WorldAndObjectTransformer.java │ │ │ │ ├── WorldConsumer.java │ │ │ │ ├── WorldJudge.java │ │ │ │ ├── WorldRunner.java │ │ │ │ ├── WorldTransformer.java │ │ │ │ └── config │ │ │ │ ├── Config.java │ │ │ │ ├── ConfigReader.java │ │ │ │ ├── ConfigVisitor.java │ │ │ │ ├── Kernel.java │ │ │ │ ├── OnAcceleration.java │ │ │ │ ├── OnKey.java │ │ │ │ ├── OnLocationChange.java │ │ │ │ ├── OnMessage.java │ │ │ │ ├── OnMouse.java │ │ │ │ ├── OnRedraw.java │ │ │ │ ├── OnTick.java │ │ │ │ ├── OnTilt.java │ │ │ │ └── StopWhen.java │ │ │ └── platform.implementation │ ├── cheney-test-2.html │ ├── cheney-test-2.js │ ├── cheney-test-3.html │ ├── cheney-test-3.js │ ├── cheney-test.html │ ├── cheney-test.js │ ├── data │ │ ├── README │ │ ├── firefox-3.1 │ │ │ ├── sumIterUsingException.txt │ │ │ ├── sumIterUsingTimeout.txt │ │ │ ├── sumUsingException.txt │ │ │ └── sumUsingTimeout.txt │ │ ├── fitting.ss │ │ └── safari │ │ │ ├── sumIterUsingException.txt │ │ │ ├── sumIterUsingTimeout.txt │ │ │ ├── sumUsingException.txt │ │ │ └── sumUsingTimeout.txt │ └── sketch.ss ├── circle │ ├── build.xml │ └── src │ │ └── MovingBall.java ├── examples │ ├── README │ ├── baduk-clock.ss │ ├── beep-volume.ss │ ├── bell-choir.ss │ ├── falling-ball.ss │ ├── flight-lander.ss │ ├── homeward-bound.ss │ ├── lullaby.ss │ ├── minding-the-store-simulated.ss │ ├── minding-the-store.ss │ ├── rolling-out-of-time-with-keys.ss │ ├── rolling-out-of-time.ss │ ├── simple-location.ss │ └── sms-receiving.ss ├── guiworld-android │ ├── AndroidManifest.xml │ ├── build.xml │ ├── res │ │ ├── layout │ │ │ └── main.xml │ │ └── values │ │ │ └── strings.xml │ └── src │ │ └── org │ │ └── plt │ │ └── GuiWorldTest.java ├── guiworld │ ├── build.xml │ └── src │ │ └── GuiWorldTest.java ├── old-src │ ├── android │ │ ├── android-packager.ss │ │ ├── helpers.ss │ │ ├── local-android-packager.ss │ │ └── server-side-packager │ │ │ ├── client-side-packager.ss │ │ │ ├── logger.ss │ │ │ └── server-side-packager.ss │ ├── bootstrap-js-compiler.ss │ ├── collects │ │ ├── bootstrap │ │ │ ├── bootstrap-teachpack.ss │ │ │ ├── cage-teachpack.ss │ │ │ └── function-teachpack.ss │ │ └── moby │ │ │ └── runtime │ │ │ ├── arity-struct.ss │ │ │ ├── binding.ss │ │ │ ├── dom-helpers.ss │ │ │ ├── dom-parameters.ss │ │ │ ├── effect-struct.ss │ │ │ ├── error-struct-to-dom.ss │ │ │ ├── error-struct.ss │ │ │ ├── permission-struct.ss │ │ │ ├── runtime-modules.ss │ │ │ ├── scheme-value-to-dom.ss │ │ │ └── stx.ss │ ├── compile-helpers-with-images.ss │ ├── compile-helpers.ss │ ├── compiler │ │ ├── analyzer.ss │ │ ├── beginner-to-javascript.ss │ │ ├── desugar.ss │ │ ├── env.ss │ │ ├── helpers.ss │ │ ├── info.ss │ │ ├── labeled-translation.ss │ │ ├── lang.ss │ │ ├── modules.ss │ │ ├── mzscheme-vm │ │ │ ├── compile.ss │ │ │ ├── env.ss │ │ │ ├── mzscheme-vm.ss │ │ │ ├── servlet-htdocs │ │ │ │ ├── evaluator.js │ │ │ │ ├── index.html │ │ │ │ └── main.js │ │ │ ├── servlet.ss │ │ │ ├── test-mzscheme-vm.ss │ │ │ └── write-support.ss │ │ ├── pinfo.ss │ │ ├── rbtree.ss │ │ ├── test-helpers.ss │ │ ├── toplevel.ss │ │ ├── transform │ │ │ ├── anormal-frag-helpers.ss │ │ │ ├── anormalize.ss │ │ │ ├── box-local-defs.ss │ │ │ ├── elim-anon.ss │ │ │ ├── fragmenter.ss │ │ │ ├── munge-ids.ss │ │ │ └── test-cases.ss │ │ └── version.ss │ ├── config.ss │ ├── dump-color-database.ss │ ├── generate-application.ss │ ├── get-intermediate-symbols.ss │ ├── image-lift.ss │ ├── info.ss │ ├── moby-lang.ss │ ├── moby.ss │ ├── mobyc.ss │ ├── private │ │ └── restricted-runtime-scheme.ss │ ├── program-resources.ss │ ├── resource.ss │ ├── serve.ss │ ├── stub │ │ ├── bootstrap.ss │ │ ├── jsworld.ss │ │ ├── lat-lon-distance.ss │ │ ├── location.ss │ │ ├── net.ss │ │ ├── parser.ss │ │ ├── sms.ss │ │ ├── tilt.ss │ │ ├── world-config.ss │ │ ├── world-effects.ss │ │ └── world.ss │ ├── stx-helpers.ss │ ├── template.ss │ ├── test-generate-application.ss │ ├── test │ │ ├── basic.ss │ │ ├── build.xml │ │ ├── eqhash-performance-check.ss │ │ ├── htdp.zip │ │ ├── java-src │ │ │ └── org │ │ │ │ └── plt │ │ │ │ ├── TestKernel.java │ │ │ │ ├── TestMath.java │ │ │ │ ├── TestNumber.java │ │ │ │ └── TestXmlParser.java │ │ ├── sample-moby-programs │ │ │ ├── approx-equal.ss │ │ │ ├── bubble-2.ss │ │ │ ├── bubble-3.ss │ │ │ ├── bubble.ss │ │ │ ├── button-with-picture.ss │ │ │ ├── chicken.ss │ │ │ ├── cowabunga.ss │ │ │ ├── falling-ball-pair.ss │ │ │ ├── falling-ball-posn.ss │ │ │ ├── falling-ball.ss │ │ │ ├── falling-cow.ss │ │ │ ├── fire-fighter.ss │ │ │ ├── flight-lander.ss │ │ │ ├── get-ip-address.ss │ │ │ ├── grocery-shopper.ss │ │ │ ├── gui-world-box-group.ss │ │ │ ├── gui-world-checkbox.ss │ │ │ ├── gui-world-drop-down.ss │ │ │ ├── gui-world-hello-world.ss │ │ │ ├── gui-world-location.ss │ │ │ ├── gui-world-text-field.ss │ │ │ ├── hello-world.ss │ │ │ ├── homeward-bound-single.ss │ │ │ ├── homeward-bound.ss │ │ │ ├── image-question.ss │ │ │ ├── info.ss │ │ │ ├── jsworld │ │ │ │ ├── jsworld-fading.ss │ │ │ │ ├── location.ss │ │ │ │ ├── maps-mashup.html │ │ │ │ ├── maps-mashup.ss │ │ │ │ ├── signal-strengths.ss │ │ │ │ └── simple-button.ss │ │ │ ├── line.ss │ │ │ ├── local.ss │ │ │ ├── location-2.ss │ │ │ ├── location.ss │ │ │ ├── move-ball.ss │ │ │ ├── net.ss │ │ │ ├── parse-google-maps-places.ss │ │ │ ├── pick-playlist.ss │ │ │ ├── pinholes.ss │ │ │ ├── rectangles.ss │ │ │ ├── reflex-scene.ss │ │ │ ├── shake-for-music.ss │ │ │ ├── shake-to-dtmf.ss │ │ │ ├── shake-to-ring.ss │ │ │ ├── simple-bootstrap-game.ss │ │ │ ├── sketch-2.ss │ │ │ ├── sketch.ss │ │ │ ├── sms.ss │ │ │ ├── spaceflight.ss │ │ │ ├── struct-question.ss │ │ │ ├── talk │ │ │ │ ├── bubble-2a.ss │ │ │ │ ├── bubble-2b.ss │ │ │ │ └── bubble-2c.ss │ │ │ ├── tilt.ss │ │ │ └── upside-down.ss │ │ └── test-harness.ss │ ├── tool.ss │ └── utils.ss ├── schanzer │ └── Archive.zip ├── sentence-maker.ss ├── timing │ └── measure-throw-time.html ├── tones │ ├── C-tone.wav │ ├── D-tone.wav │ ├── E-tone.wav │ └── G-tone.wav └── tsrj │ ├── location-announcer.ss │ ├── marble-with-trail.ss │ ├── marble.ss │ ├── silencing-music.ss │ └── simple-location.ss ├── src ├── android │ ├── android-packager.ss │ ├── android-permission.rkt │ ├── helpers.ss │ ├── local-android-packager.ss │ └── server-side-packager │ │ ├── client-side-packager.ss │ │ ├── htdocs │ │ └── index.html │ │ ├── logger.ss │ │ └── server-side-packager.ss ├── compile-helpers.rkt ├── config.rkt ├── tool.rkt └── utils.rkt └── support ├── calcdeps.py ├── closure-compiler.jar ├── icons └── icon.png ├── js.jar ├── js ├── css │ └── choose.css └── index.html └── phonegap-fork ├── .gitignore └── android-1.5 ├── AndroidManifest.xml ├── assets ├── index.html └── phonegap.js ├── build.properties ├── build.xml ├── default.properties ├── res ├── layout │ └── main.xml └── values │ └── strings.xml ├── src ├── com │ └── phonegap │ │ └── demo │ │ ├── AccelListener.java │ │ ├── AccelTuple.java │ │ ├── ArgTable.java │ │ ├── AudioHandler.java │ │ ├── CameraHandler.java │ │ ├── CameraListener.java │ │ ├── CellInfo.java │ │ ├── ConsoleOutput.java │ │ ├── DirectoryManager.java │ │ ├── DroidGap.java │ │ ├── GeoBroker.java │ │ ├── GeoListener.java │ │ ├── GeoTuple.java │ │ ├── GpsListener.java │ │ ├── HttpHandler.java │ │ ├── LifecycleService.java │ │ ├── LocationProviderListener.java │ │ ├── Network.java │ │ ├── NetworkListener.java │ │ ├── NoSuchToneException.java │ │ ├── PhoneGap.java │ │ ├── SmsListener.java │ │ ├── Telephony.java │ │ └── ToneHandler.java └── plt │ └── playlist │ ├── PickPlaylist.java │ ├── PlaylistPlayer.java │ └── PlaylistRecord.java └── tests ├── AndroidManifest.xml ├── build.properties ├── build.xml ├── default.properties ├── local.properties └── src └── com └── phonegap └── demo └── DroidGapTest.java /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/.gitmodules -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | trunk 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Moby 2 | ------ 3 | Danny Yoo (dyoo@cs.wpi.edu) 4 | 5 | Moby have been deprecated in favor of the Whalesong project. Please 6 | take a look at that instead. 7 | 8 | http://hashcollision.org/whalesong/ 9 | -------------------------------------------------------------------------------- /doc/acknowledgements.txt: -------------------------------------------------------------------------------- 1 | JUnit 4.5: http://junit.org/ 2 | License: Common Public License 1.0 3 | 4 | 5 | YUI Compressor: http://developer.yahoo.com/yui/compressor/ 6 | support/yuicompresor-2.4.2.jar 7 | 8 | 9 | Phonegap http://phonegap.com/ 10 | support/phonegap-fork 11 | 12 | 13 | Gears init http://code.google.com/apis/gears/tools.html 14 | support/js/gears_init.js 15 | 16 | 17 | excanvas: http://excanvas.sourceforge.net/ 18 | support/js/compat/excanvas.js 19 | 20 | 21 | canvas-text: http://code.google.com/p/canvas-text/ 22 | support/js/compat/canvas-text 23 | 24 | xmlhttprequest: cross browser XMLHttpRequest: http://code.google.com/p/xmlhttprequest/ 25 | 26 | 27 | jshahstable: http://www.timdown.co.uk/jshashtable/ 28 | support/js/jshashtable.js 29 | -------------------------------------------------------------------------------- /doc/contributors.txt: -------------------------------------------------------------------------------- 1 | The following people have helped implement Moby: 2 | 3 | Danny Yoo 4 | Zhe Zhang 5 | Ethan Cecchetti 6 | Brendan Hickey 7 | Shriram Krishanmurthi 8 | Caner Derici 9 | Noah Zimmt 10 | -------------------------------------------------------------------------------- /doc/images/hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/doc/images/hello.png -------------------------------------------------------------------------------- /doc/internal/bsl-todo.txt: -------------------------------------------------------------------------------- 1 | Details on Beginner Scheme primitives: 2 | 3 | 4 | Primitives that need implementation: 5 | 6 | (format 7 | image=? 8 | image-rotate) 9 | 10 | You can look at the code in support/j2me/src/org/plt/WorldKernel.java 11 | and support/common/src/org/plt/Kernel.java for implementations of the 12 | primitives we support so far. Any primitive you write also needs to 13 | be registered in moby/src/toplevel.ss. 14 | -------------------------------------------------------------------------------- /doc/internal/bugs.txt: -------------------------------------------------------------------------------- 1 | * Image transparency isn't being done during image lifting. This 2 | might be a problem in DrScheme itself, as pure white is being 3 | treated as the transparent color, which is the wrong approach: we 4 | should be using alpha transparency throughout. 5 | 6 | * The test case org.plt.TestKernel.testBigExp is failing because 7 | our current approach always converts to floating point. 8 | 9 | * BigInteger literals aren't being handled in beginner-to-javascript 10 | 11 | * Functions that are recursive can trigger an effective stack 12 | overflow, manifested as an exception in android.view.ViewRoot.draw. 13 | Run the sketch test program for some period of time, and the error 14 | should mainfest. 15 | 16 | * The unit tests in TestKernel concerning the complex numbers aren't 17 | exercising that functionality correctly. 18 | 19 | * placeImage breaks if the scene passed in is an Image, and not a 20 | Scene. 21 | 22 | * apks hosted on a web server may not be hosted properly. This may be 23 | a consequence of 24 | http://code.google.com/p/android/issues/detail?id=1085, but I'm not 25 | sure. 26 | 27 | * open-image-url breaks badly if the image url isn't good. 28 | 29 | * The reader in read.ss doesn't tell the location in the exception object 30 | it throws. 31 | 32 | * The identifiers in read.js aren't in the plt package. 33 | -------------------------------------------------------------------------------- /doc/internal/gui-world-todo.txt: -------------------------------------------------------------------------------- 1 | The GUI subclasses: 2 | 3 | canvas 4 | slider 5 | 6 | are still in need of implementation. 7 | 8 | 9 | Implement these in the GuiRenderer class: 10 | 11 | moby/support/j2me/src/org/plt/guiworld/GuiRenderer 12 | 13 | 14 | 15 | The widgets are in: 16 | 17 | moby/support/common/src/org/plt/guiworld/ 18 | 19 | 20 | As you add implementations for the widgets, adjust the GuiWorldTest 21 | program in 22 | 23 | moby/sandbox/guiworld 24 | 25 | and test the widgets out. 26 | 27 | 28 | 29 | Integrate the other event hooks (on-location, on-tilt, on-acceleration, on-key, on-tick) into gui-world. -------------------------------------------------------------------------------- /doc/internal/image-ss-todo.txt: -------------------------------------------------------------------------------- 1 | image-color? 2 | ellipse 3 | triangle 4 | star 5 | regular-polygon 6 | add-line 7 | overlay 8 | overlay/xy 9 | image-inside? 10 | find-image 11 | shrink-tl 12 | shrink-tr 13 | shrink-bl 14 | shrink-br 15 | shrink 16 | image->color-list 17 | color-list->image 18 | 19 | (struct alpha-color (alpha red green blue)) 20 | image->alpha-color-list 21 | alpha-color-list->image -------------------------------------------------------------------------------- /doc/internal/j2me-android-gui-differences.txt: -------------------------------------------------------------------------------- 1 | Catalog of differences we see in the J2ME-Android bridge. 2 | 3 | 4 | * The font used in the text image constructor produces larger text in 5 | Android than in J2ME. hello-world is an example that shows the 6 | problem. See images/hello.png, which shows a screenshot of both. 7 | 8 | 9 | * In Cowabunga, the frame rate on Android seems to be running faster 10 | than in J2ME. The controls are also slightly less responsive: 11 | sometimes pressing left doesn't register quickly enough. This might 12 | be a side effect of the fast frame rate. 13 | 14 | 15 | * Falling cow: the frame rate of the cow falling in android seems 16 | choppier than that of j2me. 17 | 18 | 19 | * Firefighter: the animation of Firefighter slows down tremendously 20 | when there are a lot of images in Android. Pressing down a lot 21 | makes the animation chunk up, with very bad latency on controls. 22 | This isn't a problem in J2ME. 23 | 24 | * Flightlander: the animation is much too fast in Android. 25 | Thread.sleep isn't performing the same? 26 | -------------------------------------------------------------------------------- /doc/internal/moby-application-proposals.txt: -------------------------------------------------------------------------------- 1 | Silencing music player: Allow the user to pick a playlist and a 2 | duration. Start playing the playlist. As the duration expires, 3 | gradually weaken the volume until it goes away. If the user shakes 4 | the phone, they're still awake -- restore the volume and keep playing. 5 | Repeat. 6 | 7 | 8 | Zombie: implement the zombie variation of the hide-and-seek game. Use 9 | location services to arrange the world in a grid. People are either 10 | regular players or zombies; if a zombie gets close enough to a player, 11 | that player becomes a zombie. 12 | 13 | 14 | rock-paper-scissors: Implement rock-paper-scissors using Universe. 15 | Conflict resolution using rock-paper-scissors. 16 | 17 | 18 | ipov: an intent-driven program. Have a program listen to SMS intents: 19 | if a particular SMS intent is received, the program should respond by 20 | sending an SMS of the current location. 21 | 22 | 23 | phone scammer/spammer warnings. 24 | (http://snappletronics.blogspot.com/2009/05/steal-this-idea-phone-scammerspammer.html) 25 | When a phone call from an unknown entity comes in, run it through 26 | whocalled.us (http://whocalled.us/) and see if it's a spammer. 27 | Possibly integrate with https://donotcall.gov/. 28 | -------------------------------------------------------------------------------- /doc/internal/wescheme-model-requirements.txt: -------------------------------------------------------------------------------- 1 | 2 | * Allow users to rate each other's programs. 3 | 4 | * Add a student / teacher hierarchical model for users. 5 | 6 | * Teachers should be able to put up homework assignment material visible only to their students. 7 | 8 | * Students should be able to submit solutions that are visible only to the teacher. 9 | 10 | * Students might work in teams. 11 | 12 | * Students should be allowed to put up new public programs, although a teacher may need to moderate it before it becomes visible. 13 | -------------------------------------------------------------------------------- /doc/known-permissions.txt: -------------------------------------------------------------------------------- 1 | PERMISSION:LOCATION 2 | PERMISSION:SEND-SMS 3 | PERMISSION:RECEIVE-SMS 4 | PERMISSION:TILT 5 | PERMISSION:SHAKE 6 | PERMISSION:INTERNET 7 | PERMISSION:TELEPHONY 8 | PERMISSION:WAKE-LOCK 9 | PERMISSION:VIBRATE 10 | PERMISSION:FFI 11 | 12 | -------------------------------------------------------------------------------- /examples/falling-ball.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/moby:3:9 2 | 3 | ;; Simple falling ball example. A red ball falls down the screen 4 | ;; until hitting the bottom. 5 | 6 | 7 | (printf "falling-ball.rkt\n") 8 | 9 | (define-struct world (radius y)) 10 | 11 | 12 | ;; The dimensions of the screen: 13 | (define WIDTH 320) 14 | (define HEIGHT 480) 15 | 16 | ;; The radius of the red circle. 17 | (define RADIUS 15) 18 | 19 | ;; The world is the distance from the top of the screen. 20 | (define INITIAL-WORLD (make-world RADIUS 0)) 21 | 22 | ;; tick: world -> world 23 | ;; Moves the ball down. 24 | (define (tick w) 25 | (make-world RADIUS (+ (world-y w) 5))) 26 | 27 | 28 | ;; hits-floor?: world -> boolean 29 | ;; Returns true when the distance reaches the screen height. 30 | (define (hits-floor? w) 31 | (>= (world-y w) HEIGHT)) 32 | 33 | ;; We have some simple test cases. 34 | (check-expect (hits-floor? (make-world RADIUS 0)) false) 35 | (check-expect (hits-floor? (make-world RADIUS HEIGHT)) true) 36 | 37 | ;; render: world -> scene 38 | ;; Produces a scene with the circle at a height described by the world. 39 | (define (render w) 40 | (place-image (circle RADIUS "solid" "red") (/ WIDTH 2) (world-y w) 41 | (empty-scene WIDTH HEIGHT))) 42 | 43 | ;; Start up a big bang, 15 frames a second. 44 | (check-expect (big-bang INITIAL-WORLD 45 | (on-tick tick 1/15) 46 | (to-draw render) 47 | (stop-when hits-floor?)) 48 | (make-world 15 480)) 49 | -------------------------------------------------------------------------------- /examples/make-falling-ball.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | (require (planet dyoo/moby:3:9)) 3 | (create-android-phone-package "falling-ball.rkt" "falling-ball.apk") 4 | 5 | -------------------------------------------------------------------------------- /examples/make-mood-ring.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | (require (planet dyoo/moby:3:9)) 3 | (create-android-phone-package "mood-ring.rkt" "mood.apk") 4 | 5 | -------------------------------------------------------------------------------- /examples/make-sensors.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | (require (planet dyoo/moby:3:9)) 3 | (create-android-phone-package "sensors.rkt" "sensors.apk") 4 | 5 | -------------------------------------------------------------------------------- /examples/mood-ring.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/moby:3:9 2 | (require (planet dyoo/moby:3:9/phone/tilt)) 3 | 4 | ; The world is a color. 5 | (define initial-world (make-color 0 0 0)) 6 | 7 | ; tilt: world number number number -> world 8 | ; Tilting the phone adjusts the color. 9 | (define (tilt w azimuth pitch roll) 10 | (make-color (scale azimuth 360) 11 | (scale (+ pitch 90) 180) 12 | (scale (+ roll 90) 180))) 13 | 14 | ; scale-azimuth: number -> number 15 | ; Take a number going from 0-360 and scale it to a number between 0-255 16 | (define (scale n domain-bound) 17 | (inexact->exact (floor (* (/ n domain-bound) 255)))) 18 | 19 | ; User interface. 20 | (define view (list (js-div '((id "background"))))) 21 | 22 | (define (draw-html w) view) 23 | 24 | (define (draw-css w) 25 | (list (list "background" 26 | (list "background-color" 27 | (format "rgb(~a, ~a, ~a)" 28 | (color-red w) 29 | (color-green w) 30 | (color-blue w))) 31 | (list "width" "300") 32 | (list "height" "300")))) 33 | 34 | 35 | 36 | (big-bang initial-world 37 | (on-tilt tilt) 38 | (to-draw-page draw-html draw-css)) 39 | -------------------------------------------------------------------------------- /examples/sensors.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/moby:3:9 2 | (require (planet dyoo/moby:3:9/phone/tilt)) 3 | (require (planet dyoo/moby:3:9/phone/location)) 4 | 5 | (define-struct gps (lat lng)) 6 | (define-struct tilt (a p r)) 7 | (define-struct accel (x y z)) 8 | 9 | (define-struct sensors (gps tilt accel)) 10 | 11 | (define (update-gps w lat lng) 12 | (make-sensors (make-gps lat lng) 13 | (sensors-tilt w) 14 | (sensors-accel w))) 15 | 16 | (define (update-tilt w a p r) 17 | (make-sensors (sensors-gps w) 18 | (make-tilt a p r) 19 | (sensors-accel w))) 20 | 21 | (define (update-accel w x y z) 22 | (make-sensors (sensors-gps w) 23 | (sensors-tilt w) 24 | (make-accel x y z))) 25 | 26 | (big-bang (make-sensors (make-gps "loading" "loading") 27 | (make-tilt "loading" "loading" "loading") 28 | (make-accel "loading" "loading" "loading")) 29 | (on-location-change update-gps) 30 | (on-tilt update-tilt) 31 | (on-acceleration update-accel)) -------------------------------------------------------------------------------- /info.ss: -------------------------------------------------------------------------------- 1 | #lang setup/infotab 2 | (define name "Moby") 3 | 4 | ;; Temporarily disabling the command-line launcher. 5 | (define required-core-version "5.0.1") 6 | 7 | #;(define drracket-name "moby") 8 | #;(define drracket-tools (list (list "src/tool.rkt"))) 9 | 10 | (define primary-file "main.rkt") 11 | (define can-be-loaded-with 'all) 12 | 13 | (define compile-omit-paths (list "doc" 14 | "examples" 15 | "sandbox" 16 | "stub" 17 | "support" 18 | "tmp")) 19 | 20 | (define scribblings '(("manual.scrbl"))) 21 | 22 | (define categories '(devtools)) 23 | (define repositories '("4.x")) 24 | 25 | (define version "3.10") 26 | 27 | (define blurb '("Provides a compiler from Advanced Student Language+world to Javascript " 28 | "for mobile smartphones.")) 29 | 30 | 31 | (define release-notes 32 | '((p "Changes" 33 | (ul 34 | 35 | (li "Jsworld has relaxed constraints on attribute values. Attribute values can now be strings or booleans. An additional type check will raise an error if a non-string, non-boolean is given.") 36 | (li "Fixed bug: world widgets would have their contents erroneously deleted under certain situations.") 37 | 38 | (li "Removed whitespace PRE styling on js-text nodes.") 39 | (li "Fixed low level bug: generated packages could be larger because they contained multiply copies of a module."))))) 40 | -------------------------------------------------------------------------------- /js-vm/base.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/lang/base)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/lang/base))) -------------------------------------------------------------------------------- /js-vm/bump-to.rkt: -------------------------------------------------------------------------------- 1 | #lang racket 2 | 3 | 4 | (define files-to-change 5 | (find-files (lambda (p) 6 | (and (file-exists? p) 7 | (bytes=? (filename-extension p) 8 | #"rkt"))))) 9 | 10 | (define (change-version b from to) 11 | (regexp-replace* (format ":~a" from) 12 | b 13 | (format ":~a" to))) 14 | 15 | 16 | (define from (vector-ref (current-command-line-arguments) 0)) 17 | (define to (vector-ref (current-command-line-arguments) 1)) 18 | (printf "Changing ~a to ~a\n" 19 | from to) 20 | (printf "Press enter to continue...") 21 | (read-line) 22 | (for ([f files-to-change]) 23 | (let ([b (file->bytes f)]) 24 | (call-with-output-file f 25 | (lambda (op) 26 | (write-bytes (change-version b from to) op)) 27 | #:exists 'replace))) 28 | -------------------------------------------------------------------------------- /js-vm/ffi/ffi.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/ffi/ffi)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/ffi/ffi))) -------------------------------------------------------------------------------- /js-vm/js-impl.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | (require (prefix-in base: (planet dyoo/js-vm:1:=14/lang/base))) 3 | (base:require (planet dyoo/js-vm:1:=14/lang/js-impl/js-impl)) 4 | (base:provide (base:all-from-out (planet dyoo/js-vm:1:=14/lang/js-impl/js-impl))) 5 | 6 | 7 | -------------------------------------------------------------------------------- /js-vm/jsworld/jsworld.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/jsworld/jsworld)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/jsworld/jsworld))) -------------------------------------------------------------------------------- /js-vm/main.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/main)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/main))) -------------------------------------------------------------------------------- /js-vm/permissions/require-permission.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/permissions/require-permission)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/permissions/require-permission))) -------------------------------------------------------------------------------- /js-vm/private/compile-moby-module.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/compile-moby-module)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/compile-moby-module))) -------------------------------------------------------------------------------- /js-vm/private/log-port.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/log-port)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/log-port))) -------------------------------------------------------------------------------- /js-vm/private/misc.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/misc)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/misc))) -------------------------------------------------------------------------------- /js-vm/private/module-record.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/module-record)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/module-record))) -------------------------------------------------------------------------------- /js-vm/private/notification-window.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/notification-window)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/notification-window))) -------------------------------------------------------------------------------- /js-vm/private/write-module-records.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/write-module-records)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/write-module-records))) -------------------------------------------------------------------------------- /js-vm/private/write-runtime.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/private/write-runtime)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/private/write-runtime))) -------------------------------------------------------------------------------- /js-vm/wescheme.rkt: -------------------------------------------------------------------------------- 1 | #lang planet dyoo/js-vm:1:=14/base 2 | 3 | (require (planet dyoo/js-vm:1:=14/lang/wescheme)) 4 | (provide (all-from-out (planet dyoo/js-vm:1:=14/lang/wescheme))) -------------------------------------------------------------------------------- /lang/moby.rkt: -------------------------------------------------------------------------------- 1 | #lang s-exp "../js-vm/base.rkt" 2 | 3 | (require "../js-vm/wescheme.rkt") 4 | (provide (all-from-out "../js-vm/wescheme.rkt")) -------------------------------------------------------------------------------- /lang/reader.rkt: -------------------------------------------------------------------------------- 1 | #lang s-exp syntax/module-reader 2 | 3 | ;; http://docs.racket-lang.org/planet/hash-lang-planet.html 4 | 5 | 6 | #:language (lambda (ip) 7 | `(file ,(path->string base-lang-path))) 8 | 9 | 10 | (require racket/runtime-path) 11 | (define-runtime-path base-lang-path "moby.rkt") 12 | -------------------------------------------------------------------------------- /make-planet-archive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | MAJOR=3 # `perl -ne 'if (/define MAJOR \"(.*)\"/) { print $1} ' src/compiler/version.ss` 3 | MINOR=10 #`perl -ne 'if (/define MINOR \"(.*)\"/) { print $1} ' src/compiler/version.ss` 4 | 5 | 6 | OLDDIR=`pwd` 7 | mkdir -p tmp 8 | rm -rf tmp/moby 9 | git archive --format=tar --prefix=moby/ HEAD | (cd tmp && tar xf -) 10 | 11 | cd $OLDDIR/tmp/moby 12 | rm -rf sandbox 13 | 14 | 15 | cd $OLDDIR/tmp 16 | 17 | planet unlink dyoo moby.plt $MAJOR $MINOR 18 | planet link dyoo moby.plt $MAJOR $MINOR moby 19 | 20 | planet create moby 21 | 22 | planet unlink dyoo moby.plt $MAJOR $MINOR 23 | 24 | cd $OLDDIR 25 | cp tmp/moby.plt . -------------------------------------------------------------------------------- /phone/in-phone.rkt: -------------------------------------------------------------------------------- 1 | #lang s-exp "../js-vm/base.rkt" 2 | 3 | (require "../js-vm/ffi/ffi.rkt") 4 | 5 | 6 | ;; running-in-phone-context? 7 | ;; Produces true if we're running in the context of a phonegap-supporting 8 | ;; environment. 9 | (define (running-in-phone-context?) 10 | (not (js-undefined? (js-get-global-value "Device")))) 11 | 12 | 13 | (provide running-in-phone-context?) -------------------------------------------------------------------------------- /phone/internet.rkt: -------------------------------------------------------------------------------- 1 | #lang s-exp "../js-vm/base.rkt" 2 | 3 | (require "../js-vm/permissions/require-permission.rkt") 4 | 5 | (require-permission "PERMISSION:INTERNET") 6 | -------------------------------------------------------------------------------- /phone/mock-location-setup.js: -------------------------------------------------------------------------------- 1 | 2 | // on setup, create a form attached to the document body 3 | EXPORTS['mock-location-setup'] = 4 | new types.PrimProc( 5 | "mock-location-setup", 1, 6 | false, false, 7 | function(onNewLocation) { 8 | var mockLocationSetter = document.createElement("div"); 9 | 10 | var latInput = document.createElement("input"); 11 | latInput.type = "text"; 12 | 13 | var latOutput = document.createElement("input"); 14 | latOutput.type = "text"; 15 | 16 | var submitButton = document.createElement("input"); 17 | submitButton.type = "button"; 18 | submitButton.value = "send lat/lng"; 19 | submitButton.onclick = function() { 20 | setTimeout( 21 | function() { 22 | onNewLocation.val(parseFloat(latInput.value), 23 | parseFloat(latOutput.value)); 24 | }, 25 | 0); 26 | return false; 27 | }; 28 | 29 | mockLocationSetter.style.border = "1pt solid black"; 30 | mockLocationSetter.appendChild( 31 | document.createTextNode("mock location setter")); 32 | mockLocationSetter.appendChild(latInput); 33 | mockLocationSetter.appendChild(latOutput); 34 | mockLocationSetter.appendChild(submitButton); 35 | 36 | document.body.appendChild(mockLocationSetter); 37 | 38 | var shutdownThunk = new types.PrimProc("clearMock", 39 | 0, 40 | false, 41 | false, 42 | function() { 43 | document.body.removeChild( 44 | mockLocationSetter); 45 | }); 46 | return shutdownThunk; 47 | }); -------------------------------------------------------------------------------- /phone/mock-location-setup.rkt: -------------------------------------------------------------------------------- 1 | #lang s-exp "../js-vm/js-impl.rkt" 2 | 3 | (require-js "mock-location-setup.js") 4 | (require "../js-vm/ffi/ffi.rkt") 5 | 6 | 7 | 8 | ;; mock-location-setup: (world lat lng -> world) -> js-shutdown-function 9 | (provide mock-location-setup) 10 | -------------------------------------------------------------------------------- /phone/mock-tilt-setup.rkt: -------------------------------------------------------------------------------- 1 | #lang s-exp "../js-vm/js-impl.rkt" 2 | 3 | (require-js "mock-tilt-setup.js") 4 | (require "../js-vm/ffi/ffi.rkt") 5 | 6 | 7 | ;; mock-acceleration-setup: (world number number number -> world) -> js-shutdown-function 8 | (provide mock-acceleration-setup) 9 | 10 | 11 | ;; mock-tilt-setup: (world number number number -> world) -> js-shutdown-function 12 | (provide mock-tilt-setup) 13 | 14 | ;; mock-shake-setup: (world -> world) -> js-shutdown-function 15 | (provide mock-shake-setup) 16 | -------------------------------------------------------------------------------- /sandbox/adder/src/Adder.java: -------------------------------------------------------------------------------- 1 | import javax.microedition.lcdui.*; 2 | import javax.microedition.midlet.*; 3 | 4 | public class Adder extends MIDlet implements CommandListener { 5 | // program state 6 | Integer val; 7 | 8 | // program ui 9 | Display display; 10 | Form form; 11 | StringItem label; 12 | static final Command pressCommand = new Command("Press me!", Command.OK, 2); 13 | 14 | // constructor. 15 | public Adder() { 16 | } 17 | 18 | /** 19 | * Start the MIDlet by creating a list of items and associating the exit 20 | * command with it. 21 | */ 22 | public void startApp() throws MIDletStateChangeException { 23 | val = new Integer(0); 24 | display = Display.getDisplay(this); 25 | label = new StringItem(null, val.toString()); 26 | form = new Form("Adder"); 27 | form.append(label); 28 | form.addCommand(pressCommand); 29 | form.setCommandListener(this); 30 | display.setCurrent(form); 31 | } 32 | 33 | public void pauseApp() { 34 | display = null; 35 | form = null; 36 | label = null; 37 | } 38 | 39 | public void destroyApp(boolean unconditional) { 40 | notifyDestroyed(); 41 | } 42 | 43 | /** 44 | * Handle events. 45 | */ 46 | public void commandAction(Command c, Displayable d) { 47 | val = new Integer(val.intValue() + 1); 48 | label.setText(val.toString()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sandbox/arview/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sandbox/arview/bin/ARView-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/arview/bin/ARView-debug.apk -------------------------------------------------------------------------------- /sandbox/arview/bin/ARView.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/arview/bin/ARView.ap_ -------------------------------------------------------------------------------- /sandbox/arview/bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/arview/bin/classes.dex -------------------------------------------------------------------------------- /sandbox/arview/default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by activitycreator. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # Instead customize values in a "build.properties" file. 4 | 5 | sdk-folder=/home/chris/src/android-sdk-linux_x86-1.0_r2 6 | -------------------------------------------------------------------------------- /sandbox/arview/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARView 4 | 5 | -------------------------------------------------------------------------------- /sandbox/arview/src/edu/brown/cs/squirrel/arview/ARView.java: -------------------------------------------------------------------------------- 1 | package edu.brown.cs.squirrel.arview; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | public class ARView extends Activity { 7 | @Override 8 | public void onCreate(Bundle bundle) { 9 | super.onCreate(bundle); 10 | setContentView(new ARViewView(this)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sandbox/arview/src/edu/brown/cs/squirrel/arview/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package edu.brown.cs.squirrel.arview; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class string { 14 | public static final int app_name=0x7f020000; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sandbox/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 | (require "moby/bootstrap-world") 5 | 6 | (define WIDTH 320) 7 | (define HEIGHT 480) 8 | 9 | (define TITLE "My Simple Game") 10 | (define background (empty-scene WIDTH HEIGHT)) 11 | 12 | (define (update-target-x x) 13 | (add1 x)) 14 | 15 | (define (update-target-y y) 16 | (sub1 y)) 17 | 18 | (define (update-player x key) 19 | (cond 20 | [(string=? key "left") 21 | (- x 10)] 22 | [(string=? key "right") 23 | (+ x 10)] 24 | [else x])) 25 | 26 | (define (update-object y) 27 | (- y 20)) 28 | 29 | (define target (circle 20 "solid" "green")) 30 | 31 | (define player (rectangle 30 40 "solid" "blue")) 32 | 33 | (define object (circle 10 "solid" "black")) 34 | 35 | (define (offscreen? x y) 36 | (or (< x 0) 37 | (> x WIDTH) 38 | (< y 0) 39 | (> y HEIGHT))) 40 | 41 | 42 | 43 | (start TITLE background update-target-x update-target-y update-player update-object target player object offscreen?) 44 | 45 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/cheney/Sketch/res/drawable/icon.png -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/layout/midpform.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/layout/midpgauge.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 17 | 18 | 25 | 26 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/layout/midplist.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/layout/midplistitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | 22 | 23 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/layout/midpstringitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | 17 | 23 | 24 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/layout/splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sketch 4 | 5 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/jad.properties: -------------------------------------------------------------------------------- 1 | midlet=org.plt.Sketch.Sketch 2 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/j2ab/android/io/LogOutputStream.java: -------------------------------------------------------------------------------- 1 | package j2ab.android.io; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.OutputStream; 6 | 7 | import android.util.Log; 8 | 9 | public class LogOutputStream extends OutputStream 10 | { 11 | public static final int LOG_LEVEL = Log.VERBOSE; 12 | private ByteArrayOutputStream bos = new ByteArrayOutputStream(); 13 | private String name; 14 | 15 | public LogOutputStream( String name ) 16 | { 17 | this.name = name; 18 | } 19 | 20 | @Override 21 | public void write( int b ) throws IOException 22 | { 23 | if( b == (int)'\n' ) 24 | { 25 | String s = new String( this.bos.toByteArray() ); 26 | Log.v( this.name, s ); 27 | this.bos = new ByteArrayOutputStream(); 28 | } 29 | else 30 | { 31 | this.bos.write( b ); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/j2ab/android/lcdui/Toolkit.java: -------------------------------------------------------------------------------- 1 | package j2ab.android.lcdui; 2 | 3 | import android.os.Handler; 4 | import android.view.View; 5 | 6 | public interface Toolkit { 7 | Handler getHandler(); 8 | 9 | void invokeAndWait( Runnable r ); 10 | 11 | int getResourceId( String resourceName ); 12 | 13 | View inflate( int resourceId ); 14 | 15 | int getScreenWidth(); 16 | 17 | int getScreenHeight(); 18 | } 19 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/Connection.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io; 2 | 3 | import java.io.IOException; 4 | 5 | public interface Connection 6 | { 7 | void close() throws IOException; 8 | } 9 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/ConnectionNotFoundException.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io; 2 | 3 | import java.io.IOException; 4 | 5 | public class ConnectionNotFoundException extends IOException 6 | { 7 | public ConnectionNotFoundException( String message ) 8 | { 9 | super( message ); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/HttpConnection.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io; 2 | 3 | import java.io.IOException; 4 | 5 | public interface HttpConnection extends StreamConnection 6 | { 7 | // TODO: add in the methods for HttpConnection! 8 | 9 | public static final String GET = "GET"; 10 | public static final String POST = "POST"; 11 | public static final String HEAD = "HEAD"; 12 | 13 | public static final int HTTP_OK = 200; 14 | 15 | public static final int HTTP_ACCEPTED = 202; 16 | public static final int HTTP_NOT_AUTHORITATIVE = 203; 17 | public static final int HTTP_NO_CONTENT = 204; 18 | public static final int HTTP_RESET = 205; 19 | 20 | public static final int HTTP_MOVED_PERM = 301; 21 | public static final int HTTP_SEE_OTHER = 303; 22 | public static final int HTTP_TEMP_REDIRECT = 307; 23 | 24 | public static final int HTTP_UNAUTHORIZED = 401; 25 | 26 | int getResponseCode() throws IOException; 27 | 28 | String getResponseMessage() throws IOException; 29 | 30 | String getRequestProperty( String key ); 31 | 32 | void setRequestProperty( String key, String value ); 33 | 34 | void setRequestMethod( String method ); 35 | 36 | String getHeaderField( String key ); 37 | } 38 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/InputConnection.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | 7 | public interface InputConnection extends Connection 8 | { 9 | DataInputStream openDataInputStream() 10 | throws IOException; 11 | 12 | InputStream openInputStream() 13 | throws IOException; 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/OutputConnection.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | import java.io.OutputStream; 6 | 7 | public interface OutputConnection extends Connection 8 | { 9 | DataOutputStream openDataOutputStream() 10 | throws IOException; 11 | 12 | OutputStream openOutputStream() 13 | throws IOException; 14 | } 15 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/StreamConnection.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io; 2 | 3 | public interface StreamConnection extends InputConnection, OutputConnection 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/file/FileSystemListener.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io.file; 2 | 3 | public interface FileSystemListener { 4 | public static final int ROOT_ADDED = 0; 5 | public static final int ROOT_REMOVED = 1; 6 | 7 | void rootChanged( int state, String rootName ); 8 | } 9 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/java/javax/microedition/io/file/FileSystemRegistry.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.io.file; 2 | 3 | import java.io.File; 4 | import java.net.MalformedURLException; 5 | import java.util.Enumeration; 6 | import java.util.Vector; 7 | 8 | public class FileSystemRegistry { 9 | 10 | public static boolean addFileSystemListener( FileSystemListener listener ) { 11 | return false; 12 | } 13 | 14 | public static boolean removeFileSystemListener( FileSystemListener listener ) { 15 | return false; 16 | } 17 | 18 | public static Enumeration listRoots() { 19 | File[] roots = File.listRoots(); 20 | Vector rootsArray = new Vector( roots.length ); 21 | for( File root : roots ) { 22 | String path = root.getPath(); 23 | if( path.startsWith( File.separator ) ) { 24 | path = path.substring( File.separator.length() ); 25 | } 26 | // root paths appear to have some rubbish characters attached to them! 27 | StringBuffer cleaned = new StringBuffer( path.length() ); 28 | for( int i=0; i 0) 18 | l = new Pair(vals[i], l); 19 | } 20 | return Kernel.reverse(l); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/lib/Sms.java: -------------------------------------------------------------------------------- 1 | package org.plt.lib; 2 | 3 | import org.plt.types.*; 4 | import org.plt.platform.Platform; 5 | 6 | public class Sms { 7 | // Fixme: consuming the world is not quite right, but 8 | // we're working under Beginner Scheme Level, where every 9 | // function must return a good value. 10 | public static Object sendTextMessage(Object address, 11 | Object message, 12 | Object world) { 13 | SmsService service = 14 | Platform.getInstance().getSmsService(); 15 | service.sendTextMessage(address.toString(), message.toString()); 16 | return world; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/lib/SmsService.java: -------------------------------------------------------------------------------- 1 | package org.plt.lib; 2 | 3 | public interface SmsService { 4 | void sendTextMessage(String destinationString, 5 | String msg); 6 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/lib/Tilt.java: -------------------------------------------------------------------------------- 1 | package org.plt.lib; 2 | 3 | import org.plt.types.*; 4 | import org.plt.platform.Platform; 5 | 6 | public class Tilt { 7 | public static Object getXAcceleration() { 8 | TiltService service = 9 | Platform.getInstance().getTiltService(); 10 | return service.getXAcceleration(); 11 | } 12 | 13 | public static Object getYAcceleration() { 14 | TiltService service = 15 | Platform.getInstance().getTiltService(); 16 | return service.getYAcceleration(); 17 | } 18 | 19 | public static Object getZAcceleration() { 20 | TiltService service = 21 | Platform.getInstance().getTiltService(); 22 | return service.getZAcceleration(); 23 | } 24 | 25 | 26 | public static Object getAzimuth() { 27 | TiltService service = 28 | Platform.getInstance().getTiltService(); 29 | return service.getAzimuth(); 30 | } 31 | 32 | public static Object getPitch() { 33 | TiltService service = 34 | Platform.getInstance().getTiltService(); 35 | return service.getPitch(); 36 | } 37 | 38 | public static Object getRoll() { 39 | TiltService service = 40 | Platform.getInstance().getTiltService(); 41 | return service.getRoll(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/lib/TiltService.java: -------------------------------------------------------------------------------- 1 | package org.plt.lib; 2 | 3 | import org.plt.world.OrientationChangeListener; 4 | import org.plt.world.AccelerationChangeListener; 5 | 6 | public interface TiltService { 7 | Object getXAcceleration(); 8 | Object getYAcceleration(); 9 | Object getZAcceleration(); 10 | 11 | Object getAzimuth(); 12 | Object getPitch(); 13 | Object getRoll(); 14 | 15 | void addOrientationChangeListener(OrientationChangeListener listener); 16 | void addAccelerationChangeListener(AccelerationChangeListener listener); 17 | 18 | void shutdownService(); 19 | void startService(); 20 | } 21 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/platform/Platform.java: -------------------------------------------------------------------------------- 1 | package org.plt.platform; 2 | 3 | import java.io.InputStream; 4 | import java.io.IOException; 5 | 6 | 7 | public class Platform { 8 | 9 | private static PlatformI instance; 10 | 11 | public static PlatformI getInstance() { 12 | return instance; 13 | } 14 | 15 | static { 16 | try { 17 | InputStream ins = 18 | Class.forName("org.plt.platform.Platform"). 19 | getResourceAsStream("/platform.implementation"); 20 | System.out.println("Reading in a line from " + ins); 21 | String platformImpl = readLine(ins); 22 | instance = (PlatformI) 23 | Class.forName(platformImpl).newInstance(); 24 | } catch(Exception ex) { 25 | throw new RuntimeException 26 | ("error loading platform.properties: " + 27 | ex.toString()); 28 | } 29 | } 30 | 31 | private static String readLine(InputStream in) { 32 | StringBuffer buf = new StringBuffer(); 33 | while(true) { 34 | try { 35 | int ch = in.read(); 36 | if (ch == -1 || ch == '\n') 37 | break; 38 | buf.append((char)ch); 39 | } catch (IOException e) { 40 | break; 41 | } 42 | } 43 | return buf.toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/platform/PlatformI.java: -------------------------------------------------------------------------------- 1 | package org.plt.platform; 2 | 3 | import org.plt.lib.LocationService; 4 | import org.plt.lib.TiltService; 5 | import org.plt.lib.SmsService; 6 | import org.plt.lib.NetworkService; 7 | 8 | public interface PlatformI { 9 | String getName(); 10 | 11 | LocationService getLocationService(); 12 | TiltService getTiltService(); 13 | SmsService getSmsService(); 14 | NetworkService getNetworkService(); 15 | } 16 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Callable.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | // Interface for callable things. 4 | 5 | public interface Callable { 6 | Object call(Object[] args); 7 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Empty.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | import org.plt.checker.SchemeException; 4 | 5 | public class Empty implements List { 6 | private Empty() { 7 | } 8 | 9 | static public Empty EMPTY = new Empty(); 10 | 11 | public Object first() { 12 | throw new SchemeException("Can't take first on empty"); 13 | } 14 | 15 | public List rest() { 16 | throw new SchemeException("Can't take rest on empty"); 17 | } 18 | 19 | public boolean isEmpty() { 20 | return true; 21 | } 22 | 23 | public boolean equals(Object other) { 24 | return (other instanceof org.plt.types.Empty); 25 | } 26 | 27 | public String toString() { 28 | return "()"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/EofObject.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | public class EofObject { 4 | static public EofObject EOF = new EofObject(); 5 | private EofObject() {} 6 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/List.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | public interface List { 3 | Object first(); 4 | List rest(); 5 | boolean isEmpty(); 6 | } 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Logic.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | public class Logic { 3 | boolean val; 4 | public static Logic TRUE = new Logic(true); 5 | public static Logic FALSE = new Logic(false); 6 | 7 | private Logic(boolean val) { 8 | this.val = val; 9 | } 10 | 11 | public boolean isTrue() { 12 | return val; 13 | } 14 | 15 | public boolean isFalse() { 16 | return !val; 17 | } 18 | 19 | public Logic negate() { 20 | if (this == TRUE) { 21 | return FALSE; 22 | } else { 23 | return TRUE; 24 | } 25 | } 26 | 27 | public String toString() { 28 | if (this == TRUE) { 29 | return "true"; 30 | } 31 | else { 32 | return "false"; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Number.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | public interface Number { 4 | int toInt(); 5 | 6 | boolean isReal(); 7 | 8 | Number toReal(); 9 | 10 | boolean isInteger(); 11 | 12 | boolean isZero(); 13 | 14 | boolean numericGreaterThan(Number other); 15 | 16 | boolean numericEqual(Number other); 17 | 18 | boolean numericLessThan(Number other); 19 | 20 | Number numericPlus(Number other); 21 | 22 | Number numericMinus(Number other); 23 | 24 | Number numericMultiply(Number other); 25 | 26 | Number numericDivide(Number other); 27 | 28 | Number abs(); 29 | 30 | Number acos(); 31 | 32 | Number asin(); 33 | 34 | Number sqrt(); 35 | 36 | Number modulo(Number other); 37 | 38 | Number floor(); 39 | 40 | Number ceiling(); 41 | 42 | Number cos(); 43 | 44 | Number sin(); 45 | 46 | Number atan(); 47 | 48 | Number angle(); 49 | 50 | Number conjugate(); 51 | 52 | Number magnitude(); 53 | } 54 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Pair.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | public class Pair implements List { 4 | private Object f; 5 | private List r; 6 | 7 | public Pair(Object first, List rest) { 8 | this.f = first; 9 | this.r = rest; 10 | } 11 | 12 | public Object first() { 13 | return this.f; 14 | } 15 | 16 | public List rest() { 17 | return this.r; 18 | } 19 | 20 | public boolean isEmpty() { 21 | return false; 22 | } 23 | 24 | public boolean equals(Object other) { 25 | if ((other instanceof org.plt.types.List) == false) 26 | return false; 27 | 28 | if (this.isEmpty() && ((org.plt.types.List) other).isEmpty()) 29 | return true; 30 | 31 | if (this.isEmpty() || ((org.plt.types.List) other).isEmpty()) 32 | return false; 33 | 34 | if (this.first().equals(((org.plt.types.List) other).first()) == false) 35 | return false; 36 | 37 | return (this.rest().equals(((org.plt.types.List) other).rest())); 38 | } 39 | 40 | public String toString() { 41 | 42 | if (this.isEmpty()) { 43 | return "()"; 44 | } 45 | List p = this; 46 | StringBuffer b = new StringBuffer(); 47 | b.append("("); 48 | b.append(p.first().toString()); 49 | p = p.rest(); 50 | while(!p.isEmpty()) { 51 | b.append(" "); 52 | b.append(p.first().toString()); 53 | p = p.rest(); 54 | } 55 | b.append(")"); 56 | return b.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Posn.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | public class Posn implements Struct { 4 | private Object x, y; 5 | public Posn(Object x, Object y) { 6 | this.x = x; 7 | this.y = y; 8 | } 9 | public Object getX() { 10 | return this.x; 11 | } 12 | public Object getY() { 13 | return this.y; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Struct.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | public interface Struct {} 4 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/Symbol.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | // Fixme: Symbols should be kept in a hashtable so we can do quick 4 | // pointer equality. 5 | 6 | public class Symbol { 7 | 8 | private String content; 9 | 10 | private Symbol(String content) { 11 | this.content = content; 12 | } 13 | 14 | static public Symbol makeInstance(String content) { 15 | return new Symbol(content); 16 | } 17 | 18 | public String toString() { 19 | return content; 20 | } 21 | 22 | public boolean equals(Object _other) { 23 | if (_other instanceof Symbol) { 24 | Symbol other = (Symbol) _other; 25 | return this.content.equals(other.content); 26 | } else { 27 | return false; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/types/VoidObject.java: -------------------------------------------------------------------------------- 1 | package org.plt.types; 2 | 3 | public class VoidObject { 4 | static public VoidObject VOID = new VoidObject(); 5 | private VoidObject() {} 6 | public String toString() { 7 | return ""; 8 | } 9 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/AccelerationChangeListener.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | public interface AccelerationChangeListener { 3 | public void onAccelerationChange(Object x, Object y, Object z); 4 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/LocationChangeListener.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | 3 | public interface LocationChangeListener { 4 | void onLocationChange(Object latitude, Object longitude); 5 | } 6 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/MessageListener.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | 3 | public interface MessageListener { 4 | void onMessage(Object sexp); 5 | } 6 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/OrientationChangeListener.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | public interface OrientationChangeListener { 3 | public void onOrientationChange(Object azumuth, Object pitch, Object roll); 4 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/WorldAndObjectTransformer.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | 3 | // Things that consume a world and produce some other object. 4 | public interface WorldAndObjectTransformer { 5 | Object transform(Object world, Object obj); 6 | } 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/WorldConsumer.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | 3 | // Things that consume a world and don't return anything. 4 | public interface WorldConsumer { 5 | void consume(Object world); 6 | } 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/WorldJudge.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | 3 | // Things that consume a world and say yes or no 4 | public interface WorldJudge { 5 | boolean judge(Object world); 6 | } 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/WorldTransformer.java: -------------------------------------------------------------------------------- 1 | package org.plt.world; 2 | 3 | // Things that consume a world and produce some other object. 4 | public interface WorldTransformer { 5 | Object transform(Object world); 6 | } 7 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/Config.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | 3 | public interface Config { 4 | void accept(ConfigVisitor visitor); 5 | } 6 | -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/ConfigVisitor.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | 3 | public interface ConfigVisitor { 4 | void visit(OnTick c); 5 | void visit(OnMouse c); 6 | void visit(OnKey c); 7 | void visit(OnMessage c); 8 | void visit(OnLocationChange c); 9 | void visit(OnTilt c); 10 | void visit(OnAcceleration c); 11 | void visit(OnRedraw c); 12 | void visit(StopWhen c); 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/Kernel.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | 3 | import org.plt.types.Callable; 4 | import org.plt.types.Number; 5 | import org.plt.types.Rational; 6 | import org.plt.types.NumberTower; 7 | 8 | public class Kernel { 9 | static public Config onKey(Object c) { 10 | return new OnKey((Callable) c); 11 | } 12 | 13 | static public Config onTick(Object delay, Object c) { 14 | Number delayInMilliseconds = 15 | (NumberTower.multiply((Number) delay, 16 | new Rational(1000, 1))); 17 | 18 | return new OnTick((Number) delayInMilliseconds, 19 | (Callable) c); 20 | } 21 | 22 | static public Config onMouse(Object c) { 23 | return new OnMouse((Callable) c); 24 | } 25 | 26 | static public Config onMessage(Object c) { 27 | return new OnMessage((Callable) c); 28 | } 29 | 30 | static public Config onLocationChange(Object c){ 31 | return new OnLocationChange((Callable) c); 32 | } 33 | 34 | static public Config onTilt(Object c) { 35 | return new OnTilt((Callable) c); 36 | } 37 | 38 | static public Config onAcceleration(Object c) { 39 | return new OnAcceleration((Callable) c); 40 | } 41 | 42 | static public Config onRedraw(Object c) { 43 | return new OnRedraw((Callable) c); 44 | } 45 | 46 | static public Config stopWhen(Object c) { 47 | return new StopWhen((Callable) c); 48 | } 49 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnAcceleration.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | 4 | public class OnAcceleration implements Config { 5 | public Callable c; 6 | 7 | public OnAcceleration(Callable c) { 8 | this.c = c; 9 | } 10 | 11 | public void accept(ConfigVisitor visitor) { 12 | visitor.visit(this); 13 | } 14 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnKey.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class OnKey implements Config { 4 | public Callable c; 5 | 6 | public OnKey(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnLocationChange.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class OnLocationChange implements Config { 4 | public Callable c; 5 | 6 | public OnLocationChange(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnMessage.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class OnMessage implements Config { 4 | public Callable c; 5 | 6 | public OnMessage(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnMouse.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class OnMouse implements Config { 4 | public Callable c; 5 | 6 | public OnMouse(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnRedraw.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class OnRedraw implements Config { 4 | public Callable c; 5 | 6 | public OnRedraw(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnTick.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | 3 | import org.plt.types.Callable; 4 | import org.plt.types.Number; 5 | 6 | public class OnTick implements Config { 7 | public Number delay; 8 | public Callable c; 9 | 10 | public OnTick(Number delay, Callable c) { 11 | this.delay = delay; 12 | this.c = c; 13 | } 14 | 15 | public void accept(ConfigVisitor visitor) { 16 | visitor.visit(this); 17 | } 18 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/OnTilt.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class OnTilt implements Config { 4 | public Callable c; 5 | 6 | public OnTilt(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/org/plt/world/config/StopWhen.java: -------------------------------------------------------------------------------- 1 | package org.plt.world.config; 2 | import org.plt.types.Callable; 3 | public class StopWhen implements Config { 4 | public Callable c; 5 | 6 | public StopWhen(Callable c) { 7 | this.c = c; 8 | } 9 | 10 | public void accept(ConfigVisitor visitor) { 11 | visitor.visit(this); 12 | } 13 | } -------------------------------------------------------------------------------- /sandbox/cheney/Sketch/src/platform.implementation: -------------------------------------------------------------------------------- 1 | org.plt.platform.AndroidPlatform -------------------------------------------------------------------------------- /sandbox/cheney/cheney-test-2.js: -------------------------------------------------------------------------------- 1 | // Test of possible Cheney on the MTA for tail calls. 2 | 3 | var trampolineThreshold = 3; 4 | var currentDepth = 0; 5 | var currentContinuation; 6 | var currentArg; 7 | 8 | // startTrampoline: continuation arg -> void 9 | // If we come out with a value, return it. Otherwise, bounce off the 10 | // trampoline and continue working. 11 | // 12 | // WARNING: startTrampoline is NOT reentrant! 13 | function startTrampoline(aContinuation, arg) { 14 | currentDepth = 0; 15 | applyContinuation(aContinuation, arg); 16 | } 17 | 18 | 19 | // Apply a continuation. 20 | function applyContinuation(aContinuation, arg) { 21 | // If the depth goes beyond the threshold, set up a timeout 22 | // Otherwise, just apply and continue. 23 | currentDepth = currentDepth + 1; 24 | if (currentDepth < trampolineThreshold) { 25 | aContinuation.restart(arg); 26 | } else { 27 | currentContinuation = aContinuation; 28 | currentArg = arg; 29 | setTimeout(continueApplication, 0); 30 | } 31 | } 32 | 33 | function continueApplication() { 34 | currentDepth = 0; 35 | currentContinuation.restart(currentArg); 36 | } 37 | 38 | 39 | 40 | function Continuation(f, env) { 41 | this.f = f; 42 | this.env = env; 43 | } 44 | 45 | 46 | // Continuation.restart: X -> void 47 | Continuation.prototype.restart = function(arg) { 48 | this.f.apply(null, [arg].concat([this.env])); 49 | } 50 | 51 | 52 | // makeContinuation: (X env -> void) env -> Continuation 53 | function makeContinuation(f, env) { 54 | return new Continuation(f, env); 55 | } 56 | -------------------------------------------------------------------------------- /sandbox/cheney/cheney-test.js: -------------------------------------------------------------------------------- 1 | // Test of possible Cheney on the MTA for tail calls. 2 | 3 | var trampolineThreshold = 3; 4 | var currentDepth = 0; 5 | 6 | 7 | function Bounce(continuation, arg) { 8 | this.continuation = continuation; 9 | this.arg = arg; 10 | } 11 | 12 | 13 | 14 | // startTrampoline: continuation arg -> void 15 | // If we come out with a value, return it. Otherwise, bounce off the 16 | // trampoline and continue working. 17 | // 18 | // WARNING: startTrampoline is NOT reentrant! 19 | function startTrampoline(aContinuation, arg) { 20 | var currentBouncing = aContinuation; 21 | var currentArg = arg; 22 | currentDepth = 0; 23 | while(true) { 24 | try { 25 | applyContinuation(currentBouncing, currentArg); 26 | break; 27 | } catch (e) { 28 | if (e instanceof Bounce) { 29 | currentBouncing = e.continuation; 30 | currentArg = e.arg; 31 | currentDepth = 0; 32 | } else { 33 | throw e; 34 | } 35 | } 36 | } 37 | } 38 | 39 | // Apply a continuation. 40 | function applyContinuation(aContinuation, arg) { 41 | // If the depth goes beyond the threshold, throw an exception. 42 | // Otherwise, just apply and continue. 43 | currentDepth = currentDepth + 1; 44 | if (currentDepth < trampolineThreshold) { 45 | // console.debug("not bouncing"); 46 | aContinuation.apply(null, [arg]); 47 | } else { 48 | // console.log("bouncing"); 49 | throw new Bounce(aContinuation, arg); 50 | } 51 | } 52 | 53 | 54 | function makeContinuation(f) { 55 | // TODO: we may want a separate continuation object. 56 | return f; 57 | } 58 | -------------------------------------------------------------------------------- /sandbox/cheney/data/README: -------------------------------------------------------------------------------- 1 | Measurements made on a Macbook Pro 2.33 Ghz Intel Core 2 Duo, 2GB 667 2 | MHz DDR2 SDRAM, using cheney-test-3.html, under Mac OS 10.5.6. 3 | 4 | Qualitative observations: With the timeout-based approaches, CPU usage 5 | is almost zero; it appears that a call to setTimeout(..., 0) does not 6 | immediately execute at high priority. The browser appears to freeze 7 | under the exception handling approach, whereas under setTimeout, the 8 | browser regains control immediately. 9 | 10 | Under Safari 3, stack height is limited to a ceiling around 90-100; 11 | going beyond that will kill whatever computation is being done without 12 | an error message. -------------------------------------------------------------------------------- /sandbox/examples/README: -------------------------------------------------------------------------------- 1 | The following are programs that demonstrate Moby's features. 2 | 3 | ---------------------------------------------------------------------- 4 | 5 | 6 | rolling-out-of-time.ss: a game that uses the tilt sensor to play a 7 | ball-rolling game. 8 | 9 | 10 | minding-the-store.ss: an application that uses the GPS location 11 | feature and Google Maps web-service to alert the user when we're close 12 | to an interesting grocery store. 13 | 14 | 15 | homeward-bound.ss: another GPS application that also uses SMS to 16 | notify another of the place where a user is located. 17 | 18 | 19 | bell-ringing.ss: uses a shake handler to play a bell sound whenever the 20 | phone is jerked. The user interface allows switching to different 21 | notes. 22 | 23 | 24 | lullaby.ss: plays songs from the user's playlist; as time 25 | progresses, the volume of the music drops unless the phone is shaked. 26 | 27 | 28 | 29 | 30 | ---------------------------------------------------------------------- 31 | 32 | Other simple examples: 33 | 34 | falling-ball.ss: a World program that shows a falling ball. 35 | 36 | simple-location.ss: a World program that shows the user's geolocation. -------------------------------------------------------------------------------- /sandbox/examples/beep-volume.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../moby-lang.ss" 2 | 3 | ;; Small program to test setting of ringer volume. 4 | 5 | ;; The world doesn't contain anything interesting. 6 | (define initial-world #f) 7 | 8 | 9 | 10 | (define user-interface 11 | (list (js-p '(("id" "aPara"))) 12 | (list (js-button! (lambda (w) w) 13 | (lambda (w) (make-effect:beep))) 14 | (list (js-text "Beep"))) 15 | (list (js-button! (lambda (w) w) 16 | (lambda (w) (make-effect:set-beep-volume 0))) 17 | (list (js-text "Mute beep volume"))) 18 | (list (js-button! (lambda (w) w) 19 | (lambda (w) (make-effect:set-beep-volume 75))) 20 | (list (js-text "Set beep volume to 75%"))))) 21 | 22 | 23 | ;; draw: world -> DOM-sexp 24 | ;; The interface includes a button for beeping, a button 25 | ;; for muting the ringer, and a button for setting the 26 | ;; ringer to 75%. 27 | (define (draw w) user-interface) 28 | 29 | 30 | ;; draw-css: world -> CSS-sexp 31 | ;; Style the dom so that the font size is large. 32 | (define (draw-css w) 33 | '(("aPara" ("font-size" "30px")))) 34 | 35 | 36 | ;; Finally, begin a big-bang. 37 | (js-big-bang initial-world 38 | '() 39 | (on-draw draw draw-css)) 40 | -------------------------------------------------------------------------------- /sandbox/examples/falling-ball.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../moby-lang.ss" 2 | 3 | ;; Simple falling ball example. A red ball falls down the screen 4 | ;; until hitting the bottom. 5 | 6 | 7 | 8 | ;; The dimensions of the screen: 9 | (define WIDTH 320) 10 | (define HEIGHT 480) 11 | 12 | ;; The radius of the red circle. 13 | (define RADIUS 15) 14 | 15 | ;; The world is the distance from the top of the screen. 16 | (define INITIAL-WORLD 0) 17 | 18 | ;; tick: world -> world 19 | ;; Moves the ball down. 20 | (define (tick w) 21 | (+ w 5)) 22 | 23 | ;; hits-floor?: world -> boolean 24 | ;; Returns true when the distance reaches the screen height. 25 | (define (hits-floor? w) 26 | (>= w HEIGHT)) 27 | 28 | ;; We have some simple test cases. 29 | (check-expect (hits-floor? 0) false) 30 | (check-expect (hits-floor? HEIGHT) true) 31 | 32 | ;; render: world -> scene 33 | ;; Produces a scene with the circle at a height described by the world. 34 | (define (render w) 35 | (place-image (circle RADIUS "solid" "red") (/ WIDTH 2) w 36 | (empty-scene WIDTH HEIGHT))) 37 | 38 | ;; Start up a big bang, 15 frames a second. 39 | (js-big-bang INITIAL-WORLD 40 | (on-tick 1/15 tick) 41 | (on-redraw render) 42 | (stop-when hits-floor?)) -------------------------------------------------------------------------------- /sandbox/examples/simple-location.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../moby-lang.ss" 2 | 3 | ;; The world is a latitude and longitude. 4 | (define-struct world (lat long)) 5 | 6 | (define initial-world (make-world 0 0)) 7 | 8 | 9 | ;; update: world number number -> world 10 | ;; Update the world to the latest latitude and longitude reading. 11 | (define (update w lat long) 12 | (make-world lat long)) 13 | 14 | 15 | ;; world->string: world -> string 16 | ;; Produces a string representation of the world. 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 | ;; Produces the DOM tree that we display. 27 | (define (draw w) 28 | (list (js-p '(("id" "aPara"))) 29 | (list (js-text "(latitude, longitude) = ")) 30 | (list (js-text (world->string w))))) 31 | 32 | 33 | ;; draw-css: world -> CSS-sexp 34 | ;; Style the dom so that the font size is large. 35 | (define (draw-css w) 36 | '(("aPara" ("font-size" "30px")))) 37 | 38 | 39 | ;; Finally, begin a big-bang. 40 | (js-big-bang initial-world 41 | '() 42 | (on-draw draw draw-css) 43 | (on-location-change update)) 44 | -------------------------------------------------------------------------------- /sandbox/examples/sms-receiving.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../moby-lang.ss" 2 | 3 | ;; The world is a string or false 4 | (define initial-world #f) 5 | 6 | 7 | ;; update: world string string -> world 8 | ;; Get a new message. 9 | (define (update w sender message) 10 | (string-append sender ": " message)) 11 | 12 | 13 | ;; world->string: world -> string 14 | ;; Produces a string representation of the world. 15 | (define (world->string w) 16 | (cond 17 | [(string? w) 18 | (string-append "Last seen SMS says: " w)] 19 | [else 20 | "No SMS message received recently"])) 21 | 22 | 23 | ;; draw: world -> DOM-sexp 24 | ;; Produces the DOM tree that we display. 25 | (define (draw w) 26 | (list (js-p '(("id" "aPara"))) 27 | (list (js-text (world->string w))))) 28 | 29 | 30 | ;; draw-css: world -> CSS-sexp 31 | ;; Style the dom so that the font size is large. 32 | (define (draw-css w) 33 | '(("aPara" ("font-size" "30px")))) 34 | 35 | 36 | ;; Finally, begin a big-bang. 37 | (js-big-bang initial-world 38 | '() 39 | (on-draw draw draw-css) 40 | (on-sms-receive update)) 41 | -------------------------------------------------------------------------------- /sandbox/guiworld-android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sandbox/guiworld-android/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sandbox/guiworld-android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | GuiWorldTest 4 | 5 | -------------------------------------------------------------------------------- /sandbox/old-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 | "../program-resources.ss") 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 program/resources -> bytes 18 | ;; Either tries to use the local android packager; if the resources aren't available, 19 | ;; then tries to use the web service. 20 | (define (build-android-package program-name program/resources) 21 | (cond 22 | [(local-android-ready?) 23 | (local:build-android-package program-name program/resources)] 24 | [else 25 | (remote:build-android-package program-name program/resources)])) 26 | 27 | 28 | (provide/contract 29 | [build-android-package (string? program/resources? . -> . bytes?)]) -------------------------------------------------------------------------------- /sandbox/old-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?)]) -------------------------------------------------------------------------------- /sandbox/old-src/collects/moby/runtime/dom-helpers.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../../../private/restricted-runtime-scheme.ss" 2 | 3 | ;; dom-string-content: dom -> string 4 | ;; Gets the string content of the dom. 5 | (define (dom-string-content a-dom) 6 | (cond 7 | [(string? a-dom) 8 | a-dom] 9 | [else 10 | (foldl (lambda (a-dom rest) 11 | (cond 12 | [(and (list? a-dom) 13 | (> (length a-dom) 2) 14 | (list? (second a-dom)) 15 | (ormap (lambda (attrib-pair) 16 | (and (symbol? (first attrib-pair)) 17 | (symbol=? (first attrib-pair) 'style) 18 | (string? (second attrib-pair)) 19 | (string=? (second attrib-pair) "display:none"))) 20 | (second a-dom))) 21 | rest] 22 | [else 23 | (string-append rest (dom-string-content a-dom))])) 24 | "" 25 | (rest (rest a-dom)))])) 26 | 27 | 28 | (provide/contract [dom-string-content (any/c . -> . string?)]) -------------------------------------------------------------------------------- /sandbox/old-src/collects/moby/runtime/dom-parameters.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../../../private/restricted-runtime-scheme.ss" 2 | 3 | ;; dom-parameters allows the user to extend the dom-transformers by providing 4 | ;; custom functions. 5 | 6 | (define-struct dom-parameters 7 | (scheme-value->dom? 8 | scheme-value->dom)) 9 | 10 | 11 | 12 | (provide/contract [struct dom-parameters ([scheme-value->dom? (any/c . -> . boolean?)] 13 | [scheme-value->dom (any/c ;; a value 14 | (any/c . -> . any) ;; a function to recur on subcomponents 15 | . -> . any)])]) -------------------------------------------------------------------------------- /sandbox/old-src/compiler/info.ss: -------------------------------------------------------------------------------- 1 | #lang setup/infotab 2 | 3 | (define compile-omit-paths 'all) -------------------------------------------------------------------------------- /sandbox/old-src/compiler/labeled-translation.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "lang.ss" 2 | 3 | 4 | ;; A labeled translation consists of a label, and a translation 5 | (define-struct labeled-translation (label ;; number 6 | translation ;; string 7 | )) 8 | 9 | 10 | (provide/contract [struct labeled-translation 11 | ([label number?] 12 | [translation string?])]) -------------------------------------------------------------------------------- /sandbox/old-src/compiler/mzscheme-vm/compile.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | 3 | (require scheme/list 4 | scheme/contract 5 | "mzscheme-vm.ss" 6 | "../pinfo.ss" 7 | "../../stx-helpers.ss" 8 | "../../../support/externals/mzscheme-vm/src/bytecode-compiler.ss" 9 | "../../../support/externals/mzscheme-vm/src/sexp.ss") 10 | 11 | 12 | ;; compile: input-port output-port #:name -> void 13 | (define (compile in out #:name name) 14 | (let*-values 15 | ([(stxs) (read-syntaxes in #:name name)] 16 | [(a-compilation-top a-pinfo) 17 | (compile-compilation-top stxs 18 | (get-base-pinfo 'moby) 19 | #:name name)] 20 | [(a-jsexp) (compile-top a-compilation-top)]) 21 | (display (jsexp->js a-jsexp) 22 | out))) 23 | 24 | 25 | ;; port-name: port -> string 26 | (define (port-name a-port) 27 | (format "~s" (object-name a-port))) 28 | 29 | 30 | ;; read-syntaxes: input-port #:name symbol -> (listof stx) 31 | (define (read-syntaxes in #:name name) 32 | (port-count-lines! in) 33 | (map syntax->stx 34 | (let loop () 35 | (let ([stx (read-syntax name in)]) 36 | (cond 37 | [(eof-object? stx) 38 | empty] 39 | [else 40 | (cons stx (loop))]))))) 41 | 42 | 43 | (provide/contract [compile (input-port? output-port? #:name symbol? . -> . any)]) -------------------------------------------------------------------------------- /sandbox/old-src/compiler/mzscheme-vm/servlet-htdocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 | 13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /sandbox/old-src/compiler/mzscheme-vm/write-support.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | 3 | (require scheme/runtime-path 4 | scheme/port 5 | scheme/contract) 6 | 7 | (define-runtime-path mzscheme-vm-library-path "../../../support/externals/mzscheme-vm/lib") 8 | 9 | 10 | ;; cat-to-port: path output-port -> void 11 | ;; Write out contents of path to output port. 12 | (define (cat-to-port a-path out-port) 13 | (call-with-input-file a-path (lambda (ip) (copy-port ip out-port)))) 14 | 15 | ;; write-platform-libraries: string output-port -> void 16 | ;; Writes out the platform-specific libraries out to the given output port. 17 | (define (write-support a-platform out-port) 18 | (let ([platform-specific-js-path 19 | (build-path mzscheme-vm-library-path 20 | (string-append a-platform "-platform.js"))]) 21 | 22 | (cond 23 | [(file-exists? platform-specific-js-path) 24 | (cat-to-port platform-specific-js-path out-port) 25 | (call-with-input-file (build-path mzscheme-vm-library-path "order") 26 | (lambda (order-ip) 27 | (for ([filename (in-lines order-ip)]) 28 | (cat-to-port (build-path mzscheme-vm-library-path filename) out-port))))] 29 | [else 30 | (error 'mobyc (format "No support for platform ~s" a-platform))]))) 31 | 32 | (provide/contract [write-support (string? output-port? . -> . any)]) -------------------------------------------------------------------------------- /sandbox/old-src/compiler/test-helpers.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | 3 | (require test-engine/scheme-tests 4 | scheme/bool 5 | "helpers.ss") 6 | 7 | (require (for-syntax "../stx-helpers.ss") 8 | (for-syntax scheme/base)) 9 | 10 | ;; e<: syntax 11 | ;; Calls expressionstx #'x)] 17 | [e2 (syntax->stx #'y)]) 18 | (syntax/loc stx 19 | (expression (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")]))) -------------------------------------------------------------------------------- /sandbox/old-src/get-intermediate-symbols.ss: -------------------------------------------------------------------------------- 1 | #lang scheme 2 | (require syntax/docprovide 3 | "compiler/toplevel.ss" 4 | "compiler/env.ss" 5 | (only-in srfi/1 lset-union lset-difference lset-intersection)) 6 | 7 | 8 | ;; Get the list of symbols in intermediate level. 9 | (define docs 10 | (lookup-documentation '(lib "htdp-intermediate-lambda.ss" "lang") 'procedures)) 11 | 12 | (define (process-category cat) 13 | (map (lambda (item) 14 | (first item)) 15 | (rest cat))) 16 | 17 | (define all-ids 18 | (apply append 19 | (map (lambda (cat) 20 | (process-category cat)) 21 | docs))) 22 | 23 | 24 | (define implemented-ids 25 | (env-keys (get-toplevel-env))) 26 | 27 | 28 | (define (union s1 s2) 29 | (lset-union symbol=? s1 s2)) 30 | 31 | (define (intersect s1 s2) 32 | (lset-intersection symbol=? s1 s2)) 33 | 34 | (define (subtract s1 s2) 35 | (lset-difference symbol=? s1 s2)) 36 | -------------------------------------------------------------------------------- /sandbox/old-src/info.ss: -------------------------------------------------------------------------------- 1 | #lang setup/infotab 2 | 3 | (define compile-omit-paths (list "test" "collects")) 4 | -------------------------------------------------------------------------------- /sandbox/old-src/private/restricted-runtime-scheme.ss: -------------------------------------------------------------------------------- 1 | #lang scheme 2 | 3 | (require (prefix-in base: scheme/base) 4 | (for-syntax scheme/base)) 5 | 6 | (provide (except-out (all-from-out scheme) 7 | define-struct)) 8 | 9 | 10 | (define-syntax (my-define-struct stx) 11 | (syntax-case stx () 12 | [(_ id (fields ...)) 13 | (syntax/loc stx 14 | (base:define-struct id (fields ...) 15 | #:prefab 16 | #:mutable))])) 17 | 18 | 19 | (define THE-UNDEFINED-VALUE 20 | (letrec ([x x]) 21 | x)) 22 | 23 | (define (undefined? x) 24 | (eq? x THE-UNDEFINED-VALUE)) 25 | 26 | 27 | (provide (rename-out (my-define-struct define-struct)) 28 | undefined?) -------------------------------------------------------------------------------- /sandbox/old-src/resource.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | 3 | (require scheme/class 4 | scheme/contract) 5 | 6 | ;; A resource is something that should be associated to a program. Examples include images 7 | ;; and music files. 8 | 9 | (define resource<%> 10 | (interface () 11 | save! ;; path -> void 12 | get-name ;; -> string 13 | get-bytes ;; -> bytes 14 | )) 15 | 16 | 17 | (define named-bytes-resource% 18 | (class* object% (resource<%>) 19 | (super-new) 20 | (init-field name) 21 | (init-field bytes) 22 | 23 | (define/public (save! a-path) 24 | (call-with-output-file (build-path a-path name) 25 | (lambda (op) 26 | (write-bytes bytes op)))) 27 | 28 | 29 | (define/public (get-name) 30 | name) 31 | 32 | (define/public (get-bytes) 33 | bytes))) 34 | 35 | 36 | 37 | (provide/contract [resource<%> interface?] 38 | [named-bytes-resource% class?]) 39 | -------------------------------------------------------------------------------- /sandbox/old-src/stub/location.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | (require lang/prim) 3 | 4 | (require "lat-lon-distance.ss") 5 | 6 | ;; Mock module for the location service 7 | ;; 8 | ;; http://www.bcca.org/misc/qiblih/latlong_us.html#MASSACHUSETTS 9 | 10 | ;; latitude: horizontal lines 11 | (define (get-latitude) 12 | (degree&minute->float 42 16)) 13 | 14 | ;; longitude: vertical lines 15 | (define (get-longitude) 16 | (- (degree&minute->float 71 52))) 17 | 18 | (define (get-altitude) 19 | 0) 20 | 21 | (define (get-bearing) 22 | 0) 23 | 24 | (define (get-speed) 25 | 0) 26 | 27 | 28 | (define (degree&minute->float degree minute) 29 | (exact->inexact (+ degree (/ minute 60)))) 30 | 31 | 32 | ;; returns distance in meters between (lat-1, long-1) and (lat-2, long-2). 33 | ;; fixme: put some approximation here. 34 | (define (location-distance lat-1 long-1 lat-2 long-2) 35 | (compute-distance lat-1 long-1 lat-2 long-2)) 36 | 37 | 38 | 39 | (provide-primitives get-latitude 40 | get-longitude 41 | get-attitude 42 | get-bearing 43 | get-speed 44 | location-distance) -------------------------------------------------------------------------------- /sandbox/old-src/stub/net.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | (require lang/prim 3 | scheme/port 4 | net/url) 5 | 6 | (define (get-url a-url-string) 7 | (with-handlers ((exn:fail? (lambda (exn) ""))) 8 | (let ([ip (get-pure-port (string->url a-url-string))] 9 | [op (open-output-string)]) 10 | (copy-port ip op) 11 | (close-input-port ip) 12 | (close-output-port op) 13 | (get-output-string op)))) 14 | 15 | 16 | 17 | (provide-primitive get-url) -------------------------------------------------------------------------------- /sandbox/old-src/stub/parser.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | 3 | 4 | (require lang/prim 5 | scheme/list 6 | xml) 7 | 8 | ;; xml->s-exp: string -> xexpr 9 | (define (xml->s-exp a-str) 10 | (let ([result 11 | (convert-cdata&normalize 12 | (xml->xexpr (document-element 13 | (read-xml (open-input-string 14 | a-str)))))]) 15 | result)) 16 | 17 | (define (convert-cdata&normalize xexpr) 18 | (cond 19 | [(cdata? xexpr) 20 | (cdata-string xexpr)] 21 | [(pair? xexpr) 22 | (cond 23 | [(attrib-list? (second xexpr)) 24 | (cons (first xexpr) 25 | (cons (cons '@ (second xexpr)) 26 | (map convert-cdata&normalize (rest (rest xexpr)))))] 27 | [else 28 | (cons (first xexpr) 29 | (cons (cons '@ empty) 30 | (map convert-cdata&normalize (rest xexpr))))])] 31 | [else 32 | xexpr])) 33 | 34 | 35 | (define (attrib-list? thing) 36 | (and (list? thing) 37 | (andmap (lambda (x) 38 | (and (list x) 39 | (= (length x) 2) 40 | (symbol? (first x)) 41 | (string? (second x)))) 42 | thing))) 43 | 44 | 45 | ;; split-whitespace: string -> (listof string) 46 | (define (split-whitespace a-str) 47 | (filter (lambda (x) 48 | (> (string-length x) 0)) 49 | (regexp-split #rx"[ \n\t]+" a-str))) 50 | 51 | 52 | (provide-primitives xml->s-exp 53 | #;split-whitespace) -------------------------------------------------------------------------------- /sandbox/old-src/stub/sms.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | (require lang/prim) 3 | 4 | 5 | ;; send-text-message: string string world -> world 6 | (define (send-text-message an-address 7 | a-message 8 | a-world) 9 | (printf "Sending message ~s to ~a~n" 10 | a-message 11 | an-address) 12 | a-world) 13 | 14 | 15 | (provide-primitive send-text-message) -------------------------------------------------------------------------------- /sandbox/old-src/stub/tilt.ss: -------------------------------------------------------------------------------- 1 | #lang scheme 2 | (require lang/prim 3 | scheme/gui/base) 4 | 5 | (define a-frame (new frame% 6 | [label "Location Stub"])) 7 | 8 | (define t-x (new text-field% 9 | [parent a-frame] 10 | [label "x tilt"] 11 | [init-value "0"])) 12 | 13 | (define t-y (new text-field% 14 | [parent a-frame] 15 | [label "y tilt"] 16 | [init-value "0"])) 17 | 18 | (define t-z (new text-field% 19 | [parent a-frame] 20 | [label "z tilt"] 21 | [init-value "0"])) 22 | (send a-frame show #t) 23 | 24 | 25 | (define ((get-tilt a-text-field)) 26 | (cond 27 | [(string->number (send a-text-field get-value)) 28 | => (lambda (x) x)] 29 | [else 30 | 0])) 31 | 32 | 33 | (define get-x-tilt (get-tilt t-x)) 34 | (define get-y-tilt (get-tilt t-y)) 35 | (define get-z-tilt (get-tilt t-z)) 36 | 37 | 38 | (provide-primitives get-x-tilt 39 | get-y-tilt 40 | get-z-tilt) -------------------------------------------------------------------------------- /sandbox/old-src/stx-helpers.ss: -------------------------------------------------------------------------------- 1 | #lang scheme/base 2 | (require "collects/moby/runtime/stx.ss") 3 | 4 | (provide (all-defined-out)) 5 | 6 | ;; syntax->stx: syntax -> stx 7 | ;; Go from Scheme's syntax objects to our own. 8 | (define (syntax->stx a-syntax) 9 | (cond 10 | [(pair? (syntax-e a-syntax)) 11 | (let ([elts 12 | (map syntax->stx (syntax->list a-syntax))]) 13 | (datum->stx #f 14 | elts 15 | (make-Loc (syntax-position a-syntax) 16 | (syntax-line a-syntax) 17 | (syntax-column a-syntax) 18 | (syntax-span a-syntax) 19 | (format "~a" (syntax-source a-syntax)))))] 20 | [else 21 | (datum->stx #f 22 | (syntax-e a-syntax) 23 | (make-Loc (syntax-position a-syntax) 24 | (syntax-line a-syntax) 25 | (syntax-column a-syntax) 26 | (syntax-span a-syntax) 27 | (format "~a" (syntax-source a-syntax))))])) -------------------------------------------------------------------------------- /sandbox/old-src/test/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /sandbox/old-src/test/eqhash-performance-check.ss: -------------------------------------------------------------------------------- 1 | #lang s-exp "../moby-lang.ss" 2 | 3 | ;; A little performance test. 4 | 5 | ;; On my Macbook pro, (OS X 10.5.8, 2.33Ghz) 6 | ;; Moby 2.26: takes about 1300 milliseconds 7 | 8 | 9 | (define BIG-NUMBER 40000) 10 | 11 | (define-struct blah ()) 12 | 13 | (define elements (build-list BIG-NUMBER (lambda (x) (make-blah)))) 14 | 15 | (define ht (make-hasheq)) 16 | 17 | "starting" 18 | 19 | (for-each (lambda (x) (hash-set! ht x true)) elements) 20 | 21 | (for-each (lambda (x) 22 | (cond 23 | [(hash-ref ht x false) 'ok] 24 | [else 25 | (error 'broke "It broke.")])) 26 | elements) 27 | 28 | (for-each (lambda (x) 29 | (cond 30 | [(hash-ref ht x false) 31 | (error 'broke "It broke.")] 32 | [else 33 | 'ok])) 34 | (build-list BIG-NUMBER (lambda (x) (make-hash)))) 35 | 36 | "done" 37 | -------------------------------------------------------------------------------- /sandbox/old-src/test/htdp.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyoo/moby-scheme/67fdf9299e9cf573834269fdcb3627d204e402ab/sandbox/old-src/test/htdp.zip -------------------------------------------------------------------------------- /sandbox/old-src/test/java-src/org/plt/TestNumber.java: -------------------------------------------------------------------------------- 1 | package org.plt; 2 | 3 | import org.plt.Kernel; 4 | import org.plt.types.*; 5 | import org.junit.Test; 6 | import static org.junit.Assert.*; 7 | 8 | public class TestNumber { 9 | @Test public void testNumberToString() { 10 | assertEquals(new Rational(10, 1).toString(), "10"); 11 | assertEquals(FloatPoint.fromString("3.14").ceiling().toString(), "4"); 12 | assertEquals(FloatPoint.fromString("2.718").floor().toString(), "2"); 13 | } 14 | 15 | 16 | @Test public void testMultipication() { 17 | assertEquals(new Rational(1, 1).numericMultiply(new Rational(1, 1)), 18 | new Rational(1, 1)); 19 | assertEquals(new Rational(-1, 1).numericMultiply(new Rational(-1, 1)), 20 | new Rational(1, 1)); 21 | assertEquals(new Rational(1, 1).numericMultiply(new Rational(-1, 1)), 22 | new Rational(-1, 1)); 23 | assertEquals(new Rational(-1, 1).numericMultiply(new Rational(1, 1)), 24 | new Rational(-1, 1)); 25 | 26 | assertEquals(new Rational(2, 1).numericMultiply(new Rational(20, 1)), 27 | new Rational(40, 1)); 28 | 29 | 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sandbox/old-src/test/java-src/org/plt/TestXmlParser.java: -------------------------------------------------------------------------------- 1 | package org.plt; 2 | 3 | import org.plt.types.*; 4 | import org.plt.Kernel; 5 | import org.junit.Test; 6 | import org.junit.Before; 7 | import static org.junit.Assert.*; 8 | 9 | import org.plt.parser.XmlParser; 10 | 11 | public class TestXmlParser { 12 | XmlParser parser; 13 | 14 | @Before 15 | public void setup() { 16 | parser = new XmlParser(); 17 | } 18 | 19 | @Test public void testParse() { 20 | assertEquals(new Pair(Symbol.makeInstance("hello"), 21 | new Pair(Empty.EMPTY, 22 | Empty.EMPTY)), 23 | parser.parseString("")); 24 | } 25 | 26 | @Test public void testParseWithAttributes() { 27 | List attr = new Pair(Symbol.makeInstance("foo"), 28 | new Pair("bar", 29 | Empty.EMPTY)); 30 | assertEquals(new Pair(Symbol.makeInstance("world"), 31 | new Pair(new Pair(attr, Empty.EMPTY), 32 | Empty.EMPTY)), 33 | parser.parseString("")); 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 | --------------------------------------------------------------------------------