fixing the js library; forgot to reroute the RUNTIME references out

This commit is contained in:
Danny Yoo 2011-09-10 15:13:29 -04:00
parent ac2aaf2a08
commit 2b05a35862
2 changed files with 28 additions and 17 deletions

View File

@ -1,18 +1,21 @@
var VOID = plt.baselib.constants.VOID_VALUE;
var makePrimitiveProcedure = plt.baselib.functions.makePrimitiveProcedure;
EXPORTS['alert'] = EXPORTS['alert'] =
RUNTIME.makePrimitiveProcedure( makePrimitiveProcedure(
'alert', 'alert',
1, 1,
function(MACHINE) { function(MACHINE) {
var elt = MACHINE.env[MACHINE.env.length - 1]; var elt = MACHINE.env[MACHINE.env.length - 1];
alert(String(elt)); alert(String(elt));
return RUNTIME.VOID; return VOID;
}); });
EXPORTS['body'] = $(document.body); EXPORTS['body'] = $(document.body);
EXPORTS['$'] = EXPORTS['$'] =
RUNTIME.makePrimitiveProcedure( makePrimitiveProcedure(
'$', '$',
1, 1,
function(MACHINE) { function(MACHINE) {
@ -21,7 +24,7 @@ EXPORTS['$'] =
}); });
EXPORTS['call-method'] = EXPORTS['call-method'] =
RUNTIME.makePrimitiveProcedure( makePrimitiveProcedure(
'call-method', 'call-method',
plt.baselib.arity.makeArityAtLeast(2), plt.baselib.arity.makeArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
@ -40,7 +43,7 @@ EXPORTS['call-method'] =
// Javascript-specific extensions. A small experiment. // Javascript-specific extensions. A small experiment.
EXPORTS['viewport-width'] = EXPORTS['viewport-width'] =
RUNTIME.makePrimitiveProcedure( makePrimitiveProcedure(
'viewport-width', 'viewport-width',
0, 0,
function(MACHINE) { function(MACHINE) {
@ -48,7 +51,7 @@ EXPORTS['viewport-width'] =
}); });
EXPORTS['viewport-height'] = EXPORTS['viewport-height'] =
RUNTIME.makePrimitiveProcedure( makePrimitiveProcedure(
'viewport-height', 'viewport-height',
0, 0,
function(MACHINE) { function(MACHINE) {
@ -57,7 +60,7 @@ EXPORTS['viewport-height'] =
EXPORTS['in-javascript-context?'] = EXPORTS['in-javascript-context?'] =
RUNTIME.makePrimitiveProcedure( makePrimitiveProcedure(
'in-javascript-context?', 'in-javascript-context?',
0, 0,
function(MACHINE) { function(MACHINE) {

View File

@ -99,7 +99,8 @@ The GitHub source repository to Whalesong can be found at
Prerequisites: at least @link["http://racket-lang.org/"]{Racket 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 @; (This might be superfluous information, so commented out
@; for the moment...) @; for the moment...)
@;The majority of the project is written @;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 Let's try making a simple, standalone executable. At the moment, the
program must be written in the base language of @racket[(planet program must be written in the base language of @racket[(planet
@ -219,21 +220,28 @@ $
}| }|
However, it can also be packaged with @filepath{whalesong}. However, it can also be packaged with @filepath{whalesong}.
@verbatim|{ @verbatim|{
$ whalesong build hello.rkt $ whalesong build hello.rkt
Writing program #<path:/home/dyoo/work/whalesong/examples/hello.js>
Writing html #<path:/home/dyoo/work/whalesong/examples/hello.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, @margin-note{Visit @link["http://hashcollision.org/whalesong/examples/hello/hello.html"]{hello.html} to execute this program.}
you should see a triumphant message show on screen. 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 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}. that accesses the JavaScript DOM. Call this file @filepath{dom-play.rkt}.
@margin-note{ @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"]{ @filebox["dom-play.rkt"]{
@codeblock|{ @codeblock|{