diff --git a/js/js-impl.js b/js/js-impl.js index 7a93cba..8d53ddc 100644 --- a/js/js-impl.js +++ b/js/js-impl.js @@ -1,18 +1,21 @@ +var VOID = plt.baselib.constants.VOID_VALUE; +var makePrimitiveProcedure = plt.baselib.functions.makePrimitiveProcedure; + EXPORTS['alert'] = - RUNTIME.makePrimitiveProcedure( + makePrimitiveProcedure( 'alert', 1, function(MACHINE) { var elt = MACHINE.env[MACHINE.env.length - 1]; alert(String(elt)); - return RUNTIME.VOID; + return VOID; }); EXPORTS['body'] = $(document.body); EXPORTS['$'] = - RUNTIME.makePrimitiveProcedure( + makePrimitiveProcedure( '$', 1, function(MACHINE) { @@ -21,7 +24,7 @@ EXPORTS['$'] = }); EXPORTS['call-method'] = - RUNTIME.makePrimitiveProcedure( + makePrimitiveProcedure( 'call-method', plt.baselib.arity.makeArityAtLeast(2), function(MACHINE) { @@ -40,7 +43,7 @@ EXPORTS['call-method'] = // Javascript-specific extensions. A small experiment. EXPORTS['viewport-width'] = - RUNTIME.makePrimitiveProcedure( + makePrimitiveProcedure( 'viewport-width', 0, function(MACHINE) { @@ -48,7 +51,7 @@ EXPORTS['viewport-width'] = }); EXPORTS['viewport-height'] = - RUNTIME.makePrimitiveProcedure( + makePrimitiveProcedure( 'viewport-height', 0, function(MACHINE) { @@ -57,7 +60,7 @@ EXPORTS['viewport-height'] = EXPORTS['in-javascript-context?'] = - RUNTIME.makePrimitiveProcedure( + makePrimitiveProcedure( 'in-javascript-context?', 0, function(MACHINE) { diff --git a/scribblings/manual.scrbl b/scribblings/manual.scrbl index 27628d4..a0ee4f3 100644 --- a/scribblings/manual.scrbl +++ b/scribblings/manual.scrbl @@ -99,7 +99,8 @@ The GitHub source repository to Whalesong can be found at Prerequisites: at least @link["http://racket-lang.org/"]{Racket -5.1.1}, and a @link["http://www.java.com"]{Java 1.6} SDK. +5.1.1}. If you wish to use the JavaScript compression option, + you will need @link["http://www.java.com"]{Java 1.6} SDK. @; (This might be superfluous information, so commented out @; for the moment...) @;The majority of the project is written @@ -194,7 +195,7 @@ recompile Whalesong on every single use, which can be very expensive. -@subsection{Making Standalone @tt{.xhtml} files with Whalesong} +@subsection{Making @tt{.html} files with Whalesong} Let's try making a simple, standalone executable. At the moment, the program must be written in the base language of @racket[(planet @@ -219,21 +220,28 @@ $ }| However, it can also be packaged with @filepath{whalesong}. @verbatim|{ - $ whalesong build hello.rkt + $ whalesong build hello.rkt + Writing program # + Writing html # + + $ ls -l hello.html + -rw-r--r-- 1 dyoo dyoo 3817 2011-09-10 15:02 hello.html + $ ls -l hello.js + -rw-r--r-- 1 dyoo dyoo 2129028 2011-09-10 15:02 hello.js - $ ls -l hello.xhtml - -rw-rw-r-- 1 dyoo nogroup 692213 Jun 7 18:00 hello.xhtml }| -Running @tt{whalesong build} on a Racket program will produce a self-contained -@filepath{.xhtml} file. If you open this file in your favorite web browser, -you should see a triumphant message show on screen. + +@margin-note{Visit @link["http://hashcollision.org/whalesong/examples/hello/hello.html"]{hello.html} to execute this program.} +Running @tt{whalesong build} on a Racket program will produce a +@filepath{.html} and @filepath{.js} file. If you open the +@filepath{.html} in your favorite web browser, you should see a +triumphant message show on screen. We can do something slightly more interesting. Let's write a Whalesong program that accesses the JavaScript DOM. Call this file @filepath{dom-play.rkt}. @margin-note{ -The generated program can be downloaded here: @link["http://hashcollision.org/whalesong/examples/dom-play.xhtml"]{dom-play.xhtml} -} +Visit @link["http://hashcollision.org/whalesong/examples/dom-play/dom-play.html"]{dom-play.html} to execute this program.} @filebox["dom-play.rkt"]{ @codeblock|{