








|
| ||
| Article | ||
1 Pull down and install the codePull down the SpiderMonkey source from Mozilla. You can use CVS, or I simply got the tars from:ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz and http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v4.7/src/nspr-4.7.tar.gz.I dropped them into ~/mozilla/tars (location doesn't matter). 4 /Users/rmills/mozilla/tars> ls -lt total 4848 -rw-r--r-- 1 rmills staff 1165607 Mar 7 10:32 js-1.7.0.tar.gz -rw------- 1 rmills staff 1304632 Feb 6 21:28 nspr-4.7.tar.gz 5 /Users/rmills/mozilla/tars>Open the tars and install them into a directory. Again, I used ~/mozilla, however it's your choice. You will however have to create a symbolic link from dist -> to the nspr dist directory (I discovered with some pain - I haven't found this documented anywhere.) 6 /P/Users/rmills/mozilla> ls -lt total 16 drwxr-xr-x 5 rmills staff 264 Mar 7 13:28 tars lrwxr-xr-x@ 1 rmills staff 29 Mar 7 13:26 dist -> nspr-4.7/mozilla/nsprpub/dist drwxr-xr-x 3 rmills staff 264 Feb 6 13:28 nspr-4.7 drwxr-xr-x 5 rmills staff 264 Oct 19 11:58 js 2 Build and install the nspr librariesBuild and install nspr (some support libraries needed for the File object and Thread Safety in SpiderMonkey).7 /Users/rmills/mozilla/nspr-4.7/mozilla/nsprpub> cd /Users/rmills/mozilla/nspr-4.7/mozilla/nsprpub 8 /Users/rmills/mozilla/nspr-4.7/mozilla/nsprpub> configure loading cache ./config.cache checking host system type... i386-apple-darwin9.2.0 ... shake rattle and roll ... 9 /Users/rmills/mozilla/nspr-4.7/mozilla/nsprpub> make .... more rattle and roll ... 10 /Users/rmills/mozilla/nspr-4.7/mozilla/nsprpub> sudo make install ... more rolling ... 3 Build SpiderMonkey libraries and js shellNow build the SpiderMonkey js shell (a command-line prompt for JavaScript).11 /Users/rmills/mozilla/nspr-4.7/mozilla/nsprpub> cd ../../../js/src 12 /Users/rmills/mozilla/js/src> make -f Makefile.ref JS_HAS_FILE_OBJECT=1 JS_THREADSAFE=1 ... do dah do dah ... 4 Test js shell
13 /Users/rmills/mozilla/js/src> Darwin_DBG.OBJ/js
js> dir = new File(".") ; "OK"
OK
js> for ( i in dir ) print(i) ;
length
parent
path
name
isDirectory
isFile
exists
canRead
canWrite
canAppend
canReplace
isOpen
type
mode
creationTime
lastModified
size
hasRandomAccess
hasAutoFlush
position
isNative
js> files = dir.list() ; "OK"
OK
js> for ( i in files ) print(files[i].name)
.cvsignore
... bla bla bla ...
Y.js
js> quit() ;
14 /Users/rmills/mozilla/js/src>
Pretty cool, right! And it has E4X (EcmaScript extensions for XML). The File object however seems to have a lot of bugs. I'll discuss them later.
5 Still to be writtenI'm going to continue this article to discuss the following additional subjects:
| ||
| Comments? | ||
|
I'm very happy to accept comments, feedback and suggestions for any of my articles. I'm always happy to hear you - especially if you have constructive suggestions. And I'm particularily pleased if you can let me know about corrections. |
||
|