From 25099db20a3e533c0ac6aabdf96c97431993dec8 Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Mon, 02 Nov 2009 20:45:18 +0000 Subject: moved useful stuff in the utils/ directory to bin/ and deleted the rest of the stuff in utils/ --- diff --git a/utils/chakra.js b/bin/chakra.js index 4628e75..4628e75 100755 --- a/utils/chakra.js +++ b/bin/chakra.js diff --git a/utils/karma.js b/bin/karma.js index 2f03b1c..2f03b1c 100755 --- a/utils/karma.js +++ b/bin/karma.js diff --git a/utils/.tusk/catalog.json b/utils/.tusk/catalog.json deleted file mode 100755 index d32df16..0000000 --- a/utils/.tusk/catalog.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "!": "This file is generated by 'tusk create-catalog', copied from '.tusk', and committed only so that it may be downloaded from Github with 'tusk update'.", - "version": 1, - "packages": { - "narwhal": { - "name": "narwhal", - "author": "Tom Robinson", - "contributors": [ - "Kris Kowal", - "George Mosochovitis", - "Kevin Dangoor", - "Hannes Wallnöfer" - ], - "main": "examples/narwhal", - "lib": [ - "lib" - ], - "githubName": "narwhal", - "type": "zip", - "location": "http://github.com/tlrobinson/narwhal/zipball/master" - }, - "jack": { - "name": "jack", - "author": "Tom Robinson", - "dependencies": [ - "narwhal" - ], - "jars": [ - "jars/simple-4.1.10.jar" - ], - "githubName": "jack", - "type": "zip", - "location": "http://github.com/tlrobinson/jack/zipball/master" - }, - "nitro": { - "name": "nitro", - "author": "George Moschovitis", - "email": "george.moschovitis@gmail.com", - "dependencies": [ - "jack", - "template" - ], - "js": "lib", - "main": "examples/simple/jackconfig", - "githubName": "nitro", - "type": "zip", - "location": "http://github.com/gmosx/nitro/zipball/master" - }, - "chiron": { - "author": "Kris Kowal", - "dependencies": [], - "lib": "src", - "githubName": "chiron", - "type": "zip", - "location": "http://github.com/kriskowal/chiron/zipball/master" - }, - "narcissus": { - "author": "Brendan Eich ", - "contributors": [ - "Kris Kowal " - ], - "license": "MPL 1.1/GPL 2.0/LGPL 2.1", - "githubName": "narcissus", - "type": "zip", - "location": "http://github.com/kriskowal/narcissus/zipball/master" - }, - "creolejs": { - "author": "Ivan Fomichev", - "contributors": [ - "Chris Purcell", - "Kris Kowal" - ], - "js": "src", - "githubName": "creolejs", - "type": "zip", - "location": "http://github.com/kriskowal/creolejs/zipball/master" - }, - "browserjs": { - "name": "browser", - "author": "Tom Robinson", - "dependencies": [], - "js": "lib", - "githubName": "browserjs", - "type": "zip", - "location": "http://github.com/tlrobinson/browserjs/zipball/master" - }, - "inspec": { - "name": "inspec", - "version": { - "label": "0.1", - "numeric": [ - 0, - 1 - ], - "status": "development" - }, - "githubName": "inspec", - "type": "zip", - "location": "http://github.com/aq1018/inspec/zipball/master" - }, - "kupo": { - "name": "kupo_site", - "author": "Jan Varwig", - "githubName": "kupo", - "type": "zip", - "location": "http://github.com/janv/kupo/zipball/master" - }, - "appengine": { - "name": "appengine", - "author": "George Moschovitis", - "email": "george.moschovitis@gmail.com", - "contributors": [], - "js": "lib", - "githubName": "appengine", - "type": "zip", - "location": "http://github.com/gmosx/appengine/zipball/master" - }, - "jack-servlet": { - "name": "jack-servelet", - "author": "Tom Robinson", - "dependencies": [ - "narwhal", - "jack" - ], - "githubName": "jack-servlet", - "type": "zip", - "location": "http://github.com/tlrobinson/jack-servlet/zipball/master" - }, - "gae": { - "name": "gae", - "title": "Google App Engine Java SDK", - "description": "Java components necessary for depolying applications on Google's App Engine.", - "author": "Google", - "version": "1.2.1", - "dependencies": [ - "jack-servlet", - "jack", - "narwhal" - ], - "lib": [], - "type": "zip", - "location": "http://googleappengine.googlecode.com/files/appengine-java-sdk-1.2.1.zip" - }, - "env": { - "githubName": "env-js", - "type": "zip", - "location": "http://github.com/kriskowal/env-js/zipball/master" - }, - "template": { - "name": "template", - "author": "George Moschovitis", - "email": "george.moschovitis@gmail.com", - "dependencies": [], - "js": "lib", - "githubName": "template", - "type": "zip", - "location": "http://github.com/gmosx/template/zipball/master" - } - } -} \ No newline at end of file diff --git a/utils/.tusk/notes.json b/utils/.tusk/notes.json deleted file mode 100755 index 06d9430..0000000 --- a/utils/.tusk/notes.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "jack": { - "files": [ - "/home/hitman/karma/mainline/utils/packages/jack/.gitignore", - "/home/hitman/karma/mainline/utils/packages/jack/README.md", - "/home/hitman/karma/mainline/utils/packages/jack/bin/fcgi-test.sh", - "/home/hitman/karma/mainline/utils/packages/jack/bin/jackup", - "/home/hitman/karma/mainline/utils/packages/jack/examples/comet.js", - "/home/hitman/karma/mainline/utils/packages/jack/examples/example.js", - "/home/hitman/karma/mainline/utils/packages/jack/examples/hello/main.js", - "/home/hitman/karma/mainline/utils/packages/jack/examples/hello/package.json", - "/home/hitman/karma/mainline/utils/packages/jack/examples/shorty.js", - "/home/hitman/karma/mainline/utils/packages/jack/examples/upload.js", - "/home/hitman/karma/mainline/utils/packages/jack/jackconfig.js", - "/home/hitman/karma/mainline/utils/packages/jack/jars/simple-4.1.10.jar", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/cascade.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/commonlogger.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/contentlength.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/file.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/fastcgi-k7.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/fastcgi-rhino.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/fastcgi.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/jetty.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/servlet.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/shttpd.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/simple.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/handler/v8cgi.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/head.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/jsonp.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/lint.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/methodoverride.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/middleware.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/mime.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/mock.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/narwhal.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/reloader.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/request.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/response.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/showexceptions.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/static.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/urlmap.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jack/utils.js", - "/home/hitman/karma/mainline/utils/packages/jack/lib/jackup.js", - "/home/hitman/karma/mainline/utils/packages/jack/package.json", - "/home/hitman/karma/mainline/utils/packages/jack/support/servlet/README", - "/home/hitman/karma/mainline/utils/packages/jack/support/v8cgi/jack.ssjs", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack-tests.js", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/all-tests.js", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/README", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/binary", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/empty", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/file1.txt", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/ie", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/nested", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/none", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/multipart/text", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/request-tests.js", - "/home/hitman/karma/mainline/utils/packages/jack/tests/jack/utils-tests.js" - ], - "requester": "user", - "finished": true - } -} \ No newline at end of file diff --git a/utils/README.md b/utils/README.md deleted file mode 100755 index e586bf9..0000000 --- a/utils/README.md +++ /dev/null @@ -1,82 +0,0 @@ -Narwhal -======= - -A general purpose JavaScript platform -------------------------------------- - -Narwhal is a cross-platform, multi-interpreter, general purpose JavaScript platform. It aims to provide a solid foundation for building JavaScript applications, primarily outside the web browser. Narwhal includes a package manager, module system, and standard library for multiple JavaScript interpreters. Currently Narwhal's [Rhino](http://www.mozilla.org/rhino/) support is the most complete, but [other platforms](platforms.html) are available too. - -Narwhal's standard library conforms to the [ServerJS standard](https://wiki.mozilla.org/ServerJS). It is designed to work with multiple JavaScript interpreters, and to be easy to add support for new interpreters. Wherever possible, it is implemented in pure JavaScript to maximize reuse of code among platforms. - -Combined with [Jack](http://jackjs.org/), a [Rack](http://rack.rubyforge.org/)-like [JSGI](http://jackjs.org/jsgi-spec.html) compatible library, Narwhal provides a platform for creating server-side JavaScript web applications and frameworks such as [Nitro](http://www.nitrojs.org/). - - -### Homepage: - -* [http://narwhaljs.org/](http://narwhaljs.org/) - -### Source & Download: - -* [http://github.com/tlrobinson/narwhal/](http://github.com/tlrobinson/narwhal/) - -### Mailing list: - -* [http://groups.google.com/group/narwhaljs](http://groups.google.com/group/narwhaljs) - -### IRC: - -* [\#narwhal on irc.freenode.net](http://webchat.freenode.net/?channels=narwhal) - - -Documentation -------------- - -* [Quick Start](quick-start.html) -* [Packages](packages.html) -* [How to Install Packages](packages.html) -* [How to Build Packages](packages-howto.html) -* [Modules](modules.html) -* [Virtual Environments / Seas](sea.html) -* [How to Build Platforms](platforms.html) -* [How Narwhal Works](narwhal.html) - - -Contributors ------------- - -* [Tom Robinson](http://tlrobinson.net/) -* [Kris Kowal](http://askawizard.blogspot.com/) -* [George Moschovitis](http://blog.gmosx.com/) -* [Kevin Dangoor](http://www.blueskyonmars.com/) -* Hannes Wallnöfer -* Sébastien Pierre -* Irakli Gozalishvili -* Christoph Dorn -* Zach Carter -* Nathan L. Smith -* Jan Varwig -* Mark Porter - - -License -------- - -Copyright (c) 2009 Thomas Robinson < 280north.com > - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/utils/bin/.gitignore b/utils/bin/.gitignore deleted file mode 100755 index 5c9571b..0000000 --- a/utils/bin/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -appcfg.cmd -appcfg.sh -dev_appserver.cmd -dev_appserver.sh -fcgi-test.sh -jackup -narwhal-platform diff --git a/utils/bin/activate b/utils/bin/activate deleted file mode 120000 index c2a8369..0000000 --- a/utils/bin/activate +++ /dev/null @@ -1 +0,0 @@ -activate.bash \ No newline at end of file diff --git a/utils/bin/activate.bash b/utils/bin/activate.bash deleted file mode 100755 index e3cf2c7..0000000 --- a/utils/bin/activate.bash +++ /dev/null @@ -1,50 +0,0 @@ - -if [ -z "${BASH_ARGV[0]}" ]; then - - # as a last recourse, use the present working directory - PACKAGE_HOME=$(pwd) - -else - - # get the absolute path of the executable - SELF_PATH=$( - cd -P -- "$(dirname -- "${BASH_ARGV[0]}")" \ - && pwd -P - ) && SELF_PATH=$SELF_PATH/$(basename -- "${BASH_ARGV[0]}") - - # resolve symlinks - while [ -h "$SELF_PATH" ]; do - DIR=$(dirname -- "$SELF_PATH") - SYM=$(readlink -- "$SELF_PATH") - SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") - done - - PACKAGE_HOME=$(dirname -- "$(dirname -- "$SELF_PATH")") - -fi - -export PACKAGE_HOME - -# which -s narwhal doesn't work (os x 10.5, kriskowal) -if [ -f "$PACKAGE_HOME"/bin/narwhal ]; then - NARWHAL="$PACKAGE_HOME"/bin/narwhal -elif [ -f "$PACKAGE_HOME"/packages/narwhal/bin/narwhal ]; then - NARWHAL="$PACKAGE_HOME"/packages/narwhal/bin/narwhal -else - env narwhal -e '' >/dev/null 2>&1 - if [ "$?" -ne 127 ]; then - NARWHAL=narwhal - else - echo "ERROR: narwhal is not in your PATH nor in $PACKAGE_HOME/bin." >&2 - fi -fi - -if [ -f "$PACKAGE_HOME"/narwhal.conf ]; then - source "$PACKAGE_HOME"/narwhal.conf - export NARWHAL_DEFAULT_PLATFORM -fi - -if [ "$NARWHAL" ]; then - export PATH="$("$NARWHAL" --package "$PACKAGE_HOME" --path :)" -fi - diff --git a/utils/bin/activate.cmd b/utils/bin/activate.cmd deleted file mode 100755 index 8619da8..0000000 --- a/utils/bin/activate.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -set PATH=%~dp0;%PATH% diff --git a/utils/bin/js b/utils/bin/js deleted file mode 120000 index c6f91aa..0000000 --- a/utils/bin/js +++ /dev/null @@ -1 +0,0 @@ -narwhal \ No newline at end of file diff --git a/utils/bin/narwhal b/utils/bin/narwhal deleted file mode 100755 index 01fd4b1..0000000 --- a/utils/bin/narwhal +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# get the absolute path of the executable -SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH="$SELF_PATH/$(basename -- "$0")" - -# resolve symlinks -while [ -h "$SELF_PATH" ]; do - DIR=$(dirname -- "$SELF_PATH") - SYM=$(readlink -- "$SELF_PATH") - SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") -done - -# NARWHAL_HOME is the 2nd ancestor directory of this shell script -NARWHAL_HOME=$(dirname -- "$(dirname -- "$SELF_PATH")") - -# use Rhino as the default if none is specified in narwhal.conf -NARWHAL_DEFAULT_PLATFORM="rhino" - -# load narwhal.conf if it exists -if [ -f "$NARWHAL_HOME/narwhal.conf" ]; then - source "$NARWHAL_HOME"/narwhal.conf -fi - -# if NARWHAL_PLATFORM isn't yet set, set it to the default platform, and export it -if [ -z "$NARWHAL_PLATFORM" ]; then - NARWHAL_PLATFORM=$NARWHAL_DEFAULT_PLATFORM -fi -export NARWHAL_HOME - -# build the executable name for the platform -EXECUTABLE_NAME="narwhal-$NARWHAL_PLATFORM" - -# search for the platform home directory -# try narwhal.conf setting -if [ "$NARWHAL_PLATFORM_HOME" ]; then - export NARWHAL_PLATFORM_HOME -# try relative -elif [ -f "$NARWHAL_HOME/platforms/$NARWHAL_PLATFORM/bin/$EXECUTABLE_NAME" ]; then - export NARWHAL_PLATFORM_HOME="$NARWHAL_HOME/platforms/$NARWHAL_PLATFORM" -# try $PATH -elif which -s "$EXECUTABLE_NAME"; then - export NARWHAL_PLATFORM_HOME=$(dirname -- "$(dirname -- "$EXECUTABLE_NAME")") -else - echo "Can't find executable for $NARWHAL_PLATFORM" - exit 1 -fi - -exec "$NARWHAL_PLATFORM_HOME"/bin/"$EXECUTABLE_NAME" "$@" diff --git a/utils/bin/narwhal.cmd b/utils/bin/narwhal.cmd deleted file mode 100755 index 98a9bfc..0000000 --- a/utils/bin/narwhal.cmd +++ /dev/null @@ -1,29 +0,0 @@ -@echo off -setlocal - -:: NARWHAL_HOME is the parent the bin directory -set NARWHAL_HOME=%~dp0.. - -:: use Rhino as the default if none is specified in narwhal.conf -set NARWHAL_DEFAULT_PLATFORM=rhino - -:: TODO: load narwhal.conf if it exists - -:: if NARWHAL_PLATFORM isn't yet set, set it to the default platform, and export it -if "%NARWHAL_PLATFORM%" == "" ( - set NARWHAL_PLATFORM=%NARWHAL_DEFAULT_PLATFORM% -) - -:: build the executable name for the platform -set EXECUTABLE_NAME=narwhal-%NARWHAL_PLATFORM%.cmd - -:: search for the platform home directory -:: TODO: look for more, including ".exe"? -if exist %NARWHAL_HOME%\platforms\%NARWHAL_PLATFORM%. ( - set NARWHAL_PLATFORM_HOME=%NARWHAL_HOME%\platforms\%NARWHAL_PLATFORM% -) else ( - echo "Can't find executable for $NARWHAL_PLATFORM" - exit -) - -call %NARWHAL_PLATFORM_HOME%\bin\%EXECUTABLE_NAME% %* diff --git a/utils/bin/sea b/utils/bin/sea deleted file mode 100755 index 13f7f52..0000000 --- a/utils/bin/sea +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# this script is intended to work both in narwhal/bin and in -# any project's bin dir; it's copied by tusk --init. - -# get the absolute path of the executable -SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") - -# resolve symlinks -while [ -h "$SELF_PATH" ]; do - DIR=$(dirname -- "$SELF_PATH") - SYM=$(readlink -- "$SELF_PATH") - SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") -done - -export PACKAGE_HOME=$(dirname -- "$(dirname -- "$SELF_PATH")") - -source "$PACKAGE_HOME/bin/activate.bash" - -export OLDSEA="$SEA" -export SEA="$PACKAGE_HOME" -export SEALVL="$((SEALVL + 1))" - -if [ "$#" -lt 1 ]; then - echo PATH="$PATH" >&2 - echo SEA="$SEA" >&2 - echo SEALVL="$SEALVL" >&2 - "$SHELL" -else - "$SHELL" -c "$*" -fi -if [ "$OLDSEA" != "" ]; then - echo SEA="$OLDSEA" >&2 -fi -echo SEALVL="$((SEALVL - 1))" >&2 - diff --git a/utils/bin/sea.cmd b/utils/bin/sea.cmd deleted file mode 100755 index bf3f2ad..0000000 --- a/utils/bin/sea.cmd +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -setlocal - -set SHELL=cmd.exe - -set PACKAGE_HOME=%~dp0\.. - -call %PACKAGE_HOME%\bin\activate.cmd - -set OLDSEA=%SEA% -set SEA=%PACKAGE_HOME% -set /a SEALVL=%SEALVL% + 1 - -if "%1" == "" ( - echo SEALVL=%SEALVL% - echo SEA=%SEA% - echo PATH=%PATH% - %SHELL% -) else ( -echo "asdfasdfadsf" - %SHELL% %* -) - -set /a SEALVL=%SEALVL% - 1 -echo SEALVL=%SEALVL% -echo SEA=%OLDSEA% diff --git a/utils/bin/tusk b/utils/bin/tusk deleted file mode 100755 index 85e2daf..0000000 --- a/utils/bin/tusk +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env narwhal -require('narwhal/tusk').main(system.args); diff --git a/utils/bin/tusk.cmd b/utils/bin/tusk.cmd deleted file mode 100755 index d6f225e..0000000 --- a/utils/bin/tusk.cmd +++ /dev/null @@ -1 +0,0 @@ -narwhal.cmd %~dpn0 %* diff --git a/utils/catalog.json b/utils/catalog.json deleted file mode 100755 index 302c53b..0000000 --- a/utils/catalog.json +++ /dev/null @@ -1,166 +0,0 @@ -{ - "!": "This file is generated by 'tusk create-catalog', copied from '.tusk', and committed only so that it may be downloaded from Github with 'tusk update'.", - "version": 1, - "packages": { - "narwhal": { - "name": "narwhal", - "author": "Tom Robinson", - "contributors": [ - "Kris Kowal", - "George Mosochovitis", - "Kevin Dangoor", - "Hannes Wallnöfer" - ], - "main": "examples/narwhal", - "lib": [ - "lib" - ], - "githubName": "narwhal", - "type": "zip", - "location": "http://github.com/tlrobinson/narwhal/zipball/master" - }, - "jack": { - "name": "jack", - "author": "Tom Robinson", - "dependencies": [ - "narwhal" - ], - "jars": [ - "jars/simple-4.1.10.jar" - ], - "githubName": "jack", - "type": "zip", - "location": "http://github.com/tlrobinson/jack/zipball/master" - }, - "nitro": { - "name": "nitro", - "author": "George Moschovitis", - "email": "george.moschovitis@gmail.com", - "dependencies": [ - "jack", - "template" - ], - "contributors": [ - "Kris Kowal" - ], - "js": "lib", - "main": "examples/simple/jackconfig", - "lean": [ - "lib" - ], - "githubName": "nitro", - "type": "zip", - "location": "http://github.com/gmosx/nitro/zipball/master" - }, - "chiron": { - "author": "Kris Kowal", - "dependencies": [], - "lib": "src", - "githubName": "chiron", - "type": "zip", - "location": "http://github.com/kriskowal/chiron/zipball/master" - }, - "narcissus": { - "author": "Brendan Eich ", - "contributors": [ - "Kris Kowal " - ], - "license": "MPL 1.1/GPL 2.0/LGPL 2.1", - "githubName": "narcissus", - "type": "zip", - "location": "http://github.com/kriskowal/narcissus/zipball/master" - }, - "creolejs": { - "author": "Ivan Fomichev", - "contributors": [ - "Chris Purcell", - "Kris Kowal" - ], - "js": "src", - "githubName": "creolejs", - "type": "zip", - "location": "http://github.com/kriskowal/creolejs/zipball/master" - }, - "browserjs": { - "name": "browser", - "author": "Tom Robinson", - "dependencies": [], - "js": "lib", - "githubName": "browserjs", - "type": "zip", - "location": "http://github.com/tlrobinson/browserjs/zipball/master" - }, - "inspec": { - "name": "inspec", - "version": { - "label": "0.1", - "numeric": [ - 0, - 1 - ], - "status": "development" - }, - "githubName": "inspec", - "type": "zip", - "location": "http://github.com/aq1018/inspec/zipball/master" - }, - "kupo": { - "name": "kupo_site", - "author": "Jan Varwig", - "githubName": "kupo", - "type": "zip", - "location": "http://github.com/janv/kupo/zipball/master" - }, - "appengine": { - "name": "appengine", - "author": "George Moschovitis", - "email": "george.moschovitis@gmail.com", - "contributors": [], - "js": "lib", - "githubName": "appengine", - "type": "zip", - "location": "http://github.com/gmosx/appengine/zipball/master" - }, - "jack-servlet": { - "name": "jack-servelet", - "author": "Tom Robinson", - "dependencies": [ - "narwhal", - "jack" - ], - "githubName": "jack-servlet", - "type": "zip", - "location": "http://github.com/tlrobinson/jack-servlet/zipball/master" - }, - "appengine-java-sdk": { - "name": "gae", - "title": "Google App Engine Java SDK", - "description": "Java components necessary for deploying applications on Google's App Engine.", - "author": "Google", - "version": "1.2.2", - "dependencies": [ - "jack-servlet", - "jack", - "narwhal" - ], - "lib": [], - "type": "zip", - "location": "http://googleappengine.googlecode.com/files/appengine-java-sdk-1.2.2.zip" - }, - "env": { - "githubName": "env-js", - "type": "zip", - "location": "http://github.com/kriskowal/env-js/zipball/master" - }, - "template": { - "name": "template", - "author": "George Moschovitis", - "email": "george.moschovitis@gmail.com", - "dependencies": [], - "js": "lib", - "githubName": "template", - "type": "zip", - "location": "http://github.com/gmosx/template/zipball/master" - } - } -} \ No newline at end of file diff --git a/utils/docs/index.md b/utils/docs/index.md deleted file mode 100755 index 85ce2b0..0000000 --- a/utils/docs/index.md +++ /dev/null @@ -1,102 +0,0 @@ - -Narwhal -======= - -A flexible JavaScript standard library --------------------------------------- - -Narwhal is a server-side JavaScript standard library conforming to the [ServerJS standard](https://wiki.mozilla.org/ServerJS). It is designed to work with multiple JavaScript interpreters, and to be easy to add support for new interpreters. Wherever possible, it is implemented in pure JavaScript to maximize reuse of code between platforms. - - -Packages --------- - -A package consists of a directory of modules conforming to the ServerJS [Securable Modules](https://wiki.mozilla.org/ServerJS/Modules/SecurableModules) specification, and a `packages.json` file in the root of the package containing the location of the modules, dependencies, and other metadata. - -A package directory might have the following files and directories: - -* `package.json` for package metadata like dependencies and overrides for the conventional directory names. -* `local.json` for overrides on `package.json` provided by the user. -* `bin` for executables. -* `lib` for all object code, including JavaScript modules, and C extensions. -* `src` for all buildable source code, including C and Java source code. -* `jars` for Java class trees and archives. -* `packages/{name}` for installed sub-packages. -* `platforms/{platform}` for platform-specific packages. -* `parent` for an inherited package tree, like the `narwhal` package installed by the system administrator or OS package management system. - -`package.json` and `local.json` may contain the following attributes: - -* `name` - the name of the package. The package system will only load one package with a given name. The name defaults to the name of the parent directory. -* `lib` - a path or array of paths to top-level module directories provided in this package. Defaults to `["lib"]`. -* `jars` - for Rhino platforms, a path or array of paths to directories to add to the Java CLASSPATH (uses a Java URLClassLoader, so accepts `.jar` paths and directory paths ending with `/`). -* `packages` - a path or array of paths to directories containing additional packages, defaults to `["packages"]`. -* `platforms` - a path or array of paths to directories containing platform-specific packages, defaults to `["platforms"]`. These platform packages will be loaded if and in the prioritized order they appear in the `system.platforms` array, and with higher priority that those in this package's generic `lib` path so that they can override platform-specific modules. -* `main` - a path to a main program if the package is run with `bin/narwhal` and its directory instead of a specific script. -* `author` - may be a comment on the package's author and email in angle brackets. -* `contributors` - may be an array of additional author names and email addresses in angle brackets. -* `parent` - a path to a package tree to inherit, like the `narwhal` package installed by the system administrator. Defaults to `parent` if a symlink exists by that name. - - -Platforms ---------- - -To add Narwhal to a new platform, you need two main things: - -1. A `thunk` which sets up a fixtures object with a few required objects, then loads `narwhal.js` (usually consists of a shell script at `bin/PLATFORM` and short JavaScript file at `narwhal-PLATFORM.js`) - -2. Platform implementations for core modules, such as File (located in `platforms/PLATFORM`) - - -Available Packages ------------------- - -* Jack: the web server and web application/framework agnostic interface, similar to Ruby's Rack and Python's WSGI. Narwhal was conceived while building Jack, and was later extracted into it's own project. - -[http://github.com/tlrobinson/jack](http://github.com/tlrobinson/jack) - -* Chiron: a system of interoperable JavaScript modules, including a type system, base types, general-purpose functions, events, encoding, decoding, hashing, and caching. - -[http://github.com/kriskowal/chiron](http://github.com/kriskowal/chiron) - -* Nitro: a web application framework built on top of Jack. - -[http://github.com/gmosx/nitro](http://github.com/gmosx/nitro) - -* getjs: a JavaScript package manager for ServerJS implementations - -[http://github.com/dangoor/getjs](http://github.com/dangoor/getjs) - - -Contributors ------------- - -* [Tom Robinson](http://tlrobinson.net/) -* [Kris Kowal](http://askawizard.blogspot.com/) -* [George Moschovitis](http://blog.gmosx.com/) -* [Kevin Dangoor](http://www.blueskyonmars.com/) -* Hannes Wallnöfer - - -License -------- - -Copyright (c) 2009 Thomas Robinson <[tlrobinson.net](http://tlrobinson.net/)\> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/utils/docs/lib/binary.wiki b/utils/docs/lib/binary.wiki deleted file mode 100755 index 51560a7..0000000 --- a/utils/docs/lib/binary.wiki +++ /dev/null @@ -1,242 +0,0 @@ -All platforms must support two types for interacting with binary data: ByteArray and ByteString. The ByteArray type resembles the interface of Array in that it is mutable, extensible, and indexing will return number values for the byte in the given position, zero by default, or undefined if the index is out of bounds. The ByteString type resembles the interface of String in that it is immutable and indexing returns a ByteString of length 1. These types are exported by the 'binary' top-level module and both types are subtypes of Binary, which is not instantiable but exists only for the convenience of referring to both ByteArray and ByteString. (The idea of using these particular two types and their respective names originated with Jason Orendorff in the [http://groups.google.com/group/serverjs/msg/89808c05d46b92d0 Binary API Brouhaha] discussion.) - -= Philosophy = - -This proposal is not an object oriented variation on pack and unpack with notions of inherent endianness, read/write head position, or intrinsic codec or charset information. The objects described in this proposal are merely for the storage and direct manipulation of strings and arrays of byte data. Some object oriented conveniences are made, but the exercise of implementing pack, unpack, or an object-oriented analog thereof are left as an exercise for a future proposal of a more abstract type or a 'struct' module (as mentioned by Ionut Gabriel Stan on [http://groups.google.com/group/serverjs/msg/592442ba98c6c70e the list]). This goes against most mentioned [[ServerJS/Binary|prior art]]. - -This proposal also does not provide named member functions for any particular subset of the possible charsets, codecs, compression algorithms, or consistent hash digests that might operate on a byte string or array. Instead, convenience member functions are provided for interfacing with any named charset, with the IANA charset name space, and with the possibility of eventually employing a system of modular extensions for other codecs or digests, requiring that the given module exports a specified interface. (As supported originally by Robert Schultz, Davey Waterson, Ross Boucher, and tacitly myself, Kris Kowal, on the [http://groups.google.com/group/serverjs/browse_thread/thread/be72ef3d8146731d/06c27162b698eef5?lnk=gst First proposition] thread on the mailing list). This proposal does not address the need for stream objects to support pipelined codecs and hash digests (mentioned by Tom Robinson and Robert Schultz in the same conversation). - -This proposal also reflects both group sentiment and a pragmatic point about properties. This isn't a decree that properties like "length" should be consistently used throughout the ServerJS APIs. However, given that all platforms support properties at the native level (to host String and Array objects) and that byte strings and arrays will require support at the native level, pursuing client-side interoperability is beyond the scope of this proposal and therefore properties have been specified. (See comments by Kris Zyp about the implementability of properties in all platforms, comments by Davey Waterson from Aptana about the counter-productivity of attempting to support this API in browsers, and support properties over accessor and mutator functions by Ionut Gabriel Stand and Cameron McCormack on the [http://groups.google.com/group/serverjs/browse_thread/thread/be72ef3d8146731d/06c27162b698eef5?lnk=gst mailing list]). - -The byte types provide functions for encoding, decoding, and transcoding, but they are all shallow interfaces that defer to a charset manager module, and may in turn use a system level charset or use a pair of pure JavaScript modules to transcode through an array or stream of canonical Unicode code points. This behavior may be specified further in the future. - -= Specification = - -The "binary" top-level module must export "Binary", "ByteArray" and "ByteString". - - -== ByteString == - -A ByteString is an immutable, fixed-width representation of a C unsigned char (byte) array. ByteString supports the String API, and indexing returns a byte substring of length 1. - -=== Constructor === - -; ByteString() -: Construct an empty byte string. -; ByteString(byteString) -: Copies byteString. -; ByteString(byteArray) -: Use the contents of byteArray. -; ByteString(arrayOfNumbers) -: Use the numbers in arrayOfNumbers as the bytes. -: If any element is outside the range 0...255, an exception (''TODO'') is thrown. -; ByteString(string, charset) -: Convert a string. The ByteString will contain string encoded with charset. - -=== Constructor methods === - -; join(array, delimiter) -: Like Array.prototype.join, but for Binarys. Returns a ByteString. - -=== Instance properties === - -; length -: The length in bytes. Immutable. - -=== Instance methods (in prototype) === - -; toByteArray() -: Returns a byte for byte copy in a ByteArray. -; toByteArray(sourceCharset, targetCharset) -: Returns a transcoded copy in a ByteArray. -; toByteString() -: Returns itself, since there's no need to copy an immutable ByteString. -; toByteString(sourceCharset, targetCharset) -: Returns a transcoded copy. -; toArray() -: Returns an array containing the bytes as numbers. -; toArray(charset) -: Returns an array containing the decoded Unicode code points. -; toString() -: Returns a debug representation like "[ByteString 10]", where 10 is the length of the Array. Alternative debug representations are valid too, as long as (1) this method will never fail, (2) the length is included. -; decodeToString(charset) -: Returns the decoded ByteArray as a string. -; indexOf(byte) -; indexOf(byte, start) -; indexOf(byte, start, stop) -: Returns the index of the first occurance of byte (a Number or a single element ByteString or ByteArray) or -1 if none was found. If start and/or stop are specified, only elements between the the indexes start and stop are searched. -; lastIndexOf(byte) -; lastIndexOf(byte, start) -; lastIndexOf(byte, start, stop) -: Returns the index of the last occurance of byte (a Number or a single element ByteString or ByteArray) or -1 if none was found. If start and/or stop are specified, only elements between the the indexes start and stop are searched. -; charCodeAt(offset) -; get(offset) -: Return the byte at offset as a Number. -; byteAt(offset) ByteString -; charAt(offset) ByteString -: Return the byte at offset as a ByteString. -; split(delimiter, [options]) -: Split at delimiter, which can by a Number, a ByteString, a ByteArray or an Array of the prior (containing multiple delimiters, i.e., "split at any of these delimiters"). Delimiters can have arbitrary size. -: Options is an optional object parameter with the following optional properties: -* ''count'' - Maximum number of elements (ignoring delimiters) to return. The last returned element may contain delimiters. -* ''includeDelimiter'' - Whether the delimiter should be included in the result. -: Returns an array of ByteStrings. -; slice() -; slice(begin) -; slice(begin, end) -: See [https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/slice Array.prototype.slice] - - -; substr(start) -: -; substr(start, length) -: -; substring(first) -: -; substring(first, last) - -; [] ByteString -: the immutable [] operator returning ByteStrings -; toSource() -: which would return "ByteString([])" for a null byte string - -ByteString does not implement toUpperCase() or toLowerCase() since they are not meaningful without the context of a charset. - -== ByteArray == - -A ByteArray is a mutable, flexible representation of a C unsigned char (byte) array. - -=== Constructor === - -; ByteArray() -: New, empty ByteArray. -; ByteArray(length) -: New ByteArray filled with length zero bytes. -; ByteArray(byteArray) -: Copy byteArray. -; ByteArray(byteString) -: Copy contents of byteString. -; ByteArray(arrayOfBytes) -: Use numbers in arrayOfBytes as contents. -: Throws an exception if any element is outside the range 0...255 (''TODO''). -; ByteArray(string, charset) -: Create a ByteArray from a Javascript string, the result being encoded with charset. - -Unlike the Array, the ByteArray is not variadic so that its initial length constructor is not ambiguous with its copy constructor. - -All values within the length of the array are numbers stored as bytes that default to 0 if they have not been explicitly set. Assigning beyond the bounds of a ByteArray implicitly grows the array, just like an Array. Retrieving a value from an index that is out of the bounds of the Array, lower than 0 or at or beyond the length, the returned value is "undefined". Assigning an index with a value that is larger than fits in a byte will be implicitly and silently masked against 0xFF. Negative numbers will be bit extended to a byte in two's complement form and likewise masked. - -=== Instance properties === - -; mutable length property -: extending a byte array fills the new entries with 0. - -=== Instance methods (in prototype) === - -; toArray() -: n array of the byte values -; toArray(charset) -: an array of the code points, decoded -; toString() -: A string debug representation like "[ByteArray 10]". Alternative debug representations are valid too, as long as (1) this method will never fail, (2) the length is included. -; decodeToString(charset) -: returns a String from its decoded bytes in a given charset. -; toByteArray() -: just a copy -; toByteArray(sourceCharset, targetCharset) -: transcoded -; toByteString() -: byte for byte copy -; toByteString(sourceCharset, targetCharset) -: transcoded -; byteAt(offset) ByteString -: Return the byte at offset as a ByteString. -; get(offset) Number -: Return the byte at offset as a Number. -; concat(other:ByteArray|ByteString|Array) -; pop() byte:Number -: -; push(...variadic Numbers...) -> count(Number) -: -; extendRight(...variadic Numbers / Arrays / ByteArrays / ByteStrings ...) -: -; shift() byte:Number -: -; unshift(...variadic Numbers...) count:Number -: -; extendLeft(...variadic Numbers / Arrays / ByteArrays / ByteStrings ...) -: -; reverse() in place reversal -: -; slice() -: -; sort() -: -; splice() -: -; indexOf() -: -; lastIndexOf() -: -; split() -: Returns an array of ByteArrays instead of ByteStrings. -; filter() -: -; forEach() -: -; every() -: -; some() -: -; map() -: -; reduce() -: -; reduceRight() -: -; displace(begin, end, values/ByteStrings/ByteArrays/Arrays...) -> length -: begin/end are specified like for slice. Can be used like splice but does not return the removed elements. -; toSource() -: Returns a string like "ByteArray([])" for a null byte-array. -; [] Number -: The mutable [] operator for numbers - -== String == - -The String prototype will be extended with the following members: - -; toByteArray(charset) -: Converts a string to a ByteArray encoded in charset. -; toByteString(charset) -: Converts a string to a ByteString encoded in charset. -; charCodes() -: Returns an array of Unicode code points (as numbers). - -== Array == - -The Array prototype will be extended with the following members: - -; toByteArray(charset) -: Converts an array of Unicode code points to a ByteArray encoded in charset. -; toByteString(charset) -: Converts an array of Unicode code points to a ByteString encoded in charset. - -== General Requirements == - -None of the specified prototypes or augmentations to existing prototypes are enumerable. - -Any operation that requires encoding, decoding, or transcoding among charsets may throw an error if that charset is not supported by the implementation. All implementations MUST support "us-ascii" and "utf-8". - -Charset strings are as defined by IANA http://www.iana.org/assignments/character-sets. - -Charsets are case insensitive. - -= Tests = - -* [http://github.com/tlrobinson/narwhal/tree/master/tests/serverjs ServerJS tests] compatible with [http://github.com/tlrobinson/narwhal/tree/master/lib/test this test framework]. - -= Relevant Discussions = - -* [http://groups.google.com/group/serverjs/browse_thread/thread/f8ad81201f7b121b ByteArray and ByteString proposal] -* [http://groups.google.com/group/serverjs/browse_thread/thread/a8d3a91af37fd355 ByteArray: byteAt method] -* [http://groups.google.com/group/serverjs/browse_thread/thread/45190ac89d7b422a Binary/B Extension Proposals and Implementation Notes] diff --git a/utils/docs/lib/file.wiki b/utils/docs/lib/file.wiki deleted file mode 100755 index da344e8..0000000 --- a/utils/docs/lib/file.wiki +++ /dev/null @@ -1,325 +0,0 @@ -Proposal A, Draft 5 (in development) - -The "file" module supports the File System API, providing an interface for path, directory, file, link, file stat, and file stream manipulation. - -For the purpose of this documentation, "fs" is a variable name for any object that implements the File System API, including the exports of the "file" module, and objects returned by "fs.chroot(path)". - - -=== Security === - -Objects implementing the File System API, including the "file" module object, are capability bearing objects that carry and mediate authority to read and write to the underlying storage. As such, the "file" module can return other objects that implement and attenuate the File System API for sandboxing. Furthermore, streams returned by the file system object are implicitly attenuated to only give the receiver authority to manipulate the given file, without knowledge of the path on which it resides or access to references that would permit it to manipulate other parts of the file system. - - -=== Interface === - -The "file" module must export the following: - -==== Files ==== - -; open(path String, mode|options) -: returns a stream object that supports an appropriate interface for the given options and mode, which include reading, writing, updating, byte, character, unbuffered, buffered, and line buffered streams. More details follow in the [#Stream] section of this document. -* path -* mode: "rwa+bxc", or -* options -** mode String -** charset String -** read Boolean -** write Boolean -** append Boolean -** update Boolean -** binary Boolean -** exclusive Boolean -** canonical Boolean -; read(path String, [mode|options]) -: opens, reads, and closes a file, returning its content. -; write(path String, content String|Binary, [mode|options]) -: opens, writes, flushes, and closes a file with the given content. If the content is a ByteArray or ByteString, the binary mode is implied. -; copy(source String, target String) -: reads one file and writes another in byte mode. -; move(from String, to String) -: -; remove(path String) -: -; rename(path String, name String) -: -; touch(path, [mtime Date]) -: - -==== Directories ==== - -('''TODO''' Should the methods in this section use "mkdir" or "makeDir" style names? [http://groups.google.com/group/serverjs/browse_thread/thread/851fea66620bae13 discussion]) - -; list(path String) Iterator -: returns an iterator that yields the names of the entries in a directory. Throws an error if the directory is inaccessible or does not exist. -; mkdir(path String) -: Create a single directory specified by ''path''. If the directory cannot be created for any reason an exception will be thrown. This includes if the parent directories of "path" are not present. -: -; mktree(path String) -: '''TODO''' Decide upon the name of this function. "mkdirs" or "mktree" or "makeTree" -: Will create the directory specified by "path" including any missing parent directories. -: -; rmdir(path String) -: Removes a directory if it is empty. If it is not, or cannot be removed for another reason an exception will be thrown. -: -; rmtree(path String) -: -: This does its best to remove the directory "path", akin to "rm -r" on Unix or "del /s" on Windows. That is it will recursively delete all directories and files under "path". - -==== Links ==== - -==== Paths ==== - -; [new] Path(path String|Path|Array, [fs FileSystem]) Path -: returns a Path object that closes on a File System object and a "path" representation. The path object is a chainable shorthand for working with paths in the context of the "file" module. "Path" objects have no more or less authority to manipulate the file system than the FileSystem object that they are attached to, as any path string is reachable by chaining operations on a path instance. The FileSystem object defaults to the "file" module if the argument is omitted or undefined. More details follow in the [#Path Path] section of this document. -; path(path String|Path, fs FileSystem) Path -: "fs.path(path)" is a shorthand for "new fs.Path(path, fs)". - -===== Working Path ===== - -The current working directory is used by all routines that resolve relative paths to absolute file system paths, including "open", and "absolute". - -; cwd() String -: returns the current working directory. -; chdir(path String) -: changes the current working directory. - -===== Traditional ===== - -; join(...) -: takes a variadic list of path Strings, joins them on the file system's path separator, and normalizes the result. -; split(path String) Array -: returns an array of path components. If the path is absolute, the first component will be an indicator of the root of the file system; for file systems with drives (such as Windows), this is the drive identifier with a colon, like "c:"; on Unix, this is an empty string "". The intent is that calling "join.apply" with the result of "split" as arguments will reconstruct the path. -; normal(path String) -: removes '.' path components and simplifies '..' paths, if possible, for a given path. -; absolute(path String) -: returns the absolute path, starting with the root of this file system object, for the given path, resolved from the current working directory. If the file system supports home directory aliases, absolute resolves those from the root of the file system. The resulting path is in normal form. On most systems, this is equivalent to expanding any user directory alias, joining the path to the current working directory, and normalizing the result. "absolute" can be implemented in terms of "cwd", "join", and "normal". -; canonical(path String) -: returns the canonical path to a given abstract path. Canonical paths are both absolute and intrinsic, such that all paths that refer to a given file (whether it exists or not) have the same corresponding canonical path. This function must not communicate information about the true parent directories of files in chroot environments. This function is equivalent to expanding a user directory alias, joining the given path to the current working directory, joining all symbolic links along the path, and normalizing the result. "canonical" can be implemented in terms of "cwd", "join", "normal" and "readlink". -; dirname(path String) String -: returns the path of a file's containing directory, albeit the parent directory if the file is a directory. A terminal directory separator is ignored. -; basename(path String, [extension String]) String -: returns the part of the path that is after the last directory separator. If an extension is provided and is equal to the file's extension, the extension is removed from the result. -; extension(path String) String -: returns the extension of a file. The extension of a file is the last dot (excluding any number of initial dots) followed by one or more non-dot characters. Returns an empty string if no valid extension exists. [http://github.com/kriskowal/narwhal-test/blob/master/src/test/file/extension.js unit test]. - -===== URL-like ===== - -; resolve(...) -: a function like "join" except that it treats each argument as as either an absolute or relative path and, as is the convention with URL's, treats everything up to the final directory separator as a location, and everything afterward as an entry in that directory, even if the entry refers to a directory in the underlying storage. Resolve starts at the location "" and walks to the locations referenced by each path, and returns the path of the last file. Thus, resolve(file, "") idempotently refers to the location containing a file or directory entry, and resolve(file, neighbor) always gives the path of a file in the same directory. "resolve" is useful for finding paths in the "neighborhood" of a given file, while gracefully accepting both absolute and relative paths at each stage. [http://github.com/kriskowal/narwhal-test/blob/master/src/test/file/resolve.js unit test]. -; relative(from, to) -: returns the relative path from one path to another using only ".." to traverse up to the two paths' common ancestor. - -==== Tests ==== - -; exists(path) -:whether a file exists at a given path: receives a path and returns whether that path, joined on the current working directory, corresponds to a file that exists. If the file is a broken symbolic link, returns false. -; isFile(path) -:returns whether a path exists and that it corresponds to a file. -; isDirectory(path) -:returns whether a path exists and that it corresponds to a directory. -; isLink(path) -:returns whether a path exists and that it corresponds to a symbolic link (TODO or shortcut?). -; isReadable(path) -:returns whether a path exists, that it corresponds to a file, and that it can be opened for reading by "fs.open". -; isWritable(path) -:If a path exists, returns whether a file may be opened for writing, or entries added or removed from an existing directory. If the path does not exist, returns whether entries for files, directories, or links can be created at its location. - -==== Metadata ==== - -; stat(path String) -:Returns an object that contains the file's metadata, including all of the following that are applicable in the target platform's file system -;; device Number -:device number of the file system -;; inode Number -:virtual node number -;; mode Number -:type and permissions, numeric -;; linkCount Number -:number of hard links to the file -;; uid Number -:numeric id of the owner user -;; rdev Number -:the device identifier for special files -;; size NUmber -:total size in bytes -;; blockSize Number -:preferred block size for file system IO, in bytes -;; blockCount Number -:number of blocks allocated -;; mtime Date -:time of last modification (write) -;; atime Date -:time of last access (read, write, update) -;; ctime Date -:(TODO created vs. stat changed. is /.time/ really the best pattern for expressing these times?) -;; xattrs -:extended attributes (reserved) -;; acls -:access control lists (reserved) - -; size(path String) -:Number -; mtime(path String) -:Date -; atime(path String) -:Date -; ctime(path String) -:Date -; same(pathA String, pathB String) Boolean -:whether the two files are identical, in that they come from the same file system, same device, and have the same node and corresponding storage, such that modifying one would implicitly and atomically modify the other. - -==== Security ==== - -; chroot(path String) -: returns an object that conforms to the File System API, like the "file" module or the "system.fs" variable, that can be safely passed into a sandbox as the "file" module and "system.fs" objects. - - -== Path == - -; [new] Path(path String|Path|Array, [fs FileSystem]) Path -: - -The prototype for the Path constructor is a String object. - -The path constructor accepts as its first argument either a String, Path, or Array. If the path is an Array (as tested by Array.isArray, not merely typeof path == "array"), it must conform to the specification for values returned by "fs.split". - -Every path object has the members "normal", "absolute", "canonical", "dirname", "basename", "join", and "resolve". All of these return new Path objects constructed by converting the path to a string, passing it through the likewise named method of "fs", and converting it back to a Path. Thus, all of these methods are chainable. In addition, "join" and "resolve" are variadic, so additional paths can be passed as arguments in either String, Path, or Array form. - -Every path object has "chroot", "copy", "exists", "extension", "isDirectory", "isFile", "isLink", "isReadable", "isWritable", "mkdir", "mkdirs", "move", "mtime", "open", "read", "remove", "rename", "rmdir", "rmtree", "same", "size", "split", "stat", "touch", and "write". All of these functions convert themselves to strings and pass the results through the likewise named method of "fs". - -In addition, paths implement: - -; toString() -: -; to(path) -: uses "fs.relative" to return a Path from this path to another one. -; from(path) -: uses "fs.relative" to return a Path to this path from another one. -; list() -: returns an iterator of Path objects for the contained directory entries. - -(TODO resolve whether it's more proper to make "Path" foundational and eliminate "fs". Wrapping the "Path" object around a central "fs" object will be necessary for "chroot" whether we expose that level of the API or not, and having routines that work with strings on one architectural layer and paths on the next up gives the programmer an oppoertunity to program at the level that makes sense for their task. It also, however, gives the programmer more to learn.) - - -== Streams == - -The "open" function mediates the construction of various kinds of streams. As "open" is the only method with the authority to manipulate files, it constructs these types on behalf of a potentially unpriviledged caller. Stream constructors are not directly callable in a secure sandbox, so where and how these stream types are implemented is beyond the necessary scope of this specification. The "open" function always creates a byte level stream, and by default wraps that in a textual IO wrapper. - -* create a "raw" byte stream. If "x" mode (with either "w" or "a" mode), only open if the file does not already exist. Create the file and open the stream atomically. -** if "r" mode, make "raw" a ByteReader -** if "w" mode, make "raw" a ByteWriter -** if "u" mode, make "raw" a ByteUpdater -* if "+", seek to end. -* if not "b" mode, return "raw". -* return a wrapper encoded/decoded string stream around "raw" with specified buffering, line buffering, and charset. -** if "r" mode, wrap "raw" in a TextReader -** if "w" mode, wrap "raw" in a TextWriter -** if "u" mode, wrap "raw" in a TextUpdater - -; ByteReader -: appropriate for reading binary opaque struct records or other binary data or protocols -; ByteWriter -: appropriate for writing binary opaque struct records or other binary data or protocols -; ByteUpdater -: appropriate for a database -; ByteReaderWriter -: appropriate for sockets -; TextReader -: appropriate for standard input -; TextWriter -: appropriate for standard output -; TextUpdater -: -; TextReaderWriter -: appropriate for a TTY - -(TODO: resolve whether it is necessary for all stream types to have a common prototype, or whether it makes sense for them to be arranged in a class hierarchy.) - -=== *Reader, *Updater === - -TextReader, ByteReader, TextUpdater, ByteUpdater, TextReaderWriter, and ByteReaderWriter have the following properties and methods: - -; read() *String -: reads and returns all of the file until EOF is encountered. Return ByteStrings for Byte* types, and Strings for Text* types. -; read(max Number) *String -: -; readInto(buffer *Array, [begin Number], [end Number]) Number -: -; canRead() Boolean -: -; skip(n Number) Number -: - -=== *Writer, *Updater === - -TextWriter, ByteWriter, TextUpdater, ByteUpdater, TextReaderWriter, and ByteReaderWriter have the following properties and methods: - -; canWrite() Boolean -: -; flush() -: - -=== ByteUpdater === - -; tell() Number -: -; seek(position Number, whence Number) -: -; truncate([length Number=0]) -: -; rewind() -: a shortcut for seek(0) - -=== Text* === - -TextReader, TextWriter, TextUpdater, and TextReaderWriter have the following properties and methods: - -; raw Byte* -: the underlying byte stream, ByteReader for TextReaders, ByteWriter for TextWriters, and so on. - -=== TextReader === - -; readLine() String -: reads a line from the reader. If EOF is encountered before any data is gathered, returns "". Otherwise, returns the line including the "newLine". -; readLines() Array*String -: returns an Array of Strings accumulated by calling readLine until an empty string turns up. Does not include the final empty string, and does include "newLine" at the end of every line. -; next() String or throws StopIteration -: returns the next line of input without its "newLine". Throws StopIteration if EOF is encountered. -; iterator() Iterator -: returns the reader itself - -=== TextWriter === - -; writeLine(line String) -: -; print(...) -: writes a "delimiter" delimited array of Strings terminated with a "newLine" - -=== TextUpdater === - -; tell() OpaqueCookie -: -; seek(position OpaqueCookie) -: -; truncate([position OpaqueCookie) -: -; rewind() -: seeks to the beginning of the file. - - -== Notes == - -* Path separators, and other file-system-specific constants are not included in this specification. - -= Todo = - -* random access IO -* locks -* canonical IO (non-blocking) -* comprehensive stat access and modification -* temporary files and directories -* symbolic links -* more open options: permissions, owner, groupOwner -* copy with metadata -* glob -* other [https://wiki.mozilla.org/ServerJS/API/file/Names proposed names]. diff --git a/utils/docs/lib/os/popen.md b/utils/docs/lib/os/popen.md deleted file mode 100755 index 4bbc389..0000000 --- a/utils/docs/lib/os/popen.md +++ /dev/null @@ -1,70 +0,0 @@ - -; popen(process):Popen -: process may be a String or Array of args. If it is a String, popen uses "/bin/sh", "-e" to execute your program. - -Popen ------ - -; stdin -: a text writer IO object attached to the stdin of subprocess. -; stdout -: a text reader IO object attached to the stdout of the supbrocess. -; stderr -: a text reader IO object attached to the stderr of the subprocess. - -; wait() -> code:Number -: blocks execution until the subprocess has exited. - -; communicate([stdin[, stdout[, stderr]]]):Communicate -: communicates with the process on stdin, stdout, and stderr concurrently with the attached streams. the given stdin may be a stream, string, or stringio stream. stdout and stderr may be streams or stringio objects, and default to stringio. communicate returns the pipes used to communicate with stdin, stdout, and stderr, by default providing stdout and stderr as stringio objects that have accumulated the entire output and errput of the subprocess. - -Communicate ------------ - -; stdin -: the text reader object used to communicate with the subprocess. if no stdin was provided as an argument to communicate, stdin will be an empty stringio. if a string was provided, stdin will be a stringio with whatever input was not consumed by the subprocess. if any other stream was provided, stdin will be that stream. -; stdout -: the text writer object that the subprocess wrote to on stdout. if no stdout was provided as an argument to communicate, stdout will be a stringio containing all of the accumulated output of the subprocess. -; stderr -: the text writer object that the subprocess wrote to on stderr. if no stderr was provided as an argument to communicate, stderr will be a stringio containing all of the accumulated errput of the subprocess. -; code -: the exit code of the subprocess - -Examples --------- - -This is the implementation of "system" in the "os" module: - - exports.system = function (command, options) { - var process = exports.popen(command, options); - return process.communicate( - '', - system.stdout, - system.stderr - ).code; - }; - -This is the implementation of the "command" function in the "os" module. "command" executes a subprocess and returns all of the output of the subprocess as a String. If the exit status code of the subprocess is non-zero, it throws an error containing all of the accumulated errput of the subprocess. - - exports.command = function (command) { - var process = exports.popen(command); - var result = process.communicate(); - if (result.code !== 0) - throw new Error(result.stderr.read()); - return result.stdout.read(); - }; - -This function uses the "sort" command to sort a list of numbers. - - var io = require("io"); - var os = require("os"); - - var list = io.StringIO(); - list.print("30"); - list.print("4"); - list.print("1000"); - list.print("200"); - - var process = os.popen(["sort", "-n", "-"]); - process.communicate(list).stdout.forEach(print); - diff --git a/utils/docs/modules.md b/utils/docs/modules.md deleted file mode 100755 index 6fe786f..0000000 --- a/utils/docs/modules.md +++ /dev/null @@ -1,38 +0,0 @@ - -Narwhal Modules -=============== - -Narwhal "scripts" are [ServerJS](https://wiki.mozilla.org/ServerJS) compatible modules, much like Python or Ruby modules. You do not have to use module pattern boilerplate; every module has its own local scope. You can get the exports object of another module by calling `require`. - - var file = require("file"); - file.isFile("foo.txt"); - -Module identifiers for `require` come in three flavors: "top-level", "relative", and "absolute". In the above case, "file" is a "top-level" identifier, so it will load any module called "file.js" in the "lib" directory of whichever package comes first in the load path. Relative identifiers have "." or ".." as their first term, and terms are delimited with "/". So, in the "foo/bar" module, "require('./baz')" will load "foo/baz". Absolute module identifiers should not be used directly, but are produced when you execute a program module outside the module path. The module is identified by its fully-qualified path, starting with "/". - -You can export an object by assigning it to `exports`. - - exports.foo = function () { - return "Hello"; - }; - -In a module, you also get a `module` object that has `module.id` and `module.path` properties so you can inspect your own top-level module identifier, and the path of your own module file. You also get a `require.main` property that tells you the top-level module identifier of the module that started the program. - - if (require.id == require.main) - main(); - - var settings = require(require.main); - - var fs = require("file"); - var path = fs.path(module.path); - var indexHtml = path.resolve("./template/index.html").read(); - -Inside a module, you also get a `print` function and a `system` object. The `system` object is equivalent to the `system` module, but always available. It exports `stdin`, `stdout`, `stderr`, `args`, `platform`, `platforms`, `prefix`, and other handy routines. - - -A Brief Tour -============ - -The main modules of the standard library are "system", "file", "io", and "os". There are also handy "json", "args", and "util" modules for a JSON codec, command line argument parsers, and utility functions. - -I have already introduced `system`. The "file" module implements functions like "open", "read", "write", "copy", "move", "list", and others. "os" exports commands like "system", "command", "exit", "popen", and "enquote" for shell args. - diff --git a/utils/docs/narwhal.md b/utils/docs/narwhal.md deleted file mode 100755 index d2a3f05..0000000 --- a/utils/docs/narwhal.md +++ /dev/null @@ -1,478 +0,0 @@ - -How Narwhal Works -================= - -This document provides information on how to use `bin/narwhal` -through its command line options, environment variables, -and configuration files, then descends into the exact -maddenning details of how it goes about bootstrapping -and configuraing itself. - - -Glossary --------- - -* module: a JavaScript file that gets its own local scope - and certain free variables so that it may export and import - APIs. - -* library: a directory that contains additional top-level - modules. - -* package: a downloadable and installable component that - may include a library of additional modules, as well - as executables, source code, or other resources. - -* sandbox: a system of module instances. sandboxes - are not necessarily secure in our parlance, but are - the finest security boundary Narwhal can support. - All modules in a sandbox are mutually vulnerable to - each other and to their containing sandbox. By - injecting frozen modules into a sandbox, or through - dependency injection using the `system` variable, - it will be eventually possible to construct secure - sandboxes. In a secure sandbox, monkey patching - globals will not be possible, and strict mode will - be enforced. However, all secure sandboxes will - be able to share the same primordial objects, particularly - Array, so managed communication among sandboxes will - be possible. - -* sea: a sea for Narwhal is like a virtual environment. - for simplicity, the directory schema of a package, a sea, - and Narwhal itself are all the same. They all - have their own configuration and libraries, but Narwhal - always starts searching for packages and modules - in the current sea before searching for packages and - modules in the main Narwhal installation, or system - Narwhal installation. - - -Command Line Options --------------------- - -* `-e -c --command COMMAND` - - evaluate command (final option) - -* `-r --require MODULE` - - pre-load a module - -* `-m --module MAIN` - - run a module as a script (final option) - -* `-I --include LIB` - - add a library path to loader in the position of - highest precedence - -* `-p --package PACKAGEPREFIXES` - - add a package prefix directory - -* `-d --debug` - - set debug mode, system.debug = true - -* `-P --no-packages` - - do not load packages automatically - -* `-v --verbose` - - verbose mode: trace 'require' calls. - -* `-l --log LEVEL` - - set the log level (critical, error, warn, info, debug) - -* `-: --path DELIMITER` - - prints an augmented PATH with all package bins/ - -* `-V --version` - - print Narwhal version number and exit. - - -Environment Variables ---------------------- - -* `NARWHAL_DEFAULT_PLATFORM` may be set in `narwhal.conf` to a - platform name like `rhino`, `v8`, or `xulrunner`. Use - `tusk platforms` for a complete list and consult the `README` in - that platform directory for details about its function and - readiness for use. - -* `NARWHAL_PLATFORM` may be set at the command line, but is - otherwise set to `NARWHAL_DEFAULT_PLATFORM` by `bin/narwhal` - and exposed in JavaScript as `system.platform`. This - is the name of the JavaScript engine in use. - -* `NARWHAL_HOME` is the path to the `narwhal` directory and - is available in JavaScript as `system.prefix`. - -* `NARWHAL_PLATFORM_HOME` is the path to the narwhal - platform directory, where `bootstrap.js` may be found, - and is set by `bin/narwhal`. - -* `NARWHAL_PATH` and `JS_PATH` can be used to add - high priority library directories to the module - search path. These values are accessible in most - sandboxes as the `require.loader.paths` variable, - and may be editable in place with methods like - `shift`, `unshift`, and `splice`. Replacing - `require.loader.paths` with a new Array may not - have any effect. In secure sandboxes, `paths` - are not available. - -* `NARWHAL_DEBUG` is an informational variable that - can also be set with the `-d` and `--debug` command - line options, and accessed or changed from within a - JavaScript module as `system.debug`. `NARWHAL_DEBUG` - gets coerced to a `Number`, and the options stack, - so `js -ddd -e 'print(system.debug)'` will print 3. - -* `NARWHAL_VERBOSE` instructs the module loader - to report when modules have started and finished - loading. This environment variable must be used - to catalog modules that are loaded in the - bootstrapping process. Otherwise, you can use - the `-v` and `--verbose` options for the same - effect for modules that are loaded after the - command line arguments have been parsed, which - happens before packages are loaded. - -* `SEA` is an environment variable set by `sea` that - notifies `narwhal` to search the given virtual - environment for packages first. This function can - be approximated by using the `-p` or `--package` - options to the `narwhal` or `js` command, and is - inspectable from within a module as the variable - `system.packagePrefixes[0]`. - -* `SEALVL` (sea level) is an informational environment - variable provided by the `sea` command, analogous to - `SHLVL` (shell level) that is the number of instances - of `sea` the present shell is running in. - - -Configuration Files -------------------- - -* `narwhal.conf` may be provided to configure site-specific - or virtual-environment (sea) specific environment - variables like `NARWHAL_DEFAULT_PLATFORM`. You can - also opt to specify `NARWHAL_PLATFORM`, but that obviates - the possibility of allowing the user to override - the narwhal platform at the command line. `narwhal.conf` - follows the BSD convention of using shell scripts as - configuration files, so you may use any `bash` syntax - in this file. A `narwhal.conf.template` exists for - illustration. - -* `package.json` describes the Narwhal package. Narwhal - itself is laid out as a package, so it might be used - as a standard library package for other engines that - might host module systems independently. `package.json` - names the package, its metadata, and its dependencies. - `package.json` should not be edited. - -* `local.json` may be created to override the values - provided in `package.json` for site-specific configurations. - A `local.json.template` exists to illustrate how this - might be used to tell Narwhal that the parent directory - contains packages, as this is a common development - scenario. - -* `sources.json` contains data for Tusk on where to - find `package.json` files and `package.zip` archives - so that it can create a catalog of all installable - packages, their descriptions, and dependencies. - This file should not be edited unless the intention - is to update the defaults provided for everyone. - -* `.tusk/sources.json` may be created for site-specific - package sources and overrides the normal `sources.json`. - -* `catalog.json` is meant to be maintained as a centrally - managed catalog that may be downloaded from Github to - `.tusk/catalog.json` using `tusk update`. - -* `.tusk/catalog.json` is where `tusk` looks for information - about packages that can be downloaded and installed. - It may be downloaded with `tusk update` or built from - `sources.json` or `.tusk/sources.json` using - `tusk create-catalog`. - - -Bootstrapping Narwhal ---------------------- - -Narwhal launches in stages. On UNIX-like systems, Narwhal starts with a `bash` script, a platform specific `bash` script, a platform specific JavaScript, then the common JavaScript. - -* `bin/narwhal` - - At this stage, Narwhal uses only environment variables - for configuration. This script discovers its own - location on the file system and sources `narwhal.conf` - as a shell script to load any system-level configuration - variables like `NARWHAL_DEFAULT_PLATFORM`. From there, - it discerns and exports the `NARWHAL_PLATFORM` and - `NARWHAL_PLATFORM_HOME` environment variables. - It then executes the - platform-specific script, - `$NARWHAL_PLATFORM_HOME/bin/narwhal-$NARWHAL_PLATFORM`. - -* `platforms/{platform}/bin/narwhal-{platform}` - - This `bash` script performs some platform-specific - configuration, like augmenting the Java `CLASSPATH` - for the Rhino platform, and executes the - platform-specific bootstrap JavaScript using the - JavaScript engine for the platform. - - Some platforms, like `k7` require the JavaScript engine - to be on the `PATH`. The Rhino platform just expects - Java to be on the `PATH`, and uses the `js.jar` included - in the repository. - -* `platforms/{platform}/bootstrap.js` - - This platform-specific JavaScript uses whatever - minimal mechanisms the JavaScript engine provides - for reading files and environment variables to - read and evaluate `narwhal.js`. `narwhal.js` evaluates - to a function expression that accepts a zygotic - `system` `Object`, to be replaced later by loading - the `system` module proper. `bootstrap.js` provides a - `system` object with `global`, `evalGlobal`, `platform`, - a `platforms` Array, `print`, `fs.read`, `fs.isFile`, - `prefix`, `packagePrefixes`, and optionally `evaluate`, - `debug`, or `verbose`. - - * `global` is the `global` `Object`. This is - passed explicitly in anticipation of times - when it will be much harder to grab this - object in platforms where its name varies - (like `window`, or `this`) and where it will - be unsafe to assume that `this` defaults - to `global` for functions called anonymously. - - * `evalGlobal` is a function that calls `eval` in - a scope where no global variables are masked - by local variables, but `var` declarations - are localized. This is passed explicitly - in anticipation of situations down the line where - it will be harder to call `eval` in a pristine - scope chain. - - * `platform` is a synonym for the `NARWHAL_PLATFORM` - environment variable, the name of the platform. - This variable is informational. - - * `prefix` is a synonym for the `NARWHAL_HOME` - environment variable, the path leading to the - `narwhal` package containing `bin/narwhal`. - - * `packagePrefixes` is a prioritized Array of all of - the package directories to search for packages - when that time comes. The first package prefix - should be the `SEA` environment variable, if it - exists and has a path. This is the first place - that the `packages` module will look for - packages to load. The last package prefix is - simply the `prefix`, `NARWHAL_HOME`. The `SEA` - prefix appears first so that virtual environments - can load their own package versions. - - * `platforms` is an Array of platform names, used - to extend the module search path at various stages - to include platform specific libraries. There will - usually be more than one platform in this Array. - For Rhino, it is `['rhino', 'default']`. The - `default` platform contains many "catch-all" modules - that, while being platform-specific, are also - general enough to be shared among almost all - platforms. Other platforms are likely to share - dynamically linked C modules in a "c" platform, - and the "rhino" platform itself is useful for - the "helma" platform. - - * `print` is a temporary shortcut for writing a line to - a logging console or standard output, favoring - the latter if it is available. - - * `fs` is a pimitive duck-type of the `file` module, - which will be loaded later. The module loader - uses `read` and `isFile` to load the initial modules. - - * `evaluate` is a module evaluator. If the platform - does not provide an evaluator, the `sandbox` module - has a suitable default, but some platforms provide - their own. For example, the "secure" platform - injects a safe, hermetic evaluator. `evaluate` - accepts a module as a String, and optionally - a file name and line number for debugging purposes. - `evaluate` returns a module factory `Function` - that accepts `require`, `exports`, `module`, `system`, - and `print`, the module-specific free variables for - getting the exported APIs of other modules, providing - their own exports, reading their meta data, and - conveniently accessing the `system` module and `print` - function respectively. - - * `debug` is informational, may be used anywhere, and - is read from the `NARWHAL_DEBUG` environment variable, - and may be set later by the `-d` or `--debug` command - options. - - * `verbose` instructs the module loader to log when - module start and finish loading, and is read - from the `NARWHAL_VERBOSE` environment variable, - and may be set later by the `-v` or `--verbose` command - options. To log the coming and going of modules - as they occur **before** the packages and program - modules get loaded, you must use the environment - variable. - -* `narwhal.js` - - This is the common script that creates a module loader, - makes the global scope consistent across platforms, - finishes the `system` module, parses command line arguments, - loads packages, executes the desired program, and - finally calls the unload event for cleanup or running - a daemon event loop. - -When Narwhal is embedded, the recommended practice is to load the `bootstrap.js` platform script directly, skipping the shell script phases. - -Some platforms, like Helma or GPSEE, may provide their own module loader implementation. In that case, they may bypass all of this bootstrapping business and simply include Narwhal as if it were a mere package. - -No system has been constructed for Windows systems yet. - - -Narwhal Script --------------- - -The `narwhal.js` script is the next layer of blubber. - -* `sandbox` module (loaded manually from `lib/sandbox.js`), - provides the means to construct a `require` function - so all other modules can be loaded. -* `global` module, monkey patches the transitive globals - so that every platform receives the same ServerJS - and EcmaScript 5 global object, or as near to that - as possible. -* `system` module, including the `file` and `logger` - modules, which is provided for convenience as a free - variable in all modules. -* `narwhal` module parses arguments. -* `packages` module loads packages. - * `packages-platform` loads jars for Java/Rhino. -* run command -* `unload` module sends an `unload` signal to any - observers, usually for cleanup or to kick off event loops. - - -Sandbox Module --------------- - -The sandbox module provides a basic module `Loader` for -module files on disk, a `MultiLoader` for plugable module -factory loaders (for things like Objective-J modules and -dynamically linked C modules), a `Sandbox` for creating and -memoizing module instances from the module factories. The -sandbox module is useful for creating new sandboxes from -within the main sandbox, which is useful for creating cheap -module system reloaders that will instantiate fresh modules but -only go to disk when the underlying module text has changed. - - -Global Module -------------- - -The global module is platform-specific, and there is sharable -version in the default platform. The purpose of the global -module is to load modules like "json", "string", "array", and -"binary", that monkey patch the globals if necessary to -bring every platform up to speed with EcmaScript 5 and -the ServerJS standard. - - -System Module -------------- - -The system module provides the ServerJS -[System](https://wiki.mozilla.org/ServerJS/System) module -standard, for standard IO streams, arguments, and environment -variables. The system module goes beyond spec by being -a free variable available in all modules, and by providing -`print`, `fs`, and `log` variables (at the time of this -writing). `print` is a late-bound alias for -`system.stdout.print`, which is to say that replacing -`system.stdout` will cause `print` to redirect to the new output -stream. `fs` is an alias for the `file` module, while `log` is a `Logger` instance from the `logger` module that prints time-stamped log messages to `system.stderr`. - - -Narwhal Module --------------- - -The Narwhal module contains the command line parser declarations -for Narwhal, and an Easter egg. - - -Packages Module ---------------- - -The packages module analyzes and installs packages, such that their libraries are available in the module search path, and also installs some platform-specific package components like Java archives at run-time. The package loader uses a five pass algorithm: - -* find and read package.json for every accessible package, - collating them into a catalog. This involves a breadth - first topological search of the `packages/` directory of each - `package` in the `system.packagePrefixes` Array. This - guarantees that the packages installed in the Sea - (virtual environment) can override the versions installed - with the system. -* verify that the catalog is internally consistent, dropping - any package that depends on another package that is - not installed. -* sort the libraries from packages so that libraries - that "depend" on other packages get higher precedence - in the module search path. -* "analyze" the packages in order. This involves finding - the library directories in each package, including - platform-specific libraries for all of the - `system.platforms`, and performing platform-specific - analysis like finding the Java archives (`jars`) installed - in each package. -* "synthesize" a configuration from the analysis. This - involves setting the module search path, and performing - platform-specific synthesis, like installing a Java - class loader for the Java archives, and creating a new, - global `Packages` object. - -Much of the weight of code in the `packages` module concerns -using both the conventional locations for libraries and whatnot, -but also handling overriden configuration values, gracefully -accepting both single Strings and Arrays of multiple options -for all directories. For example, `packages` assumes that -each package has a `lib` directory. However, the package may -provide a `package.json` that states that `lib` has been put -somewhere else, like `{"lib": "lib/js"}`, or even multiple -locations like `{"lib": ["lib/js", "usr/lib/js"]}`. This -applies to "packages" and "jars" as well. - - -Unload Module -------------- - -When the program is finished, Narwhal checks whether the -"unload" module has been used. If so, it calls the "send" -function exported by that module, so that any observers attached -with the "when" method get called in first on first off order. -This is handy for modules like "reactor" that initiate an event -loop. - diff --git a/utils/docs/packages-howto.md b/utils/docs/packages-howto.md deleted file mode 100755 index 2429018..0000000 --- a/utils/docs/packages-howto.md +++ /dev/null @@ -1,31 +0,0 @@ - -How to make Packages -==================== - -A package consists of a directory of modules conforming to the ServerJS [Securable Modules](https://wiki.mozilla.org/ServerJS/Modules/SecurableModules) specification, and a "package.json" file in the root of the package containing the location of the modules, depedencies, and other metadata. - -A package directory might have the following files and directories: - -* "package.json" for package metadata like dependencies and overrides for the conventional directory names. -* "local.json" for overrides on "package.json" provided by the user. -* "bin" for executables. -* "lib" for all object code, including JavaScript modules, and C extensions. -* "src" for all buildable source code, including C and Java source code. -* "jars" for Java class trees and archives. -* "packages/{name}" for installed sub-packages. -* "platforms/{platform}" for platform-specific packages. -* "parent" for an inherited package tree, like the "narwhal" package installed by the system administrator or OS package management system. - -"package.json" and "local.json" may contain the following attributes: - -* "name" - the name of the package. The package system will only load one package with a given name. The name defaults to the name of the parent directory. -* "lib" - a path or array of paths to top-level module directories provided in this package. Defaults to ["lib"]. -* "jars" - for Rhino platforms, a path or array of paths to directories to add to the Java CLASSPATH (uses a Java URLClassLoader, so accepts ".jar" paths and directory paths ending with "/"). -* "packages" - a path or array of paths to directories containing additional packages, defaults to ["packages"]. -* "platforms" - a path or array of paths to directories containing platform-specific packages, defaults to ["platforms"]. These platform packages will be loaded if and in the prioritized order they appear in the "system.platforms" array, and with higher priority that those in this package's generic "js" path so that they can override platform-specific modules. -* "main" - a path to a main program if the package is run with "bin/narwhal" and its directory instead of a specific script. -* "author" - may be a comment on the package's author and email in angle brackets. -* "contributors" - may be an array of additional author names and email addresses in angle brackets. -* "parent" - a path to a package tree to inherit, like the "narwhal" package installed by the system administorator. Defaults to "parent" if a symlink exists by that name. - - diff --git a/utils/docs/packages.md b/utils/docs/packages.md deleted file mode 100755 index 8b1e60c..0000000 --- a/utils/docs/packages.md +++ /dev/null @@ -1,30 +0,0 @@ - -Available Packages -================== - -You can download and install packages using the `tusk` application that comes with Narwhal. Check out `tusk help` for details. These are some of the packages: - -* `jack`: the webserver and web application/framework agnostic interface, similar to Ruby's Rack and Python's WSGI. Narwhal was conceived while building Jack, and was later extracted into it's own project. - -[http://github.com/tlrobinson/jack](http://github.com/tlrobinson/jack) - -* `chiron`: a system of interoperable JavaScript modules, including a type system, base types, general-purpose functions, events, encoding, decoding, hashing, and caching. - -[http://github.com/kriskowal/chiron](http://github.com/kriskowal/chiron) - -* `nitro`: a web application framework built on top of Jack. - -[http://github.com/gmosx/nitro](http://github.com/gmosx/nitro) - -And others including: - -* Narcissus -* Wiki Creole -* Browser -* Inspec -* Kupo -* Bespin Server Prototype -* Bespin PubSub -* Nitro Templates -* Google App Engine Utilities - diff --git a/utils/docs/platforms.md b/utils/docs/platforms.md deleted file mode 100755 index 5e25b26..0000000 --- a/utils/docs/platforms.md +++ /dev/null @@ -1,32 +0,0 @@ - -Platforms -========= - -Narwhal is a standard library and tools for multiple JavaScript engines; each engine has its own "platform" library. Use `tusk platform {name}` to select an engine, or edit `narwhal.conf`. The following engines are presently in development: - -* `rhino`: is the default and most complete platform, based on Mozilla Rhino for Java, used for out-of-the-box functionality. -* `k7`: is a `v8` based engine, in development by Sébastien Pierre. -* `helma`: is based on Rhino with extensions, being developed by Hannes Wallnöefer. -* `xulrunner`: is in development for Firefox extensions and XULRunner applications on the Spidermonkey platform by Irakli Gozalishvili, Christoph Dorn, and Zach Carter. -* `jaxer`: is an engine based on Mozilla SpiderMonkey, for deploying web pages with both server and client side scripts, being developed by Nathan L Smith. -* `v8cgi`: is based on the work of Ondrej Zara, and has not been updated in a long while. -* `default`: is a catchall platform that implements modules that can be shared among platforms. -* `browser`: will eventually be available for client side loading of modules with various techniques. -* `secure`: will eventually be available for dependency injection sandboxed module systems within some other platforms. - - -Creating new Platform Adapters ------------------------------- - -We have a template for new platforms at "platforms/template" that you can copy to "platforms/{name}" and fill in the blanks. These consist of: - -1. An executable (shell script or binary) at "platforms/{name}/bin/platform-{name}" that executes the interpreter engine of choice and causes it to load a bootstrap script. This script will be loaded by "bin/narwhal" with the environment variable `NARWHAL_HOME` set to the Narwhal project directory and `NARWHAL_PLATFORM_HOME` set to the platform directory. This script will be run if `NARWHAL_PLATFORM` is set to your platform name. You can set `NARWHAL_DEFAULT_PLATFORM` or `NARWHAL_PLATFORM` in a "narwhal.conf" in your Narwhal project directory (template provided). - -2. A "thunk", at `platforms/{name}/bootstrap.js` that evaluates `narwhal.js` and passes the returned function a preliminary `system` object with a few required properties (`global`, `evalGlobal`, `platform`, `platforms`, `print`, `evaluate`, `prefix`, `fs.read`, and `fs.isFile`). This should be enough to get to an interactive console. - -3. Platform implementations for core modules, such as `file` and `system` located in `platforms/{name}/lib/`. You can implement `file-platform` instead of `file` if you implement the subset of the ServerJS file API used by `lib/file.js` (and similar for `io`, `os`, `binary`, etc). The next steps are: - - * system: You must implement `system.args` to be able to pass command line options to Narwhal. - - * file: To enable the package system you must implement `list`, `canonical`, `mtime`, `isDirectory`, `isFile`. - diff --git a/utils/docs/posts/2009-07-29-hello-0.1.md b/utils/docs/posts/2009-07-29-hello-0.1.md deleted file mode 100755 index b48c320..0000000 --- a/utils/docs/posts/2009-07-29-hello-0.1.md +++ /dev/null @@ -1,19 +0,0 @@ -Hello 0.1 -========= - -Today we're announcing [Narwhal](http://narwhaljs.org/) 0.1 and [Jack](http://jackjs.org/) 0.1. - -### Download - -* Narwhal 0.1: [tar](http://github.com/tlrobinson/narwhal/tarball/0.1), [zip](http://github.com/tlrobinson/narwhal/zipball/0.1) -* Jack 0.1: [tar](http://github.com/tlrobinson/jack/tarball/0.1), [zip](http://github.com/tlrobinson/jack/zipball/0.1) - -Check out the [quick start guide](http://narwhaljs.org/quick-start.html) for instructions on getting up and running with Narwhal and Jack. - -### Release Notes - -* Complete [securable modules](https://wiki.mozilla.org/ServerJS/Modules/SecurableModules) implementation, in JavaScript, with hooks for native module loading. -* Various modules, including `file`, `binary`, `os`, `system`, `args`, and many others. -* The "tusk" package manager, currently using [Github](http://github.com/) as a package repository. -* Full support for the Rhino interpreter, and partial support for numerous other [platforms](http://narwhaljs.org/platforms.html). -* Preliminary support for Windows. diff --git a/utils/docs/quick-start.md b/utils/docs/quick-start.md deleted file mode 100755 index 3522a11..0000000 --- a/utils/docs/quick-start.md +++ /dev/null @@ -1,55 +0,0 @@ - -Narwhal Quick Start -=================== - -Download Narwhal. - -* download and extract the [zip](http://github.com/tlrobinson/narwhal/zipball/master) or [tar](http://github.com/tlrobinson/narwhal/tarball/master) archive, or -* `git clone git://github.com/tlrobinson/narwhal.git` - -Put Narwhal on your PATH environment variable. - -* `export PATH=$PATH:~/narwhal/bin`, or -* execute `narwhal/bin/sea` for a quick Narwhal subshell - -Run `narwhal` or `js` (they're equivalent). - -* `js narwhal/examples/hello` - -Look at the options. - -* `narwhal --help` -* `tusk help` - - -My First Web Server -=================== - -Create a project "hello-web". - - tusk init hello-web - cd hello-web - -Enter your project as a "virtual environment" using `sea` so that its libraries, binaries, and packages get automatically installed when you run Narwhal. - - bin/sea - -Install some packages you will need, like Jack, the JSGI standard library for interoperable web services. - - tusk install jack - -Tusk gets downloaded and installed at "hello-web/packages/jack". - -Create your "jackconfig.js". This is a trivial JSGI compatible application, wrapped in the `ContentLength` middleware to automatically set the "Content-Length" header. - - var jack = require("jack"); - - exports.app = jack.ContentLength(function (env) { - return [200, {"Content-type": "text/plain"}, ["Hello, Web!"]]; - }); - -Run it! - - jackup - -Next, take a look at the introduction to [modules](modules.html), for a primer on using and making modules in Narwhal. diff --git a/utils/docs/sea.md b/utils/docs/sea.md deleted file mode 100755 index 06f2d45..0000000 --- a/utils/docs/sea.md +++ /dev/null @@ -1,49 +0,0 @@ - -Narwhal, Tusk, and Sea -====================== - -Narwhal is your JavaScript interpreter. It is executable with "narwhal" or "js". See "narwhal --help" for a list of its options. It is comparable to your shell, Python or Ruby/IRB. - -Tusk is your package manager. Tusk by default installs packages whereever "narwhal" is installed. See "tusk help" for a list of options. It is comparable to "apt" or "gem". You can also use "tusk" to create new "packages", application project scaffolds, or "virtual environments", which are all the same thing. - -"sea" is a tool for entering a Narwhal "virtual environment". It executes a command or reexecutes your shell inside a "virtual environment". There is a version of "sea" that comes packed with "Narwhal", which you can use to "enter" your system "narwhal" environment, which is handy if "narwhal/bin" is not on your path. You can also source "activate.sh" if your current working directory is the package root you want to use for your Sea. - -You can use "narwhal", "tusk", and "sea" to create multiple, independent, reproducable Narwhal project installations. Assuming that "narwhal" and "tusk" are on your path, you can use "tusk init" to create two application projects. - - $ tusk init foo - $ tusk init bar - $ cd foo - foo$ bin/sea - PATH=foo/bin - SEALVL=1 - foo$ tusk install jack - foo$ edit jackconfig.js - foo$ jackup - Loading configuration module at foo/jackconfig - Jack is starting up using Simple on port 8080 - ^C - foo$ echo $SEA - foo - foo$ which sea - foo/bin/sea - foo$ exit - SEALVL=0 - foo$ cd ../bar - bar$ bin/sea - PATH=bar/bin - SEALVL=1 - ... - -When you are in a Sea, Narwhal loads all of the packages installed in that Sea and Tusk installs packages in your Sea. While you can manipulate the NARWHAL_PATH and JS_PATH environment variables manually, Seas obviate the need. - -Each sea can also have a different JavaScript engine. Edit narwhal.conf in your Sea to use a different engine. - - $ js -e 'print(system.platform)' - rhino - $ cat bar/narwhal.conf - NARWHAL_DEFAULT_PLATFORM=v8 - $ bar/bin/sea 'js -e "print(system.platform)"' - v8 - PATH=/bin - SEALVL=0 - diff --git a/utils/examples/hello b/utils/examples/hello deleted file mode 100755 index 49beb13..0000000 --- a/utils/examples/hello +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env narwhal -print("Hello, World!"); diff --git a/utils/examples/narwhal b/utils/examples/narwhal deleted file mode 100755 index 9dfc302..0000000 --- a/utils/examples/narwhal +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env narwhal -var narwhal = require('narwhal'); -print(narwhal.LEFT); diff --git a/utils/examples/not-quite-a-quine.js b/utils/examples/not-quite-a-quine.js deleted file mode 100755 index 3d68c7b..0000000 --- a/utils/examples/not-quite-a-quine.js +++ /dev/null @@ -1 +0,0 @@ -system.stdout.write(system.fs.read(module.path)).flush(); diff --git a/utils/getopt.js b/utils/getopt.js deleted file mode 100755 index 6dd6513..0000000 --- a/utils/getopt.js +++ /dev/null @@ -1,273 +0,0 @@ - -var GetOpt = function() { - this.options = {}; - this.add("", null, [], false, false, GetOpt.REQUIRED_ARGUMENT); /* main arguments */ -}; - -/** @constant */ GetOpt.NO_ARGUMENT = 1; -/** @constant */ GetOpt.REQUIRED_ARGUMENT = 2; -/** @constant */ GetOpt.OPTIONAL_ARGUMENT = 3; - -/** - * Adds an option - * @param {string} id Identifier - * @param {string} description Textual description - * @param {?} value Default value - * @param {character} shortOpt Short option character - * @param {string} longOpt Long option string - * @param {number} argument Argument type constant - */ -GetOpt.prototype.add = function(id, description, value, shortOpt, longOpt, argument) { - this.options[id] = { - description:description, - value:value, - longOpt:longOpt, - shortOpt:shortOpt, - argument:argument || GetOpt.NO_ARGUMENT - }; -} - -/** - * Retrieve option value - * @param {string} id Identifier - */ -GetOpt.prototype.get = function(id) { - var str = id || ""; - if (str in this.options) { - return this.options[str].value; - } else { - throw new Error("Unknown option '"+id+"'"); - } -} - -/** - * Parses list of options - * @param {array} array Command-line arguments - */ -GetOpt.prototype.parse = function(array) { - this._pending = false; - for (var i=0;i indent) { indent = names[i].length; } - } - indent++; - - var str = ""; - for (var i=0;i error */ - throw new Error("Missing value for '-"+character+"'"); - } else { /* unsatisfied optional */ - this._addValue(id, null); - } - } - } -} - -GetOpt.prototype._isOption = function(str) { - return (str.length > 1 && str.charAt(0) == "-"); -} - -GetOpt.prototype._findOptionShort = function(str) { - for (var id in this.options) { - if (this.options[id].shortOpt == str) { return id; } - } - return false; -} - -GetOpt.prototype._findOptionLong = function(str) { - for (var id in this.options) { - if (this.options[id].longOpt == str) { return id; } - } - return false; -} - -/** - * Set/add a value to option - */ -GetOpt.prototype._addValue = function(id, value) { - var item = this.options[id]; - if (item.argument == GetOpt.NO_ARGUMENT) { /* no argument -> switch to true */ - item.value = true; - return; - } - - if (item.value instanceof Array) { /* _add_ a new value */ - var val = value; - if (value === null) { val = true; } - item.value.push(val); - } else { /* _set_ a new value */ - if (item.argument == GetOpt.OPTIONAL_ARGUMENT) { /* optional */ - if (typeof(item.value) == "number" && value === null) { /* numeric - increment */ - item.value++; - } else if (typeof(item.value) == "number") { /* numeric value */ - item.value = parseFloat(value); - } else { /* other or null value */ - item.value = (value === null ? true : value); - } - } else { /* required */ - item.value = value; - } - } -} - -GetOpt.prototype._helpName = function(item) { - var str = ""; - if (item.shortOpt) { - str += "-"+item.shortOpt; - if (item.argument != GetOpt.NO_ARGUMENT) { str += " "; } - if (item.argument == GetOpt.OPTIONAL_ARGUMENT) { str += "["; } - if (item.argument != GetOpt.NO_ARGUMENT) { str += "value"; } - if (item.argument == GetOpt.OPTIONAL_ARGUMENT) { str += "]"; } - } - - if (item.shortOpt && item.longOpt) { str += ", "; } - - if (item.longOpt) { - str += "--"+item.longOpt; - if (item.argument == GetOpt.OPTIONAL_ARGUMENT) { str += "["; } - if (item.argument != GetOpt.NO_ARGUMENT) { str += "="; } - if (item.argument != GetOpt.NO_ARGUMENT) { str += "value"; } - if (item.argument == GetOpt.OPTIONAL_ARGUMENT) { str += "]"; } - } - - return str; -} - -exports.GetOpt = GetOpt; diff --git a/utils/i18n/#test.pot# b/utils/i18n/#test.pot# deleted file mode 100755 index a0a6c66..0000000 --- a/utils/i18n/#test.pot# +++ /dev/null @@ -1,41 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR Free Software Foundation, Inc. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -Project-Id-Version: PACKAGE VERSION -Report-Msgid-Bugs-To: bryan@olenepal.org -POT-Creation-Date: -PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE -Last-Translator: FULL NAME -Language-Team: LANGUAGE -MIME-Version: 1.0 -Content-Type: text/plain; charset=CHARSET -Content-Transfer-Encoding: 8bit - -msgctxt "HTML Tag: LABEL ID: lblScore" -msgid "The score is" - -msgctxt "HTML Tag: LABEL ID: txtScore" -msgid "0" - -msgctxt "HTML Tag: BUTTON ID: btnYes" -msgid "Yes" - -msgctxt "HTML Tag: BUTTON ID: btnNo" -msgid "No!" - -msgctxt "HTML Tag: BUTTON ID: btnRestart" -msgid "Restart" - -msgctxt "HTML Tag: META ID: "msgid "karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" diff --git a/utils/i18n/jquery.js b/utils/i18n/jquery.js deleted file mode 100755 index b1ae21d..0000000 --- a/utils/i18n/jquery.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - * jQuery JavaScript Library v1.3.2 - * http://jquery.com/ - * - * Copyright (c) 2009 John Resig - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) - * Revision: 6246 - */ -(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("",""]||!O.indexOf("",""]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!O.indexOf("",""]||(!O.indexOf("",""]||!O.indexOf("",""]||!o.support.htmlSerialize&&[1,"div
","
"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}}); -/* - * Sizzle CSS Selector Engine - v0.9.3 - * Copyright 2009, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return UT[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="

";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="
";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("
").append(M.responseText.replace(//g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='
';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})(); \ No newline at end of file diff --git a/utils/i18n/test.html b/utils/i18n/test.html deleted file mode 100755 index 7f481cf..0000000 --- a/utils/i18n/test.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - -
-
- - -
-
- - - -
-
- - - - - diff --git a/utils/i18n/test.pot b/utils/i18n/test.pot deleted file mode 100755 index 5eb8d60..0000000 --- a/utils/i18n/test.pot +++ /dev/null @@ -1,26 +0,0 @@ -Project-Id-Version: PACKAGE VERSION -Report-Msgid-Bugs-To: bryan@olenepal.org -POT-Creation-Date: -PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE -Last-Translator: FULL NAME -Language-Team: LANGUAGE -MIME-Version: 1.0 -Content-Type: text/plain; charset=CHARSET -Content-Transfer-Encoding: 8bit - -msgctxt "HTML Tag: LABEL ID: lblScore" -msgid "The score is" - -msgctxt "HTML Tag: LABEL ID: txtScore" -msgid "0" - -msgctxt "HTML Tag: BUTTON ID: btnYes" -msgid "Yes" - -msgctxt "HTML Tag: BUTTON ID: btnNo" -msgid "No!" - -msgctxt "HTML Tag: BUTTON ID: btnRestart" -msgid "Restart" - -msgctxt "HTML Tag: META ID: "msgid "karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" diff --git a/utils/i18n/testnw.txt b/utils/i18n/testnw.txt deleted file mode 100755 index 5eb8d60..0000000 --- a/utils/i18n/testnw.txt +++ /dev/null @@ -1,26 +0,0 @@ -Project-Id-Version: PACKAGE VERSION -Report-Msgid-Bugs-To: bryan@olenepal.org -POT-Creation-Date: -PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE -Last-Translator: FULL NAME -Language-Team: LANGUAGE -MIME-Version: 1.0 -Content-Type: text/plain; charset=CHARSET -Content-Transfer-Encoding: 8bit - -msgctxt "HTML Tag: LABEL ID: lblScore" -msgid "The score is" - -msgctxt "HTML Tag: LABEL ID: txtScore" -msgid "0" - -msgctxt "HTML Tag: BUTTON ID: btnYes" -msgid "Yes" - -msgctxt "HTML Tag: BUTTON ID: btnNo" -msgid "No!" - -msgctxt "HTML Tag: BUTTON ID: btnRestart" -msgid "Restart" - -msgctxt "HTML Tag: META ID: "msgid "karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" diff --git a/utils/jsdoc-toolkit/README.txt b/utils/jsdoc-toolkit/README.txt deleted file mode 100755 index 44575d3..0000000 --- a/utils/jsdoc-toolkit/README.txt +++ /dev/null @@ -1,186 +0,0 @@ -====================================================================== - -DESCRIPTION: - -This is the source code for JsDoc Toolkit, an automatic documentation -generation tool for JavaScript. It is written in JavaScript and is run -from a command line (or terminal) using the Java and Mozilla's Rhino -JavaScript runtime engine. - -Using this tool you can automatically turn JavaDoc-like comments in -your JavaScript source code into published output files, such as HTML -or XML. - -For more information, to report a bug, or to browse the technical -documentation for this tool please visit the official JsDoc Toolkit -project homepage at http://code.google.com/p/jsdoc-toolkit/ - -For the most up-to-date documentation on JsDoc Toolkit see the -official wiki at http://code.google.com/p/jsdoc-toolkit/w/list - -====================================================================== - -REQUIREMENTS: - -JsDoc Toolkit is known to work with: -java version "1.6.0_03" -Java(TM) SE Runtime Environment (build 1.6.0_03-b05) -on Windows XP, -and java version "1.5.0_13" -Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241) -on Mac OS X 10.4. - -Other versions of java may or may not work with JsDoc Toolkit. - -====================================================================== - -USAGE: - -Running JsDoc Toolkit requires you to have Java installed on your -computer. For more information see http://www.java.com/getjava/ - -Before running the JsDoc Toolkit app you should change your current -working directory to the jsdoc-toolkit folder. Then follow the -examples below, or as shown on the project wiki. - -On a computer running Windows a valid command line to run JsDoc -Toolkit might look like this: - -> java -jar jsrun.jar app\run.js -a -t=templates\jsdoc mycode.js - -On Mac OS X or Linux the same command would look like this: - -$ java -jar jsrun.jar app/run.js -a -t=templates/jsdoc mycode.js - -The above assumes your current working directory contains jsrun.jar, -the "app" and "templates" subdirectories from the standard JsDoc -Toolkit distribution and that the relative path to the code you wish -to document is "mycode.js". - -The output documentation files will be saved to a new directory named -"out" (by default) in the current directory, or if you specify a --d=somewhere_else option, to the somewhere_else directory. - -For help (usage notes) enter this on the command line: - -$ java -jar jsrun.jar app/run.js --help - -More information about the various command line options used by JsDoc -Toolkit are available on the project wiki. - -====================================================================== - -RUNNING VIA SHELL SCRIPT - -Avi Deitcher has contributed the file jsrun.sh with the following usage notes: - -A script to simplify running jsdoc from the command-line, especially when -running from within a development or build environment such as ant. - -Normally, to run jsdoc, you need a command-line as the following: -java -Djsdoc.dir=/some/long/dir/path/to/jsdoc -jar -/some/long/dir/path/to/jsdoc/jsrun.jar /some/long/dir/path/to/jsdoc/app/run.js --t=template -r=4 /some/long/dir/path/to/my/src/code - -This can get tedious to redo time and again, and difficult to use from within a -build environment. - -To simplify the process, jsrun.sh will automatically run this path, as well as -passing through any arguments. - -Usage: jsrun.sh - -All will be passed through. -Additionally, jsrun.sh will take the following actions: -1) If the environment variable JSDOCDIR is set, it will add -"-Djsdoc.dir=$JSDOCDIR" to the command-line -2) If the environment variable JSDOCTEMPLATEDIR is set, it will add -"-Djsdoc.template.dir=$JSDOCTEMPLATEDIR" to the command-line -3) java with the appropriate path to jsrun.jar and run.js will be instantiated - -If not variables are set, it is assumed that the path to jsrun.jar and app/ is -in the current working directory. - -Example: -# jsrun.sh ./src/ -Assuming JSDOCDIR=/some/path/to/my/jsdoc will cause the following command to -execute: -java -Djsdoc.dir=/some/path/to/my/jsdoc -jar /some/path/to/my/jsdoc/jsrun.jar -/some/path/to/my/jsdoc/app/run.js ./src/ - -====================================================================== - -TESTING: - -To run the suite of unit tests included with JsDoc Toolkit enter this -on the command line: - -$ java -jar jsrun.jar app/run.js -T - -To see a dump of the internal data structure that JsDoc Toolkit has -built from your source files use this command: - -$ java -jar jsrun.jar app/run.js mycode.js -Z - -====================================================================== - -LICENSE: - -JSDoc.pm - -This project is based on the JSDoc.pm tool, created by Michael -Mathews and Gabriel Reid. More information on JsDoc.pm can -be found on the JSDoc.pm homepage: http://jsdoc.sourceforge.net/ - -Complete documentation on JsDoc Toolkit can be found on the project -wiki at http://code.google.com/p/jsdoc-toolkit/w/list - -Rhino - -Rhino (JavaScript in Java) is open source and licensed by Mozilla -under the MPL 1.1 or later/GPL 2.0 or later licenses, the text of -which is available at http://www.mozilla.org/MPL/ - -You can obtain the source code for Rhino from the Mozilla web site at -http://www.mozilla.org/rhino/download.html - -JsDoc Toolkit is a larger work that uses the Rhino JavaScript engine -but is not derived from it in any way. The Rhino library is used -without modification and without any claims whatsoever. - -The Rhino Debugger - -You can obtain more information about the Rhino Debugger from the -Mozilla web site at http://www.mozilla.org/rhino/debugger.html - -JsDoc Toolkit is a larger work that uses the Rhino Debugger but -is not derived from it in any way. The Rhino Debugger is used -without modification and without any claims whatsoever. - -JsDoc Toolkit - -All code specific to JsDoc Toolkit are free, open source and licensed -for use under the X11/MIT License. - -JsDoc Toolkit is Copyright (c)2009 Michael Mathews - -This program is free software; you can redistribute it and/or -modify it under the terms below. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: The above copyright notice and this -permission notice must be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/utils/jsdoc-toolkit/app/frame.js b/utils/jsdoc-toolkit/app/frame.js deleted file mode 100755 index 1beb405..0000000 --- a/utils/jsdoc-toolkit/app/frame.js +++ /dev/null @@ -1,33 +0,0 @@ -IO.include("frame/Opt.js"); -IO.include("frame/Chain.js"); -IO.include("frame/Link.js"); -IO.include("frame/String.js"); -IO.include("frame/Hash.js"); -IO.include("frame/Namespace.js"); -//IO.include("frame/Reflection.js"); - -/** A few helper functions to make life a little easier. */ - -function defined(o) { - return (o !== undefined); -} - -function copy(o) { // todo check for circular refs - if (o == null || typeof(o) != 'object') return o; - var c = new o.constructor(); - for(var p in o) c[p] = copy(o[p]); - return c; -} - -function isUnique(arr) { - var l = arr.length; - for(var i = 0; i < l; i++ ) { - if (arr.lastIndexOf(arr[i]) > i) return false; - } - return true; -} - -/** Returns the given string with all regex meta characters backslashed. */ -RegExp.escapeMeta = function(str) { - return str.replace(/([$^\\\/()|?+*\[\]{}.-])/g, "\\$1"); -} diff --git a/utils/jsdoc-toolkit/app/frame/Chain.js b/utils/jsdoc-toolkit/app/frame/Chain.js deleted file mode 100755 index 506469d..0000000 --- a/utils/jsdoc-toolkit/app/frame/Chain.js +++ /dev/null @@ -1,102 +0,0 @@ -/**@constructor*/ -function ChainNode(object, link) { - this.value = object; - this.link = link; // describes this node's relationship to the previous node -} - -/**@constructor*/ -function Chain(valueLinks) { - this.nodes = []; - this.cursor = -1; - - if (valueLinks && valueLinks.length > 0) { - this.push(valueLinks[0], "//"); - for (var i = 1, l = valueLinks.length; i < l; i+=2) { - this.push(valueLinks[i+1], valueLinks[i]); - } - } -} - -Chain.prototype.push = function(o, link) { - if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link)); - else this.nodes.push(new ChainNode(o)); -} - -Chain.prototype.unshift = function(o, link) { - if (this.nodes.length > 0 && link) this.nodes[0].link = link; - this.nodes.unshift(new ChainNode(o)); - this.cursor++; -} - -Chain.prototype.get = function() { - if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null; - return this.nodes[this.cursor]; -} - -Chain.prototype.first = function() { - this.cursor = 0; - return this.get(); -} - -Chain.prototype.last = function() { - this.cursor = this.nodes.length-1; - return this.get(); -} - -Chain.prototype.next = function() { - this.cursor++; - return this.get(); -} - -Chain.prototype.prev = function() { - this.cursor--; - return this.get(); -} - -Chain.prototype.toString = function() { - var string = ""; - for (var i = 0, l = this.nodes.length; i < l; i++) { - if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> "; - string += this.nodes[i].value.toString(); - } - return string; -} - -Chain.prototype.joinLeft = function() { - var result = ""; - for (var i = 0, l = this.cursor; i < l; i++) { - if (result && this.nodes[i].link) result += this.nodes[i].link; - result += this.nodes[i].value.toString(); - } - return result; -} - - -/* USAGE: - -var path = "one/two/three.four/five-six"; -var pathChain = new Chain(path.split(/([\/.-])/)); -print(pathChain); - -var lineage = new Chain(); -lineage.push("Port"); -lineage.push("Les", "son"); -lineage.push("Dawn", "daughter"); -lineage.unshift("Purdie", "son"); - -print(lineage); - -// walk left -for (var node = lineage.last(); node !== null; node = lineage.prev()) { - print("< "+node.value); -} - -// walk right -var node = lineage.first() -while (node !== null) { - print(node.value); - node = lineage.next(); - if (node && node.link) print("had a "+node.link+" named"); -} - -*/ \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/frame/Dumper.js b/utils/jsdoc-toolkit/app/frame/Dumper.js deleted file mode 100755 index d8b007b..0000000 --- a/utils/jsdoc-toolkit/app/frame/Dumper.js +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @class -
-This is a lightly modified version of Kevin Jones' JavaScript
-library Data.Dump. To download the original visit:
-    http://openjsan.org/doc/k/ke/kevinj/Data/Dump/
-
-AUTHORS
-
-The Data.Dump JavaScript module is written by Kevin Jones 
-(kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
-based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
-
-COPYRIGHT
-
-Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
-Copyright 1996-1998 Gurusamy Sarathy.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the Perl Artistic License
-
-See http://www.perl.com/perl/misc/Artistic.html
-
- * @static - */ -Dumper = { - /** @param [...] The objects to dump. */ - dump: function () { - if (arguments.length > 1) - return this._dump(arguments); - else if (arguments.length == 1) - return this._dump(arguments[0]); - else - return "()"; - }, - - _dump: function (obj) { - if (typeof obj == 'undefined') return 'undefined'; - var out; - if (obj.serialize) { return obj.serialize(); } - var type = this._typeof(obj); - if (obj.circularReference) obj.circularReference++; - switch (type) { - case 'circular': - out = "{ //circularReference\n}"; - break; - case 'object': - var pairs = new Array; - - for (var prop in obj) { - if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties - pairs.push(prop + ': ' + this._dump(obj[prop])); - } - } - - out = '{' + this._format_list(pairs) + '}'; - break; - - case 'string': - for (var prop in Dumper.ESC) { - if (Dumper.ESC.hasOwnProperty(prop)) { - obj = obj.replace(prop, Dumper.ESC[prop]); - } - } - - // Escape UTF-8 Strings - if (obj.match(/^[\x00-\x7f]*$/)) { - out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"'; - } - else { - out = "unescape('"+escape(obj)+"')"; - } - break; - - case 'array': - var elems = new Array; - - for (var i=0; i 60 ? '\n' : ' '; - return nl + list.join(',' + nl) + nl; - }, - - _typeof: function (obj) { - if (obj && obj.circularReference && obj.circularReference > 1) return 'circular'; - if (Array.prototype.isPrototypeOf(obj)) return 'array'; - if (Date.prototype.isPrototypeOf(obj)) return 'date'; - if (typeof obj.nodeType != 'undefined') return 'element'; - return typeof(obj); - }, - - _dump_dom: function (obj) { - return '"' + Dumper.nodeTypes[obj.nodeType] + '"'; - } -}; - -Dumper.ESC = { - "\t": "\\t", - "\n": "\\n", - "\f": "\\f" -}; - -Dumper.nodeTypes = { - 1: "ELEMENT_NODE", - 2: "ATTRIBUTE_NODE", - 3: "TEXT_NODE", - 4: "CDATA_SECTION_NODE", - 5: "ENTITY_REFERENCE_NODE", - 6: "ENTITY_NODE", - 7: "PROCESSING_INSTRUCTION_NODE", - 8: "COMMENT_NODE", - 9: "DOCUMENT_NODE", - 10: "DOCUMENT_TYPE_NODE", - 11: "DOCUMENT_FRAGMENT_NODE", - 12: "NOTATION_NODE" -}; \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/frame/Hash.js b/utils/jsdoc-toolkit/app/frame/Hash.js deleted file mode 100755 index 62cfad6..0000000 --- a/utils/jsdoc-toolkit/app/frame/Hash.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - @constructor - @example - var _index = new Hash(); - _index.set("a", "apple"); - _index.set("b", "blue"); - _index.set("c", "coffee"); - - for (var p = _index.first(); p; p = _index.next()) { - print(p.key+" is for "+p.value); - } - - */ -var Hash = function() { - this._map = {}; - this._keys = []; - this._vals = []; - this.reset(); -} - -Hash.prototype.set = function(k, v) { - if (k != "") { - this._keys.push(k); - this._map["="+k] = this._vals.length; - this._vals.push(v); - } -} - -Hash.prototype.replace = function(k, k2, v) { - if (k == k2) return; - - var offset = this._map["="+k]; - this._keys[offset] = k2; - if (typeof v != "undefined") this._vals[offset] = v; - this._map["="+k2] = offset; - delete(this._map["="+k]); -} - -Hash.prototype.drop = function(k) { - if (k != "") { - var offset = this._map["="+k]; - this._keys.splice(offset, 1); - this._vals.splice(offset, 1); - delete(this._map["="+k]); - for (var p in this._map) { - if (this._map[p] >= offset) this._map[p]--; - } - if (this._cursor >= offset && this._cursor > 0) this._cursor--; - } -} - -Hash.prototype.get = function(k) { - if (k != "") { - return this._vals[this._map["="+k]]; - } -} - -Hash.prototype.keys = function() { - return this._keys; -} - -Hash.prototype.hasKey = function(k) { - if (k != "") { - return (typeof this._map["="+k] != "undefined"); - } -} - -Hash.prototype.values = function() { - return this._vals; -} - -Hash.prototype.reset = function() { - this._cursor = 0; -} - -Hash.prototype.first = function() { - this.reset(); - return this.next(); -} - -Hash.prototype.next = function() { - if (this._cursor++ < this._keys.length) - return {key: this._keys[this._cursor-1], value: this._vals[this._cursor-1]}; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/frame/Link.js b/utils/jsdoc-toolkit/app/frame/Link.js deleted file mode 100755 index ef5dc0a..0000000 --- a/utils/jsdoc-toolkit/app/frame/Link.js +++ /dev/null @@ -1,153 +0,0 @@ -/** Handle the creation of HTML links to documented symbols. - @constructor -*/ -function Link() { - this.alias = ""; - this.src = ""; - this.file = ""; - this.text = ""; - this.innerName = ""; - this.classLink = false; - this.targetName = ""; - - this.target = function(targetName) { - if (defined(targetName)) this.targetName = targetName; - return this; - } - this.inner = function(inner) { - if (defined(inner)) this.innerName = inner; - return this; - } - this.withText = function(text) { - if (defined(text)) this.text = text; - return this; - } - this.toSrc = function(filename) { - if (defined(filename)) this.src = filename; - return this; - } - this.toSymbol = function(alias) { - if (defined(alias)) this.alias = new String(alias); - return this; - } - this.toClass = function(alias) { - this.classLink = true; - return this.toSymbol(alias); - } - this.toFile = function(file) { - if (defined(file)) this.file = file; - return this; - } - - this.toString = function() { - var linkString; - var thisLink = this; - - if (this.alias) { - linkString = this.alias.replace(/(^|[^a-z$0-9_#.:^-])([|a-z$0-9_#.:^-]+)($|[^a-z$0-9_#.:^-])/i, - function(match, prematch, symbolName, postmatch) { - var symbolNames = symbolName.split("|"); - var links = []; - for (var i = 0, l = symbolNames.length; i < l; i++) { - thisLink.alias = symbolNames[i]; - links.push(thisLink._makeSymbolLink(symbolNames[i])); - } - return prematch+links.join("|")+postmatch; - } - ); - } - else if (this.src) { - linkString = thisLink._makeSrcLink(this.src); - } - else if (this.file) { - linkString = thisLink._makeFileLink(this.file); - } - - return linkString; - } -} - -/** prefixed for hashes */ -Link.hashPrefix = ""; - -/** Appended to the front of relative link paths. */ -Link.base = ""; - -Link.symbolNameToLinkName = function(symbol) { - var linker = ""; - if (symbol.isStatic) linker = "."; - else if (symbol.isInner) linker = "-"; - - return Link.hashPrefix+linker+symbol.name; -} - -/** Create a link to another symbol. */ -Link.prototype._makeSymbolLink = function(alias) { - var linkBase = Link.base+publish.conf.symbolsDir; - var linkTo = Link.symbolSet.getSymbol(alias); - var linkPath; - var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; - - // is it an internal link? - if (alias.charAt(0) == "#") var linkPath = alias; - - // if there is no symbol by that name just return the name unaltered - else if (!linkTo) return this.text || alias; - - // it's a symbol in another file - else { - if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property - if (linkTo.isEvent) { - linkPath = - (Link.filemap)? Link.filemap[linkTo.memberOf] - : - escape(linkTo.memberOf) || "_global_"; - linkPath += publish.conf.ext + "#event:" + Link.symbolNameToLinkName(linkTo); - } - else { - linkPath = - (Link.filemap)? Link.filemap[linkTo.memberOf] - : - escape(linkTo.memberOf) || "_global_"; - linkPath += publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo); - } - } - else { - linkPath = (Link.filemap)? Link.filemap[linkTo.alias] : escape(linkTo.alias); - linkPath += publish.conf.ext;// + (this.classLink? "":"#" + Link.hashPrefix + "constructor"); - } - linkPath = linkBase + linkPath - } - - var linkText = this.text || alias; - - var link = {linkPath: linkPath, linkText: linkText, linkInner: (this.innerName? "#"+this.innerName : "")}; - - if (typeof JSDOC.PluginManager != "undefined") { - JSDOC.PluginManager.run("onSymbolLink", link); - } - - return ""+link.linkText+""; -} - -/** Create a link to a source file. */ -Link.prototype._makeSrcLink = function(srcFilePath) { - var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; - - // transform filepath into a filename - var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "_"); - var outFilePath = Link.base + publish.conf.srcDir + srcFile + publish.conf.ext; - - if (!this.text) this.text = FilePath.fileName(srcFilePath); - return ""+this.text+""; -} - -/** Create a link to a source file. */ -Link.prototype._makeFileLink = function(filePath) { - var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; - - var outFilePath = Link.base + filePath; - - if (!this.text) this.text = filePath; - return ""+this.text+""; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/frame/Namespace.js b/utils/jsdoc-toolkit/app/frame/Namespace.js deleted file mode 100755 index fa1e41d..0000000 --- a/utils/jsdoc-toolkit/app/frame/Namespace.js +++ /dev/null @@ -1,10 +0,0 @@ -_global_ = this; - -function Namespace(name, f) { - var n = name.split("."); - for (var o = _global_, i = 0, l = n.length; i < l; i++) { - o = o[n[i]] = o[n[i]] || {}; - } - - if (f) f(); -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/frame/Opt.js b/utils/jsdoc-toolkit/app/frame/Opt.js deleted file mode 100755 index 352f159..0000000 --- a/utils/jsdoc-toolkit/app/frame/Opt.js +++ /dev/null @@ -1,134 +0,0 @@ -/** @namespace */ -Opt = { - /** - * Get commandline option values. - * @param {Array} args Commandline arguments. Like ["-a=xml", "-b", "--class=new", "--debug"] - * @param {object} optNames Map short names to long names. Like {a:"accept", b:"backtrace", c:"class", d:"debug"}. - * @return {object} Short names and values. Like {a:"xml", b:true, c:"new", d:true} - */ - get: function(args, optNames) { - var opt = {"_": []}; // the unnamed option allows multiple values - for (var i = 0; i < args.length; i++) { - var arg = new String(args[i]); - var name; - var value; - if (arg.charAt(0) == "-") { - if (arg.charAt(1) == "-") { // it's a longname like --foo - arg = arg.substring(2); - var m = arg.split("="); - name = m.shift(); - value = m.shift(); - if (typeof value == "undefined") value = true; - - for (var n in optNames) { // convert it to a shortname - if (name == optNames[n]) { - name = n; - } - } - } - else { // it's a shortname like -f - arg = arg.substring(1); - var m = arg.split("="); - name = m.shift(); - value = m.shift(); - if (typeof value == "undefined") value = true; - - for (var n in optNames) { // find the matching key - if (name == n || name+'[]' == n) { - name = n; - break; - } - } - } - if (name.match(/(.+)\[\]$/)) { // it's an array type like n[] - name = RegExp.$1; - if (!opt[name]) opt[name] = []; - } - - if (opt[name] && opt[name].push) { - opt[name].push(value); - } - else { - opt[name] = value; - } - } - else { // not associated with any optname - opt._.push(args[i]); - } - } - return opt; - } -} - -/*t: - plan(11, "Testing Opt."); - - is( - typeof Opt, - "object", - "Opt is an object." - ); - - is( - typeof Opt.get, - "function", - "Opt.get is a function." - ); - - var optNames = {a:"accept", b:"backtrace", c:"class", d:"debug", "e[]":"exceptions"}; - var t_options = Opt.get(["-a=xml", "-b", "--class=new", "--debug", "-e=one", "-e=two", "foo", "bar"], optNames); - - is( - t_options.a, - "xml", - "an option defined with a short name can be accessed by its short name." - ); - - is( - t_options.b, - true, - "an option defined with a short name and no value are true." - ); - - is( - t_options.c, - "new", - "an option defined with a long name can be accessed by its short name." - ); - - is( - t_options.d, - true, - "an option defined with a long name and no value are true." - ); - - is( - typeof t_options.e, - "object", - "an option that can accept multiple values is defined." - ); - - is( - t_options.e.length, - 2, - "an option that can accept multiple values can have more than one value." - ); - - is( - t_options.e[1], - "two", - "an option that can accept multiple values can be accessed as an array." - ); - - is( - typeof t_options._, - "object", - "the property '_' is defined for unnamed options." - ); - - is( - t_options._[0], - "foo", - "the property '_' can be accessed as an array." - ); - */ \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/frame/Reflection.js b/utils/jsdoc-toolkit/app/frame/Reflection.js deleted file mode 100755 index 0968f1c..0000000 --- a/utils/jsdoc-toolkit/app/frame/Reflection.js +++ /dev/null @@ -1,26 +0,0 @@ -/**@constructor*/ -function Reflection(obj) { - this.obj = obj; -} - -Reflection.prototype.getConstructorName = function() { - if (this.obj.constructor.name) return this.obj.constructor.name; - var src = this.obj.constructor.toSource(); - var name = src.substring(name.indexOf("function")+8, src.indexOf('(')).replace(/ /g,''); - return name; -} - -Reflection.prototype.getMethod = function(name) { - for (var p in this.obj) { - if (p == name && typeof(this.obj[p]) == "function") return this.obj[p]; - } - return null; -} - -Reflection.prototype.getParameterNames = function() { - var src = this.obj.toSource(); - src = src.substring( - src.indexOf("(", 8)+1, src.indexOf(")") - ); - return src.split(/, ?/); -} diff --git a/utils/jsdoc-toolkit/app/frame/String.js b/utils/jsdoc-toolkit/app/frame/String.js deleted file mode 100755 index c183c27..0000000 --- a/utils/jsdoc-toolkit/app/frame/String.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - @name String - @class Additions to the core string object. -*/ - -/** @author Steven Levithan, released as public domain. */ -String.prototype.trim = function() { - var str = this.replace(/^\s+/, ''); - for (var i = str.length - 1; i >= 0; i--) { - if (/\S/.test(str.charAt(i))) { - str = str.substring(0, i + 1); - break; - } - } - return str; -} -/*t: - plan(6, "Testing String.prototype.trim."); - - var s = " a bc ".trim(); - is(s, "a bc", "multiple spaces front and back are trimmed."); - - s = "a bc\n\n".trim(); - is(s, "a bc", "newlines only in back are trimmed."); - - s = "\ta bc".trim(); - is(s, "a bc", "tabs only in front are trimmed."); - - s = "\n \t".trim(); - is(s, "", "an all-space string is trimmed to empty."); - - s = "a b\nc".trim(); - is(s, "a b\nc", "a string with no spaces in front or back is trimmed to itself."); - - s = "".trim(); - is(s, "", "an empty string is trimmed to empty."); - -*/ - -String.prototype.balance = function(open, close) { - var i = 0; - while (this.charAt(i) != open) { - if (i == this.length) return [-1, -1]; - i++; - } - - var j = i+1; - var balance = 1; - while (j < this.length) { - if (this.charAt(j) == open) balance++; - if (this.charAt(j) == close) balance--; - if (balance == 0) break; - j++; - if (j == this.length) return [-1, -1]; - } - - return [i, j]; -} -/*t: - plan(16, "Testing String.prototype.balance."); - - var s = "{abc}".balance("{","}"); - is(s[0], 0, "opener in first is found."); - is(s[1], 4, "closer in last is found."); - - s = "ab{c}de".balance("{","}"); - is(s[0], 2, "opener in middle is found."); - is(s[1], 4, "closer in middle is found."); - - s = "a{b{c}de}f".balance("{","}"); - is(s[0], 1, "nested opener is found."); - is(s[1], 8, "nested closer is found."); - - s = "{}".balance("{","}"); - is(s[0], 0, "opener with no content is found."); - is(s[1], 1, "closer with no content is found."); - - s = "".balance("{","}"); - is(s[0], -1, "empty string opener is -1."); - is(s[1], -1, "empty string closer is -1."); - - s = "{abc".balance("{","}"); - is(s[0], -1, "opener with no closer returns -1."); - is(s[1], -1, "no closer returns -1."); - - s = "abc".balance("{","}"); - is(s[0], -1, "no opener or closer returns -1 for opener."); - is(s[1], -1, "no opener or closer returns -1 for closer."); - - s = "aX11/MIT License - * (See the accompanying README file for full details.) - */ - -/** - Yet another unit testing tool for JavaScript. - @author Michael Mathews micmath@gmail.com - @param {object} testCases Properties are testcase names, values are functions to execute as tests. -*/ -function testrun(testCases) { - var ran = 0; - for (t in testCases) { - var result = testCases[t](); - ran++; - } - - return testrun.reportOut+"-------------------------------\n"+((testrun.fails>0)? ":( Failed "+testrun.fails+"/" : ":) Passed all ")+testrun.count+" test"+((testrun.count == 1)? "":"s")+".\n"; -} - - -testrun.count = 0; -testrun.current = null; -testrun.passes = 0; -testrun.fails = 0; -testrun.reportOut = ""; - -/** @private */ -testrun.report = function(text) { - testrun.reportOut += text+"\n"; -} - -/** - Check if test evaluates to true. - @param {string} test To be evaluated. - @param {string} message Optional. To be displayed in the report. - @return {boolean} True if the string test evaluates to true. -*/ -ok = function(test, message) { - testrun.count++; - - var result; - try { - result = eval(test); - - if (result) { - testrun.passes++; - testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); - } - else { - testrun.fails++; - testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); - } - } - catch(e) { - testrun.fails++ - testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); - - } -} - -/** - Check if test is same as expected. - @param {string} test To be evaluated. - @param {string} expected - @param {string} message Optional. To be displayed in the report. - @return {boolean} True if (test == expected). Note that the comparison is not a strict equality check. -*/ -is = function(test, expected, message) { - testrun.count++; - - var result; - try { - result = eval(test); - - if (result == expected) { - testrun.passes++ - testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); - } - else { - testrun.fails++ - testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); - testrun.report("expected: "+expected); - testrun.report(" got: "+result); - } - } - catch(e) { - testrun.fails++ - testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); - testrun.report("expected: "+expected); - testrun.report(" got: "+result);} -} - -/** - Check if test matches pattern. - @param {string} test To be evaluated. - @param {string} pattern Used to create a RegExp. - @param {string} message Optional. To be displayed in the report. - @return {boolean} True if test matches pattern. -*/ -like = function(test, pattern, message) { - testrun.count++; - - var result; - try { - result = eval(test); - var rgx = new RegExp(pattern); - - if (rgx.test(result)) { - testrun.passes++ - testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); - } - else { - testrun.fails++ - testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); - testrun.report(" this: "+result); - testrun.report("is not like: "+pattern); - } - } - catch(e) { - testrun.fails++ - testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/handlers/FOODOC.js b/utils/jsdoc-toolkit/app/handlers/FOODOC.js deleted file mode 100755 index b208f55..0000000 --- a/utils/jsdoc-toolkit/app/handlers/FOODOC.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - This is the main container for the FOODOC handler. - @namespace -*/ -FOODOC = { -}; - -/** The current version string of this application. */ -FOODOC.VERSION = "1.0"; - -FOODOC.handle = function(srcFile, src) { - LOG.inform("Handling file '" + srcFile + "'"); - - return [ - new JSDOC.Symbol( - "foo", - [], - "VIRTUAL", - new JSDOC.DocComment("/** This is a foo. */") - ) - ]; -}; - -FOODOC.publish = function(symbolgroup) { - LOG.inform("Publishing symbolgroup."); -}; diff --git a/utils/jsdoc-toolkit/app/handlers/XMLDOC.js b/utils/jsdoc-toolkit/app/handlers/XMLDOC.js deleted file mode 100755 index 40f87b3..0000000 --- a/utils/jsdoc-toolkit/app/handlers/XMLDOC.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This is the main container for the XMLDOC handler. - * @namespace - * @author Brett Fattori (bfattori@fry.com) - * @version $Revision: 498 $ - */ -XMLDOC = { - -}; - -/** The current version string of this application. */ -XMLDOC.VERSION = "1.0"; - -/** Include the library necessary to handle XML files */ -IO.includeDir("handlers/XMLDOC/"); - -/** - * @type Symbol[] - */ -XMLDOC.handle = function(srcFile, src) { - -}; - -XMLDOC.publish = function(symbolgroup) { - -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js b/utils/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js deleted file mode 100755 index 240563d..0000000 --- a/utils/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +++ /dev/null @@ -1,159 +0,0 @@ -LOG.inform("XMLDOC.DomReader loaded"); - -XMLDOC.DomReader = function(root) { - - this.dom = root; - - /** - * The current node the reader is on - */ - this.node = root; - - /** - * Get the current node the reader is on - * @type XMLDOC.Parser.node - */ - XMLDOC.DomReader.prototype.getNode = function() { - return this.node; - }; - - /** - * Set the node the reader should be positioned on. - * @param node {XMLDOC.Parser.node} - */ - XMLDOC.DomReader.prototype.setNode = function(node) { - this.node = node; - }; - - /** - * A helper method to make sure the current node will - * never return null, unless null is passed as the root. - * @param step {String} An expression to evaluate - should return a node or null - */ - XMLDOC.DomReader.prototype.navigate = function(step) { - var n; - if ((n = step) != null) - { - this.node = n; - return this.node; - } - return null; - }; - - /** - * Get the root node of the current node's document. - */ - XMLDOC.DomReader.prototype.root = function() { - this.navigate(this.dom); - }; - - /** - * Get the parent of the current node. - */ - XMLDOC.DomReader.prototype.parent = function() { - return this.navigate(this.node.parentNode()); - }; - - /** - * Get the first child of the current node. - */ - XMLDOC.DomReader.prototype.firstChild = function() { - return this.navigate(this.node.firstChild()); - }; - - /** - * Get the last child of the current node. - */ - XMLDOC.DomReader.prototype.lastChild = function() { - return this.navigate(this.node.lastChild()); - }; - - /** - * Get the next sibling of the current node. - */ - XMLDOC.DomReader.prototype.nextSibling = function() { - return this.navigate(this.node.nextSibling()); - }; - - /** - * Get the previous sibling of the current node. - */ - XMLDOC.DomReader.prototype.prevSibling = function() { - return this.navigate(this.node.prevSibling()); - }; - - //=============================================================================================== - // Support methods - - /** - * Walk the tree starting with the current node, calling the plug-in for - * each node visited. Each time the plug-in is called, the DomReader - * is passed as the only parameter. Use the {@link XMLDOC.DomReader#getNode} method - * to access the current node. This method uses a depth first traversal pattern. - * - * @param srcFile {String} The source file being evaluated - */ - XMLDOC.DomReader.prototype.getSymbols = function(srcFile) - { - XMLDOC.DomReader.symbols = []; - XMLDOC.DomReader.currentFile = srcFile; - JSDOC.Symbol.srcFile = (srcFile || ""); - - if (defined(JSDOC.PluginManager)) { - JSDOC.PluginManager.run("onDomGetSymbols", this); - } - - return XMLDOC.DomReader.symbols; - }; - - /** - * Find the node with the given name using a depth first traversal. - * Does not modify the DomReader's current node. - * - * @param name {String} The name of the node to find - * @return the node that was found, or null if not found - */ - XMLDOC.DomReader.prototype.findNode = function(name) - { - var findNode = null; - - // Start at the current node and move into the subtree, - // looking for the node with the given name - function deeper(node, find) - { - var look = null; - - if (node) { - if (node.name == find) - { - return node; - } - - if (node.firstChild()) - { - look = deeper(node.firstChild(), find); - } - - if (!look && node.nextSibling()) - { - look = deeper(node.nextSibling(), find); - } - } - - return look; - } - - return deeper(this.getNode().firstChild(), name); - }; - - /** - * Find the next node with the given name using a depth first traversal. - * - * @param name {String} The name of the node to find - */ - XMLDOC.DomReader.prototype.findPreviousNode = function(name) - { - }; - -}; - diff --git a/utils/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js b/utils/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js deleted file mode 100755 index e9b3e3c..0000000 --- a/utils/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +++ /dev/null @@ -1,16 +0,0 @@ -LOG.inform("XMLDOC.symbolize loaded"); - -/** - * Convert the source file to a set of symbols - */ -XMLDOC.symbolize = function(srcFile, src) { - - LOG.inform("Symbolizing file '" + srcFile + "'"); - - // XML files already have a defined structure, so we don't need to - // do anything but parse them. The DOM reader can create a symbol - // table from the parsed XML. - var dr = new XMLDOC.DomReader(XMLDOC.Parser.parse(src)); - return dr.getSymbols(srcFile); - -}; diff --git a/utils/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js b/utils/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js deleted file mode 100755 index 78e8f45..0000000 --- a/utils/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +++ /dev/null @@ -1,292 +0,0 @@ -LOG.inform("XMLDOC.Parser loaded"); - -/** - * XML Parser object. Returns an {@link #XMLDOC.Parser.node} which is - * the root element of the parsed document. - *

- * By default, this parser will only handle well formed XML. To - * allow the parser to handle HTML, set the XMLDOC.Parser.strictMode - * variable to false before calling XMLDOC.Parser.parse(). - *

- * Note: If you pass poorly formed XML, it will cause the parser to throw - * an exception. - * - * @author Brett Fattori (bfattori@fry.com) - * @author $Author: micmath $ - * @version $Revision: 497 $ - */ -XMLDOC.Parser = {}; - -/** - * Strict mode setting. Setting this to false allows HTML-style source to - * be parsed. Normally, well formed XML has defined end tags, or empty tags - * are properly formed. Default: true - * @type Boolean - */ -XMLDOC.Parser.strictMode = true; - -/** - * A node in an XML Document. Node types are ROOT, ELEMENT, COMMENT, PI, and TEXT. - * @param parent {XMLDOC.Parser.node} The parent node - * @param name {String} The node name - * @param type {String} One of the types - */ -XMLDOC.Parser.node = function(parent, name, type) -{ - this.name = name; - this.type = type || "ELEMENT"; - this.parent = parent; - this.charData = ""; - this.attrs = {}; - this.nodes = []; - this.cPtr = 0; - - XMLDOC.Parser.node.prototype.getAttributeNames = function() { - var a = []; - for (var o in this.attrs) - { - a.push(o); - } - - return a; - }; - - XMLDOC.Parser.node.prototype.getAttribute = function(attr) { - return this.attrs[attr]; - }; - - XMLDOC.Parser.node.prototype.setAttribute = function(attr, val) { - this.attrs[attr] = val; - }; - - XMLDOC.Parser.node.prototype.getChild = function(idx) { - return this.nodes[idx]; - }; - - XMLDOC.Parser.node.prototype.parentNode = function() { - return this.parent; - }; - - XMLDOC.Parser.node.prototype.firstChild = function() { - return this.nodes[0]; - }; - - XMLDOC.Parser.node.prototype.lastChild = function() { - return this.nodes[this.nodes.length - 1]; - }; - - XMLDOC.Parser.node.prototype.nextSibling = function() { - var p = this.parent; - if (p && (p.nodes.indexOf(this) + 1 != p.nodes.length)) - { - return p.getChild(p.nodes.indexOf(this) + 1); - } - return null; - }; - - XMLDOC.Parser.node.prototype.prevSibling = function() { - var p = this.parent; - if (p && (p.nodes.indexOf(this) - 1 >= 0)) - { - return p.getChild(p.nodes.indexOf(this) - 1); - } - return null; - }; -}; - -/** - * Parse an XML Document from the specified source. The XML should be - * well formed, unless strict mode is disabled, then the parser will - * handle HTML-style XML documents. - * @param src {String} The source to parse - */ -XMLDOC.Parser.parse = function(src) -{ - var A = []; - - // Normailize whitespace - A = src.split("\r\n"); - src = A.join("\n"); - A = src.split("\r"); - src = A.join("\n"); - - // Remove XML and DOCTYPE specifier - src.replace(/<\?XML .*\?>/i, ""); - src.replace(//i, ""); - - // The document is the root node and cannot be modified or removed - var doc = new XMLDOC.Parser.node(null, "ROOT", "DOCUMENT"); - - // Let's break it down - XMLDOC.Parser.eat(doc, src); - - return doc; -}; - -/** - * The XML fragment processing routine. This method is private and should not be called - * directly. - * @param parentNode {XMLDOC.Parser.node} The node which is the parent of this fragment - * @param src {String} The source within the fragment to process - * @private - */ -XMLDOC.Parser.eat = function(parentNode, src) -{ - // A simple tag def - var reTag = new RegExp("<(!|)(\\?|--|)((.|\\s)*?)\\2>","g"); - - // Special tag types - var reCommentTag = //; - var rePITag = /<\?((.|\s)*?)\?>/; - - // A start tag (with potential empty marker) - var reStartTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*)\4)*(\/)?>/; - - // An empty HTML style tag (not proper XML, but we'll accept it so we can process HTML) - var reHTMLEmptyTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*)\4)*>/; - - // Fully enclosing tag with nested tags - var reEnclosingTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*?)\4)*>((.|\s)*?)<\/\1>/; - - // Breaks down attributes - var reAttributes = new RegExp(" +([\\w_\\-]*)=(\"|')(.*?)\\2","g"); - - // Find us a tag - var tag; - while ((tag = reTag.exec(src)) != null) - { - if (tag.index > 0) - { - // The next tag has some text before it - var text = src.substring(0, tag.index).replace(/^[ \t\n]+((.|\n)*?)[ \t\n]+$/, "$1"); - - if (text.length > 0 && (text != "\n")) - { - var txtnode = new XMLDOC.Parser.node(parentNode, "", "TEXT"); - txtnode.charData = text; - - // Append the new text node - parentNode.nodes.push(txtnode); - } - - // Reset the lastIndex of reTag - reTag.lastIndex -= src.substring(0, tag.index).length; - - // Eat the text - src = src.substring(tag.index); - } - - if (reCommentTag.test(tag[0])) - { - // Is this a comment? - var comment = new XMLDOC.Parser.node(parentNode, "", "COMMENT"); - comment.charData = reCommentTag.exec(tag[0])[1]; - - // Append the comment - parentNode.nodes.push(comment); - - // Move the lastIndex of reTag - reTag.lastIndex -= tag[0].length; - - // Eat the tag - src = src.replace(reCommentTag, ""); - } - else if (rePITag.test(tag[0])) - { - // Is this a processing instruction? - var pi = new XMLDOC.Parser.node(parentNode, "", "PI"); - pi.charData = rePITag.exec(tag[0])[1]; - - // Append the processing instruction - parentNode.nodes.push(pi); - - // Move the lastIndex of reTag - reTag.lastIndex -= tag[0].length; - - // Eat the tag - src = src.replace(rePITag, ""); - } - else if (reStartTag.test(tag[0])) - { - // Break it down - var e = reStartTag.exec(tag[0]); - var elem = new XMLDOC.Parser.node(parentNode, e[1], "ELEMENT"); - - // Get attributes from the tag - var a; - while ((a = reAttributes.exec(e[2])) != null ) - { - elem.attrs[a[1]] = a[3]; - } - - // Is this an empty XML-style tag? - if (e[6] == "/") - { - // Append the empty element - parentNode.nodes.push(elem); - - // Move the lastIndex of reTag (include the start tag length) - reTag.lastIndex -= e[0].length; - - // Eat the tag - src = src.replace(reStartTag, ""); - } - else - { - // Check for malformed XML tags - var htmlParsed = false; - var htmlStartTag = reHTMLEmptyTag.exec(src); - - // See if there isn't an end tag within this block - var reHTMLEndTag = new RegExp(""); - var htmlEndTag = reHTMLEndTag.exec(src); - - if (XMLDOC.Parser.strictMode && htmlEndTag == null) - { - // Poorly formed XML fails in strict mode - var err = new Error("Malformed XML passed to XMLDOC.Parser... Error contains malformed 'src'"); - err.src = src; - throw err; - } - else if (htmlEndTag == null) - { - // This is an HTML-style empty tag, store the element for it in non-strict mode - parentNode.nodes.push(elem); - - // Eat the tag - src = src.replace(reHTMLEmptyTag, ""); - htmlParsed = true; - } - - // If we didn't parse HTML-style, it must be an enclosing tag - if (!htmlParsed) - { - var enc = reEnclosingTag.exec(src); - - // Go deeper into the document - XMLDOC.Parser.eat(elem, enc[6]); - - // Append the new element node - parentNode.nodes.push(elem); - - // Eat the tag - src = src.replace(reEnclosingTag, ""); - } - } - - // Reset the lastIndex of reTag - reTag.lastIndex = 0; - } - } - - // No tag was found... append the text if there is any - src = src.replace(/^[ \t\n]+((.|\n)*?)[ \t\n]+$/, "$1"); - if (src.length > 0 && (src != "\n")) - { - var txtNode = new XMLDOC.Parser.node(parentNode, "", "TEXT"); - txtNode.charData = src; - - // Append the new text node - parentNode.nodes.push(txtNode); - } -}; diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC.js b/utils/jsdoc-toolkit/app/lib/JSDOC.js deleted file mode 100755 index 2dbc0a3..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - @overview - @date $Date: 2009-06-21 23:36:33 +0100 (Sun, 21 Jun 2009) $ - @version $Revision: 801 $ - @location $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/trunk/jsdoc-toolkit/app/lib/JSDOC.js $ - @name JSDOC.js - */ - -/** - This is the main container for the JSDOC application. - @namespace -*/ -JSDOC = { -}; - -/** - @requires Opt - */ -if (typeof arguments == "undefined") arguments = []; -JSDOC.opt = Opt.get( - arguments, - { - a: "allfunctions", - c: "conf", - d: "directory", - "D[]": "define", - e: "encoding", - "E[]": "exclude", - h: "help", - n: "nocode", - o: "out", - p: "private", - q: "quiet", - r: "recurse", - S: "securemodules", - s: "suppress", - t: "template", - T: "testmode", - u: "unique", - v: "verbose", - x: "ext" - } -); - -/** The current version string of this application. */ -JSDOC.VERSION = "2.3.0"; - -/** Print out usage information and quit. */ -JSDOC.usage = function() { - print("USAGE: java -jar jsrun.jar app/run.js [OPTIONS] ..."); - print(""); - print("OPTIONS:"); - print(" -a or --allfunctions\n Include all functions, even undocumented ones.\n"); - print(" -c or --conf\n Load a configuration file.\n"); - print(" -d= or --directory=\n Output to this directory (defaults to \"out\").\n"); - print(" -D=\"myVar:My value\" or --define=\"myVar:My value\"\n Multiple. Define a variable, available in JsDoc as JSDOC.opt.D.myVar.\n"); - print(" -e= or --encoding=\n Use this encoding to read and write files.\n"); - print(" -E=\"REGEX\" or --exclude=\"REGEX\"\n Multiple. Exclude files based on the supplied regex.\n"); - print(" -h or --help\n Show this message and exit.\n"); - print(" -n or --nocode\n Ignore all code, only document comments with @name tags.\n"); - print(" -o= or --out=\n Print log messages to a file (defaults to stdout).\n"); - print(" -p or --private\n Include symbols tagged as private, underscored and inner symbols.\n"); - print(" -q or --quiet\n Do not output any messages, not even warnings.\n"); - print(" -r= or --recurse=\n Descend into src directories.\n"); - print(" -s or --suppress\n Suppress source code output.\n"); - print(" -S or --securemodules\n Use Secure Modules mode to parse source code.\n"); - print(" -t= or --template=\n Required. Use this template to format the output.\n"); - print(" -T or --test\n Run all unit tests and exit.\n"); - print(" -u or --unique\n Force file names to be unique, but not based on symbol names.\n"); - print(" -v or --verbose\n Provide verbose feedback about what is happening.\n"); - print(" -x=[,EXT]... or --ext=[,EXT]...\n Scan source files with the given extension/s (defaults to js).\n"); - - quit(); -} - -/*t: - plan(4, "Testing JSDOC namespace."); - - is( - typeof JSDOC, - "object", - "JSDOC.usage is a function." - ); - - is( - typeof JSDOC.VERSION, - "string", - "JSDOC.VERSION is a string." - ); - - is( - typeof JSDOC.usage, - "function", - "JSDOC.usage is a function." - ); - - is( - typeof JSDOC.opt, - "object", - "JSDOC.opt is a object." - ); - */ - -if (this.IO) IO.includeDir("lib/JSDOC/"); diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/DocComment.js b/utils/jsdoc-toolkit/app/lib/JSDOC/DocComment.js deleted file mode 100755 index c6c8d7d..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +++ /dev/null @@ -1,200 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - Create a new DocComment. This takes a raw documentation comment, - and wraps it in useful accessors. - @class Represents a documentation comment object. - */ -JSDOC.DocComment = function(/**String*/comment) { - this.init(); - if (typeof comment != "undefined") { - this.parse(comment); - } -} - -JSDOC.DocComment.prototype.init = function() { - this.isUserComment = true; - this.src = ""; - this.meta = ""; - this.tagTexts = []; - this.tags = []; -} - -/** - @requires JSDOC.DocTag - */ -JSDOC.DocComment.prototype.parse = function(/**String*/comment) { - if (comment == "") { - comment = "/** @desc */"; - this.isUserComment = false; - } - - this.src = JSDOC.DocComment.unwrapComment(comment); - - this.meta = ""; - if (this.src.indexOf("#") == 0) { - this.src.match(/#(.+[+-])([\s\S]*)$/); - if (RegExp.$1) this.meta = RegExp.$1; - if (RegExp.$2) this.src = RegExp.$2; - } - - if (typeof JSDOC.PluginManager != "undefined") { - JSDOC.PluginManager.run("onDocCommentSrc", this); - } - - this.fixDesc(); - - this.src = JSDOC.DocComment.shared+"\n"+this.src; - - this.tagTexts = - this.src - .split(/(^|[\r\n])\s*@/) - .filter(function($){return $.match(/\S/)}); - - /** - The tags found in the comment. - @type JSDOC.DocTag[] - */ - this.tags = this.tagTexts.map(function($){return new JSDOC.DocTag($)}); - - if (typeof JSDOC.PluginManager != "undefined") { - JSDOC.PluginManager.run("onDocCommentTags", this); - } -} - -/*t: - plan(5, "testing JSDOC.DocComment"); - requires("../frame/String.js"); - requires("../lib/JSDOC/DocTag.js"); - - var com = new JSDOC.DocComment("/**@foo some\n* comment here*"+"/"); - is(com.tagTexts[0], "foo some\ncomment here", "first tag text is found."); - is(com.tags[0].title, "foo", "the title is found in a comment with one tag."); - - var com = new JSDOC.DocComment("/** @foo first\n* @bar second*"+"/"); - is(com.getTag("bar").length, 1, "getTag() returns one tag by that title."); - - JSDOC.DocComment.shared = "@author John Smith"; - var com = new JSDOC.DocComment("/**@foo some\n* comment here*"+"/"); - is(com.tags[0].title, "author", "shared comment is added."); - is(com.tags[1].title, "foo", "shared comment is added to existing tag."); -*/ - -/** - If no @desc tag is provided, this function will add it. - */ -JSDOC.DocComment.prototype.fixDesc = function() { - if (this.meta && this.meta != "@+") return; - if (/^\s*[^@\s]/.test(this.src)) { - this.src = "@desc "+this.src; - } -} - -/*t: - plan(5, "testing JSDOC.DocComment#fixDesc"); - - var com = new JSDOC.DocComment(); - - com.src = "this is a desc\n@author foo"; - com.fixDesc(); - is(com.src, "@desc this is a desc\n@author foo", "if no @desc tag is provided one is added."); - - com.src = "x"; - com.fixDesc(); - is(com.src, "@desc x", "if no @desc tag is provided one is added to a single character."); - - com.src = "\nx"; - com.fixDesc(); - is(com.src, "@desc \nx", "if no @desc tag is provided one is added to return and character."); - - com.src = " "; - com.fixDesc(); - is(com.src, " ", "if no @desc tag is provided one is not added to just whitespace."); - - com.src = ""; - com.fixDesc(); - is(com.src, "", "if no @desc tag is provided one is not added to empty."); -*/ - -/** - Remove slash-star comment wrapper from a raw comment string. - @type String - */ -JSDOC.DocComment.unwrapComment = function(/**String*/comment) { - if (!comment) return ""; - var unwrapped = comment.replace(/(^\/\*\*|\*\/$)/g, "").replace(/^\s*\* ?/gm, ""); - return unwrapped; -} - -/*t: - plan(5, "testing JSDOC.DocComment.unwrapComment"); - - var com = "/**x*"+"/"; - var unwrapped = JSDOC.DocComment.unwrapComment(com); - is(unwrapped, "x", "a single character jsdoc is found."); - - com = "/***x*"+"/"; - unwrapped = JSDOC.DocComment.unwrapComment(com); - is(unwrapped, "x", "three stars are allowed in the opener."); - - com = "/****x*"+"/"; - unwrapped = JSDOC.DocComment.unwrapComment(com); - is(unwrapped, "*x", "fourth star in the opener is kept."); - - com = "/**x\n * y\n*"+"/"; - unwrapped = JSDOC.DocComment.unwrapComment(com); - is(unwrapped, "x\ny\n", "leading stars and spaces are trimmed."); - - com = "/**x\n * y\n*"+"/"; - unwrapped = JSDOC.DocComment.unwrapComment(com); - is(unwrapped, "x\n y\n", "only first space after leading stars are trimmed."); -*/ - -/** - Provides a printable version of the comment. - @type String - */ -JSDOC.DocComment.prototype.toString = function() { - return this.src; -} - -/*t: - plan(1, "testing JSDOC.DocComment#fixDesc"); - var com = new JSDOC.DocComment(); - com.src = "foo"; - is(""+com, "foo", "stringifying a comment returns the unwrapped src."); -*/ - -/** - Given the title of a tag, returns all tags that have that title. - @type JSDOC.DocTag[] - */ -JSDOC.DocComment.prototype.getTag = function(/**String*/tagTitle) { - return this.tags.filter(function($){return $.title == tagTitle}); -} - -/*t: - plan(1, "testing JSDOC.DocComment#getTag"); - requires("../frame/String.js"); - requires("../lib/JSDOC/DocTag.js"); - - var com = new JSDOC.DocComment("/**@foo some\n* @bar\n* @bar*"+"/"); - is(com.getTag("bar").length, 2, "getTag returns expected number of tags."); -*/ - -/** - Used to store the currently shared tag text. -*/ -JSDOC.DocComment.shared = ""; - -/*t: - plan(2, "testing JSDOC.DocComment.shared"); - requires("../frame/String.js"); - requires("../lib/JSDOC/DocTag.js"); - - JSDOC.DocComment.shared = "@author Michael"; - - var com = new JSDOC.DocComment("/**@foo\n* @foo*"+"/"); - is(com.getTag("author").length, 1, "getTag returns shared tag."); - is(com.getTag("foo").length, 2, "getTag returns unshared tags too."); -*/ \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/DocTag.js b/utils/jsdoc-toolkit/app/lib/JSDOC/DocTag.js deleted file mode 100755 index 77ec07c..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +++ /dev/null @@ -1,294 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - @constructor - */ -JSDOC.DocTag = function(src) { - this.init(); - if (typeof src != "undefined") { - this.parse(src); - } -} - -/** - Create and initialize the properties of this. - */ -JSDOC.DocTag.prototype.init = function() { - this.title = ""; - this.type = ""; - this.name = ""; - this.isOptional = false; - this.defaultValue = ""; - this.desc = ""; - - return this; -} - -/** - Populate the properties of this from the given tag src. - @param {string} src - */ -JSDOC.DocTag.prototype.parse = function(src) { - if (typeof src != "string") throw "src must be a string not "+(typeof src); - - try { - src = this.nibbleTitle(src); - if (JSDOC.PluginManager) { - JSDOC.PluginManager.run("onDocTagSynonym", this); - } - - src = this.nibbleType(src); - - // only some tags are allowed to have names. - if (this.title == "param" || this.title == "property" || this.title == "config") { // @config is deprecated - src = this.nibbleName(src); - } - } - catch(e) { - if (LOG) LOG.warn(e); - else throw e; - } - this.desc = src; // whatever is left - - // example tags need to have whitespace preserved - if (this.title != "example") this.desc = this.desc.trim(); - - if (JSDOC.PluginManager) { - JSDOC.PluginManager.run("onDocTag", this); - } -} - -/** - Automatically called when this is stringified. - */ -JSDOC.DocTag.prototype.toString = function() { - return this.desc; -} - -/*t: - plan(1, "testing JSDOC.DocTag#toString"); - - var tag = new JSDOC.DocTag("param {object} date A valid date."); - is(""+tag, "A valid date.", "stringifying a tag returns the desc."); - */ - -/** - Find and shift off the title of a tag. - @param {string} src - @return src - */ -JSDOC.DocTag.prototype.nibbleTitle = function(src) { - if (typeof src != "string") throw "src must be a string not "+(typeof src); - - var parts = src.match(/^\s*(\S+)(?:\s([\s\S]*))?$/); - - if (parts && parts[1]) this.title = parts[1]; - if (parts && parts[2]) src = parts[2]; - else src = ""; - - return src; -} - -/*t: - plan(8, "testing JSDOC.DocTag#nibbleTitle"); - - var tag = new JSDOC.DocTag(); - - tag.init().nibbleTitle("aTitleGoesHere"); - is(tag.title, "aTitleGoesHere", "a title can be found in a single-word string."); - - var src = tag.init().nibbleTitle("aTitleGoesHere and the rest"); - is(tag.title, "aTitleGoesHere", "a title can be found in a multi-word string."); - is(src, "and the rest", "the rest is returned when the title is nibbled off."); - - src = tag.init().nibbleTitle(""); - is(tag.title, "", "given an empty string the title is empty."); - is(src, "", "the rest is empty when the tag is empty."); - - var src = tag.init().nibbleTitle(" aTitleGoesHere\n a description"); - is(tag.title, "aTitleGoesHere", "leading and trailing spaces are not part of the title."); - is(src, " a description", "leading spaces (less one) are part of the description."); - - tag.init().nibbleTitle("a.Title::Goes_Here foo"); - is(tag.title, "a.Title::Goes_Here", "titles with punctuation are allowed."); - */ - -/** - Find and shift off the type of a tag. - @requires frame/String.js - @param {string} src - @return src - */ -JSDOC.DocTag.prototype.nibbleType = function(src) { - if (typeof src != "string") throw "src must be a string not "+(typeof src); - - if (src.match(/^\s*\{/)) { - var typeRange = src.balance("{", "}"); - if (typeRange[1] == -1) { - throw "Malformed comment tag ignored. Tag type requires an opening { and a closing }: "+src; - } - this.type = src.substring(typeRange[0]+1, typeRange[1]).trim(); - this.type = this.type.replace(/\s*,\s*/g, "|"); // multiples can be separated by , or | - src = src.substring(typeRange[1]+1); - } - - return src; -} - -/*t: - plan(5, "testing JSDOC.DocTag.parser.nibbleType"); - requires("../frame/String.js"); - - var tag = new JSDOC.DocTag(); - - tag.init().nibbleType("{String[]} aliases"); - is(tag.type, "String[]", "type can have non-alpha characters."); - - tag.init().nibbleType("{ aTypeGoesHere } etc etc"); - is(tag.type, "aTypeGoesHere", "type is trimmed."); - - tag.init().nibbleType("{ oneType, twoType ,\n threeType } etc etc"); - is(tag.type, "oneType|twoType|threeType", "multiple types can be separated by commas."); - - var error; - try { tag.init().nibbleType("{widget foo"); } - catch(e) { error = e; } - is(typeof error, "string", "malformed tag type throws error."); - isnt(error.indexOf("Malformed"), -1, "error message tells tag is malformed."); - */ - -/** - Find and shift off the name of a tag. - @requires frame/String.js - @param {string} src - @return src - */ -JSDOC.DocTag.prototype.nibbleName = function(src) { - if (typeof src != "string") throw "src must be a string not "+(typeof src); - - src = src.trim(); - - // is optional? - if (src.charAt(0) == "[") { - var nameRange = src.balance("[", "]"); - if (nameRange[1] == -1) { - throw "Malformed comment tag ignored. Tag optional name requires an opening [ and a closing ]: "+src; - } - this.name = src.substring(nameRange[0]+1, nameRange[1]).trim(); - this.isOptional = true; - - src = src.substring(nameRange[1]+1); - - // has default value? - var nameAndValue = this.name.split("="); - if (nameAndValue.length) { - this.name = nameAndValue.shift().trim(); - this.defaultValue = nameAndValue.join("="); - } - } - else { - var parts = src.match(/^(\S+)(?:\s([\s\S]*))?$/); - if (parts) { - if (parts[1]) this.name = parts[1]; - if (parts[2]) src = parts[2].trim(); - else src = ""; - } - } - - return src; -} - -/*t: - requires("../frame/String.js"); - plan(9, "testing JSDOC.DocTag.parser.nibbleName"); - - var tag = new JSDOC.DocTag(); - - tag.init().nibbleName("[foo] This is a description."); - is(tag.isOptional, true, "isOptional syntax is detected."); - is(tag.name, "foo", "optional param name is found."); - - tag.init().nibbleName("[foo] This is a description."); - is(tag.isOptional, true, "isOptional syntax is detected when no type."); - is(tag.name, "foo", "optional param name is found when no type."); - - tag.init().nibbleName("[foo=7] This is a description."); - is(tag.name, "foo", "optional param name is found when default value."); - is(tag.defaultValue, 7, "optional param default value is found when default value."); - - //tag.init().nibbleName("[foo= a value] This is a description."); - //is(tag.defaultValue, " a value", "optional param default value is found when default value has spaces (issue #112)."); - - tag.init().nibbleName("[foo=[]] This is a description."); - is(tag.defaultValue, "[]", "optional param default value is found when default value is [] (issue #95)."); - - tag.init().nibbleName("[foo=a=b] This is a description."); - is(tag.name, "foo", "optional param name is found when default value is a=b."); - is(tag.defaultValue, "a=b", "optional param default value is found when default value is a=b.") - */ - -/*t: - plan(32, "Testing JSDOC.DocTag.parser."); - requires("../frame/String.js"); - - var tag = new JSDOC.DocTag(); - - is(typeof tag, "object", "JSDOC.DocTag.parser with an empty string returns an object."); - is(typeof tag.title, "string", "returned object has a string property 'title'."); - is(typeof tag.type, "string", "returned object has a string property 'type'."); - is(typeof tag.name, "string", "returned object has a string property 'name'."); - is(typeof tag.defaultValue, "string", "returned object has a string property 'defaultValue'."); - is(typeof tag.isOptional, "boolean", "returned object has a boolean property 'isOptional'."); - is(typeof tag.desc, "string", "returned object has a string property 'desc'."); - - tag = new JSDOC.DocTag("param {widget} foo"); - is(tag.title, "param", "param title is found."); - is(tag.name, "foo", "param name is found when desc is missing."); - is(tag.desc, "", "param desc is empty when missing."); - - tag = new JSDOC.DocTag("param {object} date A valid date."); - is(tag.name, "date", "param name is found with a type."); - is(tag.type, "object", "param type is found."); - is(tag.desc, "A valid date.", "param desc is found with a type."); - - tag = new JSDOC.DocTag("param aName a description goes\n here."); - is(tag.name, "aName", "param name is found without a type."); - is(tag.desc, "a description goes\n here.", "param desc is found without a type."); - - tag = new JSDOC.DocTag("param {widget}"); - is(tag.name, "", "param name is empty when it is not given."); - - tag = new JSDOC.DocTag("param {widget} [foo] This is a description."); - is(tag.name, "foo", "optional param name is found."); - - tag = new JSDOC.DocTag("return {aType} This is a description."); - is(tag.type, "aType", "when return tag has no name, type is found."); - is(tag.desc, "This is a description.", "when return tag has no name, desc is found."); - - tag = new JSDOC.DocTag("author Joe Coder "); - is(tag.title, "author", "author tag has a title."); - is(tag.type, "", "the author tag has no type."); - is(tag.name, "", "the author tag has no name."); - is(tag.desc, "Joe Coder ", "author tag has desc."); - - tag = new JSDOC.DocTag("private \t\n "); - is(tag.title, "private", "private tag has a title."); - is(tag.type, "", "the private tag has no type."); - is(tag.name, "", "the private tag has no name."); - is(tag.desc, "", "private tag has no desc."); - - tag = new JSDOC.DocTag("example\n example(code);\n more();"); - is(tag.desc, " example(code);\n more();", "leading whitespace (less one) in examples code is preserved."); - - tag = new JSDOC.DocTag("param theName \n"); - is(tag.name, "theName", "name only is found."); - - tag = new JSDOC.DocTag("type theDesc \n"); - is(tag.desc, "theDesc", "desc only is found."); - - tag = new JSDOC.DocTag("type {theType} \n"); - is(tag.type, "theType", "type only is found."); - - tag = new JSDOC.DocTag(""); - is(tag.title, "", "title is empty when tag is empty."); - */ \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js b/utils/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js deleted file mode 100755 index 2c4bfb8..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +++ /dev/null @@ -1,126 +0,0 @@ -/** - @constructor - @param [opt] Used to override the commandline options. Useful for testing. - @version $Id: JsDoc.js 773 2009-01-24 09:42:04Z micmath $ -*/ -JSDOC.JsDoc = function(/**object*/ opt) { - if (opt) { - JSDOC.opt = opt; - } - - if (JSDOC.opt.h) { - JSDOC.usage(); - quit(); - } - - // defend against options that are not sane - if (JSDOC.opt._.length == 0) { - LOG.warn("No source files to work on. Nothing to do."); - quit(); - } - if (JSDOC.opt.t === true || JSDOC.opt.d === true) { - JSDOC.usage(); - } - - if (typeof JSDOC.opt.d == "string") { - if (!JSDOC.opt.d.charAt(JSDOC.opt.d.length-1).match(/[\\\/]/)) { - JSDOC.opt.d = JSDOC.opt.d+"/"; - } - LOG.inform("Output directory set to '"+JSDOC.opt.d+"'."); - IO.mkPath(JSDOC.opt.d); - } - if (JSDOC.opt.e) IO.setEncoding(JSDOC.opt.e); - - // the -r option: scan source directories recursively - if (typeof JSDOC.opt.r == "boolean") JSDOC.opt.r = 10; - else if (!isNaN(parseInt(JSDOC.opt.r))) JSDOC.opt.r = parseInt(JSDOC.opt.r); - else JSDOC.opt.r = 1; - - // the -D option: define user variables - var D = {}; - if (JSDOC.opt.D) { - for (var i = 0; i < JSDOC.opt.D.length; i++) { - var defineParts = JSDOC.opt.D[i].split(":", 2); - if (defineParts) D[defineParts[0]] = defineParts[1]; - } - } - JSDOC.opt.D = D; - // combine any conf file D options with the commandline D options - if (defined(JSDOC.conf)) for (var c in JSDOC.conf.D) { - if (!defined(JSDOC.opt.D[c])) { - JSDOC.opt.D[c] = JSDOC.conf.D[c]; - } - } - - // Give plugins a chance to initialize - if (defined(JSDOC.PluginManager)) { - JSDOC.PluginManager.run("onInit", JSDOC.opt); - } - - JSDOC.opt.srcFiles = JSDOC.JsDoc._getSrcFiles(); - JSDOC.JsDoc._parseSrcFiles(); - JSDOC.JsDoc.symbolSet = JSDOC.Parser.symbols; -} - -/** - Retrieve source file list. - @returns {String[]} The pathnames of the files to be parsed. - */ -JSDOC.JsDoc._getSrcFiles = function() { - JSDOC.JsDoc.srcFiles = []; - - var ext = ["js"]; - if (JSDOC.opt.x) { - ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()}); - } - - for (var i = 0; i < JSDOC.opt._.length; i++) { - JSDOC.JsDoc.srcFiles = JSDOC.JsDoc.srcFiles.concat( - IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter( - function($) { - var thisExt = $.split(".").pop().toLowerCase(); - - if (JSDOC.opt.E) { - for(var n = 0; n < JSDOC.opt.E.length; n++) { - if ($.match(new RegExp(JSDOC.opt.E[n]))) { - LOG.inform("Excluding " + $); - return false; // if the file matches the regex then it's excluded. - } - } - } - - return (ext.indexOf(thisExt) > -1); // we're only interested in files with certain extensions - } - ) - ); - } - - return JSDOC.JsDoc.srcFiles; -} - -JSDOC.JsDoc._parseSrcFiles = function() { - JSDOC.Parser.init(); - for (var i = 0, l = JSDOC.JsDoc.srcFiles.length; i < l; i++) { - var srcFile = JSDOC.JsDoc.srcFiles[i]; - - if (JSDOC.opt.v) LOG.inform("Parsing file: " + srcFile); - - try { - var src = IO.readFile(srcFile); - } - catch(e) { - LOG.warn("Can't read source file '"+srcFile+"': "+e.message); - } - - var tr = new JSDOC.TokenReader(); - var ts = new JSDOC.TokenStream(tr.tokenize(new JSDOC.TextStream(src))); - - JSDOC.Parser.parse(ts, srcFile); - - } - JSDOC.Parser.finish(); - - if (JSDOC.PluginManager) { - JSDOC.PluginManager.run("onFinishedParsing", JSDOC.Parser.symbols); - } -} diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js b/utils/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js deleted file mode 100755 index 79ac61f..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +++ /dev/null @@ -1,109 +0,0 @@ -/** - @constructor -*/ -JSDOC.JsPlate = function(templateFile) { - if (templateFile) this.template = IO.readFile(templateFile); - - this.templateFile = templateFile; - this.code = ""; - this.parse(); -} - -JSDOC.JsPlate.prototype.parse = function() { - this.template = this.template.replace(/\{#[\s\S]+?#\}/gi, ""); - this.code = "var output=``"+this.template; - - this.code = this.code.replace( - //gi, - function (match, eachName, inName) { - return "``;\rvar $"+eachName+"_keys = keys("+inName+");\rfor(var $"+eachName+"_i = 0; $"+eachName+"_i < $"+eachName+"_keys.length; $"+eachName+"_i++) {\rvar $"+eachName+"_last = ($"+eachName+"_i == $"+eachName+"_keys.length-1);\rvar $"+eachName+"_key = $"+eachName+"_keys[$"+eachName+"_i];\rvar "+eachName+" = "+inName+"[$"+eachName+"_key];\routput+=``"; - } - ); - this.code = this.code.replace(//g, "``;\rif ($1) { output+=``"); - this.code = this.code.replace(//g, "``;}\relse if ($1) { output+=``"); - this.code = this.code.replace(//g, "``;}\relse { output+=``"); - this.code = this.code.replace(/<\/(if|for)>/g, "``;\r};\routput+=``"); - this.code = this.code.replace( - /\{\+\s*([\s\S]+?)\s*\+\}/gi, - function (match, code) { - code = code.replace(/"/g, "``"); // prevent qoute-escaping of inline code - code = code.replace(/(\r?\n)/g, " "); - return "``+ ("+code+") +``"; - } - ); - this.code = this.code.replace( - /\{!\s*([\s\S]+?)\s*!\}/gi, - function (match, code) { - code = code.replace(/"/g, "``"); // prevent qoute-escaping of inline code - code = code.replace(/(\n)/g, " "); - return "``; "+code+";\routput+=``"; - } - ); - this.code = this.code+"``;"; - - this.code = this.code.replace(/(\r?\n)/g, "\\n"); - this.code = this.code.replace(/"/g, "\\\""); - this.code = this.code.replace(/``/g, "\""); -} - -JSDOC.JsPlate.prototype.toCode = function() { - return this.code; -} - -JSDOC.JsPlate.keys = function(obj) { - var keys = []; - if (obj.constructor.toString().indexOf("Array") > -1) { - for (var i = 0; i < obj.length; i++) { - keys.push(i); - } - } - else { - for (var i in obj) { - keys.push(i); - } - } - return keys; -}; - -JSDOC.JsPlate.values = function(obj) { - var values = []; - if (obj.constructor.toString().indexOf("Array") > -1) { - for (var i = 0; i < obj.length; i++) { - values.push(obj[i]); - } - } - else { - for (var i in obj) { - values.push(obj[i]); - } - } - return values; -}; - -JSDOC.JsPlate.prototype.process = function(data, compact) { - var keys = JSDOC.JsPlate.keys; - var values = JSDOC.JsPlate.values; - - try { - eval(this.code); - } - catch (e) { - print(">> There was an error evaluating the compiled code from template: "+this.templateFile); - print(" The error was on line "+e.lineNumber+" "+e.name+": "+e.message); - var lines = this.code.split("\r"); - if (e.lineNumber-2 >= 0) print("line "+(e.lineNumber-1)+": "+lines[e.lineNumber-2]); - print("line "+e.lineNumber+": "+lines[e.lineNumber-1]); - print(""); - } - - if (compact) { // patch by mcbain.asm - // Remove lines that contain only space-characters, usually left by lines in the template - // which originally only contained JSPlate tags or code. This makes it easier to write - // non-tricky templates which still put out nice code (not bloated with extra lines). - // Lines purposely left blank (just a line ending) are left alone. - output = output.replace(/\s+?(\r?)\n/g, "$1\n"); - } - - /*debug*///print(this.code); - return output; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/Lang.js b/utils/jsdoc-toolkit/app/lib/JSDOC/Lang.js deleted file mode 100755 index 62919d7..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/Lang.js +++ /dev/null @@ -1,144 +0,0 @@ -/** - @namespace -*/ -JSDOC.Lang = { -} - -JSDOC.Lang.isBuiltin = function(name) { - return (JSDOC.Lang.isBuiltin.coreObjects.indexOf(name) > -1); -} -JSDOC.Lang.isBuiltin.coreObjects = ['_global_', 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', 'RegExp', 'String']; - -JSDOC.Lang.whitespace = function(ch) { - return JSDOC.Lang.whitespace.names[ch]; -} -JSDOC.Lang.whitespace.names = { - " ": "SPACE", - "\f": "FORMFEED", - "\t": "TAB", - "\u0009": "UNICODE_TAB", - "\u000A": "UNICODE_NBR", - "\u0008": "VERTICAL_TAB" -}; - -JSDOC.Lang.newline = function(ch) { - return JSDOC.Lang.newline.names[ch]; -} -JSDOC.Lang.newline.names = { - "\n": "NEWLINE", - "\r": "RETURN", - "\u000A": "UNICODE_LF", - "\u000D": "UNICODE_CR", - "\u2029": "UNICODE_PS", - "\u2028": "UNICODE_LS" -}; - -JSDOC.Lang.keyword = function(word) { - return JSDOC.Lang.keyword.names["="+word]; -} -JSDOC.Lang.keyword.names = { - "=break": "BREAK", - "=case": "CASE", - "=catch": "CATCH", - "=const": "VAR", - "=continue": "CONTINUE", - "=default": "DEFAULT", - "=delete": "DELETE", - "=do": "DO", - "=else": "ELSE", - "=false": "FALSE", - "=finally": "FINALLY", - "=for": "FOR", - "=function": "FUNCTION", - "=if": "IF", - "=in": "IN", - "=instanceof": "INSTANCEOF", - "=new": "NEW", - "=null": "NULL", - "=return": "RETURN", - "=switch": "SWITCH", - "=this": "THIS", - "=throw": "THROW", - "=true": "TRUE", - "=try": "TRY", - "=typeof": "TYPEOF", - "=void": "VOID", - "=while": "WHILE", - "=with": "WITH", - "=var": "VAR" -}; - -JSDOC.Lang.punc = function(ch) { - return JSDOC.Lang.punc.names[ch]; -} -JSDOC.Lang.punc.names = { - ";": "SEMICOLON", - ",": "COMMA", - "?": "HOOK", - ":": "COLON", - "||": "OR", - "&&": "AND", - "|": "BITWISE_OR", - "^": "BITWISE_XOR", - "&": "BITWISE_AND", - "===": "STRICT_EQ", - "==": "EQ", - "=": "ASSIGN", - "!==": "STRICT_NE", - "!=": "NE", - "<<": "LSH", - "<=": "LE", - "<": "LT", - ">>>": "URSH", - ">>": "RSH", - ">=": "GE", - ">": "GT", - "++": "INCREMENT", - "--": "DECREMENT", - "+": "PLUS", - "-": "MINUS", - "*": "MUL", - "/": "DIV", - "%": "MOD", - "!": "NOT", - "~": "BITWISE_NOT", - ".": "DOT", - "[": "LEFT_BRACKET", - "]": "RIGHT_BRACKET", - "{": "LEFT_CURLY", - "}": "RIGHT_CURLY", - "(": "LEFT_PAREN", - ")": "RIGHT_PAREN" -}; - -JSDOC.Lang.matching = function(name) { - return JSDOC.Lang.matching.names[name]; -} -JSDOC.Lang.matching.names = { - "LEFT_PAREN": "RIGHT_PAREN", - "RIGHT_PAREN": "LEFT_PAREN", - "LEFT_CURLY": "RIGHT_CURLY", - "RIGHT_CURLY": "LEFT_CURLY", - "LEFT_BRACE": "RIGHT_BRACE", - "RIGHT_BRACE": "LEFT_BRACE" -} - -JSDOC.Lang.isNumber = function(str) { - return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str); -} - -JSDOC.Lang.isHexDec = function(str) { - return /^0x[0-9A-F]+$/i.test(str); -} - -JSDOC.Lang.isWordChar = function(str) { - return /^[a-zA-Z0-9$_.]+$/.test(str); -} - -JSDOC.Lang.isSpace = function(str) { - return (typeof JSDOC.Lang.whitespace(str) != "undefined"); -} - -JSDOC.Lang.isNewline = function(str) { - return (typeof JSDOC.Lang.newline(str) != "undefined"); -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/Parser.js b/utils/jsdoc-toolkit/app/lib/JSDOC/Parser.js deleted file mode 100755 index f407dd1..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/Parser.js +++ /dev/null @@ -1,145 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - @namespace - @requires JSDOC.Walker - @requires JSDOC.Symbol - @requires JSDOC.DocComment -*/ -JSDOC.Parser = { - conf: { - ignoreCode: JSDOC.opt.n, - ignoreAnonymous: true, // factory: true - treatUnderscoredAsPrivate: true, // factory: true - explain: false // factory: false - }, - - addSymbol: function(symbol) { - -if (JSDOC.Parser.rename) { - for (var n in JSDOC.Parser.rename) { - if (symbol.alias.indexOf(n) == 0) { - if (symbol.name == symbol.alias) { - symbol.name = symbol.name.replace(n, JSDOC.Parser.rename[n]); - } - symbol.alias = symbol.alias.replace(n, JSDOC.Parser.rename[n]); - } - } -} - -if (JSDOC.opt.S) { - if (typeof JSDOC.Parser.secureModules == "undefined") JSDOC.Parser.secureModules = {}; - if (/^exports\./.test(symbol.alias)) { - symbol.srcFile.match(/(^|[\\\/])([^\\\/]+)\.js/i); - var fileNS = RegExp.$2; - symbol.alias = symbol.alias.replace(/^exports\./, fileNS); - symbol.name = symbol.name.replace(/^exports\./, ""); - symbol.memberOf = fileNS; - - // need to create the namespace associated with this file first - if (!JSDOC.Parser.secureModules[fileNS]) { - JSDOC.Parser.secureModules[fileNS] = 1; - var nsSymbol = new JSDOC.Symbol(fileNS, [], "GLOBAL", new JSDOC.DocComment("")); - nsSymbol.isNamespace = true; - nsSymbol.srcFile = ""; - nsSymbol.isPrivate = false; - nsSymbol.srcFile = symbol.srcFile; - nsSymbol.desc = (JSDOC.Parser.symbols.getSymbol(symbol.srcFile) || {desc: ""}).desc; - JSDOC.Parser.addSymbol(nsSymbol); - - } - } - else { // a method that is not exported? - if (!symbol.isNamespace) return; - } -} - // if a symbol alias is documented more than once the last one with the user docs wins - if (JSDOC.Parser.symbols.hasSymbol(symbol.alias)) { - var oldSymbol = JSDOC.Parser.symbols.getSymbol(symbol.alias); - if (oldSymbol.comment.isUserComment) { - if (symbol.comment.isUserComment) { // old and new are both documented - LOG.warn("The symbol '"+symbol.alias+"' is documented more than once."); - } - else { // old is documented but new isn't - return; - } - } - } - - // we don't document anonymous things - if (JSDOC.Parser.conf.ignoreAnonymous && symbol.name.match(/\$anonymous\b/)) return; - - // uderscored things may be treated as if they were marked private, this cascades - if (JSDOC.Parser.conf.treatUnderscoredAsPrivate && symbol.name.match(/[.#-]_[^.#-]+$/)) { - if (!symbol.comment.getTag("public").length > 0) symbol.isPrivate = true; - } - - // -p flag is required to document private things - if (!JSDOC.opt.p && symbol.isPrivate) return; // issue #161 fixed by mcbain.asm - - // ignored things are not documented, this doesn't cascade - if (symbol.isIgnored) return; - JSDOC.Parser.symbols.addSymbol(symbol); - }, - - addBuiltin: function(name) { - var builtin = new JSDOC.Symbol(name, [], "CONSTRUCTOR", new JSDOC.DocComment("")); - builtin.isNamespace = true; - builtin.srcFile = ""; - builtin.isPrivate = false; - JSDOC.Parser.addSymbol(builtin); - return builtin; - }, - - init: function() { - JSDOC.Parser.symbols = new JSDOC.SymbolSet(); - JSDOC.Parser.walker = new JSDOC.Walker(); - }, - - finish: function() { - JSDOC.Parser.symbols.relate(); - - // make a litle report about what was found - if (JSDOC.Parser.conf.explain) { - var symbols = JSDOC.Parser.symbols.toArray(); - var srcFile = ""; - for (var i = 0, l = symbols.length; i < l; i++) { - var symbol = symbols[i]; - if (srcFile != symbol.srcFile) { - srcFile = symbol.srcFile; - print("\n"+srcFile+"\n-------------------"); - } - print(i+":\n alias => "+symbol.alias + "\n name => "+symbol.name+ "\n isa => "+symbol.isa + "\n memberOf => " + symbol.memberOf + "\n isStatic => " + symbol.isStatic + ", isInner => " + symbol.isInner+ ", isPrivate => " + symbol.isPrivate); - } - print("-------------------\n"); - } - } -} - -JSDOC.Parser.parse = function(/**JSDOC.TokenStream*/ts, /**String*/srcFile) { - JSDOC.Symbol.srcFile = (srcFile || ""); - JSDOC.DocComment.shared = ""; // shared comments don't cross file boundaries - - if (!JSDOC.Parser.walker) JSDOC.Parser.init(); - JSDOC.Parser.walker.walk(ts); // adds to our symbols - - // filter symbols by option - for (var p = JSDOC.Parser.symbols._index.first(); p; p = JSDOC.Parser.symbols._index.next()) { - var symbol = p.value; - - if (!symbol) continue; - - if (symbol.is("FILE") || symbol.is("GLOBAL")) { - continue; - } - else if (!JSDOC.opt.a && !symbol.comment.isUserComment) { - JSDOC.Parser.symbols.deleteSymbol(symbol.alias); - } - - if (/#$/.test(symbol.alias)) { // we don't document prototypes - JSDOC.Parser.symbols.deleteSymbol(symbol.alias); - } - } - - return JSDOC.Parser.symbols.toArray(); -} diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js b/utils/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js deleted file mode 100755 index 9c91193..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - @namespace Holds functionality related to running plugins. -*/ -JSDOC.PluginManager = { -} - -/** - @param name A unique name that identifies that plugin. - @param handlers A collection of named functions. The names correspond to hooks in the core code. -*/ -JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) { - if (!defined(JSDOC.PluginManager.plugins)) - /** The collection of all plugins. Requires a unique name for each. - */ - JSDOC.PluginManager.plugins = {}; - - - JSDOC.PluginManager.plugins[name] = handlers; -} - -/** - @param hook The name of the hook that is being caught. - @param target Any object. This will be passed as the only argument to the handler whose - name matches the hook name. Handlers cannot return a value, so must modify the target - object to have an effect. -*/ -JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) { - for (var name in JSDOC.PluginManager.plugins) { - if (defined(JSDOC.PluginManager.plugins[name][hook])) { - JSDOC.PluginManager.plugins[name][hook](target); - } - } -} diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/Symbol.js b/utils/jsdoc-toolkit/app/lib/JSDOC/Symbol.js deleted file mode 100755 index c5b76a8..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +++ /dev/null @@ -1,645 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - Create a new Symbol. - @class Represents a symbol in the source code. - */ -JSDOC.Symbol = function() { - this.init(); - if (arguments.length) this.populate.apply(this, arguments); -} - -JSDOC.Symbol.count = 0; - -JSDOC.Symbol.prototype.init = function() { - this._name = ""; - this._params = []; - this.$args = []; - this.addOn = ""; - this.alias = ""; - this.augments = []; - this.author = ""; - this.classDesc = ""; - this.comment = {}; - this.defaultValue = undefined; - this.deprecated = ""; - this.desc = ""; - this.example = []; - this.exceptions = []; - this.fires = []; - this.id = JSDOC.Symbol.count++; - this.inherits = []; - this.inheritsFrom = []; - this.isa = "OBJECT"; - this.isConstant = false; - this.isEvent = false; - this.isIgnored = false; - this.isInner = false; - this.isNamespace = false; - this.isPrivate = false; - this.isStatic = false; - this.memberOf = ""; - this.methods = []; - this.properties = []; - this.requires = []; - this.returns = []; - this.see = []; - this.since = ""; - this.srcFile = {}; - this.type = ""; - this.version = ""; -} - -JSDOC.Symbol.prototype.serialize = function() { - var keys = []; - for (var p in this) { - keys.push (p); - } - keys = keys.sort(); - - var out = ""; - for (var i in keys) { - if (typeof this[keys[i]] == "function") continue; - out += keys[i]+" => "+Dumper.dump(this[keys[i]])+",\n"; - } - return "\n{\n" + out + "}\n"; -} - -JSDOC.Symbol.prototype.clone = function() { - var clone = new JSDOC.Symbol(); - clone.populate.apply(clone, this.$args); // repopulate using the original arguments - clone.srcFile = this.srcFile; // not the current srcFile, the one when the original was made - return clone; -} - -JSDOC.Symbol.prototype.__defineSetter__("name", - function(n) { n = n.replace(/^_global_[.#-]/, ""); n = n.replace(/\.prototype\.?/g, '#'); this._name = n; } -); -JSDOC.Symbol.prototype.__defineGetter__("name", - function() { return this._name; } -); -JSDOC.Symbol.prototype.__defineSetter__("params", - function(v) { - for (var i = 0, l = v.length; i < l; i++) { - if (v[i].constructor != JSDOC.DocTag) { // may be a generic object parsed from signature, like {type:..., name:...} - this._params[i] = new JSDOC.DocTag("param"+((v[i].type)?" {"+v[i].type+"}":"")+" "+v[i].name); - } - else { - this._params[i] = v[i]; - } - } - } -); -JSDOC.Symbol.prototype.__defineGetter__("params", - function() { return this._params; } -); - -JSDOC.Symbol.prototype.getEvents = function() { - var events = []; - for (var i = 0, l = this.methods.length; i < l; i++) { - if (this.methods[i].isEvent) { - this.methods[i].name = this.methods[i].name.replace("event:", ""); - events.push(this.methods[i]); - } - } - return events; -} - -JSDOC.Symbol.prototype.getMethods = function() { - var nonEvents = []; - for (var i = 0, l = this.methods.length; i < l; i++) { - if (!this.methods[i].isEvent) { - nonEvents.push(this.methods[i]); - } - } - return nonEvents; -} - - -JSDOC.Symbol.prototype.populate = function( - /** String */ name, - /** Object[] */ params, - /** String */ isa, - /** JSDOC.DocComment */ comment -) { - this.$args = arguments; - - this.name = name; - this.alias = this.name; - - this.params = params; - this.isa = (isa == "VIRTUAL")? "OBJECT":isa; - this.comment = comment || new JSDOC.DocComment(""); - this.srcFile = JSDOC.Symbol.srcFile; - - if (this.is("FILE") && !this.alias) this.alias = this.srcFile; - - this.setTags(); - - if (typeof JSDOC.PluginManager != "undefined") { - JSDOC.PluginManager.run("onSymbol", this); - } -} - -JSDOC.Symbol.prototype.setTags = function() { - // @author - var authors = this.comment.getTag("author"); - if (authors.length) { - this.author = authors.map(function($){return $.desc;}).join(", "); - } - - /*t: - plan(34, "testing JSDOC.Symbol"); - - requires("../lib/JSDOC/DocComment.js"); - requires("../frame/String.js"); - requires("../lib/JSDOC/DocTag.js"); - - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@author Joe Smith*"+"/")); - is(sym.author, "Joe Smith", "@author tag, author is found."); - */ - - // @desc - var descs = this.comment.getTag("desc"); - if (descs.length) { - this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@desc This is a description.*"+"/")); - is(sym.desc, "This is a description.", "@desc tag, description is found."); - */ - - // @overview - if (this.is("FILE")) { - if (!this.alias) this.alias = this.srcFile; - - var overviews = this.comment.getTag("overview"); - if (overviews.length) { - this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n"); - } - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@overview This is an overview.*"+"/")); - is(sym.desc, "\nThis is an overview.", "@overview tag, description is found."); - */ - - // @since - var sinces = this.comment.getTag("since"); - if (sinces.length) { - this.since = sinces.map(function($){return $.desc;}).join(", "); - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@since 1.01*"+"/")); - is(sym.since, "1.01", "@since tag, description is found."); - */ - - // @constant - if (this.comment.getTag("constant").length) { - this.isConstant = true; - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@constant*"+"/")); - is(sym.isConstant, true, "@constant tag, isConstant set."); - */ - - // @version - var versions = this.comment.getTag("version"); - if (versions.length) { - this.version = versions.map(function($){return $.desc;}).join(", "); - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@version 2.0x*"+"/")); - is(sym.version, "2.0x", "@version tag, version is found."); - */ - - // @deprecated - var deprecateds = this.comment.getTag("deprecated"); - if (deprecateds.length) { - this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n"); - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@deprecated Use other method.*"+"/")); - is(sym.deprecated, "Use other method.", "@deprecated tag, desc is found."); - */ - - // @example - var examples = this.comment.getTag("example"); - if (examples.length) { - this.example = examples.map( - // trim trailing whitespace - function($) { - $.desc = $.desc.replace(/\s+$/, ""); - return $; - } - ); - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@example This\n is an example. \n*"+"/")); - isnt(typeof sym.example[0], "undefined", "@example tag, creates sym.example array."); - is(sym.example[0], "This\n is an example.", "@example tag, desc is found."); - */ - - // @see - var sees = this.comment.getTag("see"); - if (sees.length) { - var thisSee = this.see; - sees.map(function($){thisSee.push($.desc);}); - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FILE", new JSDOC.DocComment("/**@see The other thing.*"+"/")); - is(sym.see, "The other thing.", "@see tag, desc is found."); - */ - - // @class - var classes = this.comment.getTag("class"); - if (classes.length) { - this.isa = "CONSTRUCTOR"; - this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none. - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@class This describes the class.*"+"/")); - is(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor."); - is(sym.classDesc, "This describes the class.", "@class tag, class description is found."); - */ - - // @namespace - var namespaces = this.comment.getTag("namespace"); - if (namespaces.length) { - this.classDesc = namespaces[0].desc; - this.isNamespace = true; - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@namespace This describes the namespace.*"+"/")); - is(sym.classDesc, "This describes the namespace.", "@namespace tag, class description is found."); - */ - - // @param - var params = this.comment.getTag("param"); - if (params.length) { - // user-defined params overwrite those with same name defined by the parser - var thisParams = this.params; - - if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in - this.params = params; - } - else { // need to overlay these user-defined params on to existing parser-defined params - for (var i = 0, l = params.length; i < l; i++) { - if (thisParams[i]) { - if (params[i].type) thisParams[i].type = params[i].type; - thisParams[i].name = params[i].name; - thisParams[i].desc = params[i].desc; - thisParams[i].isOptional = params[i].isOptional; - thisParams[i].defaultValue = params[i].defaultValue; - } - else thisParams[i] = params[i]; - } - } - } - - /*t: - var sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new JSDOC.DocComment("/**Description.*"+"/")); - is(sym.params.length, 1, "parser defined param is found."); - - sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {array} pages*"+"/")); - is(sym.params.length, 1, "user defined param is found."); - is(sym.params[0].type, "array", "user defined param type is found."); - is(sym.params[0].name, "pages", "user defined param name is found."); - - sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {string} uid*"+"/")); - is(sym.params.length, 1, "user defined param overwrites parser defined param."); - is(sym.params[0].type, "string", "user defined param type overwrites parser defined param type."); - is(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name."); - - sym = new JSDOC.Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {string} uid*"+"/")); - is(sym.params.length, 2, "user defined params overlay parser defined params."); - is(sym.params[1].type, "number", "user defined param type overlays parser defined param type."); - is(sym.params[1].name, "count", "user defined param name overlays parser defined param name."); - - sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**Description.\n@param {array} pages The pages description.*"+"/")); - is(sym.params.length, 1, "user defined param with description is found."); - is(sym.params[0].desc, "The pages description.", "user defined param description is found."); - */ - - // @constructor - if (this.comment.getTag("constructor").length) { - this.isa = "CONSTRUCTOR"; - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@constructor*"+"/")); - is(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor."); - */ - - // @static - if (this.comment.getTag("static").length) { - this.isStatic = true; - if (this.isa == "CONSTRUCTOR") { - this.isNamespace = true; - } - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@static\n@constructor*"+"/")); - is(sym.isStatic, true, "@static tag, makes isStatic true."); - is(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true."); - */ - - // @inner - if (this.comment.getTag("inner").length) { - this.isInner = true; - this.isStatic = false; - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@inner*"+"/")); - is(sym.isStatic, false, "@inner tag, makes isStatic false."); - is(sym.isInner, true, "@inner makes isInner true."); - */ - - // @name - var names = this.comment.getTag("name"); - if (names.length) { - this.name = names[0].desc; - } - - /*t: - // todo - */ - - // @field - if (this.comment.getTag("field").length) { - this.isa = "OBJECT"; - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "FUNCTION", new JSDOC.DocComment("/**@field*"+"/")); - is(sym.isa, "OBJECT", "@field tag, makes symbol an object."); - */ - - // @function - if (this.comment.getTag("function").length) { - this.isa = "FUNCTION"; - if (/event:/.test(this.alias)) this.isEvent = true; - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@function*"+"/")); - is(sym.isa, "FUNCTION", "@function tag, makes symbol a function."); - */ - - // @event - var events = this.comment.getTag("event"); - if (events.length) { - this.isa = "FUNCTION"; - this.isEvent = true; - if (!/event:/.test(this.alias)) - this.alias = this.alias.replace(/^(.*[.#-])([^.#-]+)$/, "$1event:$2"); - } - - /*t: - var sym = new JSDOC.Symbol("foo", [], "OBJECT", new JSDOC.DocComment("/**@event*"+"/")); - is(sym.isa, "FUNCTION", "@event tag, makes symbol a function."); - is(sym.isEvent, true, "@event makes isEvent true."); - */ - - // @fires - var fires = this.comment.getTag("fires"); - if (fires.length) { - for (var i = 0; i < fires.length; i++) { - this.fires.push(fires[i].desc); - } - } - - /*t: - // todo - */ - - // @property - var properties = this.comment.getTag("property"); - if (properties.length) { - thisProperties = this.properties; - for (var i = 0; i < properties.length; i++) { - var property = new JSDOC.Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new JSDOC.DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/")); - // TODO: shouldn't the following happen in the addProperty method of Symbol? - property.name = properties[i].name; - property.memberOf = this.alias; - if (properties[i].type) property.type = properties[i].type; - if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue; - this.addProperty(property); - JSDOC.Parser.addSymbol(property); - } - } - - /*t: - // todo - */ - - // @return - var returns = this.comment.getTag("return"); - if (returns.length) { // there can be many return tags in a single doclet - this.returns = returns; - this.type = returns.map(function($){return $.type}).join(", "); - } - - /*t: - // todo - */ - - // @exception - this.exceptions = this.comment.getTag("throws"); - - /*t: - // todo - */ - - // @requires - var requires = this.comment.getTag("requires"); - if (requires.length) { - this.requires = requires.map(function($){return $.desc}); - } - - /*t: - // todo - */ - - // @type - var types = this.comment.getTag("type"); - if (types.length) { - this.type = types[0].desc; //multiple type tags are ignored - } - - /*t: - // todo - */ - - // @private - if (this.comment.getTag("private").length || this.isInner) { - this.isPrivate = true; - } - - // @ignore - if (this.comment.getTag("ignore").length) { - this.isIgnored = true; - } - - /*t: - // todo - */ - - // @inherits ... as ... - var inherits = this.comment.getTag("inherits"); - if (inherits.length) { - for (var i = 0; i < inherits.length; i++) { - if (/^\s*([a-z$0-9_.#:-]+)(?:\s+as\s+([a-z$0-9_.#:-]+))?/i.test(inherits[i].desc)) { - var inAlias = RegExp.$1; - var inAs = RegExp.$2 || inAlias; - - if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#"); - - if (inAs) { - inAs = inAs.replace(/\.prototype\.?/g, "#"); - inAs = inAs.replace(/^this\.?/, "#"); - } - - if (inAs.indexOf(inAlias) != 0) { //not a full namepath - var joiner = "."; - if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") { - joiner = ""; - } - inAs = this.alias + joiner + inAs; - } - } - this.inherits.push({alias: inAlias, as: inAs}); - } - } - - /*t: - // todo - */ - - // @augments - this.augments = this.comment.getTag("augments"); - - // @default - var defaults = this.comment.getTag("default"); - if (defaults.length) { - if (this.is("OBJECT")) { - this.defaultValue = defaults[0].desc; - } - } - - /*t: - // todo - */ - - // @memberOf - var memberOfs = this.comment.getTag("memberOf"); - if (memberOfs.length) { - this.memberOf = memberOfs[0].desc; - this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#"); - } - - /*t: - // todo - */ - - // @public - if (this.comment.getTag("public").length) { - this.isPrivate = false; - } - - /*t: - // todo - */ - - if (JSDOC.PluginManager) { - JSDOC.PluginManager.run("onSetTags", this); - } -} - -JSDOC.Symbol.prototype.is = function(what) { - return this.isa === what; -} - -JSDOC.Symbol.prototype.isBuiltin = function() { - return JSDOC.Lang.isBuiltin(this.alias); -} - -JSDOC.Symbol.prototype.setType = function(/**String*/comment, /**Boolean*/overwrite) { - if (!overwrite && this.type) return; - var typeComment = JSDOC.DocComment.unwrapComment(comment); - this.type = typeComment; -} - -JSDOC.Symbol.prototype.inherit = function(symbol) { - if (!this.hasMember(symbol.name) && !symbol.isInner) { - if (symbol.is("FUNCTION")) - this.methods.push(symbol); - else if (symbol.is("OBJECT")) - this.properties.push(symbol); - } -} - -JSDOC.Symbol.prototype.hasMember = function(name) { - return (this.hasMethod(name) || this.hasProperty(name)); -} - -JSDOC.Symbol.prototype.addMember = function(symbol) { - if (symbol.is("FUNCTION")) { this.addMethod(symbol); } - else if (symbol.is("OBJECT")) { this.addProperty(symbol); } -} - -JSDOC.Symbol.prototype.hasMethod = function(name) { - var thisMethods = this.methods; - for (var i = 0, l = thisMethods.length; i < l; i++) { - if (thisMethods[i].name == name) return true; - if (thisMethods[i].alias == name) return true; - } - return false; -} - -JSDOC.Symbol.prototype.addMethod = function(symbol) { - var methodAlias = symbol.alias; - var thisMethods = this.methods; - for (var i = 0, l = thisMethods.length; i < l; i++) { - if (thisMethods[i].alias == methodAlias) { - thisMethods[i] = symbol; // overwriting previous method - return; - } - } - thisMethods.push(symbol); // new method with this alias -} - -JSDOC.Symbol.prototype.hasProperty = function(name) { - var thisProperties = this.properties; - for (var i = 0, l = thisProperties.length; i < l; i++) { - if (thisProperties[i].name == name) return true; - if (thisProperties[i].alias == name) return true; - } - return false; -} - -JSDOC.Symbol.prototype.addProperty = function(symbol) { - var propertyAlias = symbol.alias; - var thisProperties = this.properties; - for (var i = 0, l = thisProperties.length; i < l; i++) { - if (thisProperties[i].alias == propertyAlias) { - thisProperties[i] = symbol; // overwriting previous property - return; - } - } - - thisProperties.push(symbol); // new property with this alias -} - -JSDOC.Symbol.srcFile = ""; //running reference to the current file being parsed diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js b/utils/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js deleted file mode 100755 index 82657e4..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +++ /dev/null @@ -1,241 +0,0 @@ -/** @constructor */ -JSDOC.SymbolSet = function() { - this.init(); -} - -JSDOC.SymbolSet.prototype.init = function() { - this._index = new Hash(); -} - -JSDOC.SymbolSet.prototype.keys = function() { - return this._index.keys(); -} - -JSDOC.SymbolSet.prototype.hasSymbol = function(alias) { - return this._index.hasKey(alias); -} - -JSDOC.SymbolSet.prototype.addSymbol = function(symbol) { - if (this.hasSymbol(symbol.alias)) { - LOG.warn("Overwriting symbol documentation for: "+symbol.alias + "."); - } - this._index.set(symbol.alias, symbol); -} - -JSDOC.SymbolSet.prototype.getSymbol = function(alias) { - if (this.hasSymbol(alias)) return this._index.get(alias); -} - -JSDOC.SymbolSet.prototype.getSymbolByName = function(name) { - for (var p = this._index.first(); p; p = this._index.next()) { - var symbol = p.value; - if (symbol.name == name) return symbol; - } -} - -JSDOC.SymbolSet.prototype.toArray = function() { - return this._index.values(); -} - -JSDOC.SymbolSet.prototype.deleteSymbol = function(alias) { - if (!this.hasSymbol(alias)) return; - this._index.drop(alias); -} - -JSDOC.SymbolSet.prototype.renameSymbol = function(oldName, newName) { - // todo: should check if oldname or newname already exist - this._index.replace(oldName, newName); - this._index.get(newName).alias = newName; - return newName; -} - -JSDOC.SymbolSet.prototype.relate = function() { - this.resolveBorrows(); - this.resolveMemberOf(); - this.resolveAugments(); -} - -JSDOC.SymbolSet.prototype.resolveBorrows = function() { - for (var p = this._index.first(); p; p = this._index.next()) { - var symbol = p.value; - if (symbol.is("FILE") || symbol.is("GLOBAL")) continue; - - var borrows = symbol.inherits; - for (var i = 0; i < borrows.length; i++) { - -if (/#$/.test(borrows[i].alias)) { - LOG.warn("Attempted to borrow entire instance of "+borrows[i].alias+" but that feature is not yet implemented."); - return; -} - var borrowed = this.getSymbol(borrows[i].alias); - - if (!borrowed) { - LOG.warn("Can't borrow undocumented "+borrows[i].alias+"."); - continue; - } - - if (borrows[i].as == borrowed.alias) { - var assumedName = borrowed.name.split(/([#.-])/).pop(); - borrows[i].as = symbol.name+RegExp.$1+assumedName; - LOG.inform("Assuming borrowed as name is "+borrows[i].as+" but that feature is experimental."); - } - - var borrowAsName = borrows[i].as; - var borrowAsAlias = borrowAsName; - if (!borrowAsName) { - LOG.warn("Malformed @borrow, 'as' is required."); - continue; - } - - if (borrowAsName.length > symbol.alias.length && borrowAsName.indexOf(symbol.alias) == 0) { - borrowAsName = borrowAsName.replace(borrowed.alias, "") - } - else { - var joiner = ""; - if (borrowAsName.charAt(0) != "#") joiner = "."; - borrowAsAlias = borrowed.alias + joiner + borrowAsName; - } - - borrowAsName = borrowAsName.replace(/^[#.]/, ""); - - if (this.hasSymbol(borrowAsAlias)) continue; - - var clone = borrowed.clone(); - clone.name = borrowAsName; - clone.alias = borrowAsAlias; - this.addSymbol(clone); - } - } -} - -JSDOC.SymbolSet.prototype.resolveMemberOf = function() { - for (var p = this._index.first(); p; p = this._index.next()) { - var symbol = p.value; - if (symbol.is("FILE") || symbol.is("GLOBAL")) continue; - - // the memberOf value was provided in the @memberOf tag - else if (symbol.memberOf) { - - // like foo.bar is a memberOf foo - if (symbol.alias.indexOf(symbol.memberOf) == 0) { - var memberMatch = new RegExp("^("+symbol.memberOf+")[.#-]?(.+)$"); - var aliasParts = symbol.alias.match(memberMatch); - - if (aliasParts) { - symbol.memberOf = aliasParts[1]; - symbol.name = aliasParts[2]; - } - - var nameParts = symbol.name.match(memberMatch); - - if (nameParts) { - symbol.name = nameParts[2]; - } - } - // like bar is a memberOf foo - else { - var joiner = symbol.memberOf.charAt(symbol.memberOf.length-1); - if (!/[.#-]/.test(joiner)) symbol.memberOf += "."; - this.renameSymbol(symbol.alias, symbol.memberOf + symbol.name); - } - } - // the memberOf must be calculated - else { - var parts = symbol.alias.match(/^(.*[.#-])([^.#-]+)$/); - if (parts) { - symbol.memberOf = parts[1]; - symbol.name = parts[2]; - } - } - - // set isStatic, isInner - if (symbol.memberOf) { - switch (symbol.memberOf.charAt(symbol.memberOf.length-1)) { - case '#' : - symbol.isStatic = false; - symbol.isInner = false; - break; - case '.' : - symbol.isStatic = true; - symbol.isInner = false; - break; - case '-' : - symbol.isStatic = false; - symbol.isInner = true; - break; - default: // memberOf ends in none of the above - symbol.isStatic = true; - break; - } - } - - // unowned methods and fields belong to the global object - if (!symbol.is("CONSTRUCTOR") && !symbol.isNamespace && symbol.memberOf == "") { - symbol.memberOf = "_global_"; - } - - // clean up - if (symbol.memberOf.match(/[.#-]$/)) { - symbol.memberOf = symbol.memberOf.substr(0, symbol.memberOf.length-1); - } - // add to parent's methods or properties list - if (symbol.memberOf) { - - var container = this.getSymbol(symbol.memberOf); - if (!container) { - if (JSDOC.Lang.isBuiltin(symbol.memberOf)) container = JSDOC.Parser.addBuiltin(symbol.memberOf); - else { - LOG.warn("Trying to document "+symbol.name +" as a member of undocumented symbol "+symbol.memberOf+"."); - } - } - - if (container) container.addMember(symbol); - } - } -} - -JSDOC.SymbolSet.prototype.resolveAugments = function() { - for (var p = this._index.first(); p; p = this._index.next()) { - var symbol = p.value; - - if (symbol.alias == "_global_" || symbol.is("FILE")) continue; - JSDOC.SymbolSet.prototype.walk.apply(this, [symbol]); - } -} - -JSDOC.SymbolSet.prototype.walk = function(symbol) { - var augments = symbol.augments; - for(var i = 0; i < augments.length; i++) { - var contributer = this.getSymbol(augments[i]); - if (!contributer && JSDOC.Lang.isBuiltin(''+augments[i])) { - contributer = new JSDOC.Symbol("_global_."+augments[i], [], augments[i], new JSDOC.DocComment("Built in.")); - contributer.isNamespace = true; - contributer.srcFile = ""; - contributer.isPrivate = false; - JSDOC.Parser.addSymbol(contributer); - } - - if (contributer) { - if (contributer.augments.length) { - JSDOC.SymbolSet.prototype.walk.apply(this, [contributer]); - } - - symbol.inheritsFrom.push(contributer.alias); - //if (!isUnique(symbol.inheritsFrom)) { - // LOG.warn("Can't resolve augments: Circular reference: "+symbol.alias+" inherits from "+contributer.alias+" more than once."); - //} - //else { - var cmethods = contributer.methods; - var cproperties = contributer.properties; - - for (var ci = 0, cl = cmethods.length; ci < cl; ci++) { - if (!cmethods[ci].isStatic) symbol.inherit(cmethods[ci]); - } - for (var ci = 0, cl = cproperties.length; ci < cl; ci++) { - if (!cproperties[ci].isStatic) symbol.inherit(cproperties[ci]); - } - //} - } - else LOG.warn("Can't augment contributer: "+augments[i]+", not found."); - } -} diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/TextStream.js b/utils/jsdoc-toolkit/app/lib/JSDOC/TextStream.js deleted file mode 100755 index ccc48a8..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +++ /dev/null @@ -1,41 +0,0 @@ - -/** - @constructor -*/ -JSDOC.TextStream = function(text) { - if (typeof(text) == "undefined") text = ""; - text = ""+text; - this.text = text; - this.cursor = 0; -} - -JSDOC.TextStream.prototype.look = function(n) { - if (typeof n == "undefined") n = 0; - - if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { - var result = new String(""); - result.eof = true; - return result; - } - return this.text.charAt(this.cursor+n); -} - -JSDOC.TextStream.prototype.next = function(n) { - if (typeof n == "undefined") n = 1; - if (n < 1) return null; - - var pulled = ""; - for (var i = 0; i < n; i++) { - if (this.cursor+i < this.text.length) { - pulled += this.text.charAt(this.cursor+i); - } - else { - var result = new String(""); - result.eof = true; - return result; - } - } - - this.cursor += n; - return pulled; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/Token.js b/utils/jsdoc-toolkit/app/lib/JSDOC/Token.js deleted file mode 100755 index fb7f9d9..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/Token.js +++ /dev/null @@ -1,18 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - @constructor -*/ -JSDOC.Token = function(data, type, name) { - this.data = data; - this.type = type; - this.name = name; -} - -JSDOC.Token.prototype.toString = function() { - return "<"+this.type+" name=\""+this.name+"\">"+this.data+""; -} - -JSDOC.Token.prototype.is = function(what) { - return this.name === what || this.type === what; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js b/utils/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js deleted file mode 100755 index 9f658fb..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +++ /dev/null @@ -1,332 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - @class Search a {@link JSDOC.TextStream} for language tokens. -*/ -JSDOC.TokenReader = function() { - this.keepDocs = true; - this.keepWhite = false; - this.keepComments = false; -} - -/** - @type {JSDOC.Token[]} - */ -JSDOC.TokenReader.prototype.tokenize = function(/**JSDOC.TextStream*/stream) { - var tokens = []; - /**@ignore*/ tokens.last = function() { return tokens[tokens.length-1]; } - /**@ignore*/ tokens.lastSym = function() { - for (var i = tokens.length-1; i >= 0; i--) { - if (!(tokens[i].is("WHIT") || tokens[i].is("COMM"))) return tokens[i]; - } - } - - while (!stream.look().eof) { - if (this.read_mlcomment(stream, tokens)) continue; - if (this.read_slcomment(stream, tokens)) continue; - if (this.read_dbquote(stream, tokens)) continue; - if (this.read_snquote(stream, tokens)) continue; - if (this.read_regx(stream, tokens)) continue; - if (this.read_numb(stream, tokens)) continue; - if (this.read_punc(stream, tokens)) continue; - if (this.read_newline(stream, tokens)) continue; - if (this.read_space(stream, tokens)) continue; - if (this.read_word(stream, tokens)) continue; - - // if execution reaches here then an error has happened - tokens.push(new JSDOC.Token(stream.next(), "TOKN", "UNKNOWN_TOKEN")); - } - return tokens; -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_word = function(/**JSDOC.TokenStream*/stream, tokens) { - var found = ""; - while (!stream.look().eof && JSDOC.Lang.isWordChar(stream.look())) { - found += stream.next(); - } - - if (found === "") { - return false; - } - else { - var name; - if ((name = JSDOC.Lang.keyword(found))) tokens.push(new JSDOC.Token(found, "KEYW", name)); - else tokens.push(new JSDOC.Token(found, "NAME", "NAME")); - return true; - } -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_punc = function(/**JSDOC.TokenStream*/stream, tokens) { - var found = ""; - var name; - while (!stream.look().eof && JSDOC.Lang.punc(found+stream.look())) { - found += stream.next(); - } - - if (found === "") { - return false; - } - else { - tokens.push(new JSDOC.Token(found, "PUNC", JSDOC.Lang.punc(found))); - return true; - } -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_space = function(/**JSDOC.TokenStream*/stream, tokens) { - var found = ""; - - while (!stream.look().eof && JSDOC.Lang.isSpace(stream.look())) { - found += stream.next(); - } - - if (found === "") { - return false; - } - else { - if (this.collapseWhite) found = " "; - if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "SPACE")); - return true; - } -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_newline = function(/**JSDOC.TokenStream*/stream, tokens) { - var found = ""; - - while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())) { - found += stream.next(); - } - - if (found === "") { - return false; - } - else { - if (this.collapseWhite) found = "\n"; - if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "NEWLINE")); - return true; - } -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_mlcomment = function(/**JSDOC.TokenStream*/stream, tokens) { - if (stream.look() == "/" && stream.look(1) == "*") { - var found = stream.next(2); - - while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) { - found += stream.next(); - } - - // to start doclet we allow /** or /*** but not /**/ or /**** - if (/^\/\*\*([^\/]|\*[^*])/.test(found) && this.keepDocs) tokens.push(new JSDOC.Token(found, "COMM", "JSDOC")); - else if (this.keepComments) tokens.push(new JSDOC.Token(found, "COMM", "MULTI_LINE_COMM")); - return true; - } - return false; -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_slcomment = function(/**JSDOC.TokenStream*/stream, tokens) { - var found; - if ( - (stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2))) - || - (stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4))) - ) { - - while (!stream.look().eof && !JSDOC.Lang.isNewline(stream.look())) { - found += stream.next(); - } - - if (this.keepComments) { - tokens.push(new JSDOC.Token(found, "COMM", "SINGLE_LINE_COMM")); - } - return true; - } - return false; -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_dbquote = function(/**JSDOC.TokenStream*/stream, tokens) { - if (stream.look() == "\"") { - // find terminator - var string = stream.next(); - - while (!stream.look().eof) { - if (stream.look() == "\\") { - if (JSDOC.Lang.isNewline(stream.look(1))) { - do { - stream.next(); - } while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())); - string += "\\\n"; - } - else { - string += stream.next(2); - } - } - else if (stream.look() == "\"") { - string += stream.next(); - tokens.push(new JSDOC.Token(string, "STRN", "DOUBLE_QUOTE")); - return true; - } - else { - string += stream.next(); - } - } - } - return false; // error! unterminated string -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_snquote = function(/**JSDOC.TokenStream*/stream, tokens) { - if (stream.look() == "'") { - // find terminator - var string = stream.next(); - - while (!stream.look().eof) { - if (stream.look() == "\\") { // escape sequence - string += stream.next(2); - } - else if (stream.look() == "'") { - string += stream.next(); - tokens.push(new JSDOC.Token(string, "STRN", "SINGLE_QUOTE")); - return true; - } - else { - string += stream.next(); - } - } - } - return false; // error! unterminated string -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_numb = function(/**JSDOC.TokenStream*/stream, tokens) { - if (stream.look() === "0" && stream.look(1) == "x") { - return this.read_hex(stream, tokens); - } - - var found = ""; - - while (!stream.look().eof && JSDOC.Lang.isNumber(found+stream.look())){ - found += stream.next(); - } - - if (found === "") { - return false; - } - else { - if (/^0[0-7]/.test(found)) tokens.push(new JSDOC.Token(found, "NUMB", "OCTAL")); - else tokens.push(new JSDOC.Token(found, "NUMB", "DECIMAL")); - return true; - } -} -/*t: - requires("../lib/JSDOC/TextStream.js"); - requires("../lib/JSDOC/Token.js"); - requires("../lib/JSDOC/Lang.js"); - - plan(3, "testing JSDOC.TokenReader.prototype.read_numb"); - - //// setup - var src = "function foo(num){while (num+8.0 >= 0x20 && num < 0777){}}"; - var tr = new JSDOC.TokenReader(); - var tokens = tr.tokenize(new JSDOC.TextStream(src)); - - var hexToken, octToken, decToken; - for (var i = 0; i < tokens.length; i++) { - if (tokens[i].name == "HEX_DEC") hexToken = tokens[i]; - if (tokens[i].name == "OCTAL") octToken = tokens[i]; - if (tokens[i].name == "DECIMAL") decToken = tokens[i]; - } - //// - - is(decToken.data, "8.0", "decimal number is found in source."); - is(hexToken.data, "0x20", "hexdec number is found in source (issue #99)."); - is(octToken.data, "0777", "octal number is found in source."); -*/ - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_hex = function(/**JSDOC.TokenStream*/stream, tokens) { - var found = stream.next(2); - - while (!stream.look().eof) { - if (JSDOC.Lang.isHexDec(found) && !JSDOC.Lang.isHexDec(found+stream.look())) { // done - tokens.push(new JSDOC.Token(found, "NUMB", "HEX_DEC")); - return true; - } - else { - found += stream.next(); - } - } - return false; -} - -/** - @returns {Boolean} Was the token found? - */ -JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/stream, tokens) { - var last; - if ( - stream.look() == "/" - && - ( - - ( - !(last = tokens.lastSym()) // there is no last, the regex is the first symbol - || - ( - !last.is("NUMB") - && !last.is("NAME") - && !last.is("RIGHT_PAREN") - && !last.is("RIGHT_BRACKET") - ) - ) - ) - ) { - var regex = stream.next(); - - while (!stream.look().eof) { - if (stream.look() == "\\") { // escape sequence - regex += stream.next(2); - } - else if (stream.look() == "/") { - regex += stream.next(); - - while (/[gmi]/.test(stream.look())) { - regex += stream.next(); - } - - tokens.push(new JSDOC.Token(regex, "REGX", "REGX")); - return true; - } - else { - regex += stream.next(); - } - } - // error: unterminated regex - } - return false; -} diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js b/utils/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js deleted file mode 100755 index 1eeb44c..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +++ /dev/null @@ -1,133 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** - @constructor -*/ -JSDOC.TokenStream = function(tokens) { - this.tokens = (tokens || []); - this.rewind(); -} - -/** - @constructor - @private -*/ -function VoidToken(/**String*/type) { - this.toString = function() {return ""}; - this.is = function(){return false;} -} - -JSDOC.TokenStream.prototype.rewind = function() { - this.cursor = -1; -} - -/** - @type JSDOC.Token -*/ -JSDOC.TokenStream.prototype.look = function(/**Number*/n, /**Boolean*/considerWhitespace) { - if (typeof n == "undefined") n = 0; - - if (considerWhitespace == true) { - if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {}; - return this.tokens[this.cursor+n]; - } - else { - var count = 0; - var i = this.cursor; - - while (true) { - if (i < 0) return new JSDOC.Token("", "VOID", "START_OF_STREAM"); - else if (i > this.tokens.length) return new JSDOC.Token("", "VOID", "END_OF_STREAM"); - - if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT"))) { - if (n < 0) i--; else i++; - continue; - } - - if (count == Math.abs(n)) { - return this.tokens[i]; - } - count++; - (n < 0)? i-- : i++; - } - - return new JSDOC.Token("", "VOID", "STREAM_ERROR"); // because null isn't an object and caller always expects an object - } -} - -/** - @type JSDOC.Token|JSDOC.Token[] -*/ -JSDOC.TokenStream.prototype.next = function(/**Number*/howMany) { - if (typeof howMany == "undefined") howMany = 1; - if (howMany < 1) return null; - var got = []; - - for (var i = 1; i <= howMany; i++) { - if (this.cursor+i >= this.tokens.length) { - return null; - } - got.push(this.tokens[this.cursor+i]); - } - this.cursor += howMany; - - if (howMany == 1) { - return got[0]; - } - else return got; -} - -/** - @type JSDOC.Token[] -*/ -JSDOC.TokenStream.prototype.balance = function(/**String*/start, /**String*/stop) { - if (!stop) stop = JSDOC.Lang.matching(start); - - var depth = 0; - var got = []; - var started = false; - - while ((token = this.look())) { - if (token.is(start)) { - depth++; - started = true; - } - - if (started) { - got.push(token); - } - - if (token.is(stop)) { - depth--; - if (depth == 0) return got; - } - if (!this.next()) break; - } -} - -JSDOC.TokenStream.prototype.getMatchingToken = function(/**String*/start, /**String*/stop) { - var depth = 0; - var cursor = this.cursor; - - if (!start) { - start = JSDOC.Lang.matching(stop); - depth = 1; - } - if (!stop) stop = JSDOC.Lang.matching(start); - - while ((token = this.tokens[cursor])) { - if (token.is(start)) { - depth++; - } - - if (token.is(stop) && cursor) { - depth--; - if (depth == 0) return this.tokens[cursor]; - } - cursor++; - } -} - -JSDOC.TokenStream.prototype.insertAhead = function(/**JSDOC.Token*/token) { - this.tokens.splice(this.cursor+1, 0, token); -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/Util.js b/utils/jsdoc-toolkit/app/lib/JSDOC/Util.js deleted file mode 100755 index 6d7edb3..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/Util.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @namespace - * @deprecated Use {@link FilePath} instead. - */ -JSDOC.Util = { -} - -/** - * @deprecated Use {@link FilePath.fileName} instead. - */ -JSDOC.Util.fileName = function(path) { - LOG.warn("JSDOC.Util.fileName is deprecated. Use FilePath.fileName instead."); - var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); - return path.substring(nameStart); -} - -/** - * @deprecated Use {@link FilePath.fileExtension} instead. - */ -JSDOC.Util.fileExtension = function(filename) { - LOG.warn("JSDOC.Util.fileExtension is deprecated. Use FilePath.fileExtension instead."); - return filename.split(".").pop().toLowerCase(); -}; - -/** - * @deprecated Use {@link FilePath.dir} instead. - */ -JSDOC.Util.dir = function(path) { - LOG.warn("JSDOC.Util.dir is deprecated. Use FilePath.dir instead."); - var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); - return path.substring(0, nameStart-1); -} diff --git a/utils/jsdoc-toolkit/app/lib/JSDOC/Walker.js b/utils/jsdoc-toolkit/app/lib/JSDOC/Walker.js deleted file mode 100755 index befec4d..0000000 --- a/utils/jsdoc-toolkit/app/lib/JSDOC/Walker.js +++ /dev/null @@ -1,474 +0,0 @@ -if (typeof JSDOC == "undefined") JSDOC = {}; - -/** @constructor */ -JSDOC.Walker = function(/**JSDOC.TokenStream*/ts) { - this.init(); - if (typeof ts != "undefined") { - this.walk(ts); - } -} - -JSDOC.Walker.prototype.init = function() { - this.ts = null; - - var globalSymbol = new JSDOC.Symbol("_global_", [], "GLOBAL", new JSDOC.DocComment("")); - globalSymbol.isNamespace = true; - globalSymbol.srcFile = ""; - globalSymbol.isPrivate = false; - JSDOC.Parser.addSymbol(globalSymbol); - this.lastDoc = null; - this.token = null; - - /** - The chain of symbols under which we are currently nested. - @type Array - */ - this.namescope = [globalSymbol]; - this.namescope.last = function(n){ if (!n) n = 0; return this[this.length-(1+n)] || "" }; -} - -JSDOC.Walker.prototype.walk = function(/**JSDOC.TokenStream*/ts) { - this.ts = ts; - while (this.token = this.ts.look()) { - if (this.token.popNamescope) { - - var symbol = this.namescope.pop(); - if (symbol.is("FUNCTION")) { - if (this.ts.look(1).is("LEFT_PAREN") && symbol.comment.getTag("function").length == 0) { - symbol.isa = "OBJECT"; - } - } - } - this.step(); - if (!this.ts.next()) break; - } -} - -JSDOC.Walker.prototype.step = function() { - if (this.token.is("JSDOC")) { // it's a doc comment - - var doc = new JSDOC.DocComment(this.token.data); - - - if (doc.getTag("exports").length > 0) { - var exports = doc.getTag("exports")[0]; - - exports.desc.match(/(\S+) as (\S+)/i); - var n1 = RegExp.$1; - var n2 = RegExp.$2; - - if (!n1 && n2) throw "@exports tag requires a value like: 'name as ns.name'"; - - JSDOC.Parser.rename = (JSDOC.Parser.rename || {}); - JSDOC.Parser.rename[n1] = n2 - } - - if (doc.getTag("lends").length > 0) { - var lends = doc.getTag("lends")[0]; - - var name = lends.desc - if (!name) throw "@lends tag requires a value."; - - var symbol = new JSDOC.Symbol(name, [], "OBJECT", doc); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - - this.lastDoc = null; - return true; - } - else if (doc.getTag("name").length > 0 && doc.getTag("overview").length == 0) { // it's a virtual symbol - var virtualName = doc.getTag("name")[0].desc; - if (!virtualName) throw "@name tag requires a value."; - - var symbol = new JSDOC.Symbol(virtualName, [], "VIRTUAL", doc); - - JSDOC.Parser.addSymbol(symbol); - - this.lastDoc = null; - return true; - } - else if (doc.meta) { // it's a meta doclet - if (doc.meta == "@+") JSDOC.DocComment.shared = doc.src; - else if (doc.meta == "@-") JSDOC.DocComment.shared = ""; - else if (doc.meta == "nocode+") JSDOC.Parser.conf.ignoreCode = true; - else if (doc.meta == "nocode-") JSDOC.Parser.conf.ignoreCode = JSDOC.opt.n; - else throw "Unrecognized meta comment: "+doc.meta; - - this.lastDoc = null; - return true; - } - else if (doc.getTag("overview").length > 0) { // it's a file overview - symbol = new JSDOC.Symbol("", [], "FILE", doc); - - JSDOC.Parser.addSymbol(symbol); - - this.lastDoc = null; - return true; - } - else { - this.lastDoc = doc; - return false; - } - } - else if (!JSDOC.Parser.conf.ignoreCode) { // it's code - if (this.token.is("NAME")) { // it's the name of something - var symbol; - var name = this.token.data; - var doc = null; if (this.lastDoc) doc = this.lastDoc; - var params = []; - - // it's inside an anonymous object - if (this.ts.look(1).is("COLON") && this.ts.look(-1).is("LEFT_CURLY") && !(this.ts.look(-2).is("JSDOC") || this.namescope.last().comment.getTag("lends").length || this.ts.look(-2).is("ASSIGN") || this.ts.look(-2).is("COLON"))) { - name = "$anonymous"; - name = this.namescope.last().alias+"-"+name - - params = []; - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - - JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken(null, "RIGHT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // function foo() {} - else if (this.ts.look(-1).is("FUNCTION") && this.ts.look(1).is("LEFT_PAREN")) { - var isInner; - - if (this.lastDoc) doc = this.lastDoc; - name = this.namescope.last().alias+"-"+name; - if (!this.namescope.last().is("GLOBAL")) isInner = true; - - params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN")); - - symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc); - if (isInner) symbol.isInner = true; - - if (this.ts.look(1).is("JSDOC")) { - var inlineReturn = ""+this.ts.look(1).data; - inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, ""); - symbol.type = inlineReturn; - } - - JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // foo = function() {} - else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("FUNCTION")) { - var isInner; - if (this.ts.look(-1).is("VAR") || this.isInner) { - name = this.namescope.last().alias+"-"+name - if (!this.namescope.last().is("GLOBAL")) isInner = true; - } - else if (name.indexOf("this.") == 0) { - name = this.resolveThis(name); - } - - if (this.lastDoc) doc = this.lastDoc; - params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN")); - - symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc); - if (isInner) symbol.isInner = true; - - if (this.ts.look(1).is("JSDOC")) { - var inlineReturn = ""+this.ts.look(1).data; - inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, ""); - symbol.type = inlineReturn; - } - - JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // foo = new function() {} or foo = (function() {} - else if (this.ts.look(1).is("ASSIGN") && (this.ts.look(2).is("NEW") || this.ts.look(2).is("LEFT_PAREN")) && this.ts.look(3).is("FUNCTION")) { - var isInner; - if (this.ts.look(-1).is("VAR") || this.isInner) { - name = this.namescope.last().alias+"-"+name - if (!this.namescope.last().is("GLOBAL")) isInner = true; - } - else if (name.indexOf("this.") == 0) { - name = this.resolveThis(name); - } - - this.ts.next(3); // advance past the "new" or "(" - - if (this.lastDoc) doc = this.lastDoc; - params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN")); - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - if (isInner) symbol.isInner = true; - - if (this.ts.look(1).is("JSDOC")) { - var inlineReturn = ""+this.ts.look(1).data; - inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, ""); - symbol.type = inlineReturn; - } - - JSDOC.Parser.addSymbol(symbol); - - symbol.scopeType = "INSTANCE"; - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // foo: function() {} - else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("FUNCTION")) { - name = (this.namescope.last().alias+"."+name).replace("#.", "#"); - - if (this.lastDoc) doc = this.lastDoc; - params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN")); - - if (doc && doc.getTag("constructs").length) { - name = name.replace(/\.prototype(\.|$)/, "#"); - - if (name.indexOf("#") > -1) name = name.match(/(^[^#]+)/)[0]; - else name = this.namescope.last().alias; - - symbol = new JSDOC.Symbol(name, params, "CONSTRUCTOR", doc); - } - else { - symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc); - } - - if (this.ts.look(1).is("JSDOC")) { - var inlineReturn = ""+this.ts.look(1).data; - inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, ""); - symbol.type = inlineReturn; - } - - JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // foo = {} - else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("LEFT_CURLY")) { - var isInner; - if (this.ts.look(-1).is("VAR") || this.isInner) { - name = this.namescope.last().alias+"-"+name - if (!this.namescope.last().is("GLOBAL")) isInner = true; - } - else if (name.indexOf("this.") == 0) { - name = this.resolveThis(name); - } - - if (this.lastDoc) doc = this.lastDoc; - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - if (isInner) symbol.isInner = true; - - - if (doc) JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // var foo; - else if (this.ts.look(1).is("SEMICOLON")) { - var isInner; - - if (this.ts.look(-1).is("VAR") || this.isInner) { - name = this.namescope.last().alias+"-"+name - if (!this.namescope.last().is("GLOBAL")) isInner = true; - - if (this.lastDoc) doc = this.lastDoc; - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - if (isInner) symbol.isInner = true; - - - if (doc) JSDOC.Parser.addSymbol(symbol); - } - } - // foo = x - else if (this.ts.look(1).is("ASSIGN")) { - var isInner; - if (this.ts.look(-1).is("VAR") || this.isInner) { - name = this.namescope.last().alias+"-"+name - if (!this.namescope.last().is("GLOBAL")) isInner = true; - } - else if (name.indexOf("this.") == 0) { - name = this.resolveThis(name); - } - - if (this.lastDoc) doc = this.lastDoc; - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - if (isInner) symbol.isInner = true; - - - if (doc) JSDOC.Parser.addSymbol(symbol); - } - // foo: {} - else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("LEFT_CURLY")) { - name = (this.namescope.last().alias+"."+name).replace("#.", "#"); - - if (this.lastDoc) doc = this.lastDoc; - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - - - if (doc) JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - // foo: x - else if (this.ts.look(1).is("COLON")) { - name = (this.namescope.last().alias+"."+name).replace("#.", "#");; - - if (this.lastDoc) doc = this.lastDoc; - - symbol = new JSDOC.Symbol(name, params, "OBJECT", doc); - - - if (doc) JSDOC.Parser.addSymbol(symbol); - } - // foo(...) - else if (this.ts.look(1).is("LEFT_PAREN")) { - if (typeof JSDOC.PluginManager != "undefined") { - var functionCall = {name: name}; - - var cursor = this.ts.cursor; - params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN")); - this.ts.cursor = cursor; - - for (var i = 0; i < params.length; i++) - functionCall["arg" + (i + 1)] = params[i].name; - - JSDOC.PluginManager.run("onFunctionCall", functionCall); - if (functionCall.doc) { - this.ts.insertAhead(new JSDOC.Token(functionCall.doc, "COMM", "JSDOC")); - } - } - } - this.lastDoc = null; - } - else if (this.token.is("FUNCTION")) { // it's an anonymous function - if ( - (!this.ts.look(-1).is("COLON") || !this.ts.look(-1).is("ASSIGN")) - && !this.ts.look(1).is("NAME") - ) { - if (this.lastDoc) doc = this.lastDoc; - - name = "$anonymous"; - name = this.namescope.last().alias+"-"+name - - params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN")); - - symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc); - - JSDOC.Parser.addSymbol(symbol); - - this.namescope.push(symbol); - - var matching = this.ts.getMatchingToken("LEFT_CURLY"); - if (matching) matching.popNamescope = name; - else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + "."); - } - } - } - return true; -} - -/** - Resolves what "this." means when it appears in a name. - @param name The name that starts with "this.". - @returns The name with "this." resolved. - */ -JSDOC.Walker.prototype.resolveThis = function(name) { - name.match(/^this\.(.+)$/) - var nameFragment = RegExp.$1; - if (!nameFragment) return name; - - var symbol = this.namescope.last(); - var scopeType = symbol.scopeType || symbol.isa; - - // if we are in a constructor function, `this` means the instance - if (scopeType == "CONSTRUCTOR") { - name = symbol.alias+"#"+nameFragment; - } - - // if we are in an anonymous constructor function, `this` means the instance - else if (scopeType == "INSTANCE") { - name = symbol.alias+"."+nameFragment; - } - - // if we are in a function, `this` means the container (possibly the global) - else if (scopeType == "FUNCTION") { - // in a method of a prototype, so `this` means the constructor - if (symbol.alias.match(/(^.*)[#.-][^#.-]+/)) { - var parentName = RegExp.$1; - var parent = JSDOC.Parser.symbols.getSymbol(parentName); - - if (!parent) { - if (JSDOC.Lang.isBuiltin(parentName)) parent = JSDOC.Parser.addBuiltin(parentName); - else { - if (symbol.alias.indexOf("$anonymous") < 0) // these will be ignored eventually - LOG.warn("Trying to document "+symbol.alias+" without first documenting "+parentName+"."); - } - } - if (parent) name = parentName+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment; - } - else { - parent = this.namescope.last(1); - name = parent.alias+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment; - } - } - // otherwise it means the global - else { - name = nameFragment; - } - - return name; -} - -JSDOC.Walker.onParamList = function(/**Array*/paramTokens) { - if (!paramTokens) { - LOG.warn("Malformed parameter list. Can't parse code."); - return []; - } - var params = []; - for (var i = 0, l = paramTokens.length; i < l; i++) { - if (paramTokens[i].is("JSDOC")) { - var paramType = paramTokens[i].data.replace(/(^\/\*\* *| *\*\/$)/g, ""); - - if (paramTokens[i+1] && paramTokens[i+1].is("NAME")) { - i++; - params.push({type: paramType, name: paramTokens[i].data}); - } - } - else if (paramTokens[i].is("NAME")) { - params.push({name: paramTokens[i].data}); - } - } - return params; -} diff --git a/utils/jsdoc-toolkit/app/main.js b/utils/jsdoc-toolkit/app/main.js deleted file mode 100755 index 9b78182..0000000 --- a/utils/jsdoc-toolkit/app/main.js +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @version $Id: main.js 795 2009-06-19 07:03:22Z micmath $ - */ - -function main() { - IO.include("lib/JSDOC.js"); - IO.includeDir("plugins/"); - - // process the options - - // the -c option: options are defined in a configuration file - if (JSDOC.opt.c) { - eval("JSDOC.conf = " + IO.readFile(JSDOC.opt.c)); - - LOG.inform("Using configuration file at '"+JSDOC.opt.c+"'."); - - for (var c in JSDOC.conf) { - if (c !== "D" && !defined(JSDOC.opt[c])) { // commandline overrules config file - JSDOC.opt[c] = JSDOC.conf[c]; - } - } - - if (typeof JSDOC.conf["_"] != "undefined") { - JSDOC.opt["_"] = JSDOC.opt["_"].concat(JSDOC.conf["_"]); - } - - LOG.inform("With configuration: "); - for (var o in JSDOC.opt) { - LOG.inform(" "+o+": "+JSDOC.opt[o]); - } - } - - // be verbose - if (JSDOC.opt.v) LOG.verbose = true; - - // send log messages to a file - if (JSDOC.opt.o) LOG.out = IO.open(JSDOC.opt.o); - - // run the unit tests - if (JSDOC.opt.T) { - LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+"."); - IO.include("frame/Testrun.js"); - IO.include("test.js"); - } - else { - // a template must be defined and must be a directory path - if (!JSDOC.opt.t && System.getProperty("jsdoc.template.dir")) { - JSDOC.opt.t = System.getProperty("jsdoc.template.dir"); - } - if (JSDOC.opt.t && !JSDOC.opt.t.charAt(JSDOC.opt.t.length-1).match(/[\\\/]/)) { - JSDOC.opt.t += SYS.slash; - } - - // verbose messages about the options we were given - LOG.inform("JsDoc Toolkit main() running at "+new Date()+"."); - LOG.inform("With options: "); - for (var o in JSDOC.opt) { - LOG.inform(" "+o+": "+JSDOC.opt[o]); - } - - // initialize and build a symbolSet from your code - JSDOC.JsDoc(); - - // debugger's option: dump the entire symbolSet produced from your code - if (JSDOC.opt.Z) { - LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs..."); - IO.include("frame/Dumper.js"); - var symbols = JSDOC.JsDoc.symbolSet.toArray(); - for (var i = 0, l = symbols.length; i < l; i++) { - var symbol = symbols[i]; - print("// symbol: " + symbol.alias); - print(symbol.serialize()); - } - } - else { - if (typeof JSDOC.opt.t != "undefined") { - try { - // a file named "publish.js" must exist in the template directory - load(JSDOC.opt.t+"publish.js"); - - // and must define a function named "publish" - if (!publish) { - LOG.warn("No publish() function is defined in that template so nothing to do."); - } - else { - // which will be called with the symbolSet produced from your code - publish(JSDOC.JsDoc.symbolSet); - } - } - catch(e) { - LOG.warn("Sorry, that doesn't seem to be a valid template: "+JSDOC.opt.t+"publish.js : "+e); - } - } - else { - LOG.warn("No template given. Might as well read the usage notes."); - JSDOC.usage(); - } - } - } - - // notify of any warnings - if (!JSDOC.opt.q && LOG.warnings.length) { - print(LOG.warnings.length+" warning"+(LOG.warnings.length != 1? "s":"")+"."); - } - - // stop sending log messages to a file - if (LOG.out) { - LOG.out.flush(); - LOG.out.close(); - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/plugins/commentSrcJson.js b/utils/jsdoc-toolkit/app/plugins/commentSrcJson.js deleted file mode 100755 index e826b57..0000000 --- a/utils/jsdoc-toolkit/app/plugins/commentSrcJson.js +++ /dev/null @@ -1,20 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.commentSrcJson", - { - onDocCommentSrc: function(comment) { - var json; - if (/^\s*@json\b/.test(comment)) { - comment.src = new String(comment.src).replace("@json", ""); - - eval("json = "+comment.src); - var tagged = ""; - for (var i in json) { - var tag = json[i]; - // todo handle cases where tag is an object - tagged += "@"+i+" "+tag+"\n"; - } - comment.src = tagged; - } - } - } -); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/plugins/frameworkPrototype.js b/utils/jsdoc-toolkit/app/plugins/frameworkPrototype.js deleted file mode 100755 index 9c41751..0000000 --- a/utils/jsdoc-toolkit/app/plugins/frameworkPrototype.js +++ /dev/null @@ -1,16 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.frameworkPrototype", - { - onPrototypeClassCreate: function(classCreator) { - var desc = ""; - if (classCreator.comment) { - desc = classCreator.comment; - } - var insert = desc+"/** @name "+classCreator.name+"\n@constructor\n@scope "+classCreator.name+".prototype */" - - insert = insert.replace(/\*\/\/\*\*/g, "\n"); - /*DEBUG*///print("insert is "+insert); - classCreator.addComment.data = insert; - } - } -); diff --git a/utils/jsdoc-toolkit/app/plugins/functionCall.js b/utils/jsdoc-toolkit/app/plugins/functionCall.js deleted file mode 100755 index 6f87705..0000000 --- a/utils/jsdoc-toolkit/app/plugins/functionCall.js +++ /dev/null @@ -1,10 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.functionCall", - { - onFunctionCall: function(functionCall) { - if (functionCall.name == "dojo.define" && functionCall.arg1) { - functionCall.doc = "/** @lends "+eval(functionCall.arg1)+".prototype */"; - } - } - } -); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/plugins/publishSrcHilite.js b/utils/jsdoc-toolkit/app/plugins/publishSrcHilite.js deleted file mode 100755 index 65514f2..0000000 --- a/utils/jsdoc-toolkit/app/plugins/publishSrcHilite.js +++ /dev/null @@ -1,62 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.publishSrcHilite", - { - onPublishSrc: function(src) { - if (src.path in JsHilite.cache) { - return; // already generated src code - } - else JsHilite.cache[src.path] = true; - - try { - var sourceCode = IO.readFile(src.path); - } - catch(e) { - print(e.message); - quit(); - } - - var hiliter = new JsHilite(sourceCode, src.charset); - src.hilited = hiliter.hilite(); - } - } -); - -function JsHilite(src, charset) { - - var tr = new JSDOC.TokenReader(); - - tr.keepComments = true; - tr.keepDocs = true; - tr.keepWhite = true; - - this.tokens = tr.tokenize(new JSDOC.TextStream(src)); - - // TODO is redefining toString() the best way? - JSDOC.Token.prototype.toString = function() { - return ""+this.data.replace(/"; - } - - if (!charset) charset = "utf-8"; - - this.header = ' '+ - "

";
-	this.footer = "
"; - this.showLinenumbers = true; -} - -JsHilite.cache = {}; - -JsHilite.prototype.hilite = function() { - var hilited = this.tokens.join(""); - var line = 1; - if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+""+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+" "}); - - return this.header+hilited+this.footer; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/plugins/symbolLink.js b/utils/jsdoc-toolkit/app/plugins/symbolLink.js deleted file mode 100755 index c87f1ca..0000000 --- a/utils/jsdoc-toolkit/app/plugins/symbolLink.js +++ /dev/null @@ -1,10 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.symbolLink", - { - onSymbolLink: function(link) { - // modify link.linkPath (the href part of the link) - // or link.linkText (the text displayed) - // or link.linkInner (the #name part of the link) - } - } -); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/plugins/tagParamConfig.js b/utils/jsdoc-toolkit/app/plugins/tagParamConfig.js deleted file mode 100755 index 3ea8a1b..0000000 --- a/utils/jsdoc-toolkit/app/plugins/tagParamConfig.js +++ /dev/null @@ -1,31 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.tagParamConfig", - { - onDocCommentTags: function(comment) { - var currentParam = null; - var tags = comment.tags; - for (var i = 0, l = tags.length; i < l; i++) { - - if (tags[i].title == "param") { - if (tags[i].name.indexOf(".") == -1) { - currentParam = i; - } - } - else if (tags[i].title == "config") { - tags[i].title = "param"; - if (currentParam == null) { - tags[i].name = "arguments"+"."+tags[i].name; - } - else if (tags[i].name.indexOf(tags[currentParam].name+".") != 0) { - tags[i].name = tags[currentParam].name+"."+tags[i].name; - } - currentParam != null - //tags[currentParam].properties.push(tags[i]); - } - else { - currentParam = null; - } - } - } - } -); diff --git a/utils/jsdoc-toolkit/app/plugins/tagSynonyms.js b/utils/jsdoc-toolkit/app/plugins/tagSynonyms.js deleted file mode 100755 index 49a874f..0000000 --- a/utils/jsdoc-toolkit/app/plugins/tagSynonyms.js +++ /dev/null @@ -1,43 +0,0 @@ -JSDOC.PluginManager.registerPlugin( - "JSDOC.tagSynonyms", - { - onDocCommentSrc: function(comment) { - comment.src = comment.src.replace(/@methodOf\b/i, "@function\n@memberOf"); - comment.src = comment.src.replace(/@fieldOf\b/i, "@field\n@memberOf"); - }, - - onDocCommentTags: function(comment) { - for (var i = 0, l = comment.tags.length; i < l; i++) { - var title = comment.tags[i].title.toLowerCase(); - var syn; - if ((syn = JSDOC.tagSynonyms.synonyms["="+title])) { - comment.tags[i].title = syn; - } - } - } - } -); - -new Namespace( - "JSDOC.tagSynonyms", - function() { - JSDOC.tagSynonyms.synonyms = { - "=member": "memberOf", - "=memberof": "memberOf", - "=description": "desc", - "=exception": "throws", - "=argument": "param", - "=returns": "return", - "=classdescription": "class", - "=fileoverview": "overview", - "=extends": "augments", - "=base": "augments", - "=projectdescription": "overview", - "=classdescription": "class", - "=link": "see", - "=borrows": "inherits", - "=scope": "lends", - "=construct": "constructor" - } - } -); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/run.js b/utils/jsdoc-toolkit/app/run.js deleted file mode 100755 index 1f875cd..0000000 --- a/utils/jsdoc-toolkit/app/run.js +++ /dev/null @@ -1,348 +0,0 @@ -/** - * @fileOverview - * A bootstrap script that creates some basic required objects - * for loading other scripts. - * @author Michael Mathews, micmath@gmail.com - * @version $Id: run.js 756 2009-01-07 21:32:58Z micmath $ - */ - -/** - * @namespace Keep track of any messages from the running script. - */ -LOG = { - warn: function(msg, e) { - if (JSDOC.opt.q) return; - if (e) msg = e.fileName+", line "+e.lineNumber+": "+msg; - - msg = ">> WARNING: "+msg; - LOG.warnings.push(msg); - if (LOG.out) LOG.out.write(msg+"\n"); - else print(msg); - }, - - inform: function(msg) { - if (JSDOC.opt.q) return; - msg = " > "+msg; - if (LOG.out) LOG.out.write(msg+"\n"); - else if (typeof LOG.verbose != "undefined" && LOG.verbose) print(msg); - } -}; -LOG.warnings = []; -LOG.verbose = false -LOG.out = undefined; - -/** - * @class Manipulate a filepath. - */ -function FilePath(absPath, separator) { - this.slash = separator || "/"; - this.root = this.slash; - this.path = []; - this.file = ""; - - var parts = absPath.split(/[\\\/]/); - if (parts) { - if (parts.length) this.root = parts.shift() + this.slash; - if (parts.length) this.file = parts.pop() - if (parts.length) this.path = parts; - } - - this.path = this.resolvePath(); -} - -/** Collapse any dot-dot or dot items in a filepath. */ -FilePath.prototype.resolvePath = function() { - var resolvedPath = []; - for (var i = 0; i < this.path.length; i++) { - if (this.path[i] == "..") resolvedPath.pop(); - else if (this.path[i] != ".") resolvedPath.push(this.path[i]); - } - return resolvedPath; -} - -/** Trim off the filename. */ -FilePath.prototype.toDir = function() { - if (this.file) this.file = ""; - return this; -} - -/** Go up a directory. */ -FilePath.prototype.upDir = function() { - this.toDir(); - if (this.path.length) this.path.pop(); - return this; -} - -FilePath.prototype.toString = function() { - return this.root - + this.path.join(this.slash) - + ((this.path.length > 0)? this.slash : "") - + this.file; -} - -/** - * Turn a path into just the name of the file. - */ -FilePath.fileName = function(path) { - var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); - return path.substring(nameStart); -} - -/** - * Get the extension of a filename - */ -FilePath.fileExtension = function(filename) { - return filename.split(".").pop().toLowerCase(); -}; - -/** - * Turn a path into just the directory part. - */ -FilePath.dir = function(path) { - var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); - return path.substring(0, nameStart-1); -} - - -importClass(java.lang.System); - -/** - * @namespace A collection of information about your system. - */ -SYS = { - /** - * Information about your operating system: arch, name, version. - * @type string - */ - os: [ - new String(System.getProperty("os.arch")), - new String(System.getProperty("os.name")), - new String(System.getProperty("os.version")) - ].join(", "), - - /** - * Which way does your slash lean. - * @type string - */ - slash: System.getProperty("file.separator")||"/", - - /** - * The path to the working directory where you ran java. - * @type string - */ - userDir: new String(System.getProperty("user.dir")), - - /** - * Where is Java's home folder. - * @type string - */ - javaHome: new String(System.getProperty("java.home")), - - /** - * The absolute path to the directory containing this script. - * @type string - */ - pwd: undefined -}; - -// jsrun appends an argument, with the path to here. -if (arguments[arguments.length-1].match(/^-j=(.+)/)) { - if (RegExp.$1.charAt(0) == SYS.slash || RegExp.$1.charAt(1) == ":") { // absolute path to here - SYS.pwd = new FilePath(RegExp.$1).toDir().toString(); - } - else { // relative path to here - SYS.pwd = new FilePath(SYS.userDir + SYS.slash + RegExp.$1).toDir().toString(); - } - arguments.pop(); -} -else { - print("The run.js script requires you use jsrun.jar."); - quit(); -} - -// shortcut -var File = Packages.java.io.File; - -/** - * @namespace A collection of functions that deal with reading a writing to disk. - */ -IO = { - - /** - * Create a new file in the given directory, with the given name and contents. - */ - saveFile: function(/**string*/ outDir, /**string*/ fileName, /**string*/ content) { - var out = new Packages.java.io.PrintWriter( - new Packages.java.io.OutputStreamWriter( - new Packages.java.io.FileOutputStream(outDir+SYS.slash+fileName), - IO.encoding - ) - ); - out.write(content); - out.flush(); - out.close(); - }, - - /** - * @type string - */ - readFile: function(/**string*/ path) { - if (!IO.exists(path)) { - throw "File doesn't exist there: "+path; - } - return readFile(path, IO.encoding); - }, - - /** - * @param inFile - * @param outDir - * @param [fileName=The original filename] - */ - copyFile: function(/**string*/ inFile, /**string*/ outDir, /**string*/ fileName) { - if (fileName == null) fileName = FilePath.fileName(inFile); - - var inFile = new File(inFile); - var outFile = new File(outDir+SYS.slash+fileName); - - var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096); - var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096); - var theChar; - while ((theChar = bis.read()) != -1) { - bos.write(theChar); - } - bos.close(); - bis.close(); - }, - - /** - * Creates a series of nested directories. - */ - mkPath: function(/**Array*/ path) { - if (path.constructor != Array) path = path.split(/[\\\/]/); - var make = ""; - for (var i = 0, l = path.length; i < l; i++) { - make += path[i] + SYS.slash; - if (! IO.exists(make)) { - IO.makeDir(make); - } - } - }, - - /** - * Creates a directory at the given path. - */ - makeDir: function(/**string*/ path) { - (new File(path)).mkdir(); - }, - - /** - * @type string[] - * @param dir The starting directory to look in. - * @param [recurse=1] How many levels deep to scan. - * @returns An array of all the paths to files in the given dir. - */ - ls: function(/**string*/ dir, /**number*/ recurse, _allFiles, _path) { - if (_path === undefined) { // initially - var _allFiles = []; - var _path = [dir]; - } - if (_path.length == 0) return _allFiles; - if (recurse === undefined) recurse = 1; - - dir = new File(dir); - if (!dir.directory) return [String(dir)]; - var files = dir.list(); - - for (var f = 0; f < files.length; f++) { - var file = String(files[f]); - if (file.match(/^\.[^\.\/\\]/)) continue; // skip dot files - - if ((new File(_path.join(SYS.slash)+SYS.slash+file)).list()) { // it's a directory - _path.push(file); - if (_path.length-1 < recurse) IO.ls(_path.join(SYS.slash), recurse, _allFiles, _path); - _path.pop(); - } - else { - _allFiles.push((_path.join(SYS.slash)+SYS.slash+file).replace(SYS.slash+SYS.slash, SYS.slash)); - } - } - - return _allFiles; - }, - - /** - * @type boolean - */ - exists: function(/**string*/ path) { - file = new File(path); - - if (file.isDirectory()){ - return true; - } - if (!file.exists()){ - return false; - } - if (!file.canRead()){ - return false; - } - return true; - }, - - /** - * - */ - open: function(/**string*/ path, /**string*/ append) { - var append = true; - var outFile = new File(path); - var out = new Packages.java.io.PrintWriter( - new Packages.java.io.OutputStreamWriter( - new Packages.java.io.FileOutputStream(outFile, append), - IO.encoding - ) - ); - return out; - }, - - /** - * Sets {@link IO.encoding}. - * Encoding is used when reading and writing text to files, - * and in the meta tags of HTML output. - */ - setEncoding: function(/**string*/ encoding) { - if (/ISO-8859-([0-9]+)/i.test(encoding)) { - IO.encoding = "ISO8859_"+RegExp.$1; - } - else { - IO.encoding = encoding; - } - }, - - /** - * @default "utf-8" - * @private - */ - encoding: "utf-8", - - /** - * Load the given script. - */ - include: function(relativePath) { - load(SYS.pwd+relativePath); - }, - - /** - * Loads all scripts from the given directory path. - */ - includeDir: function(path) { - if (!path) return; - - for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++) - if (/\.js$/i.test(lib[i])) load(lib[i]); - } -} - -// now run the application -IO.include("frame.js"); -IO.include("main.js"); - -main(); diff --git a/utils/jsdoc-toolkit/app/t/TestDoc.js b/utils/jsdoc-toolkit/app/t/TestDoc.js deleted file mode 100755 index c0768b7..0000000 --- a/utils/jsdoc-toolkit/app/t/TestDoc.js +++ /dev/null @@ -1,144 +0,0 @@ -var TestDoc = { - fails: 0, - plans: 0, - passes: 0, - results: [] -}; - -TestDoc.record = function(result) { - TestDoc.results.push(result); - if (typeof result.verdict == "boolean") { - if (result.verdict === false) TestDoc.fails++; - if (result.verdict === true) TestDoc.passes++; - } -} - -TestDoc.prove = function(filePath) { - if (typeof document != "undefined" && typeof document.write != "undefined") { - if (TestDoc.console) print = function(s) { TestDoc.console.appendChild(document.createTextNode(s+"\n")); } - else print = function(s) { document.write(s+"
"); } - } - TestDoc.run(TestDoc.readFile(filePath)); -} - -TestDoc.run = function(src) { - try { eval(src); } catch(e) { print("# ERROR! "+e); } - - var chunks = src.split(/\/\*t:/); - - var run = function(chunk) { - // local shortcuts - var is = TestDoc.assertEquals; - var isnt = TestDoc.assertNotEquals; - var plan = TestDoc.plan; - var requires = TestDoc.requires; - - try { eval(chunk); } catch(e) { print("# ERROR! "+e); } - } - for (var start = -1, end = 0; (start = src.indexOf("/*t:", end)) > end; start = end) { - run( - src.substring( - start+4, - (end = src.indexOf("*/", start)) - ) - ); - } -} - -TestDoc.Result = function(verdict, message) { - this.verdict = verdict; - this.message = message; -} - -TestDoc.Result.prototype.toString = function() { - if (typeof this.verdict == "boolean") { - return (this.verdict? "ok" : "not ok") + " " + (++TestDoc.report.counter) + " - " + this.message; - } - - return "# " + this.message; -} - -TestDoc.requires = function(file) { - if (!TestDoc.requires.loaded[file]) { - load(file); - TestDoc.requires.loaded[file] = true; - } -} -TestDoc.requires.loaded = {}; - -TestDoc.report = function() { - TestDoc.report.counter = 0; - print("1.."+TestDoc.plans); - for (var i = 0; i < TestDoc.results.length; i++) { - print(TestDoc.results[i]); - } - print("----------------------------------------"); - if (TestDoc.fails == 0 && TestDoc.passes == TestDoc.plans) { - print("All tests successful."); - } - else { - print("Failed " + TestDoc.fails + "/" + TestDoc.plans + " tests, "+((TestDoc.plans == 0)? 0 : Math.round(TestDoc.passes/(TestDoc.passes+TestDoc.fails)*10000)/100)+"% okay. Planned to run "+TestDoc.plans+", did run "+(TestDoc.passes+TestDoc.fails)+".") - } -} - -TestDoc.plan = function(n, message) { - TestDoc.plans += n; - TestDoc.record(new TestDoc.Result(null, message+" ("+n+" tests)")); -} - -TestDoc.assertEquals = function(a, b, message) { - var result = (a == b); - if (!result) message += "\n#\n# " + a + " does not equal " + b + "\n#"; - TestDoc.record(new TestDoc.Result(result, message)); -} - -TestDoc.assertNotEquals = function(a, b, message) { - var result = (a != b); - if (!result) message += "\n#\n# " + a + " equals " + b + "\n#"; - TestDoc.record(new TestDoc.Result(result, message)); -} - -TestDoc.readFile = (function(){ - // rhino - if (typeof readFile == "function") { - return function(url) { - var text = readFile(url); - return text || ""; - } - } - - // a web browser - else { - return function(url) { - var httpRequest; - - if (window.XMLHttpRequest) { // Mozilla, Safari, etc - httpRequest = new XMLHttpRequest(); - } - else if (window.ActiveXObject) { // IE - try { - httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); - } - catch (e) { - try { - httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); - } - catch (e) { - } - } - } - - if (!httpRequest) { throw "Cannot create HTTP Request."; } - - httpRequest.open('GET', url, false); - httpRequest.send(''); - if (httpRequest.readyState == 4) { - if (httpRequest.status >= 400) { - throw "The HTTP Request returned an error code: "+httpRequest.status; - } - } - - return httpRequest.responseText || ""; - } - } -})(); diff --git a/utils/jsdoc-toolkit/app/t/runner.js b/utils/jsdoc-toolkit/app/t/runner.js deleted file mode 100755 index 3f9fb4c..0000000 --- a/utils/jsdoc-toolkit/app/t/runner.js +++ /dev/null @@ -1,13 +0,0 @@ -// try: java -jar ../../jsrun.jar runner.js - -load("TestDoc.js"); - -TestDoc.prove("../frame/Opt.js"); -TestDoc.prove("../lib/JSDOC.js"); -TestDoc.prove("../frame/String.js"); -TestDoc.prove("../lib/JSDOC/DocTag.js"); -TestDoc.prove("../lib/JSDOC/DocComment.js"); -TestDoc.prove("../lib/JSDOC/TokenReader.js"); -TestDoc.prove("../lib/JSDOC/Symbol.js"); - -TestDoc.report(); diff --git a/utils/jsdoc-toolkit/app/test.js b/utils/jsdoc-toolkit/app/test.js deleted file mode 100755 index 787d84f..0000000 --- a/utils/jsdoc-toolkit/app/test.js +++ /dev/null @@ -1,325 +0,0 @@ -load("app/frame/Dumper.js"); -function symbolize(opt) { - symbols = null; - JSDOC.JsDoc(opt); - symbols = JSDOC.JsDoc.symbolSet; -} - -var testCases = [ - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/overview.js"]}); - //print(Dumper.dump(symbols)); - is('symbols.getSymbolByName("My Cool Library").name', 'My Cool Library', 'File overview can be found by alias.'); - } - , - function() { - symbolize({_: [SYS.pwd+"test/name.js"]}); - - is('symbols.getSymbol("Response").name', "Response", 'Virtual class name is found.'); - is('symbols.getSymbol("Response#text").alias', "Response#text", 'Virtual method name is found.'); - is('symbols.getSymbol("Response#text").memberOf', "Response", 'Virtual method parent name is found.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/prototype.js"]}); - - is('symbols.getSymbol("Article").name', "Article", 'Function set to constructor prototype with inner constructor name is found.'); - is('symbols.getSymbol("Article").hasMethod("init")', true, 'The initializer method name of prototype function is correct.'); - is('symbols.getSymbol("Article").hasMember("counter")', true, 'A static property set in the prototype definition is found.'); - is('symbols.getSymbol("Article").hasMember("title")', true, 'An instance property set in the prototype is found.'); - is('symbols.getSymbol("Article#title").isStatic', false, 'An instance property has isStatic set to false.'); - is('symbols.getSymbol("Article.counter").name', "counter", 'A static property set in the initializer has the name set correctly.'); - is('symbols.getSymbol("Article.counter").memberOf', "Article", 'A static property set in the initializer has the memberOf set correctly.'); - is('symbols.getSymbol("Article.counter").isStatic', true, 'A static property set in the initializer has isStatic set to true.'); - } - , - function() { - symbolize({a:true, _: [SYS.pwd+"test/prototype_oblit.js"]}); - - is('symbols.getSymbol("Article").name', "Article", 'Oblit set to constructor prototype name is found.'); - is('typeof symbols.getSymbol("Article.prototype")', "undefined", 'The prototype oblit is not a symbol.'); - is('symbols.getSymbol("Article#getTitle").name', "getTitle", 'The nonstatic method name of prototype oblit is correct.'); - is('symbols.getSymbol("Article#getTitle").alias', "Article#getTitle", 'The alias of non-static method of prototype oblit is correct.'); - is('symbols.getSymbol("Article#getTitle").isStatic', false, 'The isStatic of a nonstatic method of prototype oblit is correct.'); - is('symbols.getSymbol("Article.getTitle").name', "getTitle", 'The static method name of prototype oblit is correct.'); - is('symbols.getSymbol("Article.getTitle").isStatic', true, 'The isStatic of a static method of prototype oblit is correct.'); - is('symbols.getSymbol("Article#getTitle").isa', "FUNCTION", 'The isa of non-static method of prototype oblit is correct.'); - is('symbols.getSymbol("Article.getTitle").alias', "Article.getTitle", 'The alias of a static method of prototype oblit is correct.'); - is('symbols.getSymbol("Article.getTitle").isa', "FUNCTION", 'The isa of static method of prototype oblit is correct.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/prototype_oblit_constructor.js"]}); - - is('symbols.getSymbol("Article").name', "Article", 'Oblit set to constructor prototype with inner constructor name is found.'); - is('symbols.getSymbol("Article#init").name', "init", 'The initializer method name of prototype oblit is correct.'); - is('symbols.getSymbol("Article").hasMember("pages")', true, 'Property set by initializer method "this" is on the outer constructor.'); - is('symbols.getSymbol("Article#Title").name', "Title", 'Name of the inner constructor name is found.'); - is('symbols.getSymbol("Article#Title").memberOf', "Article", 'The memberOf of the inner constructor name is found.'); - is('symbols.getSymbol("Article#Title").isa', "CONSTRUCTOR", 'The isa of the inner constructor name is constructor.'); - is('symbols.getSymbol("Article#Title").hasMember("title")', true, 'A property set on the inner constructor "this" is on the inner constructor.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/inner.js"]}); - - is('symbols.getSymbol("Outer").name', "Outer", 'Outer constructor prototype name is found.'); - is('symbols.getSymbol("Outer").methods.length', 1, 'Inner function doesnt appear as a method of the outer.'); - is('symbols.getSymbol("Outer").hasMethod("open")', true, 'Outer constructors methods arent affected by inner function.'); - is('symbols.getSymbol("Outer-Inner").alias', "Outer-Inner", 'Alias of inner function is found.'); - is('symbols.getSymbol("Outer-Inner").isa', "CONSTRUCTOR", 'isa of inner function constructor is found.'); - is('symbols.getSymbol("Outer-Inner").memberOf', "Outer", 'The memberOf of inner function is found.'); - is('symbols.getSymbol("Outer-Inner").name', "Inner", 'The name of inner function is found.'); - is('symbols.getSymbol("Outer-Inner#name").name', "name", 'A member of the inner function constructor, attached to "this" is found on inner.'); - is('symbols.getSymbol("Outer-Inner#name").memberOf', "Outer-Inner", 'The memberOf of an inner function member is found.'); - } - , - function() { - symbolize({a:true, _: [SYS.pwd+"test/prototype_nested.js"]}); - - is('symbols.getSymbol("Word").name', "Word", 'Base constructor name is found.'); - is('symbols.getSymbol("Word").hasMethod("reverse")', true, 'Base constructor method is found.'); - is('symbols.getSymbol("Word").methods.length', 1, 'Base constructor has only one method.'); - is('symbols.getSymbol("Word").memberOf', "", 'Base constructor memberOf is empty.'); - is('symbols.getSymbol("Word#reverse").name', "reverse", 'Member of constructor prototype name is found.'); - is('symbols.getSymbol("Word#reverse").memberOf', "Word", 'Member of constructor prototype memberOf is found.'); - is('symbols.getSymbol("Word#reverse.utf8").name', "utf8", 'Member of constructor prototype method name is found.'); - is('symbols.getSymbol("Word#reverse.utf8").memberOf', "Word#reverse", 'Static nested member memberOf is found.'); - } - , - function() { - symbolize({a:true, _: [SYS.pwd+"test/namespace_nested.js"]}); - - is('symbols.getSymbol("ns1").name', "ns1", 'Base namespace name is found.'); - is('symbols.getSymbol("ns1").memberOf', "", 'Base namespace memberOf is empty (its a constructor).'); - is('symbols.getSymbol("ns1.ns2").name', "ns2", 'Nested namespace name is found.'); - is('symbols.getSymbol("ns1.ns2").alias', "ns1.ns2", 'Nested namespace alias is found.'); - is('symbols.getSymbol("ns1.ns2").memberOf', "ns1", 'Nested namespace memberOf is found.'); - is('symbols.getSymbol("ns1.ns2.Function1").name', "Function1", 'Method of nested namespace name is found.'); - is('symbols.getSymbol("ns1.ns2.Function1").memberOf', "ns1.ns2", 'Constructor of nested namespace memberOf is found.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/functions_nested.js"]}); - - is('symbols.getSymbol("Zop").name', "Zop", 'Any constructor name is found.'); - is('symbols.getSymbol("Zop").isa', "CONSTRUCTOR", 'It isa constructor.'); - is('symbols.getSymbol("Zop").hasMethod("zap")', true, 'Its method name, set later, is in methods array.'); - is('symbols.getSymbol("Foo").name', "Foo", 'The containing constructor name is found.'); - is('symbols.getSymbol("Foo").hasMethod("methodOne")', true, 'Its method name is found.'); - is('symbols.getSymbol("Foo").hasMethod("methodTwo")', true, 'Its second method name is found.'); - is('symbols.getSymbol("Foo#methodOne").alias', "Foo#methodOne", 'A methods alias is found.'); - is('symbols.getSymbol("Foo#methodOne").isStatic', false, 'A methods is not static.'); - is('symbols.getSymbol("Bar").name', "Bar", 'A global function declared inside another function is found.'); - is('symbols.getSymbol("Bar").isa', "FUNCTION", 'It isa function.'); - is('symbols.getSymbol("Bar").memberOf', "_global_", 'It is global.'); - is('symbols.getSymbol("Foo-inner").name', "inner", 'An inner functions name is found.'); - is('symbols.getSymbol("Foo-inner").memberOf', "Foo", 'It is member of the outer function.'); - is('symbols.getSymbol("Foo-inner").isInner', true, 'It is an inner function.'); - } - , - function() { - symbolize({a:true, _: [SYS.pwd+"test/memberof_constructor.js"]}); - - is('symbols.getSymbol("Circle#Tangent").name', "Tangent", 'Constructor set on prototype using @member has correct name.'); - is('symbols.getSymbol("Circle#Tangent").memberOf', "Circle", 'Constructor set on prototype using @member has correct memberOf.'); - is('symbols.getSymbol("Circle#Tangent").alias', "Circle#Tangent", 'Constructor set on prototype using @member has correct alias.'); - is('symbols.getSymbol("Circle#Tangent").isa', "CONSTRUCTOR", 'Constructor set on prototype using @member has correct isa.'); - is('symbols.getSymbol("Circle#Tangent").isStatic', false, 'Constructor set on prototype using @member is not static.'); - is('symbols.getSymbol("Circle#Tangent#getDiameter").name', "getDiameter", 'Method set on prototype using @member has correct name.'); - is('symbols.getSymbol("Circle#Tangent#getDiameter").memberOf', "Circle#Tangent", 'Method set on prototype using @member has correct memberOf.'); - is('symbols.getSymbol("Circle#Tangent#getDiameter").alias', "Circle#Tangent#getDiameter", 'Method set on prototype using @member has correct alias.'); - is('symbols.getSymbol("Circle#Tangent#getDiameter").isa', "FUNCTION", 'Method set on prototype using @member has correct isa.'); - is('symbols.getSymbol("Circle#Tangent#getDiameter").isStatic', false, 'Method set on prototype using @member is not static.'); - } - , - function() { - symbolize({a:true, p: true, _: [SYS.pwd+"test/memberof.js"]}); - - is('symbols.getSymbol("pack.install").alias', "pack.install", 'Using @memberOf sets alias, when parent name is in memberOf tag.'); - is('symbols.getSymbol("pack.install.overwrite").name', "install.overwrite", 'Using @memberOf sets name, even if the name is dotted.'); - is('symbols.getSymbol("pack.install.overwrite").memberOf', "pack", 'Using @memberOf sets memberOf.'); - is('symbols.getSymbol("pack.install.overwrite").isStatic', true, 'Using @memberOf with value not ending in octothorp sets isStatic to true.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/borrows.js"]}); - - is('symbols.getSymbol("Layout").name', "Layout", 'Constructor can be found.'); - is('symbols.getSymbol("Layout").hasMethod("init")', true, 'Constructor method name can be found.'); - is('symbols.getSymbol("Layout").hasMember("orientation")', true, 'Constructor property name can be found.'); - - is('symbols.getSymbol("Page").hasMethod("reset")', true, 'Second constructor method name can be found.'); - is('symbols.getSymbol("Page").hasMember("orientation")', true, 'Second constructor borrowed property name can be found in properties.'); - is('symbols.getSymbol("Page#orientation").memberOf', "Page", 'Second constructor borrowed property memberOf can be found.'); - is('symbols.getSymbol("Page-getInnerElements").alias', "Page-getInnerElements", 'Can borrow an inner function and it is still inner.'); - is('symbols.getSymbol("Page.units").alias', "Page.units", 'Can borrow a static function and it is still static.'); - - is('symbols.getSymbol("ThreeColumnPage#init").alias', "ThreeColumnPage#init", 'Third constructor method can be found even though method with same name is borrowed.'); - is('symbols.getSymbol("ThreeColumnPage#reset").alias', "ThreeColumnPage#reset", 'Borrowed method can be found.'); - is('symbols.getSymbol("ThreeColumnPage#orientation").alias', "ThreeColumnPage#orientation", 'Twice borrowed method can be found.'); - - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/borrows2.js"]}); - - is('symbols.getSymbol("Foo").hasMethod("my_zop")', true, 'Borrowed method can be found.'); - is('symbols.getSymbol("Bar").hasMethod("my_zip")', true, 'Second borrowed method can be found.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/constructs.js"]}); - - is('symbols.getSymbol("Person").hasMethod("say")', true, 'The constructs tag creates a class that lends can add a method to.'); - } - , - function() { - symbolize({a: true, _: [SYS.pwd+"test/augments.js", SYS.pwd+"test/augments2.js"]}); - - is('symbols.getSymbol("Page").augments[0]', "Layout", 'An augmented class can be found.'); - is('symbols.getSymbol("Page#reset").alias', "Page#reset", 'Method of augmenter can be found.'); - is('symbols.getSymbol("Page").hasMethod("Layout#init")', true, 'Method from augmented can be found.'); - is('symbols.getSymbol("Page").hasMember("Layout#orientation")', true, 'Property from augmented can be found.'); - is('symbols.getSymbol("Page").methods.length', 3, 'Methods of augmented class are included in methods array.'); - - is('symbols.getSymbol("ThreeColumnPage").augments[0]', "Page", 'The extends tag is a synonym for augments.'); - is('symbols.getSymbol("ThreeColumnPage").hasMethod("ThreeColumnPage#init")', true, 'Local method overrides augmented method of same name.'); - is('symbols.getSymbol("ThreeColumnPage").methods.length', 3, 'Local method count is right.'); - - is('symbols.getSymbol("NewsletterPage").augments[0]', "ThreeColumnPage", 'Can augment across file boundaries.'); - is('symbols.getSymbol("NewsletterPage").augments.length', 2, 'Multiple augments are supported.'); - is('symbols.getSymbol("NewsletterPage").inherits[0].alias', "Junkmail#annoy", 'Inherited method with augments.'); - is('symbols.getSymbol("NewsletterPage").methods.length', 6, 'Methods of augmented class are included in methods array across files.'); - is('symbols.getSymbol("NewsletterPage").properties.length', 1, 'Properties of augmented class are included in properties array across files.'); - } - , - function() { - symbolize({a:true, _: [SYS.pwd+"test/static_this.js"]}); - - is('symbols.getSymbol("box.holder").name', "holder", 'Static namespace name can be found.'); - is('symbols.getSymbol("box.holder.foo").name', "foo", 'Static namespace method name can be found.'); - is('symbols.getSymbol("box.holder").isStatic', true, 'Static namespace method is static.'); - - is('symbols.getSymbol("box.holder.counter").name', "counter", 'Instance namespace property name set on "this" can be found.'); - is('symbols.getSymbol("box.holder.counter").alias', "box.holder.counter", 'Instance namespace property alias set on "this" can be found.'); - is('symbols.getSymbol("box.holder.counter").memberOf', "box.holder", 'Static namespace property memberOf set on "this" can be found.'); - } - , - function() { - symbolize({a:true, p: true, _: [SYS.pwd+"test/lend.js"]}); - - is('symbols.getSymbol("Person").name', "Person", 'Class defined in lend comment is found.'); - is('symbols.getSymbol("Person").hasMethod("initialize")', true, 'Lent instance method name can be found.'); - is('symbols.getSymbol("Person").hasMethod("say")', true, 'Second instance method can be found.'); - is('symbols.getSymbol("Person#sing").isStatic', false, 'Instance method is known to be not static.'); - - is('symbols.getSymbol("Person.getCount").name', "getCount", 'Static method name from second lend comment can be found.'); - is('symbols.getSymbol("Person.getCount").isStatic', true, 'Static method from second lend comment is known to be static.'); - - is('LOG.warnings.filter(function($){if($.indexOf("notok") > -1) return $}).length', 1, 'A warning is emitted when lending to an undocumented parent.'); - } - , - function() { - symbolize({a:true, _: [SYS.pwd+"test/param_inline.js"]}); - - is('symbols.getSymbol("Layout").params[0].type', "int", 'Inline param name is set.'); - is('symbols.getSymbol("Layout").params[0].desc', "The number of columns.", 'Inline param desc is set from comment.'); - is('symbols.getSymbol("Layout#getElement").params[0].name', "id", 'User defined param documentation takes precedence over parser defined.'); - is('symbols.getSymbol("Layout#getElement").params[0].isOptional', true, 'Default for param is to not be optional.'); - is('symbols.getSymbol("Layout#getElement").params[1].isOptional', false, 'Can mark a param as being optional.'); - is('symbols.getSymbol("Layout#getElement").params[1].type', "number|string", 'Type of inline param doc can have multiple values.'); - is('symbols.getSymbol("Layout#Canvas").params[0].type', "", 'Type can be not defined for some params.'); - is('symbols.getSymbol("Layout#Canvas").params[2].type', "int", 'Type can be defined inline for only some params.'); - is('symbols.getSymbol("Layout#rotate").params.length', 0, 'Docomments inside function sig is ignored without a param.'); - is('symbols.getSymbol("Layout#init").params[2].type', "zoppler", 'Doc comment type overrides inline type for param with same name.'); - } - , - function() { - symbolize({a: true, _: [SYS.pwd+"test/shared.js", SYS.pwd+"test/shared2.js"]}); - - is('symbols.getSymbol("Array#some").name', 'some', 'The name of a symbol in a shared section is found.'); - is('symbols.getSymbol("Array#some").alias', 'Array#some', 'The alias of a symbol in a shared section is found.'); - is('symbols.getSymbol("Array#some").desc', "Extension to builtin array.", 'A description can be shared.'); - is('symbols.getSymbol("Array#filter").desc', "Extension to builtin array.\nChange every element of an array.", 'A shared description is appended.'); - is('symbols.getSymbol("Queue").desc', "A first in, first out data structure.", 'A description is not shared when outside a shared section.'); - is('symbols.getSymbol("Queue.rewind").alias', "Queue.rewind", 'Second shared tag can be started.'); - is('symbols.getSymbol("startOver").alias', "startOver", 'Shared tag doesnt cross over files.'); - } - , - function() { - symbolize({a: true, _: [SYS.pwd+"test/config.js"]}); - is('symbols.getSymbol("Contact").params[0].name', 'person', 'The name of a param is found.'); - is('symbols.getSymbol("Contact").params[1].name', 'person.name', 'The name of a param set with a dot name is found.'); - is('symbols.getSymbol("Contact").params[2].name', 'person.age', 'The name of a second param set with a dot name is found.'); - is('symbols.getSymbol("Contact").params[4].name', 'connection', 'The name of a param after config is found.'); - - is('symbols.getSymbol("Family").params[0].name', 'persons', 'Another name of a param is found.'); - is('symbols.getSymbol("Family").params[1].name', 'persons.Father', 'The name of a param+config is found.'); - is('symbols.getSymbol("Family").params[2].name', 'persons.Mother', 'The name of a second param+config is found.'); - is('symbols.getSymbol("Family").params[3].name', 'persons.Children', 'The name of a third param+config is found.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/ignore.js"]}); - is('LOG.warnings.filter(function($){if($.indexOf("undocumented symbol Ignored") > -1) return $}).length', 1, 'A warning is emitted when documenting members of an ignored parent.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/functions_anon.js"]}); - is('symbols.getSymbol("a.b").alias', 'a.b', 'In anonymous constructor this is found to be the container object.'); - is('symbols.getSymbol("a.f").alias', 'a.f', 'In anonymous constructor this can have a method.'); - is('symbols.getSymbol("a.c").alias', 'a.c', 'In anonymous constructor method this is found to be the container object.'); - is('symbols.getSymbol("g").alias', 'g', 'In anonymous function executed inline this is the global.'); - is('symbols.getSymbol("bar2.p").alias', 'bar2.p', 'In named constructor executed inline this is the container object.'); - is('symbols.getSymbol("module.pub").alias', 'module.pub', 'In parenthesized anonymous function executed inline function scoped variables arent documented.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/oblit_anon.js"]}); - is('symbols.getSymbol("opt").name', 'opt', 'Anonymous object properties are created.'); - is('symbols.getSymbol("opt.conf.keep").alias', 'opt.conf.keep', 'Anonymous object first property is assigned to $anonymous.'); - is('symbols.getSymbol("opt.conf.base").alias', 'opt.conf.base', 'Anonymous object second property is assigned to $anonymous.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/params_optional.js"]}); - is('symbols.getSymbol("Document").params.length', 3, 'Correct number of params are found when optional param syntax is used.'); - is('symbols.getSymbol("Document").params[1].name', "id", 'Name of optional param is found.'); - is('symbols.getSymbol("Document").params[1].isOptional', true, 'Optional param is marked isOptional.'); - is('symbols.getSymbol("Document").params[2].name', "title", 'Name of optional param with default value is found.'); - is('symbols.getSymbol("Document").params[2].isOptional', true, 'Optional param with default value is marked isOptional.'); - is('symbols.getSymbol("Document").params[2].defaultValue', " This is untitled.", 'Optional param default value is found.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/synonyms.js"]}); - is('symbols.getSymbol("myObject.myFunc").type', 'function', 'Type can be set to function.'); - } - , - function() { - symbolize({a:true, p:true, _: [SYS.pwd+"test/event.js"]}); - is('symbols.getSymbol("Kitchen#event:cakeEaten").isEvent', true, 'Function with event prefix is an event.'); - is('symbols.getSymbol("Kitchen#cakeEaten").isa', "FUNCTION", 'Function with same name as event isa function.'); - } - , - function() { - symbolize({x:"js", a:true, _: [SYS.pwd+"test/scripts/"]}); - is('JSDOC.JsDoc.srcFiles.length', 1, 'Only js files are scanned when -x=js.'); - } - , - function() { - symbolize({x:"js", a:true, _: [SYS.pwd+"test/exports.js"]}); - is('symbols.getSymbol("mxn.Map#doThings").name', 'doThings', 'Exports creates a documentation alias that can have methods.'); - } - , - function() { - symbolize({p:true, a:true, _: [SYS.pwd+"test/module.js"]}); - is('symbols.getSymbol("myProject.myModule.myPublicMethod").name', 'myPublicMethod', 'A function wrapped in parens can be recognized.'); - is('symbols.getSymbol("myProject.myModule-myPrivateMethod").name', 'myPrivateMethod', 'A private method in the scope of a function wrapped in parens can be recognized.'); - is('symbols.getSymbol("myProject.myModule-myPrivateVar").name', 'myPrivateVar', 'A private member in the scope of a function wrapped in parens can be recognized.'); - } -]; - -//// run and print results -print(testrun(testCases)); diff --git a/utils/jsdoc-toolkit/app/test/addon.js b/utils/jsdoc-toolkit/app/test/addon.js deleted file mode 100755 index 8886205..0000000 --- a/utils/jsdoc-toolkit/app/test/addon.js +++ /dev/null @@ -1,24 +0,0 @@ -String.prototype.reverse = function() { -} - -String.prototype.reverse.utf8 = function() { -} - -Function.count = function() { -} - -/** @memberOf Function */ -Function.count.reset = function() { -} - -/** @memberOf Function */ -count.getValue = function() { -} - -/** @memberOf Function.prototype */ -getSig = function() { -} - -/** @memberOf Function.prototype */ -Function.prototype.getProps = function() { -} diff --git a/utils/jsdoc-toolkit/app/test/anon_inner.js b/utils/jsdoc-toolkit/app/test/anon_inner.js deleted file mode 100755 index 227eeee..0000000 --- a/utils/jsdoc-toolkit/app/test/anon_inner.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @name bar - * @namespace - */ - -new function() { - /** - * @name bar-foo - * @function - * @param {number} x - */ - function foo(x) { - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/augments.js b/utils/jsdoc-toolkit/app/test/augments.js deleted file mode 100755 index 12e706e..0000000 --- a/utils/jsdoc-toolkit/app/test/augments.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -@constructor -*/ -function Layout(p) { - this.init = function(p) { - } - - this.getId = function() { - } - - /** @type Page */ - this.orientation = "landscape"; -} - -/** -@constructor -@augments Layout -*/ -function Page() { - this.reset = function(b) { - } -} - -/** -@extends Page -@constructor -*/ -function ThreeColumnPage() { - this.init = function(resetCode) { - } -} diff --git a/utils/jsdoc-toolkit/app/test/augments2.js b/utils/jsdoc-toolkit/app/test/augments2.js deleted file mode 100755 index e8388f0..0000000 --- a/utils/jsdoc-toolkit/app/test/augments2.js +++ /dev/null @@ -1,26 +0,0 @@ -/** -@constructor -*/ -function LibraryItem() { - this.reserve = function() { - } -} - -/** -@constructor -*/ -function Junkmail() { - this.annoy = function() { - } -} - -/** -@inherits Junkmail.prototype.annoy as pester -@augments ThreeColumnPage -@augments LibraryItem -@constructor -*/ -function NewsletterPage() { - this.getHeadline = function() { - } -} diff --git a/utils/jsdoc-toolkit/app/test/borrows.js b/utils/jsdoc-toolkit/app/test/borrows.js deleted file mode 100755 index a5d8ea4..0000000 --- a/utils/jsdoc-toolkit/app/test/borrows.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -@constructor -*/ -function Layout(p) { - /** initilize 1 */ - this.init = function(p) { - } - - /** get the id */ - this.getId = function() { - } - - /** @type string */ - this.orientation = "landscape"; - - function getInnerElements(elementSecretId){ - } -} - -/** A static method. */ -Layout.units = function() { -} - -/** -@constructor -@borrows Layout#orientation -@borrows Layout-getInnerElements -@borrows Layout.units -*/ -function Page() { - /** reset the page */ - this.reset = function(b) { - } -} - -/** -@constructor -@borrows Layout.prototype.orientation as this.orientation -@borrows Layout.prototype.init as #init -@inherits Page.prototype.reset as #reset -*/ -function ThreeColumnPage() { - /** initilize 2 */ - this.init = function(p) { - } -} diff --git a/utils/jsdoc-toolkit/app/test/borrows2.js b/utils/jsdoc-toolkit/app/test/borrows2.js deleted file mode 100755 index c0d5ea2..0000000 --- a/utils/jsdoc-toolkit/app/test/borrows2.js +++ /dev/null @@ -1,23 +0,0 @@ -// testing circular borrows - -/** - @class - @borrows Bar#zop as this.my_zop -*/ -function Foo() { - /** this is a zip. */ - this.zip = function() {} - - this.my_zop = new Bar().zop; -} - -/** - @class - @borrows Foo#zip as this.my_zip -*/ -function Bar() { - /** this is a zop. */ - this.zop = function() {} - - this.my_zip = new Foo().zip; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/config.js b/utils/jsdoc-toolkit/app/test/config.js deleted file mode 100755 index 0748a21..0000000 --- a/utils/jsdoc-toolkit/app/test/config.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @constructor - * @param person The person. - * @param {string} person.name The person's name. - * @config {integer} age The person's age. - * @config [id=1] Optional id number to use. - * @param connection - */ -function Contact(person, connection) { - -} - -/** - * @constructor - * @param persons - * @config {string} Father The paternal person. - * @config {string} Mother The maternal person. - * @config {string[]} Children And the rest. - */ -function Family(/**Object*/persons) { - -} diff --git a/utils/jsdoc-toolkit/app/test/constructs.js b/utils/jsdoc-toolkit/app/test/constructs.js deleted file mode 100755 index cca5dbd..0000000 --- a/utils/jsdoc-toolkit/app/test/constructs.js +++ /dev/null @@ -1,18 +0,0 @@ -var Person = makeClass( - /** - @scope Person - */ - { - /** - This is just another way to define a constructor. - @constructs - @param {string} name The name of the person. - */ - initialize: function(name) { - this.name = name; - }, - say: function(message) { - return this.name + " says: " + message; - } - } -); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/encoding.js b/utils/jsdoc-toolkit/app/test/encoding.js deleted file mode 100755 index ba64219..0000000 --- a/utils/jsdoc-toolkit/app/test/encoding.js +++ /dev/null @@ -1,10 +0,0 @@ - -/** - * @Constructor - * @desc 配置文件 - * @class 什么也不返回 - */ -function Test(conf) { - // do something; -} - diff --git a/utils/jsdoc-toolkit/app/test/encoding_other.js b/utils/jsdoc-toolkit/app/test/encoding_other.js deleted file mode 100755 index b144da4..0000000 --- a/utils/jsdoc-toolkit/app/test/encoding_other.js +++ /dev/null @@ -1,12 +0,0 @@ - -/** - * @Constructor - * @desc - * @class - */ -function Test(conf) { - // do something; -} - -// run with commanline option -e=iso-8859-5 - diff --git a/utils/jsdoc-toolkit/app/test/event.js b/utils/jsdoc-toolkit/app/test/event.js deleted file mode 100755 index 7e41d6f..0000000 --- a/utils/jsdoc-toolkit/app/test/event.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @name Kitchen - * @constructor - * @fires Bakery#event:donutOrdered - */ - -/** - * Fired when some cake is eaten. - * @name Kitchen#event:cakeEaten - * @function - * @param {Number} pieces The number of pieces eaten. - */ - -/** - * Find out if cake was eaten. - * @name Kitchen#cakeEaten - * @function - * @param {Boolean} wasEaten - */ - -/** - * @name getDesert - * @function - * @fires Kitchen#event:cakeEaten - */ - -/** - * @name Bakery - * @constructor - * @extends Kitchen - */ - -/** - * Fired when a donut order is made. - * @name Bakery#event:donutOrdered - * @event - * @param {Event} e The event object. - * @param {String} [e.topping] Optional sprinkles. - */ - -/** - * @constructor - * @borrows Bakery#event:donutOrdered as this.event:cakeOrdered - */ -function CakeShop() { -} - -/** @event */ -CakeShop.prototype.icingReady = function(isPink) { -} - -/** @event */ -function amHungry(/**Boolean*/enoughToEatAHorse) { -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/exports.js b/utils/jsdoc-toolkit/app/test/exports.js deleted file mode 100755 index 63a87cb..0000000 --- a/utils/jsdoc-toolkit/app/test/exports.js +++ /dev/null @@ -1,14 +0,0 @@ -/** @namespace */ -var mxn = {}; - -(function(){ - /** @exports Map as mxn.Map */ - var Map = - /** @constructor */ - mxn.Map = function() { - }; - - /** A method. */ - Map.prototype.doThings = function() { - }; -})(); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/functions_anon.js b/utils/jsdoc-toolkit/app/test/functions_anon.js deleted file mode 100755 index e9dd6c1..0000000 --- a/utils/jsdoc-toolkit/app/test/functions_anon.js +++ /dev/null @@ -1,39 +0,0 @@ -/** an anonymous constructor executed inline */ -a = new function() { - /** a.b*/ - this.b = 1; - /** a.f */ - this.f = function() { - /** a.c */ - this.c = 2; - } -} - - -/** - named function executed inline -*/ -bar1 = function Zoola1() { - /** property of global */ - this.g = 1; -}(); - -/** - named constructor executed inline -*/ -bar2 = new function Zoola2() { - /** property of bar */ - this.p = 1; -}; - -/** module pattern */ -module = (function () { - /** won't appear in documentation */ - var priv = 1; - - /** @scope module */ - return { - /** will appear as a property of module */ - pub: 1 - } -})(); diff --git a/utils/jsdoc-toolkit/app/test/functions_nested.js b/utils/jsdoc-toolkit/app/test/functions_nested.js deleted file mode 100755 index f044faf..0000000 --- a/utils/jsdoc-toolkit/app/test/functions_nested.js +++ /dev/null @@ -1,33 +0,0 @@ -/** @constructor */ -function Zop() { -} - -/** - @class -*/ -Foo = function(id) { - // this is a bit twisted, but if you call Foo() you will then - // modify Foo(). This is kinda, sorta non-insane, because you - // would have to call Foo() 100% of the time to use Foo's methods - Foo.prototype.methodOne = function(bar) { - alert(bar); - }; - - // same again - Foo.prototype.methodTwo = function(bar2) { - alert(bar2); - }; - - // and these are only executed if the enclosing function is actually called - // and who knows if that will ever happen? - Bar = function(pez) { - alert(pez); - }; - Zop.prototype.zap = function(p){ - alert(p); - }; - - // but this is only visible inside Foo - function inner() { - } -}; diff --git a/utils/jsdoc-toolkit/app/test/global.js b/utils/jsdoc-toolkit/app/test/global.js deleted file mode 100755 index 5ea4894..0000000 --- a/utils/jsdoc-toolkit/app/test/global.js +++ /dev/null @@ -1,13 +0,0 @@ -/** ecks */ -var x = [1, 2, 4]; - -var y = { - foo: function(){ - } -} - -bar = function() { -} - -function zop() { -} diff --git a/utils/jsdoc-toolkit/app/test/globals.js b/utils/jsdoc-toolkit/app/test/globals.js deleted file mode 100755 index 3f83fb1..0000000 --- a/utils/jsdoc-toolkit/app/test/globals.js +++ /dev/null @@ -1,25 +0,0 @@ -function example(/**Circle*/a, b) { - /** a global defined in function */ - var number = a; - - var hideNumber = function(){ - } - - setNumber = function(){ - } - alert('You have chosen: ' + b); -} - -function initPage() { - var supported = document.createElement && document.getElementsByTagName; - if (!supported) return; - // start of DOM script - var x = document.getElementById('writeroot'); - // etc. -} - -/** an example var */ -var document = new Document(x, y); - -var getNumber = function(){ -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/ignore.js b/utils/jsdoc-toolkit/app/test/ignore.js deleted file mode 100755 index d3fac9e..0000000 --- a/utils/jsdoc-toolkit/app/test/ignore.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * A test constructor. - * @constructor - * @ignore - */ -function Ignored() { - /** a method */ - this.bar = function() { - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/inner.js b/utils/jsdoc-toolkit/app/test/inner.js deleted file mode 100755 index 37cfa9d..0000000 --- a/utils/jsdoc-toolkit/app/test/inner.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @constructor - */ -function Outer() { - /** - * @constructor - */ - function Inner(name) { - /** The name of this. */ - this.name = name; - } - - this.open = function(name) { - return (new Inner(name)); - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/jsdoc_test.js b/utils/jsdoc-toolkit/app/test/jsdoc_test.js deleted file mode 100755 index 0817712..0000000 --- a/utils/jsdoc-toolkit/app/test/jsdoc_test.js +++ /dev/null @@ -1,477 +0,0 @@ -/** - * @fileoverview This file is to be used for testing the JSDoc parser - * It is not intended to be an example of good JavaScript OO-programming, - * nor is it intended to fulfill any specific purpose apart from - * demonstrating the functionality of the - * JSDoc parser - * - * @author Gabriel Reid gab_reid@users.sourceforge.net - * @version 0.1 - */ - - -/** - * Construct a new Shape object. - * @class This is the basic Shape class. - * It can be considered an abstract class, even though no such thing - * really existing in JavaScript - * @constructor - * @throws MemoryException if there is no more memory - * @throws GeneralShapeException rarely (if ever) - * @return {Shape|Coordinate} A new shape. - */ -function Shape(){ - - /** - * This is an example of a function that is not given as a property - * of a prototype, but instead it is assigned within a constructor. - * For inner functions like this to be picked up by the parser, the - * function that acts as a constructor must be denoted with - * the @constructor tag in its comment. - * @type String - */ - this.getClassName = function(){ - return "Shape"; - } - - /** - * This is an inner method, just used here as an example - * @since version 0.5 - * @author Sue Smart - */ - function addReference(){ - // Do nothing... - } - -} - -/** - * Create a new Hexagon instance. - * @extends Shape - * @class Hexagon is a class that is a logical sublcass of - * {@link Shape} (thanks to the @extends tag), but in - * reality it is completely unrelated to Shape. - * @param {int} sideLength The length of one side for the new Hexagon - * @example - * var h = new Hexagon(2); - * @example - * if (hasHex) { - * hex = new Hexagon(5); - * color = hex.getColor(); - * } - */ -function Hexagon(sideLength) { -} - - -/** - * This is an unattached (static) function that adds two integers together. - * @param {int} One The first number to add - * @param {int} Two The second number to add - * @author Gabriel Reid - * @deprecated So you shouldn't use it anymore! Use {@link Shape#getClassName} instead. - */ -function Add(One, Two){ - return One + Two; -} - - -/** - * The color of this shape - * @type Color - */ -Shape.prototype.color = null; - -/** - * The border of this shape. - * @field - * @type int - */ -Shape.prototype.border = function(){return border;}; - -/* - * These are all the instance method implementations for Shape - */ - -/** - * Get the coordinates of this shape. It is assumed that we're always talking - * about shapes in a 2D location here. - * @requires The {@link Shape} class - * @returns A Coordinate object representing the location of this Shape - * @type Coordinate[] - */ -Shape.prototype.getCoords = function(){ - return this.coords; -} - -/** - * Get the color of this shape. - * @see #setColor - * @see The Color library. - * @link Shape - * @type Color - */ -Shape.prototype.getColor = function(){ - return this.color; -} - -/** - * Set the coordinates for this Shape - * @param {Coordinate} coordinates The coordinates to set for this Shape - */ -Shape.prototype.setCoords = function(coordinates){ - this.coords = coordinates; -} - -/** - * Set the color for this Shape - * @param {Color} color The color to set for this Shape - * @param other There is no other param, but it can still be documented if - * optional parameters are used - * @throws NonExistantColorException (no, not really!) - * @see #getColor - */ -Shape.prototype.setColor = function(color){ - this.color = color; -} - -/** - * Clone this shape - * @returns A copy of this shape - * @type Shape - * @author Gabriel Reid - */ -Shape.prototype.clone = function(){ - return new Shape(); -} - -/** - * Create a new Rectangle instance. - * @class A basic rectangle class, inherits from Shape. - * This class could be considered a concrete implementation class - * @constructor - * @param {int} width The optional width for this Rectangle - * @param {int} height Thie optional height for this Rectangle - * @author Gabriel Reid - * @see Shape is the base class for this - * @augments Shape - * @hilited - */ -function Rectangle(width, // This is the width - height // This is the height - ){ - if (width){ - this.width = width; - if (height){ - this.height = height; - } - } -} - - -/* Inherit from Shape */ -Rectangle.prototype = new Shape(); - -/** - * Value to represent the width of the Rectangle. - *
Text in bold and italic and a - * link to SourceForge - * @private - * @type int - */ -Rectangle.prototype.width = 0; - -/** - * Value to represent the height of the Rectangle - * @private - * @type int - */ -Rectangle.prototype.height = 0; - -/** - * Get the type of this object. - * @type String - */ -Rectangle.prototype.getClassName= function(){ - return "Rectangle"; -} - -/** - * Get the value of the width for the Rectangle - * @type int - * @see Rectangle#setWidth - */ -Rectangle.prototype.getWidth = function(){ - return this.width; -} - -/** - * Get the value of the height for the Rectangle. - * Another getter is the {@link Shape#getColor} method in the - * {@link Shape} base class. - * @return The height of this Rectangle - * @type int - * @see Rectangle#setHeight - */ -Rectangle.prototype.getHeight = function(){ - return this.height; -} - -/** - * Set the width value for this Rectangle. - * @param {int} width The width value to be set - * @see #setWidth - */ -Rectangle.prototype.setWidth = function(width){ - this.width = width; -} - -/** - * Set the height value for this Rectangle. - * @param {int} height The height value to be set - * @see #getHeight - */ -Rectangle.prototype.setHeight = function(height){ - this.height = height; -} - -/** - * Get the value for the total area of this Rectangle - * @return total area of this Rectangle - * @type int - */ -Rectangle.prototype.getArea = function(){ - return width * height; -} - - -/** - * Create a new Square instance. - * @class A Square is a subclass of {@link Rectangle} - * @param {int} width The optional width for this Rectangle - * @param {int} height The optional height for this Rectangle - * @augments Rectangle - */ -function Square(width, height){ - if (width){ - this.width = width; - if (height){ - this.height = height; - } - } - -} - -/* Square is a subclass of Rectangle */ -Square.prototype = new Rectangle(); - -/** - * Set the width value for this Shape. - * @param {int} width The width value to be set - * @see #getWidth - */ -Square.prototype.setWidth = function(width){ - this.width = this.height = width; -} - -/** - * Set the height value for this Shape - * Sets the {@link Rectangle#height} attribute in the Rectangle. - * @param {int} height The height value to be set - */ -Square.prototype.setHeight = function(height){ - this.height = this.width = height; -} - - -/** - * Create a new Circle instance based on a radius. - * @class Circle class is another subclass of Shape - * @extends Shape - * @param {int} radius The optional radius of this {@link Circle } - * @mixin Square.prototype.setWidth as this.setDiameter - */ -function Circle(radius){ - if (radius) { - /** The radius of the this Circle. */ - this.radius = radius; - } -} - -/* Circle inherits from {@link Shape} */ -Circle.prototype = new Shape(); - -/** - * The radius value for this Circle - * @private - * @type int - */ -Circle.prototype.radius = 0; - -/** - * A very simple class (static) field that is also a constant - * @final - * @type float - */ -Circle.PI = 3.14; - -/** - * Get the radius value for this Circle - * @type int - * @see #setRadius - */ -Circle.prototype.getRadius = function(){ - return this.radius; -} - -/** - * Set the radius value for this Circle - * @param {int} radius The {@link Circle#radius} value to set - * @see #getRadius - */ -Circle.prototype.setRadius = function(radius){ - this.radius = radius; -} - -/** - * An example of a class (static) method that acts as a factory for Circle - * objects. Given a radius value, this method creates a new Circle. - * @param {int} radius The radius value to use for the new Circle. - * @type Circle - */ -Circle.createCircle = function(radius){ - return new Circle(radius); -} - - -/** - * Create a new Coordinate instance based on x and y grid data. - * @class Coordinate is a class that can encapsulate location information. - * @param {int} [x=0] The optional x portion of the Coordinate - * @param {int} [y=0] The optinal y portion of the Coordinate - */ -function Coordinate(x, y){ - if (x){ - this.x = x; - if (y){ - this.y = y; - } - } -} - -/** - * The x portion of the Coordinate - * @type int - * @see #getX - * @see #setX - */ -Coordinate.prototype.x = 0; - -/** - * The y portion of the Coordinate - * @type int - * @see #getY - * @see #setY - */ -Coordinate.prototype.y = 0; - -/** - * Gets the x portion of the Coordinate. - * @type int - * @see #setX - */ -Coordinate.prototype.getX = function(){ - return this.x; -} - -/** - * Get the y portion of the Coordinate. - * @type int - * @see #setY - */ -Coordinate.prototype.getY = function(){ - return this.y; -} - -/** - * Sets the x portion of the Coordinate. - * @param {int} x The x value to set - * @see #getX - */ -Coordinate.prototype.setX = function(x){ - this.x = x; -} - -/** - * Sets the y portion of the Coordinate. - * @param {int} y The y value to set - * @see #getY - */ -Coordinate.prototype.setY = function(y){ - this.y = y; -} - -/** - * @class This class exists to demonstrate the assignment of a class prototype - * as an anonymous block. - */ -function ShapeFactory(){ -} - -ShapeFactory.prototype = { - /** - * Creates a new {@link Shape} instance. - * @return A new {@link Shape} - * @type Shape - */ - createShape: function(){ - return new Shape(); - } -} - -/** - * An example of a singleton class - * @param ... Arguments represent {@link coordinate}s in the shape. - * @constructor - */ -MySingletonShapeFactory = function(){ - - /** - * Get the next {@link Shape} - * @type Shape - * @return A new {@link Shape} - */ - this.getShape = function(){ - return null; - } - -} - - -/** - * Create a new Foo instance. - * @class This is the Foo class. It exists to demonstrate 'nested' classes. - * @constructor - * @see Foo.Bar - */ -function Foo(){} - -/** - * Creates a new instance of Bar. - * @class This class exists to demonstrate 'nested' classes. - * @constructor - * @see Foo.Bar - */ -function Bar(){} - -/** - * Nested class - * @constructor - */ -Foo.Bar = function(){ - /** The x. */ this.x = 2; -} - -Foo.Bar.prototype = new Bar(); -/** The y. */ -Foo.Bar.prototype.y = '3'; diff --git a/utils/jsdoc-toolkit/app/test/lend.js b/utils/jsdoc-toolkit/app/test/lend.js deleted file mode 100755 index 92b15d5..0000000 --- a/utils/jsdoc-toolkit/app/test/lend.js +++ /dev/null @@ -1,33 +0,0 @@ - /** @class */ -var Person = Class.create( - /** - @lends Person.prototype - */ - { - initialize: function(name) { - this.name = name; - }, - say: function(message) { - return this.name + ': ' + message; - } - } - ); - -/** @lends Person.prototype */ -{ - /** like say but more musical */ - sing: function(song) { - } -} - -/** @lends Person */ -{ - getCount: function() { - } -} - -/** @lends Unknown.prototype */ -{ - notok: function() { - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/memberof.js b/utils/jsdoc-toolkit/app/test/memberof.js deleted file mode 100755 index 883bbde..0000000 --- a/utils/jsdoc-toolkit/app/test/memberof.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @constructor */ -pack = function() { - this.init = function(){} - function config(){} -} - - pack.build = function(task) {}; - -/** @memberOf pack */ -pack.install = function() {} - -/** @memberOf pack */ -pack.install.overwrite = function() {} - -/** @memberOf pack */ -clean = function() {} - -/** @memberOf pack-config */ -install = function() {}; diff --git a/utils/jsdoc-toolkit/app/test/memberof_constructor.js b/utils/jsdoc-toolkit/app/test/memberof_constructor.js deleted file mode 100755 index 80fde73..0000000 --- a/utils/jsdoc-toolkit/app/test/memberof_constructor.js +++ /dev/null @@ -1,17 +0,0 @@ -/** @constructor */ -function Circle(){} - -/** - @constructor - @memberOf Circle# - */ -Circle.prototype.Tangent = function(){}; - -// renaming Circle#Tangent to Circle#Circle#Tangent - -/** - @memberOf Circle#Tangent# - */ -Circle.prototype.Tangent.prototype.getDiameter = function(){}; - - diff --git a/utils/jsdoc-toolkit/app/test/module.js b/utils/jsdoc-toolkit/app/test/module.js deleted file mode 100755 index 5b3fe42..0000000 --- a/utils/jsdoc-toolkit/app/test/module.js +++ /dev/null @@ -1,17 +0,0 @@ -/** @namespace */ -myProject = myProject || {}; - -/** @namespace */ -myProject.myModule = (function () { - /** describe myPrivateVar here */ - var myPrivateVar = ""; - - var myPrivateMethod = function () { - } - - /** @scope myProject.myModule */ - return { - myPublicMethod: function () { - } - }; -})(); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/name.js b/utils/jsdoc-toolkit/app/test/name.js deleted file mode 100755 index e88a51a..0000000 --- a/utils/jsdoc-toolkit/app/test/name.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - @name Response - @class -*/ - -Response.prototype = { - /** - @name Response#text - @function - @description - Gets the body of the response as plain text - @returns {String} - Response as text - */ - - text: function() { - return this.nativeResponse.responseText; - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/namespace_nested.js b/utils/jsdoc-toolkit/app/test/namespace_nested.js deleted file mode 100755 index 46cafa2..0000000 --- a/utils/jsdoc-toolkit/app/test/namespace_nested.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - @namespace This is the first namespace. -*/ -ns1 = {}; - -/** - This is the second namespace. - @namespace -*/ -ns1.ns2 = {}; - -/** - This part of ns1.ns2 - @constructor -*/ -ns1.ns2.Function1 = function() { -}; - -ns1.staticFunction = function() { -}; - -/** A static field in a namespace. */ -ns1.ns2.staticField = 1; diff --git a/utils/jsdoc-toolkit/app/test/nocode.js b/utils/jsdoc-toolkit/app/test/nocode.js deleted file mode 100755 index 1cf99bc..0000000 --- a/utils/jsdoc-toolkit/app/test/nocode.js +++ /dev/null @@ -1,13 +0,0 @@ -/**#nocode+*/ - /** - @name star - @function - */ - function blahblah() { - - } -/**#nocode-*/ - -function yaddayadda() { - -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/oblit_anon.js b/utils/jsdoc-toolkit/app/test/oblit_anon.js deleted file mode 100755 index 8d9e941..0000000 --- a/utils/jsdoc-toolkit/app/test/oblit_anon.js +++ /dev/null @@ -1,20 +0,0 @@ -/** the options */ -opt = Opt.get( - arguments, - { - d: "directory", - c: "conf", - "D[]": "define" - } -); - -/** configuration */ -opt.conf = { - /** keep */ - keep: true, - /** base */ - base: getBase(this, {p: properties}) -} - - - diff --git a/utils/jsdoc-toolkit/app/test/overview.js b/utils/jsdoc-toolkit/app/test/overview.js deleted file mode 100755 index 1dfc09b..0000000 --- a/utils/jsdoc-toolkit/app/test/overview.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @overview This "library" contains a - * lot of classes and functions. - * @example -
-	var x (x < 1);
-	alert("This 'is' \"code\"");
- 
- * @name My Cool Library - * @author Joe Smith jsmith@company.com - * @version 0.1 - */ - -/** - * Gets the current foo - * @param {String} fooId The unique identifier for the foo. - * @return {Object} Returns the current foo. - */ -function getFoo(fooID){ -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/param_inline.js b/utils/jsdoc-toolkit/app/test/param_inline.js deleted file mode 100755 index 09845b2..0000000 --- a/utils/jsdoc-toolkit/app/test/param_inline.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - @constructor - @param columns The number of columns. -*/ -function Layout(/**int*/columns){ - /** - @param [id] The id of the element. - @param elName The name of the element. - */ - this.getElement = function( - /** string */ elName, - /** number|string */ id - ) { - }; - - /** - @constructor - */ - this.Canvas = function(top, left, /**int*/width, height) { - /** Is it initiated yet? */ - this.initiated = true; - } - - this.rotate = function(/**nothing*/) { - } - - /** - @param x - @param y - @param {zoppler} z*/ - this.init = function(x, y, /**abbler*/z) { - /** The xyz. */ - this.xyz = x+y+z; - this.getXyz = function() { - } - } -} diff --git a/utils/jsdoc-toolkit/app/test/params_optional.js b/utils/jsdoc-toolkit/app/test/params_optional.js deleted file mode 100755 index 18bf598..0000000 --- a/utils/jsdoc-toolkit/app/test/params_optional.js +++ /dev/null @@ -1,8 +0,0 @@ - -/** - * @param {Page[]} pages - * @param {number} [id] Specifies the id, if applicable. - * @param {String} [title = This is untitled.] Specifies the title. - */ -function Document(pages, id, title){ -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/prototype.js b/utils/jsdoc-toolkit/app/test/prototype.js deleted file mode 100755 index 1147008..0000000 --- a/utils/jsdoc-toolkit/app/test/prototype.js +++ /dev/null @@ -1,17 +0,0 @@ -/** @constructor */ -function Article() { -} - -Article.prototype.init = function(title) { - /** the instance title */ - this.title = title; - - /** the static counter */ - Article.counter = 1; -} - -a = new Article(); -a.Init("my title"); - -print(a.title); -print(Article.counter); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/prototype_nested.js b/utils/jsdoc-toolkit/app/test/prototype_nested.js deleted file mode 100755 index e8ca1ce..0000000 --- a/utils/jsdoc-toolkit/app/test/prototype_nested.js +++ /dev/null @@ -1,9 +0,0 @@ -/** @constructor */ -function Word() { -} - -Word.prototype.reverse = function() { -} - -Word.prototype.reverse.utf8 = function() { -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/prototype_oblit.js b/utils/jsdoc-toolkit/app/test/prototype_oblit.js deleted file mode 100755 index 6cfc39c..0000000 --- a/utils/jsdoc-toolkit/app/test/prototype_oblit.js +++ /dev/null @@ -1,13 +0,0 @@ -/** @constructor */ -function Article() { -} - -Article.prototype = { - /** instance get title */ - getTitle: function(){ - } -} - -/** static get title */ -Article.getTitle = function(){ -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/prototype_oblit_constructor.js b/utils/jsdoc-toolkit/app/test/prototype_oblit_constructor.js deleted file mode 100755 index 9248248..0000000 --- a/utils/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +++ /dev/null @@ -1,24 +0,0 @@ -/** @constructor */ -function Article() { -} - -Article.prototype = { - /** @constructor */ - Title: function(title) { - /** the value of the Title instance */ - this.title = title; - }, - - init: function(pages) { - /** the value of the pages of the Article instance */ - this.pages = pages; - } -} - -f = new Article(); -f.init("one two three"); - -t = new f.Title("my title"); - -print(f.pages); -print(t.title); \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/public.js b/utils/jsdoc-toolkit/app/test/public.js deleted file mode 100755 index 35d34f6..0000000 --- a/utils/jsdoc-toolkit/app/test/public.js +++ /dev/null @@ -1,10 +0,0 @@ -/**@constructor*/ -function Foo() { - /** - @public - @static - @field - */ - var bar = function(x) { - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/scripts/code.js b/utils/jsdoc-toolkit/app/test/scripts/code.js deleted file mode 100755 index e9d7ed2..0000000 --- a/utils/jsdoc-toolkit/app/test/scripts/code.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - @class - */ -function thisiscode() { -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/scripts/notcode.txt b/utils/jsdoc-toolkit/app/test/scripts/notcode.txt deleted file mode 100755 index fcd737e..0000000 --- a/utils/jsdoc-toolkit/app/test/scripts/notcode.txt +++ /dev/null @@ -1,5 +0,0 @@ -(This is not code) -function foo(){{{{ -( -! -@ \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/shared.js b/utils/jsdoc-toolkit/app/test/shared.js deleted file mode 100755 index e1c277a..0000000 --- a/utils/jsdoc-toolkit/app/test/shared.js +++ /dev/null @@ -1,42 +0,0 @@ - -/** - * Builtin object. - * @class - * @name Array - */ - -/**#@+ - * Extension to builtin array. - * @memberOf Array - * @method - */ - -/** - * @returns Boolen if some array members... - */ -Array.prototype.some = function(){}; - -/** - * Change every element of an array. - * @returns Filtered array copy. - */ -Array.prototype.filter = function(){}; - -/**#@-*/ - - -/** - * A first in, first out data structure. - * @constructor - */ -Queue = function(){}; - -/**#@+ - * Extension to Queue. - * @memberOf Queue - */ - -rewind = function(){ -} - -// should close automatically here. \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/shared2.js b/utils/jsdoc-toolkit/app/test/shared2.js deleted file mode 100755 index 3f7736a..0000000 --- a/utils/jsdoc-toolkit/app/test/shared2.js +++ /dev/null @@ -1,2 +0,0 @@ -startOver = function(){ -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/shortcuts.js b/utils/jsdoc-toolkit/app/test/shortcuts.js deleted file mode 100755 index f738f1e..0000000 --- a/utils/jsdoc-toolkit/app/test/shortcuts.js +++ /dev/null @@ -1,22 +0,0 @@ -// /**#=+ -// * { -// * 'D': 'Date.prototype', -// * '$N': 'Number' -// * } -// */ -// var D = Date.prototype, -// $N = Number; -// -// D.locale = function(){ -// }; -// -// /** -// @return {string} The cardinal number string. -// */ -// $N.nth = function(n){ -// }; -// -// LOAD.file = function(){ -// } -// -// /**#=-*/ \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/static_this.js b/utils/jsdoc-toolkit/app/test/static_this.js deleted file mode 100755 index 9407b20..0000000 --- a/utils/jsdoc-toolkit/app/test/static_this.js +++ /dev/null @@ -1,13 +0,0 @@ -/** the parent */ -var box = {}; - -/** @namespace */ -box.holder = {} - -box.holder.foo = function() { - /** the counter */ - this.counter = 1; -} - -box.holder.foo(); -print(box.holder.counter); diff --git a/utils/jsdoc-toolkit/app/test/synonyms.js b/utils/jsdoc-toolkit/app/test/synonyms.js deleted file mode 100755 index 09066b9..0000000 --- a/utils/jsdoc-toolkit/app/test/synonyms.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - @class - @inherits Bar#zop as #my_zop -*/ -function Foo() { - /** this is a zip. */ - this.zip = function() {} - - /** from Bar */ - this.my_zop = new Bar().zop; -} - -/** - @class - @borrows Foo#zip as this.my_zip -*/ -function Bar() { - /** this is a zop. */ - this.zop = function() {} - - /** from Foo */ - this.my_zip = new Foo().zip; -} - -/** @namespace */ -var myObject = { - /** - @type function - */ - myFunc: getFunction() -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/tosource.js b/utils/jsdoc-toolkit/app/test/tosource.js deleted file mode 100755 index 706d476..0000000 --- a/utils/jsdoc-toolkit/app/test/tosource.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @param {Object} object - * @return {string} - */ -function valueOf(object) {} - -/** - * @param {Object} object - * @return {string} - */ -function toString(object) {} - -/** - * @param {Object} object - * @return {string} - */ -function toSource(object) {} - -/** - * @param {Object} object - * @return {string} - */ -function constructor(object) {} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/app/test/variable_redefine.js b/utils/jsdoc-toolkit/app/test/variable_redefine.js deleted file mode 100755 index 2c07da0..0000000 --- a/utils/jsdoc-toolkit/app/test/variable_redefine.js +++ /dev/null @@ -1,14 +0,0 @@ -/** @constructor */ -function Foo() { - var bar = 1; - bar = 2; // redefining a private - - this.baz = 1; - baz = 2; // global - - /** a private */ - var blap = { - /** in here */ - tada: 1 - } -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/changes.txt b/utils/jsdoc-toolkit/changes.txt deleted file mode 100755 index 35ee299..0000000 --- a/utils/jsdoc-toolkit/changes.txt +++ /dev/null @@ -1,96 +0,0 @@ -== 2.3.0 == - - * Added option -u, --unique to avoid bug that causes multiple symbols with names that differ only by case to overwrite each others output on case-insensitive filesystems. ( issue #162 ) - * Fixed bug where {@links} in @deprecated tags did not resolve. ( issue #220 ) - * Fixed bug that caused parens around a function to make it to be unrecognized. ( issue #213 ) - * Fixed bug prevented explicit links to named anchors from working (thanks katgao.pku). ( issue #215 ) - * Fixed bug that prevented full description from appearing in file overview. ( issue #224 ) - -== 2.2.1 == - - * Fixed bug with class template, where sorting of methods was accidentally removed (thanks dezfowler). - * Added missing test files for the @exports unit tests. - -== 2.2.0 == - - * Fixed bug that caused exception when given a folder containing non-js files, even with the x commandline option set to "js". ( issue #193 ) - * Fixed typo in index template [patch submitted by olle]. ( issue #198 ) - * Modified @borrows tag experimentally to allow for missing "as ..." clause. - * Added support for the @exports tag, to allow one symbol to be documented as another. - * Added support for the -S option to document code following the Secure Modules pattern. - -== 2.1.0 == - - * Added support for the @event tag. - * Fixed bug that prevented the : character from appearing in symbol names. - * Fixed bug that prevented underscored symbols marked with @public being tagged as private. (issue #184 ) - * Fixed bug that randomly affected the @memberOf tag when the name of the symbol did not include the parent name. - * Fixed bug that prevented templates that were not in the jsdoc-toolkit folder from being found. ( issue #176 ) - * Added ability to check for trailing slash on template path. ( issue #177 ) - * Modified classDesc so that it no longer is appended with the constructor desc. - * Fixed call to plugin onDocCommentSrc. - * Added missing support for inline doc comments for function return types. ( issue #189 ) - * Added command line option -q, --quiet. - * Added command line option -E, --exclude. ( issue #143 ) - * Added 2 more hooks for plugins. ( issue #163 ) - * Added support for extending built-ins. ( issue #160 ) - * Added "compact" option to JSDOC.JsPlate.prototype.process. ( issue #159 ) - * @augments no longer documents static members as inherited. ( issue #138 ) - * @link to a class now goes to the page for that class, not the constructor. ( issue #178 ) - * Warnings of mismatched curly brace now include filename. ( issue #166 ) - * Fixed bug affecting template paths loaded via a configuration file when the trailing slash is missing. ( issue #191 ) - * Minor optimizations. - -== 2.0.2 == - - * Fixed bug that sometimes caused an example of division in the source code to be interpretted as a regex by the JsDoc Toolkit analyzer. ( issue #158 ) - * Fixed a bug that prevented private variables marked as @public from appearing in the documentation. ( issue #161 ) - * Fixed bug that prevented variable names with underscored properties from appearing in summaries. ( issue #173 ) - -== 2.0.1 == - - * Fixed bug that prevented @fileOverview tag from being recognized. - * Added support for @fieldOf as a synonym for @field plus @memberOf. - * Added support for @name tag in a @fileOverview comment to control the displayed name of the file. - * Added support for multiple @example tags. ( issue #152 ) - * Modified style sheet of jsdoc template to make more readable. ( issue #151 ) - * Fixed bug that prevented @since documentation from displaying correctly when it appeared in a class. ( issue #150 ) - * Fixed bug that caused inhertited properties to sometimes not resolve correctly. ( issue #144 ) - * Modified so that trailing whitespace in @example is always trimmed. ( issue #153 ) - * Added support for elseif to JsPlate. (hat tip to fredck) - * Added support for @location urls in the @overview comment to the jsdoc template. - -== Changes From Versions 1.4.0 to 2.0.0 == - - * Upgraded included version of Rhino from 1.6 to 1.7R1. - * Removed circular references in parsed documentation objects. - * Improved inheritance handling, now properties and events can be inherited same as methods. - * Improved handling of cross-file relationships, now having two related objects in separate files is not a problem. - * Improved ability to recognize membership of previously defined objects. - * Added ability to redefine parsing behavior with plugins. - * @methodOf is a synonym for @function and @memberOf. - * Added @default to document default values of members that are objects. - * Added ability to parse and refer to inner functions. - * Fixed bug that appeared when calling a method to set properties of the instance referred to by "this". - * Added ability to automatically create links to other symbols. - * New "jsdoc" template now produces fully W3C valid XHTML. - * Inline parameter type hint comments are now documented. - * Fixed error: Locally scoped variables (declared with var) no longer appear as global. - * It is now possible to run JsDoc Toolkit from any directory. - * Added support for inline {@link ...} tags. - * Added support for the -H command-line option to allow for custom content handlers. - * Tag names @inherits and @scope changed to @borrows and @lends. - ? Combining @constructor in a doclet with @lends now supported. - * Multiple @lend tags now supported. - * Added support for the @constructs tag, used inside a @lends block. - * Added support for the @constant tag. - * Fixed bug that prevented the use of [] as a default value. - * Added support for the @field tag. - * Added support for the @public tag (applied to inner functions). - * @namespace tag can now be applied to functions, not just object literals. - * Added support for the -s command line option to suppress source code output. - * Added new unit test framework. - * Underscored symbols are now treated as if they have a @private tag by default. - * Improved support for anonymous constructors. - * Added support for the nocode meta tag. - \ No newline at end of file diff --git a/utils/jsdoc-toolkit/conf/sample.conf b/utils/jsdoc-toolkit/conf/sample.conf deleted file mode 100755 index ad0f08e..0000000 --- a/utils/jsdoc-toolkit/conf/sample.conf +++ /dev/null @@ -1,31 +0,0 @@ -/* - This is an example of one way you could set up a configuration file to more - conveniently define some commandline options. You might like to do this if - you frequently reuse the same options. Note that you don't need to define - every option in this file, you can combine a configuration file with - additional options on the commandline if your wish. - - You would include this configuration file by running JsDoc Toolkit like so: - java -jar jsrun.jar app/run.js -c=conf/sample.conf - -*/ - -{ - // source files to use - _: ['app/test/jsdoc_test.js'], - - // document all functions, even uncommented ones - a: true, - - // including those marked @private - p: true, - - // some extra variables I want to include - D: {generatedBy: "Michael Mathews", copyright: "2008"}, - - // use this directory as the output directory - d: "docs", - - // use this template - t: "templates/jsdoc" -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/java/build.xml b/utils/jsdoc-toolkit/java/build.xml deleted file mode 100755 index bb845ce..0000000 --- a/utils/jsdoc-toolkit/java/build.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/utils/jsdoc-toolkit/java/build_1.4.xml b/utils/jsdoc-toolkit/java/build_1.4.xml deleted file mode 100755 index ab408a4..0000000 --- a/utils/jsdoc-toolkit/java/build_1.4.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/utils/jsdoc-toolkit/java/classes/js.jar b/utils/jsdoc-toolkit/java/classes/js.jar deleted file mode 100755 index 0352cb1..0000000 --- a/utils/jsdoc-toolkit/java/classes/js.jar +++ /dev/null Binary files differ diff --git a/utils/jsdoc-toolkit/java/src/JsDebugRun.java b/utils/jsdoc-toolkit/java/src/JsDebugRun.java deleted file mode 100755 index 319a5c6..0000000 --- a/utils/jsdoc-toolkit/java/src/JsDebugRun.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * A trivial bootstrap class that simply adds the path to the - * .js file as an argument to the Rhino call. This little hack - * allows the code in the .js file to have access to it's own - * path via the Rhino arguments object. This is necessary to - * allow the .js code to find resource files in a location - * relative to itself. - * - * USAGE: java -jar jsdebug.jar path/to/file.js - */ -public class JsDebugRun { - public static void main(String[] args) { - String[] jsargs = {"-j="+args[0]}; - - String[] allArgs = new String[jsargs.length + args.length]; - System.arraycopy(args, 0, allArgs, 0, args.length); - System.arraycopy(jsargs, 0, allArgs, args.length ,jsargs.length); - - org.mozilla.javascript.tools.debugger.Main.main(allArgs); - } -} diff --git a/utils/jsdoc-toolkit/java/src/JsRun.java b/utils/jsdoc-toolkit/java/src/JsRun.java deleted file mode 100755 index 25f519a..0000000 --- a/utils/jsdoc-toolkit/java/src/JsRun.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * A trivial bootstrap class that simply adds the path to the - * .js file as an argument to the Rhino call. This little hack - * allows the code in the .js file to have access to it's own - * path via the Rhino arguments object. This is necessary to - * allow the .js code to find resource files in a location - * relative to itself. - * - * USAGE: java -jar jsrun.jar path/to/file.js - */ -public class JsRun { - public static void main(String[] args) { - String[] jsargs = {"-j="+args[0]}; - - String[] allArgs = new String[jsargs.length + args.length]; - System.arraycopy(args, 0, allArgs, 0, args.length); - System.arraycopy(jsargs, 0, allArgs, args.length ,jsargs.length); - - org.mozilla.javascript.tools.shell.Main.main(allArgs); - } -} diff --git a/utils/jsdoc-toolkit/jsdebug.jar b/utils/jsdoc-toolkit/jsdebug.jar deleted file mode 100755 index a0ac7da..0000000 --- a/utils/jsdoc-toolkit/jsdebug.jar +++ /dev/null Binary files differ diff --git a/utils/jsdoc-toolkit/jsrun.jar b/utils/jsdoc-toolkit/jsrun.jar deleted file mode 100755 index 49c03f4..0000000 --- a/utils/jsdoc-toolkit/jsrun.jar +++ /dev/null Binary files differ diff --git a/utils/jsdoc-toolkit/jsrun.sh b/utils/jsdoc-toolkit/jsrun.sh deleted file mode 100755 index 74ca79c..0000000 --- a/utils/jsdoc-toolkit/jsrun.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/ksh - -# launcher script for jsdoc -# Author: Avi Deitcher -# -# This program is released under the MIT License as follows: - -# Copyright (c) 2008-2009 Atomic Inc -# -#Permission is hereby granted, free of charge, to any person -#obtaining a copy of this software and associated documentation -#files (the "Software"), to deal in the Software without -#restriction, including without limitation the rights to use, -#copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the -#Software is furnished to do so, subject to the following -#conditions: -## -#The above copyright notice and this permission notice shall be -#included in all copies or substantial portions of the Software. -# -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -#OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -#NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -#WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -#OTHER DEALINGS IN THE SOFTWARE. -# - - -if [[ -n "$JSDOCDIR" ]]; then - _DOCDIR="-Djsdoc.dir=$JSDOCDIR" - _APPDIR="$JSDOCDIR/app" - _BASEDIR="$JSDOCDIR" -else - _DOCDIR="" - _APPDIR="./app" - _BASEDIR="." -fi - -if [[ -n "$JSDOCTEMPLATEDIR" ]]; then - _TDIR="-Djsdoc.template.dir=$JSDOCTEMPLATEDIR" -else - _TDIR="" -fi - -CMD="java $_DOCDIR $_TDIR -jar $_BASEDIR/jsrun.jar $_APPDIR/run.js $@" -echo $CMD -$CMD - diff --git a/utils/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl b/utils/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl deleted file mode 100755 index 32f4358..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +++ /dev/null @@ -1,17 +0,0 @@ -
{+new Link().toFile("index.html").withText("Class Index")+} -| {+new Link().toFile("files.html").withText("File Index")+}
-
-

Classes

-
    - -
  • {! - if (thisClass.alias == "_global_") { - output += ""+new Link().toClass(thisClass.alias)+""; - } - else { - output += new Link().toClass(thisClass.alias); - } - !}
  • -
    -
-
\ No newline at end of file diff --git a/utils/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl b/utils/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl deleted file mode 100755 index 86c7590..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {! Link.base = ""; /* all generated links will be relative to this */ !} - JsDoc Reference - File Index - - - - - - - {+include("static/header.html")+} - -
- {+publish.classesIndex+} -
- -
-

File Index

- - -
-

{+new Link().toSrc(item.alias).withText(item.name)+}

- {+resolveLinks(item.desc)+} -
- -
Author:
-
{+item.author+}
-
- -
Version:
-
{+item.version+}
-
- {! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !} - -
Location:
- -
{+location+}
-
-
-
-
-
-
- -
-
- ©{+JSDOC.opt.D.copyright+}
- Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} -
- - \ No newline at end of file diff --git a/utils/jsdoc-toolkit/templates/jsdoc/class.tmpl b/utils/jsdoc-toolkit/templates/jsdoc/class.tmpl deleted file mode 100755 index e51f1d3..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/class.tmpl +++ /dev/null @@ -1,646 +0,0 @@ - - - - - - {! Link.base = "../"; /* all generated links will be relative to this */ !} - JsDoc Reference - {+data.alias+} - - - - - - - - {+include("static/header.html")+} - - - -
- - {+publish.classesIndex+} - -
- -
- -

- {! - var classType = ""; - - if (data.isBuiltin()) { - classType += "Built-In "; - } - - if (data.isNamespace) { - if (data.is('FUNCTION')) { - classType += "Function "; - } - classType += "Namespace "; - } - else { - classType += "Class "; - } - !} - {+classType+}{+data.alias+} -

- - -

-
Extends - {+ - data.augments - .sort() - .map( - function($) { return new Link().toSymbol($); } - ) - .join(", ") - +}.
-
- - {+resolveLinks(data.classDesc)+} - - {# isn't defined in any file #} -
Defined in: {+new Link().toSrc(data.srcFile)+}. -
-

- - - - - - - - - - - - - - - - - -
{+classType+}Summary
Constructor AttributesConstructor Name and Description
{! - if (data.isPrivate) output += "<private> "; - if (data.isInner) output += "<inner> "; - !}  -
- {+ new Link().toSymbol(data.alias).inner('constructor')+}{+ makeSignature(data.params) +} -
-
{+resolveLinks(summarize(data.desc))+}
-
-
- - - - {! var ownProperties = data.properties.filter(function($){return $.memberOf == data.alias && !$.isNamespace}).sort(makeSortby("name")); !} - - - - - - - - - - - - - - - - - -
Field Summary
Field AttributesField Name and Description
{! - if (member.isPrivate) output += "<private> "; - if (member.isInner) output += "<inner> "; - if (member.isStatic) output += "<static> "; - if (member.isConstant) output += "<constant> "; - !}  -
- {+member.memberOf+}.{+new Link().toSymbol(member.alias).withText(member.name)+} -
-
{+resolveLinks(summarize(member.desc))+}
-
-
- - -
- {! - var borrowedMembers = data.properties.filter(function($) {return $.memberOf != data.alias}); - - var contributers = []; - borrowedMembers.map(function($) {if (contributers.indexOf($.memberOf) < 0) contributers.push($.memberOf)}); - for (var i = 0, l = contributers.length; i < l; i++) { - output += - "
Fields borrowed from class "+new Link().toSymbol(contributers[i])+":
" - + - "
" + - borrowedMembers - .filter( - function($) { return $.memberOf == contributers[i] } - ) - .sort(makeSortby("name")) - .map( - function($) { return new Link().toSymbol($.alias).withText($.name) } - ) - .join(", ") - + - "
"; - } - !} -
-
-
- - - - {! var ownMethods = data.methods.filter(function($){return $.memberOf == data.alias && !$.isNamespace}).sort(makeSortby("name")); !} - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
{! - if (member.isPrivate) output += "<private> "; - if (member.isInner) output += "<inner> "; - if (member.isStatic) output += "<static> "; - !}  -
{+member.memberOf+}.{+new Link().toSymbol(member.alias).withText(member.name)+}{+makeSignature(member.params)+} -
-
{+resolveLinks(summarize(member.desc))+}
-
-
- - -
- {! - var borrowedMembers = data.methods.filter(function($) {return $.memberOf != data.alias}); - var contributers = []; - borrowedMembers.map(function($) {if (contributers.indexOf($.memberOf) < 0) contributers.push($.memberOf)}); - for (var i = 0, l = contributers.length; i < l; i++) { - output += - "
Methods borrowed from class "+new Link().toSymbol(contributers[i])+":
" - + - "
" + - borrowedMembers - .filter( - function($) { return $.memberOf == contributers[i] } - ) - .sort(makeSortby("name")) - .map( - function($) { return new Link().toSymbol($.alias).withText($.name) } - ) - .join(", ") - + - "
"; - } - - !} -
-
-
- - - {! var ownEvents = data.events.filter(function($){return $.memberOf == data.alias && !$.isNamespace}).sort(makeSortby("name")); !} - - - - - - - - - - - - - - - - - -
Event Summary
Event AttributesEvent Name and Description
{! - if (member.isPrivate) output += "<private> "; - if (member.isInner) output += "<inner> "; - if (member.isStatic) output += "<static> "; - !}  -
{+member.memberOf+}.{+new Link().toSymbol(member.alias).withText(member.name)+}{+makeSignature(member.params)+} -
-
{+resolveLinks(summarize(member.desc))+}
-
-
- - -
- {! - var borrowedMembers = data.events.filter(function($) {return $.memberOf != data.alias}); - var contributers = []; - borrowedMembers.map(function($) {if (contributers.indexOf($.memberOf) < 0) contributers.push($.memberOf)}); - for (var i = 0, l = contributers.length; i < l; i++) { - output += - "
Events borrowed from class "+new Link().toSymbol(contributers[i])+":
" - + - "
" + - borrowedMembers - .filter( - function($) { return $.memberOf == contributers[i] } - ) - .sort(makeSortby("name")) - .map( - function($) { return new Link().toSymbol($.alias).withText($.name) } - ) - .join(", ") - + - "
"; - } - - !} -
-
-
- - - -
-
- {+classType+}Detail -
- -
{! - if (data.isPrivate) output += "<private> "; - if (data.isInner) output += "<inner> "; - !} - {+ data.alias +}{+ makeSignature(data.params) +} -
- -
- {+resolveLinks(data.desc)+} -
Author: {+data.author+}.
-
- - - -
{+example+}
-
-
- - - -
-
Parameters:
- -
- {+((item.type)?""+("{"+(new Link().toSymbol(item.type)+"} ")) : "")+} {+item.name+} - Optional, Default: {+item.defaultValue+} -
-
{+resolveLinks(item.desc)+}
-
-
-
- -
-
Deprecated:
-
- {+resolveLinks(data.deprecated)+} -
-
-
- -
-
Since:
-
{+ data.since +}
-
-
- -
-
Throws:
- -
- {+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+} {+item.name+} -
-
{+resolveLinks(item.desc)+}
-
-
-
- -
-
Returns:
- -
{+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+}{+resolveLinks(item.desc)+}
-
-
-
- -
-
Requires:
- -
{+ resolveLinks(item) +}
-
-
-
- -
-
See:
- -
{+ new Link().toSymbol(item) +}
-
-
-
- -
-
- - - -
- Field Detail -
- - -
{! - if (member.isPrivate) output += "<private> "; - if (member.isInner) output += "<inner> "; - if (member.isStatic) output += "<static> "; - if (member.isConstant) output += "<constant> "; - !} - - {{+new Link().toSymbol(member.type)+}} - {+member.memberOf+}.{+member.name+} - -
-
- {+resolveLinks(member.desc)+} - -
- Defined in: {+new Link().toSrc(member.srcFile)+}. -
-
Author: {+member.author+}.
-
- - - -
{+example+}
-
-
- - -
-
Deprecated:
-
- {+ resolveLinks(member.deprecated) +} -
-
-
- -
-
Since:
-
{+ member.since +}
-
-
- -
-
See:
- -
{+ new Link().toSymbol(item) +}
-
-
-
- -
-
Default Value:
-
- {+resolveLinks(member.defaultValue)+} -
-
-
- -
-
-
- - - -
- Method Detail -
- - -
{! - if (member.isPrivate) output += "<private> "; - if (member.isInner) output += "<inner> "; - if (member.isStatic) output += "<static> "; - !} - - {{+new Link().toSymbol(member.type)+}} - {+member.memberOf+}.{+member.name+}{+makeSignature(member.params)+} - -
-
- {+resolveLinks(member.desc)+} - -
- Defined in: {+new Link().toSrc(member.srcFile)+}. -
-
Author: {+member.author+}.
-
- - - -
{+example+}
-
-
- - -
-
Parameters:
- -
- {+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+}{+item.name+} - Optional, Default: {+item.defaultValue+} -
-
{+resolveLinks(item.desc)+}
-
-
-
- -
-
Deprecated:
-
- {+ resolveLinks(member.deprecated) +} -
-
-
- -
-
Since:
-
{+ member.since +}
-
- -
- -
-
Throws:
- -
- {+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+} {+item.name+} -
-
{+resolveLinks(item.desc)+}
-
-
-
- -
-
Returns:
- -
{+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+}{+resolveLinks(item.desc)+}
-
-
-
- -
-
Requires:
- -
{+ resolveLinks(item) +}
-
-
-
- -
-
See:
- -
{+ new Link().toSymbol(item) +}
-
-
-
- -
-
-
- - - -
- Event Detail -
- - -
{! - if (member.isPrivate) output += "<private> "; - if (member.isInner) output += "<inner> "; - if (member.isStatic) output += "<static> "; - !} - - {{+new Link().toSymbol(member.type)+}} - {+member.memberOf+}.{+member.name+}{+makeSignature(member.params)+} - -
-
- {+resolveLinks(member.desc)+} - -
- Defined in: {+new Link().toSrc(member.srcFile)+}. -
-
Author: {+member.author+}.
-
- - - -
{+example+}
-
-
- - -
-
Parameters:
- -
- {+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+}{+item.name+} - Optional, Default: {+item.defaultValue+} -
-
{+ resolveLinks(item.desc) +}
-
-
-
- -
-
Deprecated:
-
- {+ resolveLinks(member.deprecated) +} -
-
-
- -
-
Since:
-
{+ member.since +}
-
- -
- -
-
Throws:
- -
- {+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+} {+item.name+} -
-
{+ resolveLinks(item.desc) +}
-
-
-
- -
-
Returns:
- -
{+((item.type)?"{"+(new Link().toSymbol(item.type))+"} " : "")+}{+resolveLinks(item.desc)+}
-
-
-
- -
-
Requires:
- -
{+ resolveLinks(item) +}
-
-
-
- -
-
See:
- -
{+ new Link().toSymbol(item) +}
-
-
-
- -
-
-
- -
-
- - - -
- ©{+JSDOC.opt.D.copyright+}
- Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} -
- - diff --git a/utils/jsdoc-toolkit/templates/jsdoc/index.tmpl b/utils/jsdoc-toolkit/templates/jsdoc/index.tmpl deleted file mode 100755 index a5dc115..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/index.tmpl +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - JsDoc Reference - Index - - - - - - - {+include("static/header.html")+} - -
- {+publish.classesIndex+} -
- -
-

Class Index

- - -
-

{+(new Link().toSymbol(thisClass.alias))+}

- {+resolveLinks(summarize(thisClass.classDesc))+} -
-
-
- -
-
- ©{+JSDOC.opt.D.copyright+}
- Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} -
- - \ No newline at end of file diff --git a/utils/jsdoc-toolkit/templates/jsdoc/publish.js b/utils/jsdoc-toolkit/templates/jsdoc/publish.js deleted file mode 100755 index 446c92b..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/publish.js +++ /dev/null @@ -1,200 +0,0 @@ -/** Called automatically by JsDoc Toolkit. */ -function publish(symbolSet) { - publish.conf = { // trailing slash expected for dirs - ext: ".html", - outDir: JSDOC.opt.d || SYS.pwd+"../out/jsdoc/", - templatesDir: JSDOC.opt.t || SYS.pwd+"../templates/jsdoc/", - symbolsDir: "symbols/", - srcDir: "symbols/src/" - }; - - // is source output is suppressed, just display the links to the source file - if (JSDOC.opt.s && defined(Link) && Link.prototype._makeSrcLink) { - Link.prototype._makeSrcLink = function(srcFilePath) { - return "<"+srcFilePath+">"; - } - } - - // create the folders and subfolders to hold the output - IO.mkPath((publish.conf.outDir+"symbols/src").split("/")); - - // used to allow Link to check the details of things being linked to - Link.symbolSet = symbolSet; - - // create the required templates - try { - var classTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"class.tmpl"); - var classesTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allclasses.tmpl"); - } - catch(e) { - print("Couldn't create the required templates: "+e); - quit(); - } - - // some ustility filters - function hasNoParent($) {return ($.memberOf == "")} - function isaFile($) {return ($.is("FILE"))} - function isaClass($) {return ($.is("CONSTRUCTOR") || $.isNamespace)} - - // get an array version of the symbolset, useful for filtering - var symbols = symbolSet.toArray(); - - // create the hilited source code files - var files = JSDOC.opt.srcFiles; - for (var i = 0, l = files.length; i < l; i++) { - var file = files[i]; - var srcDir = publish.conf.outDir + "symbols/src/"; - makeSrcFile(file, srcDir); - } - - // get a list of all the classes in the symbolset - var classes = symbols.filter(isaClass).sort(makeSortby("alias")); - - // create a filemap in which outfiles must be to be named uniquely, ignoring case - if (JSDOC.opt.u) { - var filemapCounts = {}; - Link.filemap = {}; - for (var i = 0, l = classes.length; i < l; i++) { - var lcAlias = classes[i].alias.toLowerCase(); - - if (!filemapCounts[lcAlias]) filemapCounts[lcAlias] = 1; - else filemapCounts[lcAlias]++; - - Link.filemap[classes[i].alias] = - (filemapCounts[lcAlias] > 1)? - lcAlias+"_"+filemapCounts[lcAlias] : lcAlias; - } - } - - // create a class index, displayed in the left-hand column of every class page - Link.base = "../"; - publish.classesIndex = classesTemplate.process(classes); // kept in memory - - // create each of the class pages - for (var i = 0, l = classes.length; i < l; i++) { - var symbol = classes[i]; - - symbol.events = symbol.getEvents(); // 1 order matters - symbol.methods = symbol.getMethods(); // 2 - - var output = ""; - output = classTemplate.process(symbol); - - IO.saveFile(publish.conf.outDir+"symbols/", ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias) + publish.conf.ext, output); - } - - // regenerate the index with different relative links, used in the index pages - Link.base = ""; - publish.classesIndex = classesTemplate.process(classes); - - // create the class index page - try { - var classesindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"index.tmpl"); - } - catch(e) { print(e.message); quit(); } - - var classesIndex = classesindexTemplate.process(classes); - IO.saveFile(publish.conf.outDir, "index"+publish.conf.ext, classesIndex); - classesindexTemplate = classesIndex = classes = null; - - // create the file index page - try { - var fileindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allfiles.tmpl"); - } - catch(e) { print(e.message); quit(); } - - var documentedFiles = symbols.filter(isaFile); // files that have file-level docs - var allFiles = []; // not all files have file-level docs, but we need to list every one - - for (var i = 0; i < files.length; i++) { - allFiles.push(new JSDOC.Symbol(files[i], [], "FILE", new JSDOC.DocComment("/** */"))); - } - - for (var i = 0; i < documentedFiles.length; i++) { - var offset = files.indexOf(documentedFiles[i].alias); - allFiles[offset] = documentedFiles[i]; - } - - allFiles = allFiles.sort(makeSortby("name")); - - // output the file index page - var filesIndex = fileindexTemplate.process(allFiles); - IO.saveFile(publish.conf.outDir, "files"+publish.conf.ext, filesIndex); - fileindexTemplate = filesIndex = files = null; -} - - -/** Just the first sentence (up to a full stop). Should not break on dotted variable names. */ -function summarize(desc) { - if (typeof desc != "undefined") - return desc.match(/([\w\W]+?\.)[^a-z0-9_$]/i)? RegExp.$1 : desc; -} - -/** Make a symbol sorter by some attribute. */ -function makeSortby(attribute) { - return function(a, b) { - if (a[attribute] != undefined && b[attribute] != undefined) { - a = a[attribute].toLowerCase(); - b = b[attribute].toLowerCase(); - if (a < b) return -1; - if (a > b) return 1; - return 0; - } - } -} - -/** Pull in the contents of an external file at the given path. */ -function include(path) { - var path = publish.conf.templatesDir+path; - return IO.readFile(path); -} - -/** Turn a raw source file into a code-hilited page in the docs. */ -function makeSrcFile(path, srcDir, name) { - if (JSDOC.opt.s) return; - - if (!name) { - name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_"); - name = name.replace(/\:/g, "_"); - } - - var src = {path: path, name:name, charset: IO.encoding, hilited: ""}; - - if (defined(JSDOC.PluginManager)) { - JSDOC.PluginManager.run("onPublishSrc", src); - } - - if (src.hilited) { - IO.saveFile(srcDir, name+publish.conf.ext, src.hilited); - } -} - -/** Build output for displaying function parameters. */ -function makeSignature(params) { - if (!params) return "()"; - var signature = "(" - + - params.filter( - function($) { - return $.name.indexOf(".") == -1; // don't show config params in signature - } - ).map( - function($) { - return $.name; - } - ).join(", ") - + - ")"; - return signature; -} - -/** Find symbol {@link ...} strings in text and turn into html links */ -function resolveLinks(str, from) { - str = str.replace(/\{@link ([^} ]+) ?\}/gi, - function(match, symbolName) { - return new Link().toSymbol(symbolName); - } - ); - - return str; -} diff --git a/utils/jsdoc-toolkit/templates/jsdoc/static/default.css b/utils/jsdoc-toolkit/templates/jsdoc/static/default.css deleted file mode 100755 index 97e021e..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/static/default.css +++ /dev/null @@ -1,162 +0,0 @@ -/* default.css */ -body -{ - font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 800px; -} - -.header -{ - clear: both; - background-color: #ccc; - padding: 8px; -} - -h1 -{ - font-size: 150%; - font-weight: bold; - padding: 0; - margin: 1em 0 0 .3em; -} - -hr -{ - border: none 0; - border-top: 1px solid #7F8FB1; - height: 1px; -} - -pre.code -{ - display: block; - padding: 8px; - border: 1px dashed #ccc; -} - -#index -{ - margin-top: 24px; - float: left; - width: 160px; - position: absolute; - left: 8px; - background-color: #F3F3F3; - padding: 8px; -} - -#content -{ - margin-left: 190px; - width: 600px; -} - -.classList -{ - list-style-type: none; - padding: 0; - margin: 0 0 0 8px; - font-family: arial, sans-serif; - font-size: 1em; - overflow: auto; -} - -.classList li -{ - padding: 0; - margin: 0 0 8px 0; -} - -.summaryTable { width: 100%; } - -h1.classTitle -{ - font-size:170%; - line-height:130%; -} - -h2 { font-size: 110%; } -caption, div.sectionTitle -{ - background-color: #7F8FB1; - color: #fff; - font-size:130%; - text-align: left; - padding: 2px 6px 2px 6px; - border: 1px #7F8FB1 solid; -} - -div.sectionTitle { margin-bottom: 8px; } -.summaryTable thead { display: none; } - -.summaryTable td -{ - vertical-align: top; - padding: 4px; - border-bottom: 1px #7F8FB1 solid; - border-right: 1px #7F8FB1 solid; -} - -/*col#summaryAttributes {}*/ -.summaryTable td.attributes -{ - border-left: 1px #7F8FB1 solid; - width: 140px; - text-align: right; -} - -td.attributes, .fixedFont -{ - line-height: 15px; - color: #002EBE; - font-family: "Courier New",Courier,monospace; - font-size: 13px; -} - -.summaryTable td.nameDescription -{ - text-align: left; - font-size: 13px; - line-height: 15px; -} - -.summaryTable td.nameDescription, .description -{ - line-height: 15px; - padding: 4px; - padding-left: 4px; -} - -.summaryTable { margin-bottom: 8px; } - -ul.inheritsList -{ - list-style: square; - margin-left: 20px; - padding-left: 0; -} - -.detailList { - margin-left: 20px; - line-height: 15px; -} -.detailList dt { margin-left: 20px; } - -.detailList .heading -{ - font-weight: bold; - padding-bottom: 6px; - margin-left: 0; -} - -.light, td.attributes, .light a:link, .light a:visited -{ - color: #777; - font-style: italic; -} - -.fineprint -{ - text-align: right; - font-size: 10px; -} \ No newline at end of file diff --git a/utils/jsdoc-toolkit/templates/jsdoc/static/header.html b/utils/jsdoc-toolkit/templates/jsdoc/static/header.html deleted file mode 100755 index 353b735..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/static/header.html +++ /dev/null @@ -1,2 +0,0 @@ - \ No newline at end of file diff --git a/utils/jsdoc-toolkit/templates/jsdoc/static/index.html b/utils/jsdoc-toolkit/templates/jsdoc/static/index.html deleted file mode 100755 index 661f6f6..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/static/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Generated Javascript Documentation - - - - - - <body> - <p> - This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. - </p> - </body> - - - \ No newline at end of file diff --git a/utils/jsdoc-toolkit/templates/jsdoc/symbol.tmpl b/utils/jsdoc-toolkit/templates/jsdoc/symbol.tmpl deleted file mode 100755 index f8f4bd1..0000000 --- a/utils/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +++ /dev/null @@ -1,35 +0,0 @@ - - {+data.name+} - {+data.memberOf+} - {+data.isStatic+} - {+data.isa+} - {+data.desc+} - {+data.classDesc+} - - - - {+method.name+} - {+method.memberOf+} - {+method.isStatic+} - {+method.desc+} - - - {+param.type+} - {+param.name+} - {+param.desc+} - {+param.defaultValue+} - - - - - - - - {+property.name+} - {+property.memberOf+} - {+property.isStatic+} - {+property.desc+} - {+property.type+} - - - diff --git a/utils/lib/.args.js.swp b/utils/lib/.args.js.swp deleted file mode 100755 index 9c2cec9..0000000 --- a/utils/lib/.args.js.swp +++ /dev/null Binary files differ diff --git a/utils/lib/args.js b/utils/lib/args.js deleted file mode 100755 index 4c7f450..0000000 --- a/utils/lib/args.js +++ /dev/null @@ -1,702 +0,0 @@ - -var os = require('os'); -var util = require('util'); -var stream = require('term').stream; - -exports.Parser = function () { - this._options = []; - this._def = {}; - this._long = {}; - this._short = {}; - this._commands = {}; - this._args = []; - this._vargs = undefined; -}; - -exports.Parser.prototype.option = function () { - var self = this; - var option = new this.Option(this, arguments); - this._options.push(option); - return option; -}; - -exports.Parser.prototype.def = function (name, value) { - this._def[name] = value; - return this; -}; - -exports.Parser.prototype.command = function (name, handler) { - var parent = this; - if (!handler) { - var parser = new exports.Parser(); - this._commands[name] = function () { - return parser; - }; - return parser; - } else if (typeof handler == "string") { - this._commands[name] = function () { - return require(handler).parser; - }; - return; - } else { - var parser = new this.Parser(); - parser.action(handler); - this._commands[name] = function () { - return parser; - }; - return parser; - } -}; - -exports.Parser.prototype.arg = function (name) { - var argument = new exports.Argument(this).name(name); - this._args.push(argument); - return argument; -}; - -exports.Parser.prototype.args = function (name) { - var argument = new exports.Argument(this).name(name); - this._vargs = argument; - return argument; -}; - -exports.Parser.prototype.act = function (args, options) { - if (!this._action) { - this.error(options, "Not yet implemented."); - this.exit(-1); - } - options.acted = true; - this._action.call(this, this.parse(args), options); -}; - -exports.Parser.prototype.action = function (action) { - this._action = action; - return this; -}; - -// should be called last -exports.Parser.prototype.helpful = function () { - var self = this; - this.option('-h', '--help') - .help('displays usage information') - .action(function (options) { - return self.printHelp(options); - }) - .halt(); - if (util.len(this._commands)) - this.command('help', function (options) { - self.printHelp(options); - }).help('displays usage information'); - return this; -}; - -exports.Parser.prototype.usage = function (usage) { - this._usage = usage; - return this; -}; - -exports.Parser.prototype.help = function (help) { - this._help = help; - return this; -}; - -exports.Parser.prototype.printHelp = function (options) { - if (options.args.length) { - util.put(options.args, 1, '--help'); - this._commands[options.args[0]]().act(options.args, options); - } else { - this.printUsage(options); - // todo, parse args for deep help - if (this._help) - this.print('\0cyan(\0bold(' + this._help + '\0)\0)'); - this.printCommands(options); - this.printOptions(options); - this.exit(); - } -}; - -exports.Parser.prototype.printUsage = function (options) { - this.print( - 'Usage: \0bold(\0blue(' + system.fs.basename(options.command || '') + ' [OPTIONS]' + - (util.len(this._commands) ? - ' COMMAND' : - '' - ) + - (util.len(this._args) ? - ' ' + this._args.map(function (arg) { - if (arg._optional) { - return '[' + arg._name.toUpperCase() + ']'; - } else { - return arg._name.toUpperCase(); - } - }).join(' ') : - '' - ) + - (this._vargs ? - ' [' + this._vargs._name.toUpperCase() + ' ...]': - '' - ) + - (this._usage ? - ' ' + this._usage : - '' - ) + "\0)\0)" - ); -}; - -exports.Parser.prototype.printCommands = function (options) { - var self = this; - util.forEachApply( - util.items(this._commands), - function (name, command) { - var parser = command(); - self.print(' \0bold(\0green(' + name + '\0)\0)' + ( - parser._help ? - ( - ': ' + - ( - parser._action? - '': '\0red(NYI\0): ' - ) + - parser._help - ) : '' - )); - } - ); -}; - -exports.Parser.prototype.printOptions = function (options) { - var self = this; - this._options.forEach(function (option) { - if (option._hidden) - return; - var message = []; - if (option._short.length) - message.push(option._short.map(function (_short) { - return ' \0bold(\0green(-' + _short + '\0)\0)'; - }).join('')); - if (option._long.length) - message.push(option._long.map(function (_long) { - return ' \0bold(\0green(--' + _long + '\0)\0)'; - }).join('')); - if (option._action.length > 2) - message.push( - ' ' + - util.range(option._action.length - 2) - .map(function () { - return '\0bold(\0green(' + util.upper( - option.getName() - ) + '\0)\0)'; - }).join(' ') - ); - if (option._help) - message.push(': ' + option._help + ''); - if (option._choices) { - var choices = option._choices; - if (!util.isArrayLike(choices)) - choices = util.keys(choices); - message.push(' \0bold(\0blue((' + choices.join(', ') + ')\0)\0)'); - } - if (option._halt) - message.push(' \0bold(\0blue((final option)\0)\0)'); - self.print(message.join('')); - }); -}; - -exports.Parser.prototype.error = function (options, message) { - if (this._parser) { - this._parser.error.apply( - this._parser, - arguments - ); - } else { - this.print('\0red(' + message + '\0)'); - this.exit(); - } -}; - -exports.Parser.prototype.exit = function (status) { - if (this._parser) - this._parser.exit.apply( - this._parser, - arguments - ); - else { - os.exit(status); - throw new Error("exit failed"); - } -}; - -exports.Parser.prototype.print = function () { - if (this._parser) - this._parser.print.apply( - this._parser, - arguments - ); - else - stream.print.apply(null, arguments); -}; - -exports.Parser.prototype.parse = function (args, options, noCommand) { - var self = this; - - if (!args) - args = system.args; - if (!options) - options = {}; - - options.args = args; - if (!noCommand && args.length && !/^-/.test(args[0])) - options.command = args.shift(); - - function mandatoryShift(n, name) { - if (n > args.length) { - this.error( - options, - 'ERROR: The ' + util.enquote(name) + - ' option requires ' + n + ' arguments.' - ); - } - return args.shift(n); - }; - - function validate (option, value) { - try { - return option._validate.call(self, value); - } catch (exception) { - self.error(options, exception); - } - }; - - // initial values - for (var name in this._def) { - if (util.has(this._def, name) && !util.has(options, name)) - options[name] = util.copy(this._def[name]); - } - this._options.forEach(function (option) { - if (!util.has(options, option._name)) - options[option._name] = option._def; - }); - - // walk args - ARGS: while (args.length) { - var arg = args.shift(); - if (arg == "--") { - break; - - } else if (/^--/.test(arg)) { - - var pattern = arg.match(/^--([^=]+)(?:=(.*))?/).slice(1); - var word = pattern[0]; - var value = pattern[1]; - - if (!!value) { - args.unshift(value); - } - - if (util.has(this._long, word)) { - - var option = this._long[word]; - if (!option._action) { - self.error( - options, - "Programmer error: The " + word + - " option does not have an associated action." - ); - } - if (option._action.length <= 2) { - option._action.call( - self, - options, - option._name - ); - } else if (option._action.length <= 3) { - option._action.apply( - self, - [ - options, - option.getName(), - validate(option, mandatoryShift.call( - this, - Math.max(0, option._action.length - 2), - word - )) - ] - ); - } else { - option._action.apply( - self, - [ - options, - option.getName() - ].concat( - validate(option, mandatoryShift.call( - this, - Math.max(0, option._action.length - 2), - word - )) - ) - ); - } - - if (option._halt) - break ARGS; - - } else { - this.error(options, 'ERROR: Unrecognized option: ' + util.enquote(word)); - } - - } else if (/^-/.test(arg)) { - - var letters = arg.match(/^-(.*)/)[1].split(''); - while (letters.length) { - var letter = letters.shift(); - if (util.has(this._short, letter)) { - var option = this._short[letter]; - if (option._action.length > 2) { - if (letters.length) { - option._action.call( - self, - options, - option._name, - validate(option, letters.join('')) - ); - letters = ''; - } else { - option._action.apply( - self, - [ - options, - option._name, - ].concat( - validate(option, args.shift(option._action.length - 2)) - ) - ); - } - } else { - option._action.call(self, options, option._name); - } - - if (option._halt) - break ARGS; - - } else { - this.error(options, 'ERROR: unrecognized option: ' + util.enquote(letter)); - } - } - - } else { - args.unshift(arg); - break; - } - - } - - if (util.len(this._commands)) { - if (args.length) { - if (util.has(this._commands, args[0])) { - var command = this._commands[args[0]]; - command().act(args, options); - } else { - this.error(options, 'ERROR: unrecognized command'); - } - } else { - this.printHelp(options); - this.exit(0); - } - } - - return options; -}; - -exports.Argument = function (parser) { - this._parser = parser; - return this; -}; - -exports.Argument.prototype.name = function (name) { - this._name = name; - return this; -}; - -exports.Argument.prototype.optional = function () { - this._optional = true; - return this; -}; - -exports.Option = function (parser, args) { - var self = this; - this._parser = parser; - this._validate = function (value) { - return value; - }; - this._long = []; - this._short = []; - util.forEach(args, function (arg) { - if (typeof arg == "function") { - self.action(arg); - } else if (typeof arg !== "string") { - for (var name in arg) { - var value = arg[name]; - self[name](value); - } - } else if (/ /.test(arg)) { - self.help(arg); - } else if (/^--/.test(arg)) { - arg = arg.match(/^--(.*)/)[1]; - self.__(arg); - } else if (/^-.$/.test(arg)) { - arg = arg.match(/^-(.)/)[1]; - self._(arg); - } else if (/^-/.test(arg)) { - throw new Error("option names with one dash can only have one letter."); - } else { - self.name(arg); - } - }); - return this; -}; - -exports.Option.prototype._ = function (letter) { - this._short.push(letter); - this._parser._short[letter] = this; - return this; -}; - -exports.Option.prototype.__ = function (word) { - this._long.push(word); - this._parser._long[word] = this; - return this; -}; - -exports.Option.prototype.name = function (name) { - this._name = name; - return this; -}; - -exports.Option.prototype.getName = function () { - if (this._name) - return this._name; - if (this._long.length); - return this._long[0] - if (this._short.length) - return this._short[0] - throw new Error("Programmer error: unnamed option"); -}; - -exports.Option.prototype.action = function (action) { - var self = this; - if (typeof action == "string") { - this._action = self._parser[action]; - } else { - this._action = action; - } - return this; -}; - -exports.Option.prototype.set = function (value) { - var option = this; - if (arguments.length == 0) - return this.action(function (options, name, value) { - options[name] = value; - }); - else if (arguments.length == 1) - return this.action(function (options, name) { - options[name] = value; - }); - else - throw new Error("Option().set takes 0 or 1 arguments"); -}; - -exports.Option.prototype.push = function () { - var option = this; - return this.def([]).action(function (options, name, value) { - options[option._name].push(option._validate.call( - this, - value - )); - }); -}; - -exports.Option.prototype.inc = function () { - return this.def(0).action(function (options, name) { - options[name]++; - }); -}; - -exports.Option.prototype.dec = function () { - return this.def(0).action(function (options, name) { - options[name]--; - }); -}; - -exports.Option.prototype.choices = function (choices) { - this.set(); - this._choices = choices; - var self = this; - if (util.isArrayLike(choices)) { - return this.validate(function (value) { - if (choices.indexOf(value) < 0) - throw new Error( - "choice for " + util.upper(self.getName()) + - " is invalid: " + util.enquote(value) + "\n" + - "Use one of: " + choices.map(function (choice) { - return util.enquote(choice); - }).join(', ') - ); - return value; - }) - } else { - return this.validate(function (value) { - if (!util.has(choices, value)) - throw new Error( - "choice for " + util.upper(self.getName()) + - " is invalid: " + util.enquote(value) + "\n" + - "Use one of: " + util.keys(choices).map(function (choice) { - return util.enquote(choice); - }).join(', ') - ); - return choices[value]; - }); - } -}; - -exports.Option.prototype.def = function (value) { - if (this._def === undefined) - this._def = value; - return this; -}; - -exports.Option.prototype.validate = function (validate) { - this._validate = validate; - return this; -}; - -exports.Option.prototype.input = function () { - this.set().validate(function (value) { - if (value == "-") - return system.stdin; - else - return system.fs.open(value, 'r'); - }); -}; - -exports.Option.prototype.output = function () { - this.set().validate(function (value) { - if (value == "-") - return system.stdout; - else - return system.fs.open(value, 'w'); - }); -}; - -exports.Option.prototype.number = function () { - return this.set().validate(function (value) { - var result = +value; - if (result == NaN) - throw new Error("not a number"); - return result; - }); -}; - -exports.Option.prototype.oct = function () { - return this.set().validate(function (value) { - var result = parseInt(value, 8); - if (result == 0 && +value !== 0) - throw new Error("not an octal value"); - return result; - }); -}; - -exports.Option.prototype.hex = function () { - return this.set().validate(function (value) { - var result = parseInt(value, 16); - if (result == 0 && +value !== 0) - throw new Error("not an hex value"); - return result; - }); -}; - -exports.Option.prototype.integer = function () { - return this.set().validate(function (value) { - var result = value >>> 0; - if (result !== value) - throw new Error("not an integer"); - return result; - }); -}; - -exports.Option.prototype.natural = function () { - return this.set().validate(function (value) { - var result = value >>> 0; - if (result !== +value || result < 0) - throw new Error("not a natural number"); - return result; - }); -}; - -exports.Option.prototype.whole = function () { - return this.set().validate(function (value) { - var result = value >>> 0; - if (result !== +value || result < 1) - throw new Error("not a whole number"); - return result; - }); -}; - -exports.Option.prototype.bool = function (def) { - if (def === undefined) - def = true; - return this.def(!def).set(!!def); -}; - -exports.Option.prototype.inverse = function () { - var args = arguments; - if (!args.length) { - args = []; - this._short.forEach(function (_) { - args.push('-' + _.toUpperCase()); - }); - this._long.forEach(function (__) { - args.push('--no-' + __); - }); - if (this._name) - args.push(this._name); - } - var parser = this._parser; - var inverse = this._inverse = parser.option.apply( - parser, - args - ).set(!this._def).help('^ inverse'); - return this; -}; - -exports.Option.prototype.help = function (text) { - this._help = text; - return this; -}; - -exports.Option.prototype.halt = function () { - this._halt = true; - return this; -}; - -exports.Option.prototype.hidden = function () { - this._hidden = true; - return this; -}; - -exports.Option.prototype.end = function () { - return this._parser; -}; - -exports.Option.prototype.option = function () { - return this.end().option.apply(this, arguments); -}; - -exports.Parser.prototype.end = function () { - return this._parser; -}; - -exports.Parser.prototype.Option = exports.Option; -exports.Parser.prototype.Parser = exports.Parser; - diff --git a/utils/lib/base16.js b/utils/lib/base16.js deleted file mode 100755 index b8e54c7..0000000 --- a/utils/lib/base16.js +++ /dev/null @@ -1,16 +0,0 @@ - -var util = require('util'); -var binary = require('binary'); -var struct = require('struct'); - -exports.encode = function (n) { - var length = n.length; - var result = []; - var alphabet = struct.alphabet16Lower; - for (var i = 0; i < length; i++) { - n[i] = n[i] & 0xFF; - result.push(alphabet[(n.charCodeAt(i) >>> 4) & 0xF], alphabet[n.charCodeAt(i) & 0xF]); - } - return result.join(''); -}; - diff --git a/utils/lib/base64.js b/utils/lib/base64.js deleted file mode 100755 index 0579e80..0000000 --- a/utils/lib/base64.js +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 1999 Masanao Izumo - * Version: 1.0 - * LastModified: Dec 25 1999 - * This library is free. You can redistribute it and/or modify it. - */ - -/* modified by Kris Kowal to add support for Binary for Narwhal */ - -var encodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -var decodeChars = [ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, - -1, 0, 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, -1, -1, -1, -1, -1, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 -]; - -var binary = require('binary'); - -exports.encode = function (str) { - var out, i, length; - var c1, c2, c3; - - length = len(str); - i = 0; - out = []; - while(i < length) { - c1 = str.charCodeAt(i++) & 0xff; - if(i == length) - { - out.push(encodeChars.charCodeAt(c1 >> 2)); - out.push(encodeChars.charCodeAt((c1 & 0x3) << 4)); - out.push("=".charCodeAt(0)); - out.push("=".charCodeAt(0)); - break; - } - c2 = str.charCodeAt(i++); - if(i == length) - { - out.push(encodeChars.charCodeAt(c1 >> 2)); - out.push(encodeChars.charCodeAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4))); - out.push(encodeChars.charCodeAt((c2 & 0xF) << 2)); - out.push("=".charCodeAt(0)); - break; - } - c3 = str.charCodeAt(i++); - out.push(encodeChars.charCodeAt(c1 >> 2)); - out.push(encodeChars.charCodeAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4))); - out.push(encodeChars.charCodeAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6))); - out.push(encodeChars.charCodeAt(c3 & 0x3F)); - } - return binary.ByteString(out).toString('ascii'); -}; - -exports.decode = function (str) { - var c1, c2, c3, c4; - var i, length, out; - - length = len(str); - i = 0; - out = []; - while(i < length) { - /* c1 */ - do { - c1 = decodeChars[str.charCodeAt(i++) & 0xff]; - } while(i < length && c1 == -1); - if(c1 == -1) - break; - - /* c2 */ - do { - c2 = decodeChars[str.charCodeAt(i++) & 0xff]; - } while(i < length && c2 == -1); - if(c2 == -1) - break; - - out.push(String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4))); - - /* c3 */ - do { - c3 = str.charCodeAt(i++) & 0xff; - if(c3 == 61) - return out.join(''); - c3 = decodeChars[c3]; - } while(i < length && c3 == -1); - if(c3 == -1) - break; - - out.push(String.fromCharCode(((c2 & 0xF) << 4) | ((c3 & 0x3C) >> 2))); - - /* c4 */ - do { - c4 = str.charCodeAt(i++) & 0xff; - if(c4 == 61) - return out.join(''); - c4 = decodeChars[c4]; - } while(i < length && c4 == -1); - - if(c4 == -1) - break; - - out.push(String.fromCharCode(((c3 & 0x03) << 6) | c4)); - } - - return out.join(''); -}; - -var len = function (object) { - if (object.length !== undefined) { - return object.length; - } else if (object.getLength !== undefined) { - return object.getLength(); - } else { - return undefined; - } -}; - diff --git a/utils/lib/codec/base64.js b/utils/lib/codec/base64.js deleted file mode 100755 index 6913d84..0000000 --- a/utils/lib/codec/base64.js +++ /dev/null @@ -1,7 +0,0 @@ -system.log.warn("codec/base64 is deprecated. use base64 directly."); -var base64 = require("base64"); -for (var name in base64) { - if (Object.prototype.hasOwnProperty.call(base64, name)) { - exports[name] = base64[name]; - } -} diff --git a/utils/lib/crc32.js b/utils/lib/crc32.js deleted file mode 100755 index 71a9443..0000000 --- a/utils/lib/crc32.js +++ /dev/null @@ -1,60 +0,0 @@ - -var util = require('./util'); - -/*** polynomials -*/ -exports.polynomials = { - 'ieee802_3': 0xEDB88320, - 'castagnoli': 0x82F63B78, - 'kooperman': 0xEB31D82E -}; - -/*** Table -*/ -exports.Table = function (polynomial) { - var term, table = []; - for (var i = 0; i < 256; i++) { - term = i; - for (var j = 0; j < 8; j++) { - if (term & 1) - term = (term >>> 1) ^ polynomial; - else - term = term >>> 1; - } - table[i] = term; - } - return table; -}; - -/*** table -*/ -exports.table = exports.Table(exports.polynomials.ieee802_3); - -/*** hash - returns the crc32 hash for a string as an integer. -*/ -exports.hash = function (bin, table) { - if (util.no(table)) - table = exports.table; - var crc = 0xFFFFFFFF; - for (var i = 0; i < bin.length; i ++) { - var x = bin.charCodeAt(i); - if (x & ~0xFF) - throw new Error( - "crc32 can only encode strings of bytes. " + - "Consider using utf8.js#encode." - ); - crc = (crc >>> 8) ^ table[x ^ (crc & 0xFF)]; - } - return ~crc; -}; - -/* - - References - ========== - - http://www.webtoolkit.info/ - Javascript crc32 - -*/ diff --git a/utils/lib/env.rhino.js b/utils/lib/env.rhino.js deleted file mode 100755 index eb086c7..0000000 --- a/utils/lib/env.rhino.js +++ /dev/null @@ -1,9041 +0,0 @@ -/** - * @author thatcher - */ -var Envjs = function(){ - if(arguments.length === 2){ - for ( var i in arguments[1] ) { - var g = arguments[1].__lookupGetter__(i), - s = arguments[1].__lookupSetter__(i); - if ( g || s ) { - if ( g ) Envjs.__defineGetter__(i, g); - if ( s ) Envjs.__defineSetter__(i, s); - } else - Envjs[i] = arguments[1][i]; - } - } - window.location = arguments[0]; -}; - -/* -* env.rhino.js -*/ -(function($env){ - - //You can emulate different user agents by overriding these after loading env - $env.appCodeName = "Envjs";//eg "Mozilla" - $env.appName = "Resig/20070309 BirdDog/0.0.0.1";//eg "Gecko/20070309 Firefox/2.0.0.3" - - //set this to true and see profile/profile.js to select which methods - //to profile - $env.profile = false; - - $env.log = function(msg, level){}; - $env.debug = function(){}; - $env.info = function(){}; - $env.warn = function(){}; - $env.error = function(){}; - - //uncomment these if you want to get some internal log statementes - /*$env.debug = function(msg){ - $env.log(msg,"DEBUG"); - };*/ - $env.info = function(msg){ - $env.log(msg,"INFO"); - }; - $env.warn = function(msg){ - $env.log(msg,"WARNIING"); - }; - $env.error = function(msg, e){ - $env.log(msg+ " Line: "+ $env.lineSource(e),'ERROR'); - $env.log(e||"",'ERROR'); - }; - - $env.info("Initializing Core Platform Env"); - - $env.lineSource = function(e){}; - - $env.hashCode = function(obj){}; - - //resolves location relative to base or window location - $env.location = function(path, base){}; - - //For Java the window.timer is created using the java.lang.Thread in combination - //with the java.lang.Runnable - $env.timer = function(fn, time){}; - - $env.javaEnabled = false; - - //Used in the XMLHttpRquest implementation to run a - // request in a seperate thread - $env.runAsync = function(fn){}; - - //Used to write to a local file - $env.writeToFile = function(text, url){}; - - //Used to write to a local file - $env.writeToTempFile = function(text, suffix){}; - - //Used to delete a local file - $env.deleteFile = function(url){}; - - $env.connection = function(xhr, responseHandler, data){}; - - $env.parseHTML = function(htmlstring){}; - $env.parseXML = function(xmlstring){}; - $env.xpath = function(expression, doc){}; - - $env.tmpdir = ''; - $env.os_name = ''; - $env.os_arch = ''; - $env.os_version = ''; - $env.lang = ''; - $env.platform = "Rhino ";//how do we get the version - - $env.safeScript = function(){ - //do nothing - }; - - $env.scriptTypes = { - "text/javascript" :false, - "text/envjs" :true - }; - - $env.loadLocalScript = function(script, parser){ - $env.debug("loading script "); - var types, type, src, i, base, - docWrites = [], - write = document.write, - writeln = document.writeln; - //temporarily replace document write becuase the function - //has a different meaning during parsing - document.write = function(text){ - docWrites.push(text); - }; - try{ - if(script.type){ - types = script.type?script.type.split(";"):[]; - for(i=0;i1){ - return new java.net.URL(path).toString()+''; - }else if(base){ - return new java.net.URL(new java.net.URL(base), path).toString()+''; - }else{ - //return an absolute url from a url relative to the window location - if(window.location.href.length > 0){ - base = window.location.href.substring(0, window.location.href.lastIndexOf('/')); - return base + '/' + path; - }else{ - return new java.io.File( path ).toURL().toString()+''; - } - } - }; - - //For Java the window.timer is created using the java.lang.Thread in combination - //with the java.lang.Runnable - $env.timer = function(fn, time){ - var running = true; - var thread = new java.lang.Thread(new java.lang.Runnable({ - run: function(){ - while (running){ - java.lang.Thread.currentThread().sleep(time); - //$env.debug("calling in timer "+time); - fn(); - } - } - })); - this.start = function(){ - thread.start(); - }; - this.stop = function(){ - running = false; - } - }; - - //Since we're running in rhino I guess we can safely assume - //java is 'enabled'. I'm sure this requires more thought - //than I've given it here - $env.javaEnabled = true; - - - //Used in the XMLHttpRquest implementation to run a - // request in a seperate thread - $env.runAsync = function(fn){ - $env.debug("running async"); - (new java.lang.Thread(new java.lang.Runnable({ - run: fn - }))).start(); - }; - - //Used to write to a local file - $env.writeToFile = function(text, url){ - $env.debug("writing text to url : " + url); - var out = new java.io.FileWriter( - new java.io.File( - new java.net.URI(url.toString()))); - out.write( text, 0, text.length ); - out.flush(); - out.close(); - }; - - //Used to write to a local file - $env.writeToTempFile = function(text, suffix){ - $env.debug("writing text to temp url : " + suffix); - // Create temp file. - var temp = java.io.File.createTempFile("envjs-tmp", suffix); - - // Delete temp file when program exits. - temp.deleteOnExit(); - - // Write to temp file - var out = new java.io.FileWriter(temp); - out.write(text, 0, text.length); - out.close(); - return temp.getAbsolutePath().toString()+''; - }; - - //Used to delete a local file - $env.deleteFile = function(url){ - var file = new java.io.File( new java.net.URI( url ) ); - file["delete"](); - }; - - $env.connection = function(xhr, responseHandler, data){ - var url = java.net.URL(xhr.url);//, $w.location); - var connection; - if ( /^file\:/.test(url) ) { - if ( xhr.method == "PUT" ) { - var text = data || "" ; - $env.writeToFile(text, url); - } else if ( xhr.method == "DELETE" ) { - $env.deleteFile(url); - } else { - connection = url.openConnection(); - connection.connect(); - } - } else { - connection = url.openConnection(); - connection.setRequestMethod( xhr.method ); - - // Add headers to Java connection - for (var header in xhr.headers){ - connection.addRequestProperty(header+'', xhr.headers[header]+''); - } - - //write data to output stream if required - if(data&&data.length&&data.length>0){ - if ( xhr.method == "PUT" ) { - connection.setDoOutput(true); - var outstream = connection.getOutputStream(), - outbuffer = new java.lang.String(data).getBytes('UTF-8'); - - outstream.write(outbuffer, 0, outbuffer.length); - outstream.close(); - } - }else{ - connection.connect(); - } - - - var respheadlength = connection.getHeaderFields().size(); - // Stick the response headers into responseHeaders - for (var i = 0; i < respheadlength; i++) { - var headerName = connection.getHeaderFieldKey(i); - var headerValue = connection.getHeaderField(i); - if (headerName) - xhr.responseHeaders[headerName+''] = headerValue+''; - } - } - if(connection){ - xhr.readyState = 4; - xhr.status = parseInt(connection.responseCode,10) || undefined; - xhr.statusText = connection.responseMessage || ""; - - var contentEncoding = connection.getContentEncoding() || "utf-8", - stream = (contentEncoding.equalsIgnoreCase("gzip") || contentEncoding.equalsIgnoreCase("decompress") )? - new java.util.zip.GZIPInputStream(connection.getInputStream()) : - connection.getInputStream(), - baos = new java.io.ByteArrayOutputStream(), - buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024), - length, - responseXML = null; - - while ((length = stream.read(buffer)) != -1) { - baos.write(buffer, 0, length); - } - - baos.close(); - stream.close(); - - xhr.responseText = java.nio.charset.Charset.forName("UTF-8"). - decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+""; - - } - if(responseHandler){ - responseHandler(); - } - }; - - var htmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(); - htmlDocBuilder.setNamespaceAware(false); - htmlDocBuilder.setValidating(false); - - $env.parseHTML = function(htmlstring){ - return htmlDocBuilder.newDocumentBuilder().parse( - new java.io.ByteArrayInputStream( - (new java.lang.String(htmlstring)).getBytes("UTF8")))+""; - }; - - var xmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(); - xmlDocBuilder.setNamespaceAware(true); - xmlDocBuilder.setValidating(true); - - $env.parseXML = function(xmlstring){ - return xmlDocBuilder.newDocumentBuilder().parse( - new java.io.ByteArrayInputStream( - (new java.lang.String(xmlstring)).getBytes("UTF8")))+""; - }; - - - $env.xpath = function(expression, doc){ - return Packages.javax.xml.xpath. - XPathFactory.newInstance().newXPath(). - evaluate(expression, doc, javax.xml.xpath.XPathConstants.NODESET); - }; - - $env.tmpdir = java.lang.System.getProperty("java.io.tmpdir"); - $env.os_name = java.lang.System.getProperty("os.name"); - $env.os_arch = java.lang.System.getProperty("os.arch"); - $env.os_version = java.lang.System.getProperty("os.version"); - $env.lang = java.lang.System.getProperty("user.lang"); - $env.platform = "Rhino ";//how do we get the version - - $env.safeScript = function(){ - //do nothing - }; - - $env.scriptTypes = { - "text/javascript" :false, - "text/envjs" :true - }; - - - $env.loadInlineScript = function(script){ - $env.debug("loading inline script :" + script.text); - var tmpFile = $env.writeToTempFile(script.text, 'js') ; - $env.debug("loading " + tmpFile); - load(tmpFile); - }; - -})(Envjs);/* - * Pure JavaScript Browser Environment - * By John Resig - * Copyright 2008 John Resig, under the MIT License - */ - - -// The Window Object -var __this__ = this; -this.__defineGetter__('window', function(){ - return __this__; -}); - -try{ -(function($w, $env){ - /* -* window.js -* - this file will be wrapped in a closure providing the window object as $w -*/ -// a logger or empty function available to all modules. -var $log = $env.log, - $debug = $env.debug, - $info = $env.info, - $warn = $env.warn, - $error = $env.error; - -//The version of this application -var $version = "0.1"; -//This should be hooked to git or svn or whatever -var $revision = "0.0.0.0"; - -//These descriptions of window properties are taken loosely David Flanagan's -//'JavaScript - The Definitive Guide' (O'Reilly) - -/**> $cookies - see cookie.js <*/ -// read only boolean specifies whether the window has been closed -var $closed = false; - -// a read/write string that specifies the default message that appears in the status line -var $defaultStatus = "Done"; - -// a read-only reference to the Document object belonging to this window -/**> $document - See document.js <*/ - -//IE only, refers to the most recent event object - this maybe be removed after review -var $event = null; - -//A read-only array of window objects -var $frames = []; - -// a read-only reference to the History object -/**> $history - see location.js <**/ - -// read-only properties that specify the height and width, in pixels -var $innerHeight = 600, $innerWidth = 800; - -// a read-only reference to the Location object. the location object does expose read/write properties -/**> $location - see location.js <**/ - -// a read only property specifying the name of the window. Can be set when using open() -// and may be used when specifying the target attribute of links -var $name = 'Resig Env Browser'; - -// a read-only reference to the Navigator object -/**> $navigator - see navigator.js <**/ - -// a read/write reference to the Window object that contained the script that called open() to -//open this browser window. This property is valid only for top-level window objects. -var $opener; - -// Read-only properties that specify the total height and width, in pixels, of the browser window. -// These dimensions include the height and width of the menu bar, toolbars, scrollbars, window -// borders and so on. These properties are not supported by IE and IE offers no alternative -// properties; -var $outerHeight = $innerHeight, $outerWidth = $innerWidth; - -// Read-only properties that specify the number of pixels that the current document has been scrolled -//to the right and down. These are not supported by IE. -var $pageXOffset = 0, $pageYOffset = 0; - -//A read-only reference to the Window object that contains this window or frame. If the window is -// a top-level window, parent refers to the window itself. If this window is a frame, this property -// refers to the window or frame that conatins it. -var $parent; - -// a read-only refernce to the Screen object that specifies information about the screen: -// the number of available pixels and the number of available colors. -/**> $screen - see screen.js <**/ - -// read only properties that specify the coordinates of the upper-left corner of the screen. -var $screenX = 0, $screenY = 0; -var $screenLeft = $screenX, $screenTop = $screenY; - -// a read-only refernce to this window itself. -var $self; - -// a read/write string that specifies the current contents of the status line. -var $status = ''; - -// a read-only reference to the top-level window that contains this window. If this -// window is a top-level window it is simply a refernce to itself. If this window -// is a frame, the top property refers to the top-level window that contains the frame. -var $top; - -// the window property is identical to the self property. -var $window = $w; - -$debug("Initializing Window."); -__extend__($w,{ - get closed(){return $closed;}, - get defaultStatus(){return $defaultStatus;}, - set defaultStatus(_defaultStatus){$defaultStatus = _defaultStatus;}, - //get document(){return $document;}, - see document.js - get event(){return $event;}, - get frames(){return $frames;}, - //get history(){return $history;}, - see location.js - get innerHeight(){return $innerHeight;}, - get innerWidth(){return $innerWidth;}, - get clientHeight(){return $innerHeight;}, - get clientWidth(){return $innerWidth;}, - //get location(){return $location;}, see location.js - get name(){return $name;}, - //get navigator(){return $navigator;}, see navigator.js - get opener(){return $opener;}, - get outerHeight(){return $outerHeight;}, - get outerWidth(){return $outerWidth;}, - get pageXOffest(){return $pageXOffset;}, - get pageYOffset(){return $pageYOffset;}, - get parent(){return $parent;}, - //get screen(){return $screen;}, see screen.js - get screenLeft(){return $screenLeft;}, - get screenTop(){return $screenTop;}, - get screenX(){return $screenX;}, - get screenY(){return $screenY;}, - get self(){return $self;}, - get status(){return $status;}, - set status(_status){$status = _status;}, - get top(){return $top || $window;}, - get window(){return $window;} -}); - -$w.open = function(url, name, features, replace){ - //TODO -}; - -$w.close = function(){ - //TODO -}; - -/* Time related functions - see timer.js -* - clearTimeout -* - clearInterval -* - setTimeout -* - setInterval -*/ - -/* -* Events related functions - see event.js -* - addEventListener -* - attachEvent -* - detachEvent -* - removeEventListener -* -* These functions are identical to the Element equivalents. -*/ - -/* -* UIEvents related functions - see uievent.js -* - blur -* - focus -* -* These functions are identical to the Element equivalents. -*/ - -/* Dialog related functions - see dialog.js -* - alert -* - confirm -* - prompt -*/ - -/* Screen related functions - see screen.js -* - moveBy -* - moveTo -* - print -* - resizeBy -* - resizeTo -* - scrollBy -* - scrollTo -*/ - -/* CSS related functions - see css.js -* - getComputedStyle -*/ - -/* -* Shared utility methods -*/ -// Helper method for extending one object with another. -function __extend__(a,b) { - for ( var i in b ) { - var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i); - if ( g || s ) { - if ( g ) a.__defineGetter__(i, g); - if ( s ) a.__defineSetter__(i, s); - } else - a[i] = b[i]; - } return a; -}; - - -// from ariel flesler http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html -// this might be a good utility function to provide in the env.core -// as in might be useful to the parser and other areas as well -function trim( str ){ - return (str || "").replace( /^\s+|\s+$/g, "" ); - -}; -/*function trim( str ){ - var start = -1, - end = str.length; - /*jsl:ignore* - while( str.charCodeAt(--end) < 33 ); - while( str.charCodeAt(++start) < 33 ); - /*jsl:end* - return str.slice( start, end + 1 ); -};*/ - -//from jQuery -function __setArray__( target, array ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - target.length = 0; - Array.prototype.push.apply( target, array ); -}; - - -$debug("Defining NodeList"); -/* -* NodeList - DOM Level 2 -*/ -/** - * @class DOMNodeList - provides the abstraction of an ordered collection of nodes - * - * @author Jon van Noort (jon@webarcana.com.au) - * - * @param ownerDocument : DOMDocument - the ownerDocument - * @param parentNode : DOMNode - the node that the DOMNodeList is attached to (or null) - */ -var DOMNodeList = function(ownerDocument, parentNode) { - this.length = 0; - this.parentNode = parentNode; - this.ownerDocument = ownerDocument; - - this._readonly = false; - - __setArray__(this, []); -}; -__extend__(DOMNodeList.prototype, { - item : function(index) { - var ret = null; - //$log("NodeList item("+index+") = " + this[index]); - if ((index >= 0) && (index < this.length)) { // bounds check - ret = this[index]; // return selected Node - } - - return ret; // if the index is out of bounds, default value null is returned - }, - get xml() { - var ret = ""; - - // create string containing the concatenation of the string values of each child - for (var i=0; i < this.length; i++) { - if(this[i]){ - if(this[i].nodeType == DOMNode.TEXT_NODE && i>0 && this[i-1].nodeType == DOMNode.TEXT_NODE){ - //add a single space between adjacent text nodes - ret += " "+this[i].xml; - }else{ - ret += this[i].xml; - } - } - } - - return ret; - }, - toArray: function () { - var children = []; - for ( var i=0; i < this.length; i++) { - children.push (this[i]); - } - return children; - }, - toString: function(){ - return "[ "+(this.length > 0?Array.prototype.join.apply(this, [", "]):"Empty NodeList")+" ]"; - } -}); - - -/** - * @method DOMNodeList._findItemIndex - find the item index of the node with the specified internal id - * @author Jon van Noort (jon@webarcana.com.au) - * @param id : int - unique internal id - * @return : int - */ -var __findItemIndex__ = function (nodelist, id) { - var ret = -1; - - // test that id is valid - if (id > -1) { - for (var i=0; i= 0) && (refChildIndex < nodelist.length)) { // bounds check - - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment - // append the children of DocumentFragment - Array.prototype.splice.apply(nodelist,[refChildIndex, 0].concat(newChild.childNodes.toArray())); - } - else { - // append the newChild - Array.prototype.splice.apply(nodelist,[refChildIndex, 0, newChild]); - } - } -}; - -/** - * @method DOMNodeList._replaceChild - replace the specified Node in the NodeList at the specified index - * Used by DOMNode.replaceChild(). Note: DOMNode.replaceChild() is responsible for Node Pointer surgery - * DOMNodeList._replaceChild() simply modifies the internal data structure (Array). - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param newChild : DOMNode - the Node to be inserted - * @param refChildIndex : int - the array index to hold the Node - */ -var __replaceChild__ = function(nodelist, newChild, refChildIndex) { - var ret = null; - - if ((refChildIndex >= 0) && (refChildIndex < nodelist.length)) { // bounds check - ret = nodelist[refChildIndex]; // preserve old child for return - - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment - // get array containing children prior to refChild - Array.prototype.splice.apply(nodelist,[refChildIndex, 1].concat(newChild.childNodes.toArray())); - } - else { - // simply replace node in array (links between Nodes are made at higher level) - nodelist[refChildIndex] = newChild; - } - } - - return ret; // return replaced node -}; - -/** - * @method DOMNodeList._removeChild - remove the specified Node in the NodeList at the specified index - * Used by DOMNode.removeChild(). Note: DOMNode.removeChild() is responsible for Node Pointer surgery - * DOMNodeList._replaceChild() simply modifies the internal data structure (Array). - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param refChildIndex : int - the array index holding the Node to be removed - */ -var __removeChild__ = function(nodelist, refChildIndex) { - var ret = null; - - if (refChildIndex > -1) { // found it! - ret = nodelist[refChildIndex]; // return removed node - - // rebuild array without removed child - Array.prototype.splice.apply(nodelist,[refChildIndex, 1]); - } - - return ret; // return removed node -}; - -/** - * @method DOMNodeList._appendChild - append the specified Node to the NodeList - * Used by DOMNode.appendChild(). Note: DOMNode.appendChild() is responsible for Node Pointer surgery - * DOMNodeList._appendChild() simply modifies the internal data structure (Array). - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param newChild : DOMNode - the Node to be inserted - */ -var __appendChild__ = function(nodelist, newChild) { - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment - // append the children of DocumentFragment - Array.prototype.push.apply(nodelist, newChild.childNodes.toArray() ); - } else { - // simply add node to array (links between Nodes are made at higher level) - Array.prototype.push.apply(nodelist, [newChild]); - } - -}; - -/** - * @method DOMNodeList._cloneNodes - Returns a NodeList containing clones of the Nodes in this NodeList - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param deep : boolean - If true, recursively clone the subtree under each of the nodes; - * if false, clone only the nodes themselves (and their attributes, if it is an Element). - * @param parentNode : DOMNode - the new parent of the cloned NodeList - * @return : DOMNodeList - NodeList containing clones of the Nodes in this NodeList - */ -var __cloneNodes__ = function(nodelist, deep, parentNode) { - var cloneNodeList = new DOMNodeList(nodelist.ownerDocument, parentNode); - - // create list containing clones of each child - for (var i=0; i < nodelist.length; i++) { - __appendChild__(cloneNodeList, nodelist[i].cloneNode(deep)); - } - - return cloneNodeList; -}; - -$w.NodeList = DOMNodeList; - -/** - * @class DOMNamedNodeMap - used to represent collections of nodes that can be accessed by name - * typically a set of Element attributes - * - * @extends DOMNodeList - note W3C spec says that this is not the case, - * but we need an item() method identicle to DOMNodeList's, so why not? - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : DOMDocument - the ownerDocument - * @param parentNode : DOMNode - the node that the DOMNamedNodeMap is attached to (or null) - */ -var DOMNamedNodeMap = function(ownerDocument, parentNode) { - //$log("\t\tcreating dom namednodemap"); - this.DOMNodeList = DOMNodeList; - this.DOMNodeList(ownerDocument, parentNode); - __setArray__(this, []); -}; -DOMNamedNodeMap.prototype = new DOMNodeList; -__extend__(DOMNamedNodeMap.prototype, { - getNamedItem : function(name) { - var ret = null; - - // test that Named Node exists - var itemIndex = __findNamedItemIndex__(this, name); - - if (itemIndex > -1) { // found it! - ret = this[itemIndex]; // return NamedNode - } - - return ret; // if node is not found, default value null is returned - }, - setNamedItem : function(arg) { - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if arg was not created by this Document - if (this.ownerDocument != arg.ownerDocument) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if DOMNamedNodeMap is readonly - if (this._readonly || (this.parentNode && this.parentNode._readonly)) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if arg is already an attribute of another Element object - if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { - throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); - } - } - - // get item index - var itemIndex = __findNamedItemIndex__(this, arg.name); - var ret = null; - - if (itemIndex > -1) { // found it! - ret = this[itemIndex]; // use existing Attribute - - // throw Exception if DOMAttr is readonly - if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } else { - this[itemIndex] = arg; // over-write existing NamedNode - this[arg.name] = arg; - } - } else { - // add new NamedNode - Array.prototype.push.apply(this, [arg]); - this[arg.name] = arg; - } - - arg.ownerElement = this.parentNode; // update ownerElement - - return ret; // return old node or null - }, - removeNamedItem : function(name) { - var ret = null; - // test for exceptions - // throw Exception if DOMNamedNodeMap is readonly - if (__ownerDocument__(this).implementation.errorChecking && - (this._readonly || (this.parentNode && this.parentNode._readonly))) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get item index - var itemIndex = __findNamedItemIndex__(this, name); - - // throw Exception if there is no node named name in this map - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // get Node - var oldNode = this[itemIndex]; - //this[oldNode.name] = undefined; - - // throw Exception if Node is readonly - if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // return removed node - return __removeChild__(this, itemIndex); - }, - getNamedItemNS : function(namespaceURI, localName) { - var ret = null; - - // test that Named Node exists - var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName); - - if (itemIndex > -1) { // found it! - ret = this[itemIndex]; // return NamedNode - } - - return ret; // if node is not found, default value null is returned - }, - setNamedItemNS : function(arg) { - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if DOMNamedNodeMap is readonly - if (this._readonly || (this.parentNode && this.parentNode._readonly)) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if arg was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(arg)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if arg is already an attribute of another Element object - if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { - throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); - } - } - - // get item index - var itemIndex = __findNamedItemNSIndex__(this, arg.namespaceURI, arg.localName); - var ret = null; - - if (itemIndex > -1) { // found it! - ret = this[itemIndex]; // use existing Attribute - // throw Exception if DOMAttr is readonly - if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } else { - this[itemIndex] = arg; // over-write existing NamedNode - } - }else { - // add new NamedNode - Array.prototype.push.apply(this, [arg]); - } - arg.ownerElement = this.parentNode; - - - return ret; // return old node or null - }, - removeNamedItemNS : function(namespaceURI, localName) { - var ret = null; - - // test for exceptions - // throw Exception if DOMNamedNodeMap is readonly - if (__ownerDocument__(this).implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get item index - var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName); - - // throw Exception if there is no matching node in this map - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // get Node - var oldNode = this[itemIndex]; - - // throw Exception if Node is readonly - if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - return __removeChild__(this, itemIndex); // return removed node - }, - get xml() { - var ret = ""; - - // create string containing concatenation of all (but last) Attribute string values (separated by spaces) - for (var i=0; i < this.length -1; i++) { - ret += this[i].xml +" "; - } - - // add last Attribute to string (without trailing space) - if (this.length > 0) { - ret += this[this.length -1].xml; - } - - return ret; - } - -}); - -/** - * @method DOMNamedNodeMap._findNamedItemIndex - find the item index of the node with the specified name - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param name : string - the name of the required node - * @param isnsmap : if its a DOMNamespaceNodeMap - * @return : int - */ -var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) { - var ret = -1; - - // loop through all nodes - for (var i=0; i -1) { // found it! - ret = true; // return true - } - - return ret; // if node is not found, default value false is returned -} - -/** - * @method DOMNamedNodeMap._hasAttributeNS - Returns true if specified node exists - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param namespaceURI : string - the namespace URI of the required node - * @param localName : string - the local name of the required node - * @return : boolean - */ -var __hasAttributeNS__ = function(namednodemap, namespaceURI, localName) { - var ret = false; - - // test that Named Node exists - var itemIndex = __findNamedItemNSIndex__(namednodemap, namespaceURI, localName); - - if (itemIndex > -1) { // found it! - ret = true; // return true - } - - return ret; // if node is not found, default value false is returned -} - -/** - * @method DOMNamedNodeMap._cloneNodes - Returns a NamedNodeMap containing clones of the Nodes in this NamedNodeMap - * - * @author Jon van Noort (jon@webarcana.com.au) - * @param parentNode : DOMNode - the new parent of the cloned NodeList - * @param isnsmap : bool - is this a DOMNamespaceNodeMap - * @return : DOMNamedNodeMap - NamedNodeMap containing clones of the Nodes in this DOMNamedNodeMap - */ -var __cloneNamedNodes__ = function(namednodemap, parentNode, isnsmap) { - var cloneNamedNodeMap = isnsmap? - new DOMNamespaceNodeMap(namednodemap.ownerDocument, parentNode): - new DOMNamedNodeMap(namednodemap.ownerDocument, parentNode); - - // create list containing clones of all children - for (var i=0; i < namednodemap.length; i++) { - $debug("cloning node in named node map :" + namednodemap[i]); - __appendChild__(cloneNamedNodeMap, namednodemap[i].cloneNode(false)); - } - - return cloneNamedNodeMap; -}; - - -/** - * @class DOMNamespaceNodeMap - used to represent collections of namespace nodes that can be accessed by name - * typically a set of Element attributes - * - * @extends DOMNamedNodeMap - * - * @author Jon van Noort (jon@webarcana.com.au) - * - * @param ownerDocument : DOMDocument - the ownerDocument - * @param parentNode : DOMNode - the node that the DOMNamespaceNodeMap is attached to (or null) - */ -var DOMNamespaceNodeMap = function(ownerDocument, parentNode) { - //$log("\t\t\tcreating dom namespacednodemap"); - this.DOMNamedNodeMap = DOMNamedNodeMap; - this.DOMNamedNodeMap(ownerDocument, parentNode); - __setArray__(this, []); -}; -DOMNamespaceNodeMap.prototype = new DOMNamedNodeMap; -__extend__(DOMNamespaceNodeMap.prototype, { - get xml() { - var ret = ""; - - // identify namespaces declared local to this Element (ie, not inherited) - for (var ind = 0; ind < this.length; ind++) { - // if namespace declaration does not exist in the containing node's, parentNode's namespaces - var ns = null; - try { - var ns = this.parentNode.parentNode._namespaces. - getNamedItem(this[ind].localName); - } - catch (e) { - //breaking to prevent default namespace being inserted into return value - break; - } - if (!(ns && (""+ ns.nodeValue == ""+ this[ind].nodeValue))) { - // display the namespace declaration - ret += this[ind].xml +" "; - } - } - - return ret; - } -}); -$debug("Defining Node"); -/* -* Node - DOM Level 2 -*/ -/** - * @class DOMNode - The Node interface is the primary datatype for the entire Document Object Model. - * It represents a single node in the document tree. - * @author Jon van Noort (jon@webarcana.com.au), David Joham (djoham@yahoo.com) and Scott Severtson - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMNode = function(ownerDocument) { - if (ownerDocument) { - this._id = ownerDocument._genId(); // generate unique internal id - } - - this.namespaceURI = ""; // The namespace URI of this node (Level 2) - this.prefix = ""; // The namespace prefix of this node (Level 2) - this.localName = ""; // The localName of this node (Level 2) - - this.nodeName = ""; // The name of this node - this.nodeValue = null; // The value of this node - this.className = ""; // The CSS class name of this node. - - // The parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent. - // However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null - this.parentNode = null; - - // A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. - // The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object - // that it was created from are immediately reflected in the nodes returned by the NodeList accessors; - // it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method. - this.childNodes = new DOMNodeList(ownerDocument, this); - - this.firstChild = null; // The first child of this node. If there is no such node, this is null - this.lastChild = null; // The last child of this node. If there is no such node, this is null. - this.previousSibling = null; // The node immediately preceding this node. If there is no such node, this is null. - this.nextSibling = null; // The node immediately following this node. If there is no such node, this is null. - - this.ownerDocument = ownerDocument; // The Document object associated with this node - this.attributes = new DOMNamedNodeMap(this.ownerDocument, this); - this._namespaces = new DOMNamespaceNodeMap(ownerDocument, this); // The namespaces in scope for this node - this._readonly = false; -}; - -// nodeType constants -DOMNode.ELEMENT_NODE = 1; -DOMNode.ATTRIBUTE_NODE = 2; -DOMNode.TEXT_NODE = 3; -DOMNode.CDATA_SECTION_NODE = 4; -DOMNode.ENTITY_REFERENCE_NODE = 5; -DOMNode.ENTITY_NODE = 6; -DOMNode.PROCESSING_INSTRUCTION_NODE = 7; -DOMNode.COMMENT_NODE = 8; -DOMNode.DOCUMENT_NODE = 9; -DOMNode.DOCUMENT_TYPE_NODE = 10; -DOMNode.DOCUMENT_FRAGMENT_NODE = 11; -DOMNode.NOTATION_NODE = 12; -DOMNode.NAMESPACE_NODE = 13; - -__extend__(DOMNode.prototype, { - hasAttributes : function() { - if (this.attributes.length == 0) { - return false; - }else{ - return true; - } - }, - insertBefore : function(newChild, refChild) { - var prevNode; - - if(newChild==null || refChild==null){ - return newChild; - } - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if DOMNode is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if newChild was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(newChild)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if the node is an ancestor - if (__isAncestor__(this, newChild)) { - throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR)); - } - } - - if (refChild) { // if refChild is specified, insert before it - // find index of refChild - var itemIndex = __findItemIndex__(this.childNodes, refChild._id); - - // throw Exception if there is no child node with this id - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // if the newChild is already in the tree, - var newChildParent = newChild.parentNode; - if (newChildParent) { - // remove it - newChildParent.removeChild(newChild); - } - - // insert newChild into childNodes - __insertBefore__(this.childNodes, newChild, - __findItemIndex__(this.childNodes, refChild._id)); - - // do node pointer surgery - prevNode = refChild.previousSibling; - - // handle DocumentFragment - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { - if (newChild.childNodes.length > 0) { - // set the parentNode of DocumentFragment's children - for (var ind = 0; ind < newChild.childNodes.length; ind++) { - newChild.childNodes[ind].parentNode = this; - } - - // link refChild to last child of DocumentFragment - refChild.previousSibling = newChild.childNodes[newChild.childNodes.length-1]; - } - }else { - newChild.parentNode = this; // set the parentNode of the newChild - refChild.previousSibling = newChild; // link refChild to newChild - } - }else { // otherwise, append to end - prevNode = this.lastChild; - this.appendChild(newChild); - } - - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { - // do node pointer surgery for DocumentFragment - if (newChild.childNodes.length > 0) { - if (prevNode) { - prevNode.nextSibling = newChild.childNodes[0]; - }else { // this is the first child in the list - this.firstChild = newChild.childNodes[0]; - } - - newChild.childNodes[0].previousSibling = prevNode; - newChild.childNodes[newChild.childNodes.length-1].nextSibling = refChild; - } - }else { - // do node pointer surgery for newChild - if (prevNode) { - prevNode.nextSibling = newChild; - }else { // this is the first child in the list - this.firstChild = newChild; - } - - newChild.previousSibling = prevNode; - newChild.nextSibling = refChild; - } - - return newChild; - }, - replaceChild : function(newChild, oldChild) { - var ret = null; - - if(newChild==null || oldChild==null){ - return oldChild; - } - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if DOMNode is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if newChild was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(newChild)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if the node is an ancestor - if (__isAncestor__(this, newChild)) { - throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR)); - } - } - - // get index of oldChild - var index = __findItemIndex__(this.childNodes, oldChild._id); - - // throw Exception if there is no child node with this id - if (__ownerDocument__(this).implementation.errorChecking && (index < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // if the newChild is already in the tree, - var newChildParent = newChild.parentNode; - if (newChildParent) { - // remove it - newChildParent.removeChild(newChild); - } - - // add newChild to childNodes - ret = __replaceChild__(this.childNodes,newChild, index); - - - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { - // do node pointer surgery for Document Fragment - if (newChild.childNodes.length > 0) { - for (var ind = 0; ind < newChild.childNodes.length; ind++) { - newChild.childNodes[ind].parentNode = this; - } - - if (oldChild.previousSibling) { - oldChild.previousSibling.nextSibling = newChild.childNodes[0]; - } else { - this.firstChild = newChild.childNodes[0]; - } - - if (oldChild.nextSibling) { - oldChild.nextSibling.previousSibling = newChild; - } else { - this.lastChild = newChild.childNodes[newChild.childNodes.length-1]; - } - - newChild.childNodes[0].previousSibling = oldChild.previousSibling; - newChild.childNodes[newChild.childNodes.length-1].nextSibling = oldChild.nextSibling; - } - } else { - // do node pointer surgery for newChild - newChild.parentNode = this; - - if (oldChild.previousSibling) { - oldChild.previousSibling.nextSibling = newChild; - }else{ - this.firstChild = newChild; - } - if (oldChild.nextSibling) { - oldChild.nextSibling.previousSibling = newChild; - }else{ - this.lastChild = newChild; - } - newChild.previousSibling = oldChild.previousSibling; - newChild.nextSibling = oldChild.nextSibling; - } - return ret; - }, - removeChild : function(oldChild) { - if(!oldChild){ - return null; - } - // throw Exception if DOMNamedNodeMap is readonly - if (__ownerDocument__(this).implementation.errorChecking && (this._readonly || oldChild._readonly)) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get index of oldChild - var itemIndex = __findItemIndex__(this.childNodes, oldChild._id); - - // throw Exception if there is no child node with this id - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // remove oldChild from childNodes - __removeChild__(this.childNodes, itemIndex); - - // do node pointer surgery - oldChild.parentNode = null; - - if (oldChild.previousSibling) { - oldChild.previousSibling.nextSibling = oldChild.nextSibling; - }else { - this.firstChild = oldChild.nextSibling; - } - if (oldChild.nextSibling) { - oldChild.nextSibling.previousSibling = oldChild.previousSibling; - }else { - this.lastChild = oldChild.previousSibling; - } - - oldChild.previousSibling = null; - oldChild.nextSibling = null; - - return oldChild; - }, - appendChild : function(newChild) { - if(!newChild){ - return null; - } - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Node is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if arg was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(this)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if the node is an ancestor - if (__isAncestor__(this, newChild)) { - throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR)); - } - } - - // if the newChild is already in the tree, - var newChildParent = newChild.parentNode; - if (newChildParent) { - // remove it - newChildParent.removeChild(newChild); - } - - // add newChild to childNodes - __appendChild__(this.childNodes, newChild); - - if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { - // do node pointer surgery for DocumentFragment - if (newChild.childNodes.length > 0) { - for (var ind = 0; ind < newChild.childNodes.length; ind++) { - newChild.childNodes[ind].parentNode = this; - } - - if (this.lastChild) { - this.lastChild.nextSibling = newChild.childNodes[0]; - newChild.childNodes[0].previousSibling = this.lastChild; - this.lastChild = newChild.childNodes[newChild.childNodes.length-1]; - } - else { - this.lastChild = newChild.childNodes[newChild.childNodes.length-1]; - this.firstChild = newChild.childNodes[0]; - } - } - } - else { - // do node pointer surgery for newChild - newChild.parentNode = this; - if (this.lastChild) { - this.lastChild.nextSibling = newChild; - newChild.previousSibling = this.lastChild; - this.lastChild = newChild; - } - else { - this.lastChild = newChild; - this.firstChild = newChild; - } - } - - return newChild; - }, - hasChildNodes : function() { - return (this.childNodes.length > 0); - }, - cloneNode: function(deep) { - // use importNode to clone this Node - //do not throw any exceptions - try { - return __ownerDocument__(this).importNode(this, deep); - } catch (e) { - //there shouldn't be any exceptions, but if there are, return null - return null; - } - }, - normalize : function() { - var inode; - var nodesToRemove = new DOMNodeList(); - - if (this.nodeType == DOMNode.ELEMENT_NODE || this.nodeType == DOMNode.DOCUMENT_NODE) { - var adjacentTextNode = null; - - // loop through all childNodes - for(var i = 0; i < this.childNodes.length; i++) { - inode = this.childNodes.item(i); - - if (inode.nodeType == DOMNode.TEXT_NODE) { // this node is a text node - if (inode.length < 1) { // this text node is empty - __appendChild__(nodesToRemove, inode); // add this node to the list of nodes to be remove - }else { - if (adjacentTextNode) { // if previous node was also text - adjacentTextNode.appendData(inode.data); // merge the data in adjacent text nodes - __appendChild__(nodesToRemove, inode); // add this node to the list of nodes to be removed - }else { - adjacentTextNode = inode; // remember this node for next cycle - } - } - } else { - adjacentTextNode = null; // (soon to be) previous node is not a text node - inode.normalize(); // normalise non Text childNodes - } - } - - // remove redundant Text Nodes - for(var i = 0; i < nodesToRemove.length; i++) { - inode = nodesToRemove.item(i); - inode.parentNode.removeChild(inode); - } - } - }, - isSupported : function(feature, version) { - // use Implementation.hasFeature to determin if this feature is supported - return __ownerDocument__(this).implementation.hasFeature(feature, version); - }, - getElementsByTagName : function(tagname) { - // delegate to _getElementsByTagNameRecursive - // recurse childNodes - var nodelist = new DOMNodeList(__ownerDocument__(this)); - for(var i = 0; i < this.childNodes.length; i++) { - nodeList = __getElementsByTagNameRecursive__(this.childNodes.item(i), tagname, nodelist); - } - return nodelist; - }, - getElementsByTagNameNS : function(namespaceURI, localName) { - // delegate to _getElementsByTagNameNSRecursive - return __getElementsByTagNameNSRecursive__(this, namespaceURI, localName, - new DOMNodeList(__ownerDocument__(this))); - }, - importNode : function(importedNode, deep) { - - var importNode; - //$debug("importing node " + importedNode.nodeName + "(?deep = "+deep+")"); - //there is no need to perform namespace checks since everything has already gone through them - //in order to have gotten into the DOM in the first place. The following line - //turns namespace checking off in ._isValidNamespace - __ownerDocument__(this)._performingImportNodeOperation = true; - - if (importedNode.nodeType == DOMNode.ELEMENT_NODE) { - if (!__ownerDocument__(this).implementation.namespaceAware) { - // create a local Element (with the name of the importedNode) - importNode = __ownerDocument__(this).createElement(importedNode.tagName); - - // create attributes matching those of the importedNode - for(var i = 0; i < importedNode.attributes.length; i++) { - importNode.setAttribute(importedNode.attributes.item(i).name, importedNode.attributes.item(i).value); - } - }else { - // create a local Element (with the name & namespaceURI of the importedNode) - importNode = __ownerDocument__(this).createElementNS(importedNode.namespaceURI, importedNode.nodeName); - - // create attributes matching those of the importedNode - for(var i = 0; i < importedNode.attributes.length; i++) { - importNode.setAttributeNS(importedNode.attributes.item(i).namespaceURI, - importedNode.attributes.item(i).name, importedNode.attributes.item(i).value); - } - - // create namespace definitions matching those of the importedNode - for(var i = 0; i < importedNode._namespaces.length; i++) { - importNode._namespaces[i] = __ownerDocument__(this).createNamespace(importedNode._namespaces.item(i).localName); - importNode._namespaces[i].value = importedNode._namespaces.item(i).value; - } - } - } else if (importedNode.nodeType == DOMNode.ATTRIBUTE_NODE) { - if (!__ownerDocument__(this).implementation.namespaceAware) { - // create a local Attribute (with the name of the importedAttribute) - importNode = __ownerDocument__(this).createAttribute(importedNode.name); - } else { - // create a local Attribute (with the name & namespaceURI of the importedAttribute) - importNode = __ownerDocument__(this).createAttributeNS(importedNode.namespaceURI, importedNode.nodeName); - - // create namespace definitions matching those of the importedAttribute - for(var i = 0; i < importedNode._namespaces.length; i++) { - importNode._namespaces[i] = __ownerDocument__(this).createNamespace(importedNode._namespaces.item(i).localName); - importNode._namespaces[i].value = importedNode._namespaces.item(i).value; - } - } - - // set the value of the local Attribute to match that of the importedAttribute - importNode.value = importedNode.value; - - } else if (importedNode.nodeType == DOMNode.DOCUMENT_FRAGMENT) { - // create a local DocumentFragment - importNode = __ownerDocument__(this).createDocumentFragment(); - } else if (importedNode.nodeType == DOMNode.NAMESPACE_NODE) { - // create a local NamespaceNode (with the same name & value as the importedNode) - importNode = __ownerDocument__(this).createNamespace(importedNode.nodeName); - importNode.value = importedNode.value; - } else if (importedNode.nodeType == DOMNode.TEXT_NODE) { - // create a local TextNode (with the same data as the importedNode) - importNode = __ownerDocument__(this).createTextNode(importedNode.data); - } else if (importedNode.nodeType == DOMNode.CDATA_SECTION_NODE) { - // create a local CDATANode (with the same data as the importedNode) - importNode = __ownerDocument__(this).createCDATASection(importedNode.data); - } else if (importedNode.nodeType == DOMNode.PROCESSING_INSTRUCTION_NODE) { - // create a local ProcessingInstruction (with the same target & data as the importedNode) - importNode = __ownerDocument__(this).createProcessingInstruction(importedNode.target, importedNode.data); - } else if (importedNode.nodeType == DOMNode.COMMENT_NODE) { - // create a local Comment (with the same data as the importedNode) - importNode = __ownerDocument__(this).createComment(importedNode.data); - } else { // throw Exception if nodeType is not supported - throw(new DOMException(DOMException.NOT_SUPPORTED_ERR)); - } - - if (deep) { // recurse childNodes - for(var i = 0; i < importedNode.childNodes.length; i++) { - importNode.appendChild(__ownerDocument__(this).importNode(importedNode.childNodes.item(i), true)); - } - } - - //reset _performingImportNodeOperation - __ownerDocument__(this)._performingImportNodeOperation = false; - return importNode; - - }, - contains : function(node){ - while(node && node != this ){ - node = node.parentNode; - } - return !!node; - }, - compareDocumentPosition : function(b){ - var a = this; - var number = (a != b && a.contains(b) && 16) + (a != b && b.contains(a) && 8); - //find position of both - var all = document.getElementsByTagName("*"); - var my_location = 0, node_location = 0; - for(var i=0; i < all.length; i++){ - if(all[i] == a) my_location = i; - if(all[i] == b) node_location = i; - if(my_location && node_location) break; - } - number += (my_location < node_location && 4) - number += (my_location > node_location && 2) - return number; - } - -}); - -/** - * @method DOMNode._getElementsByTagNameRecursive - implements getElementsByTagName() - * @param elem : DOMElement - The element which are checking and then recursing into - * @param tagname : string - The name of the tag to match on. The special value "*" matches all tags - * @param nodeList : DOMNodeList - The accumulating list of matching nodes - * - * @return : DOMNodeList - */ -var __getElementsByTagNameRecursive__ = function (elem, tagname, nodeList) { - - if (elem.nodeType == DOMNode.ELEMENT_NODE || elem.nodeType == DOMNode.DOCUMENT_NODE) { - - if(elem.nodeType !== DOMNode.DOCUMENT_NODE && - ((elem.nodeName.toUpperCase() == tagname.toUpperCase()) || - (tagname == "*")) ){ - __appendChild__(nodeList, elem); // add matching node to nodeList - } - - // recurse childNodes - for(var i = 0; i < elem.childNodes.length; i++) { - nodeList = __getElementsByTagNameRecursive__(elem.childNodes.item(i), tagname, nodeList); - } - } - - return nodeList; -}; - -/** - * @method DOMNode._getElementsByTagNameNSRecursive - implements getElementsByTagName() - * - * @param elem : DOMElement - The element which are checking and then recursing into - * @param namespaceURI : string - the namespace URI of the required node - * @param localName : string - the local name of the required node - * @param nodeList : DOMNodeList - The accumulating list of matching nodes - * - * @return : DOMNodeList - */ -var __getElementsByTagNameNSRecursive__ = function(elem, namespaceURI, localName, nodeList) { - if (elem.nodeType == DOMNode.ELEMENT_NODE || elem.nodeType == DOMNode.DOCUMENT_NODE) { - - if (((elem.namespaceURI == namespaceURI) || (namespaceURI == "*")) && ((elem.localName == localName) || (localName == "*"))) { - __appendChild__(nodeList, elem); // add matching node to nodeList - } - - // recurse childNodes - for(var i = 0; i < elem.childNodes.length; i++) { - nodeList = __getElementsByTagNameNSRecursive__(elem.childNodes.item(i), namespaceURI, localName, nodeList); - } - } - - return nodeList; -}; - -/** - * @method DOMNode._isAncestor - returns true if node is ancestor of target - * @param target : DOMNode - The node we are using as context - * @param node : DOMNode - The candidate ancestor node - * @return : boolean - */ -var __isAncestor__ = function(target, node) { - // if this node matches, return true, - // otherwise recurse up (if there is a parentNode) - return ((target == node) || ((target.parentNode) && (__isAncestor__(target.parentNode, node)))); -}; - -var __ownerDocument__ = function(node){ - return (node.nodeType == DOMNode.DOCUMENT_NODE)?node:node.ownerDocument; -}; - -$w.Node = DOMNode; - -/** - * @class DOMNamespace - The Namespace interface represents an namespace in an Element object - * - * @extends DOMNode - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMNamespace = function(ownerDocument) { - this.DOMNode = DOMNode; - this.DOMNode(ownerDocument); - - this.name = ""; // the name of this attribute - - // If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false. - // Note that the implementation is in charge of this attribute, not the user. - // If the user changes the value of the attribute (even if it ends up having the same value as the default value) - // then the specified flag is automatically flipped to true - this.specified = false; -}; -DOMNamespace.prototype = new DOMNode; -__extend__(DOMNamespace.prototype, { - get value(){ - // the value of the attribute is returned as a string - return this.nodeValue; - }, - set value(value){ - this.nodeValue = value+''; - }, - get nodeType(){ - return DOMNode.NAMESPACE_NODE; - }, - get xml(){ - var ret = ""; - - // serialize Namespace Declaration - if (this.nodeName != "") { - ret += this.nodeName +"=\""+ __escapeXML__(this.nodeValue) +"\""; - } - else { // handle default namespace - ret += "xmlns=\""+ __escapeXML__(this.nodeValue) +"\""; - } - - return ret; - }, - toString: function(){ - return "Namespace #" + this.id; - } -}); - -$debug("Defining CharacterData"); -/* -* CharacterData - DOM Level 2 -*/ -/** - * @class DOMCharacterData - parent abstract class for DOMText and DOMComment - * @extends DOMNode - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMCharacterData = function(ownerDocument) { - this.DOMNode = DOMNode; - this.DOMNode(ownerDocument); -}; -DOMCharacterData.prototype = new DOMNode; -__extend__(DOMCharacterData.prototype,{ - get data(){ - return this.nodeValue; - }, - set data(data){ - this.nodeValue = data; - }, - get length(){return this.nodeValue.length;}, - appendData: function(arg){ - // throw Exception if DOMCharacterData is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - // append data - this.data = "" + this.data + arg; - }, - deleteData: function(offset, count){ - // throw Exception if DOMCharacterData is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - if (this.data) { - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length) || (count < 0))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // delete data - if(!count || (offset + count) > this.data.length) { - this.data = this.data.substring(0, offset); - }else { - this.data = this.data.substring(0, offset). - concat(this.data.substring(offset + count)); - } - } - }, - insertData: function(offset, arg){ - // throw Exception if DOMCharacterData is readonly - if(__ownerDocument__(this).implementation.errorChecking && this._readonly){ - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - if(this.data){ - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // insert data - this.data = this.data.substring(0, offset).concat(arg, this.data.substring(offset)); - }else { - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && (offset != 0)) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // set data - this.data = arg; - } - }, - replaceData: function(offset, count, arg){ - // throw Exception if DOMCharacterData is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - if (this.data) { - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length) || (count < 0))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // replace data - this.data = this.data.substring(0, offset). - concat(arg, this.data.substring(offset + count)); - }else { - // set data - this.data = arg; - } - }, - substringData: function(offset, count){ - var ret = null; - if (this.data) { - // throw Exception if offset is negative or greater than the data length, - // or the count is negative - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length) || (count < 0))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - // if count is not specified - if (!count) { - ret = this.data.substring(offset); // default to 'end of string' - }else{ - ret = this.data.substring(offset, offset + count); - } - } - return ret; - } -}); - -$w.CharacterData = DOMCharacterData;$debug("Defining Text"); -/* -* Text - DOM Level 2 -*/ -/** - * @class DOMText - The Text interface represents the textual content (termed character data in XML) of an Element or Attr. - * If there is no markup inside an element's content, the text is contained in a single object implementing the Text interface - * that is the only child of the element. If there is markup, it is parsed into a list of elements and Text nodes that form the - * list of children of the element. - * @extends DOMCharacterData - * @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMText = function(ownerDocument) { - this.DOMCharacterData = DOMCharacterData; - this.DOMCharacterData(ownerDocument); - - this.nodeName = "#text"; -}; -DOMText.prototype = new DOMCharacterData; -__extend__(DOMText.prototype,{ - //Breaks this Text node into two Text nodes at the specified offset, - // keeping both in the tree as siblings. This node then only contains all the content up to the offset point. - // And a new Text node, which is inserted as the next sibling of this node, contains all the content at and after the offset point. - splitText : function(offset) { - var data, inode; - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Node is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if offset is negative or greater than the data length, - if ((offset < 0) || (offset > this.data.length)) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - } - - if (this.parentNode) { - // get remaining string (after offset) - data = this.substringData(offset); - - // create new TextNode with remaining string - inode = __ownerDocument__(this).createTextNode(data); - - // attach new TextNode - if (this.nextSibling) { - this.parentNode.insertBefore(inode, this.nextSibling); - } - else { - this.parentNode.appendChild(inode); - } - - // remove remaining string from original TextNode - this.deleteData(offset); - } - - return inode; - }, - get nodeType(){ - return DOMNode.TEXT_NODE; - }, - get xml(){ - return __escapeXML__(""+ this.nodeValue); - }, - toString: function(){ - return "Text #" + this._id; - } -}); - -$w.Text = DOMText;$debug("Defining CDATASection"); -/* -* CDATASection - DOM Level 2 -*/ -/** - * @class DOMCDATASection - CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup. - * The only delimiter that is recognized in a CDATA section is the "\]\]\>" string that ends the CDATA section - * @extends DOMCharacterData - * @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMCDATASection = function(ownerDocument) { - this.DOMText = DOMText; - this.DOMText(ownerDocument); - - this.nodeName = "#cdata-section"; -}; -DOMCDATASection.prototype = new DOMText; -__extend__(DOMCDATASection.prototype,{ - get nodeType(){ - return DOMNode.CDATA_SECTION_NODE; - }, - get xml(){ - return ""; - }, - toString : function(){ - return "CDATA #"+this._id; - } -}); - -$w.CDATASection = DOMCDATASection;$debug("Defining Comment"); -/* -* Comment - DOM Level 2 -*/ -/** - * @class DOMComment - This represents the content of a comment, i.e., all the characters between the starting '' - * @extends DOMCharacterData - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMComment = function(ownerDocument) { - this.DOMCharacterData = DOMCharacterData; - this.DOMCharacterData(ownerDocument); - - this.nodeName = "#comment"; -}; -DOMComment.prototype = new DOMCharacterData; -__extend__(DOMComment.prototype, { - get nodeType(){ - return DOMNode.COMMENT_NODE; - }, - get xml(){ - return ""; - }, - toString : function(){ - return "Comment #"+this._id; - } -}); - -$w.Comment = DOMComment; -$debug("Defining DocumentType"); -;/* -* DocumentType - DOM Level 2 -*/ -var DOMDocumentType = function() { - $error("DOMDocumentType.constructor(): Not Implemented" ); -}; - -$w.DocumentType = DOMDocumentType; -$debug("Defining Attr"); -/* -* Attr - DOM Level 2 -*/ -/** - * @class DOMAttr - The Attr interface represents an attribute in an Element object - * @extends DOMNode - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMAttr = function(ownerDocument) { - this.DOMNode = DOMNode; - this.DOMNode(ownerDocument); - - this.ownerElement = null; // set when Attr is added to NamedNodeMap -}; -DOMAttr.prototype = new DOMNode; -__extend__(DOMAttr.prototype, { - // the name of this attribute - get name(){ - return this.nodeName; - }, - set name(name){ - this.nodeName = name; - }, - // the value of the attribute is returned as a string - get value(){ - return this.nodeValue; - }, - set value(value){ - // throw Exception if Attribute is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - // delegate to node - this.nodeValue = value; - }, - get specified(){ - return (this.value.length > 0); - }, - get nodeType(){ - return DOMNode.ATTRIBUTE_NODE; - }, - get xml(){ - return this.nodeName + '="' + __escapeXML__(this.nodeValue) + '" '; - }, - toString : function(){ - return "Attr #" + this._id + " " + this.name; - } -}); - -$w.Attr = DOMAttr; -$debug("Defining Element"); -/** - * @class DOMElement - By far the vast majority of objects (apart from text) that authors encounter - * when traversing a document are Element nodes. - * @extends DOMNode - * @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMElement = function(ownerDocument) { - this.DOMNode = DOMNode; - this.DOMNode(ownerDocument); - this.id = ""; // the ID of the element -}; -DOMElement.prototype = new DOMNode; -__extend__(DOMElement.prototype, { - // The name of the element. - get tagName(){ - return this.nodeName; - }, - set tagName(name){ - this.nodeName = name; - }, - addEventListener : function(){ window.addEventListener.apply(this, arguments) }, - removeEventListener : function(){ window.removeEventListener.apply(this, arguments) }, - dispatchEvent : function(){ window.dispatchEvent.apply(this, arguments) }, - getAttribute: function(name) { - var ret = null; - // if attribute exists, use it - var attr = this.attributes.getNamedItem(name); - if (attr) { - ret = attr.value; - } - return ret; // if Attribute exists, return its value, otherwise, return "" - }, - setAttribute : function (name, value) { - // if attribute exists, use it - var attr = this.attributes.getNamedItem(name); - var value = value+''; - //I had to add this check becuase as the script initializes - //the id may be set in the constructor, and the html element - //overrides the id property with a getter/setter. - if(__ownerDocument__(this)){ - if (!attr) { - attr = __ownerDocument__(this).createAttribute(name); // otherwise create it - } - - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Attribute is readonly - if (attr._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if the value string contains an illegal character - if (!__isValidString__(value)) { - throw(new DOMException(DOMException.INVALID_CHARACTER_ERR)); - } - } - - if (__isIdDeclaration__(name)) { - // this.id = value; // cache ID for getElementById() - } - - // assign values to properties (and aliases) - attr.value = value; - - // add/replace Attribute in NamedNodeMap - this.attributes.setNamedItem(attr); - } - }, - removeAttribute : function removeAttribute(name) { - // delegate to DOMNamedNodeMap.removeNamedItem - return this.attributes.removeNamedItem(name); - }, - getAttributeNode : function getAttributeNode(name) { - // delegate to DOMNamedNodeMap.getNamedItem - return this.attributes.getNamedItem(name); - }, - setAttributeNode: function(newAttr) { - // if this Attribute is an ID - if (__isIdDeclaration__(newAttr.name)) { - this.id = newAttr.value; // cache ID for getElementById() - } - // delegate to DOMNamedNodeMap.setNamedItem - return this.attributes.setNamedItem(newAttr); - }, - removeAttributeNode: function(oldAttr) { - // throw Exception if Attribute is readonly - if (__ownerDocument__(this).implementation.errorChecking && oldAttr._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get item index - var itemIndex = this.attributes._findItemIndex(oldAttr._id); - - // throw Exception if node does not exist in this map - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - return this.attributes._removeChild(itemIndex); - }, - getAttributeNS : function(namespaceURI, localName) { - var ret = ""; - // delegate to DOMNAmedNodeMap.getNamedItemNS - var attr = this.attributes.getNamedItemNS(namespaceURI, localName); - if (attr) { - ret = attr.value; - } - return ret; // if Attribute exists, return its value, otherwise return "" - }, - setAttributeNS : function(namespaceURI, qualifiedName, value) { - // call DOMNamedNodeMap.getNamedItem - var attr = this.attributes.getNamedItem(namespaceURI, qualifiedName); - - if (!attr) { // if Attribute exists, use it - // otherwise create it - attr = __ownerDocument__(this).createAttributeNS(namespaceURI, qualifiedName); - } - - var value = value+''; - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Attribute is readonly - if (attr._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if the Namespace is invalid - if (!__isValidNamespace__(namespaceURI, qualifiedName)) { - throw(new DOMException(DOMException.NAMESPACE_ERR)); - } - - // throw Exception if the value string contains an illegal character - if (!__isValidString__(value)) { - throw(new DOMException(DOMException.INVALID_CHARACTER_ERR)); - } - } - - // if this Attribute is an ID - if (__isIdDeclaration__(name)) { - this.id = value; // cache ID for getElementById() - } - - // assign values to properties (and aliases) - attr.value = value; - attr.nodeValue = value; - - // delegate to DOMNamedNodeMap.setNamedItem - this.attributes.setNamedItemNS(attr); - }, - removeAttributeNS : function(namespaceURI, localName) { - // delegate to DOMNamedNodeMap.removeNamedItemNS - return this.attributes.removeNamedItemNS(namespaceURI, localName); - }, - getAttributeNodeNS : function(namespaceURI, localName) { - // delegate to DOMNamedNodeMap.getNamedItemNS - return this.attributes.getNamedItemNS(namespaceURI, localName); - }, - setAttributeNodeNS : function(newAttr) { - // if this Attribute is an ID - if ((newAttr.prefix == "") && __isIdDeclaration__(newAttr.name)) { - this.id = newAttr.value+''; // cache ID for getElementById() - } - - // delegate to DOMNamedNodeMap.setNamedItemNS - return this.attributes.setNamedItemNS(newAttr); - }, - hasAttribute : function(name) { - // delegate to DOMNamedNodeMap._hasAttribute - return __hasAttribute__(this.attributes,name); - }, - hasAttributeNS : function(namespaceURI, localName) { - // delegate to DOMNamedNodeMap._hasAttributeNS - return __hasAttributeNS__(this.attributes, namespaceURI, localName); - }, - get nodeType(){ - return DOMNode.ELEMENT_NODE; - }, - get xml() { - var ret = ""; - - // serialize namespace declarations - var ns = this._namespaces.xml; - if (ns.length > 0) ns = " "+ ns; - - // serialize Attribute declarations - var attrs = this.attributes.xml; - if (attrs.length > 0) attrs = " "+ attrs; - - // serialize this Element - ret += "<" + this.nodeName.toLowerCase() + ns + attrs +">"; - ret += this.childNodes.xml; - ret += ""; - - return ret; - }, - toString : function(){ - return "Element #"+this._id + " "+ this.tagName + (this.id?" => "+this.id:''); - } -}); - -$w.Element = DOMElement; -/** - * @class DOMException - raised when an operation is impossible to perform - * @author Jon van Noort (jon@webarcana.com.au) - * @param code : int - the exception code (one of the DOMException constants) - */ -var DOMException = function(code) { - this.code = code; -}; - -// DOMException constants -// Introduced in DOM Level 1: -DOMException.INDEX_SIZE_ERR = 1; -DOMException.DOMSTRING_SIZE_ERR = 2; -DOMException.HIERARCHY_REQUEST_ERR = 3; -DOMException.WRONG_DOCUMENT_ERR = 4; -DOMException.INVALID_CHARACTER_ERR = 5; -DOMException.NO_DATA_ALLOWED_ERR = 6; -DOMException.NO_MODIFICATION_ALLOWED_ERR = 7; -DOMException.NOT_FOUND_ERR = 8; -DOMException.NOT_SUPPORTED_ERR = 9; -DOMException.INUSE_ATTRIBUTE_ERR = 10; - -// Introduced in DOM Level 2: -DOMException.INVALID_STATE_ERR = 11; -DOMException.SYNTAX_ERR = 12; -DOMException.INVALID_MODIFICATION_ERR = 13; -DOMException.NAMESPACE_ERR = 14; -DOMException.INVALID_ACCESS_ERR = 15; -$debug("Defining DocumentFragment"); -/* -* DocumentFragment - DOM Level 2 -*/ -/** - * @class DOMDocumentFragment - DocumentFragment is a "lightweight" or "minimal" Document object. - * @extends DOMNode - * @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMDocumentFragment = function(ownerDocument) { - this.DOMNode = DOMNode; - this.DOMNode(ownerDocument); - this.nodeName = "#document-fragment"; -}; -DOMDocumentFragment.prototype = new DOMNode; -__extend__(DOMDocumentFragment.prototype,{ - get nodeType(){ - return DOMNode.DOCUMENT_FRAGMENT_NODE; - }, - get xml(){ - var xml = "", - count = this.childNodes.length; - - // create string concatenating the serialized ChildNodes - for (var i = 0; i < count; i++) { - xml += this.childNodes.item(i).xml; - } - - return xml; - }, - toString : function(){ - return "DocumentFragment #"+this._id; - } -}); - -$w.DocumentFragment = DOMDocumentFragment; -$debug("Defining ProcessingInstruction"); -/* -* ProcessingInstruction - DOM Level 2 -*/ -/** - * @class DOMProcessingInstruction - The ProcessingInstruction interface represents a "processing instruction", - * used in XML as a way to keep processor-specific information in the text of the document - * @extends DOMNode - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : DOMDocument - The Document object associated with this node. - */ -var DOMProcessingInstruction = function(ownerDocument) { - this.DOMNode = DOMNode; - this.DOMNode(ownerDocument); -}; -DOMProcessingInstruction.prototype = new DOMNode; -__extend__(DOMProcessingInstruction.prototype, { - get data(){ - return this.nodeValue; - }, - set data(data){ - // throw Exception if DOMNode is readonly - if (__ownerDocument__(this).errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - this.nodeValue = data; - }, - get target(){ - // The target of this processing instruction. - // XML defines this as being the first token following the markup that begins the processing instruction. - // The content of this processing instruction. - return this.nodeName; - }, - get nodeType(){ - return DOMNode.PROCESSING_INSTRUCTION_NODE; - }, - get xml(){ - return ""; - }, - toString : function(){ - return "ProcessingInstruction #"+this._id; - } -}); - -$w.ProcessesingInstruction = DOMProcessingInstruction; -$debug("Defining DOMParser"); -/* -* DOMParser -*/ - -var DOMParser = function(){}; -__extend__(DOMParser.prototype,{ - parseFromString: function(xmlString){ - //$log("Parsing XML String: " +xmlString); - return document.implementation.createDocument().loadXML(xmlString); - } -}); - -$debug("Initializing Internal DOMParser."); -//keep one around for internal use -$domparser = new DOMParser(); - -$w.DOMParser = DOMParser; -// ========================================================================= -// -// xmlsax.js - an XML SAX parser in JavaScript. -// -// version 3.1 -// -// ========================================================================= -// -// Copyright (C) 2001 - 2002 David Joham (djoham@yahoo.com) and Scott Severtson -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. - -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// -// Visit the XML for ' - ] - ]; - }, - - /* this uses dynamic, synchronous http requests */ - "xhr": function (env) { - return [ - 200, - {'Content-type': 'text/html'}, - [ - '' - ] - ]; - } - - } - ); - app = exports.App(app); - app = require("jack").ContentLength(app); - exports.app = app; - require("jackup").main(["jackup", module.path]); -} - diff --git a/utils/lib/narwhal/tusk.js b/utils/lib/narwhal/tusk.js deleted file mode 100755 index ded05cc..0000000 --- a/utils/lib/narwhal/tusk.js +++ /dev/null @@ -1,169 +0,0 @@ - -var fs = require("file"); -var packages = require("packages"); -var util = require("util"); -var json = require("json"); -var http = require("http"); - -var minCatalogVersion = 1; - -var args = require("args"); -var parser = exports.parser = new args.Parser(); - -parser.help('A Narwhal project package manager.'); - -// parser.option('sources', exports.sources); - -parser.command('list', module.id + '/list') - -parser.command('install', module.id + '/install'); - -parser.command('upgrade', null) - .help('downloads the latest version of a package'); - -parser.command('remove', null) - .help('removes the local copy of package'); - -parser.command('update', module.id + '/update'); - -parser.command('search', null) - .help('searches the package catalog'); - -parser.command('init', module.id + '/init'); - -parser.command('platform', module.id + '/platform'); - -parser.command('freeze', null) - .help('writes a freeze.json file'); - -parser.command('bundle', null) - .help('creates an archive of your project and its package dependencies'); - -parser.command('reheat', module.id + '/reheat'); - -parser.command('clone', module.id + '/clone'); - -parser.command('catalog', module.id + '/catalog'); - -parser.command('create-catalog', module.id + '/create-catalog'); - -parser.command('orphans', null) - .help('lists packages that are no longer wanted by the user or other packages.') - -parser.command('consolidate', module.id + '/consolidate'); - -parser.helpful(); - -// utilities -// - -exports.getDirectory = function () { - return fs.path(system.packagePrefixes[0]); -}; - -exports.getPackagesDirectory = function () { - return exports.getDirectory().join('packages'); -}; - -exports.getTuskDirectory = function () { - var tuskDirectory = exports.getDirectory().join('.tusk'); - tuskDirectory.mkdirs(); - return tuskDirectory; -} - -exports.getZipsDirectory = function () { - return exports.getDirectory().join('zips'); -}; - -exports.getCatalogPath = function () { - return exports.getTuskDirectory().join('catalog.json'); -}; - -exports.readCatalog = function () { - var catalogPath = exports.getCatalogPath(); - if (!catalogPath.exists()) - throw new Error(catalogPath + " does not exist."); - if (!catalogPath.isFile()) - throw new Error(catalogPath + " is not a file."); - var catalog = json.decode(catalogPath.read({charset: 'utf-8'})); - if (catalog.version === undefined || +catalog.version < minCatalogVersion) - throw new Error("catalog is out of date. use tusk update or create-catalog"); - return catalog; -}; - -exports.writeCatalog = function (catalog) { - var catalogPath = exports.getCatalogPath(); - print('Writing ' + catalogPath); - return catalogPath.write( - json.encode(catalog, null, 4), - {charset: 'utf-8'} - ); -}; - -exports.update = function (options) { - require('./tusk/update').update.call(this, options); -}; - -exports.getSourcesPath = function () { - var try1 = exports.getTuskDirectory().join('sources.json'); - var try2 = exports.getDirectory().join('sources.json'); - if (try1.isFile()) - return try1; - if (try2.isFile()) - return try2; -}; - -exports.readSources = function () { - var sources = json.decode(exports.getSourcesPath().read( - {charset: 'utf-8'} - )); - if ( - sources.version === undefined || - +sources.version < minCatalogVersion - ) - throw new Error( - "sources file is out of date. version " + - minCatalogVersion + " is required." - ); - sources.packages = sources.packages || {}; - return sources; -}; - -exports.writeSources = function (sources) { - return exports.getSourcesPath().write( - json.encode(sources, null, 4), - {charset: 'utf-8'} - ); -}; - -exports.getNotesPath = function () { - return exports.getTuskDirectory().join('notes.json'); -}; - -exports.readNotes = function () { - var notesPath = exports.getNotesPath(); - if (!notesPath.isFile()) - return {}; - return json.decode(notesPath.read( - {charset: 'utf-8'} - )); -}; - -exports.writeNotes = function (notes) { - return exports.getNotesPath().write( - json.encode(notes, null, 4), - {charset: 'utf-8'} - ); -}; - -// run it - -exports.main = function (args) { - var options = parser.parse(args); - if (!options.acted) - parser.printHelp(options); -}; - -if (module.id == require.main) - exports.main(system.args); - diff --git a/utils/lib/narwhal/tusk/bin.js b/utils/lib/narwhal/tusk/bin.js deleted file mode 100755 index fdd8716..0000000 --- a/utils/lib/narwhal/tusk/bin.js +++ /dev/null @@ -1,13 +0,0 @@ - -var util = require('util'); -var tusk = require('../tusk'); -var args = require('args'); - -var parser = exports.parser = new args.Parser(); - -parser.help('lists all packaged executables'); - -parser.action(function (options) { -}); - - diff --git a/utils/lib/narwhal/tusk/bundle.js b/utils/lib/narwhal/tusk/bundle.js deleted file mode 100755 index e69de29..0000000 --- a/utils/lib/narwhal/tusk/bundle.js +++ /dev/null diff --git a/utils/lib/narwhal/tusk/catalog.js b/utils/lib/narwhal/tusk/catalog.js deleted file mode 100755 index 347bfcc..0000000 --- a/utils/lib/narwhal/tusk/catalog.js +++ /dev/null @@ -1,15 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); - -var parser = exports.parser = new args.Parser(); - -parser.help('lists all packages in the catalog'); - -parser.action(function (options) { - if (!tusk.getCatalogPath().isFile()) - require('./update').update.call(this, options); - Object.keys(tusk.readCatalog().packages).forEach(print); -}); - diff --git a/utils/lib/narwhal/tusk/clone.js b/utils/lib/narwhal/tusk/clone.js deleted file mode 100755 index 425dc5c..0000000 --- a/utils/lib/narwhal/tusk/clone.js +++ /dev/null @@ -1,66 +0,0 @@ - -var tusk = require("../tusk"); -var os = require("os"); -var util = require("util"); -var args = require("args"); - -var parser = exports.parser = new args.Parser(); - -parser.help('clones a package from its version control system.') - -parser.args('package'); - -parser.option('-o', '--owner', 'owner') - .help("clone from the owner's repository") - .bool() - .inverse(); - -parser.option('-u', '--user', 'user') - .help('overrides the user name from which to clone the package') - .set(); - -parser.action(function (options) { - var self = this; - if (!util.len(options.args)) - throw new Error("Package name required"); - var packagesDirectory = tusk.getPackagesDirectory(); - var sources = tusk.readSources().packages; - var catalog = tusk.readCatalog().packages; - var owner = options.owner; - options.args.forEach(function (name) { - if (!util.has(sources, name)) - throw new Error("Package does not exist: " + name); - var source = util.get(sources, name); - if (source.type !== "github") - throw new Error("Package " + util.enquote(name) + " is not a Github package."); - }); - options.args.forEach(function (name) { - var source = util.get(sources, name); - var githubName = util.get(source, 'name', name); - var user = options.user || source.user; - var command = [ - 'git', - 'clone', - owner ? - ( - 'git@github.com:' + user + - '/' + githubName + '.git' - ): - ( - 'git://github.com/' + - user + '/' + githubName + '.git' - ), - packagesDirectory.join(name) - ]; - self.print('\0cyan(' + command.map(function (term) { - var enquoted = os.enquote(term); - if (enquoted != "'" + term + "'") - return enquoted; - return term; - }).join(' ') + '\0)'); - os.system(command); - }); -}); - -parser.helpful(); - diff --git a/utils/lib/narwhal/tusk/consolidate.js b/utils/lib/narwhal/tusk/consolidate.js deleted file mode 100755 index 9decdc8..0000000 --- a/utils/lib/narwhal/tusk/consolidate.js +++ /dev/null @@ -1,25 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var fs = require("file"); -var packages = require("packages"); - -var parser = exports.parser = new args.Parser(); - -parser.help('consolidates all installed packages into the current sea.'); - -parser.action(function (options) { - var self = this; - var packagesDirectory = tusk.getPackagesDirectory(); - util.forEachApply(util.items(packages.catalog), function (name, info) { - var target = packagesDirectory.join(name); - if (!target.exists()) { - fs.symlink(info.directory, target); - self.print(target + ' -> ' + info.directory); - } - }); -}); - -parser.helpful(); - diff --git a/utils/lib/narwhal/tusk/create-catalog.js b/utils/lib/narwhal/tusk/create-catalog.js deleted file mode 100755 index f717cea..0000000 --- a/utils/lib/narwhal/tusk/create-catalog.js +++ /dev/null @@ -1,79 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var http = require("http"); -var json = require("json"); - -var parser = exports.parser = new args.Parser(); - -parser.help('creates a catalog of packages from sources.json'); - -parser.action(function (options) { - var self = this; - var sources = tusk.readSources(); - var catalog = {}; - catalog['!'] = "This file is generated by 'tusk create-catalog', copied from '.tusk', and committed only so that it may be downloaded from Github with 'tusk update'."; - catalog.version = util.copy(sources.version); - var packages = catalog.packages = {}; - util.forEachApply( - util.items(sources.packages || {}), - function (name, source) { - var info; - - if (source['package.json']) - info = util.copy(source['package.json']); - - if (source.type == "inline") { - if (!info) { - self.print( - "\0red(dropped:\0) " + name + - " \0blue(because it did not provide a " + - "package.json inline.\0)" - ); - return; - } - - } else if (source.type == "github") { - - var githubName = source.name || name; - if (!source.user) - throw new Error("package source " + util.enquote(name) + " did not have a github user name"); - var project = source.user + '/' + githubName; - var url = "http://github.com/" + project + "/raw/master/package.json"; - - // download package.json if not already provided - if (!info) { - try { - var text = http.read(url).toString('utf-8'); - } catch (exception) { - self.print("\0red(dropped:\0) " + name + " \0blue(because of an HTTP error\0)"); - return; - } - try { - info = json.decode(text); - } catch (exception) { - self.print("\0red(dropped:\0) " + name + " \0blue(because of a JSON error\0)"); - return; - } - } - - info.githubName = githubName; - info.type = "zip"; - info.location = 'http://github.com/' + source.user + '/' + githubName + '/zipball/master'; - - } else { - throw new Error( - "Project " + util.enquote(name) + - " has an urecognized type: " + - util.enquote(source.type) - ); - } - - self.print('\0green(' + name + '\0)'); - packages[name] = info; - } - ); - tusk.writeCatalog(catalog); -}); - diff --git a/utils/lib/narwhal/tusk/freeze.js b/utils/lib/narwhal/tusk/freeze.js deleted file mode 100755 index e69de29..0000000 --- a/utils/lib/narwhal/tusk/freeze.js +++ /dev/null diff --git a/utils/lib/narwhal/tusk/init.js b/utils/lib/narwhal/tusk/init.js deleted file mode 100755 index 3c73fda..0000000 --- a/utils/lib/narwhal/tusk/init.js +++ /dev/null @@ -1,60 +0,0 @@ - -var fs = require("file"); -var json = require("json"); -var util = require("util"); -var args = require("args"); -var parser = exports.parser = new args.Parser(); - -parser.help('initializes a Narwhal package/project directory'); - -parser.option('--name', 'name').def("").set(); -parser.option('--author', 'author').def("").set(); -parser.option('--dependency', 'dependencies').push(); -parser.option('--contributor', 'contributors').push(); - -parser.action(function (options, parentOptions) { - parentOptions.acted = true; - var packageInfo = {}; - var path; - if (options.args.length && !/^-/.test(options.args[0])) - path = options.args.shift(); - else - path = fs.cwd(); - util.update(packageInfo, options); - delete packageInfo.args; - delete packageInfo.command; - path = fs.path(path).absolute(); - print(path); - path.join('.tusk').mkdirs(); - path.join('bin').mkdirs(); - path.join('lib').mkdirs(); - system.platforms.forEach(function (platform) { - platform = path.join('platforms', platform); - platform.join('lib').mkdirs(); - }); - path.join('packages').mkdirs(); - - var sea = path.join('bin', 'sea'); - fs.path(system.prefix).join('bin', 'sea').copy(sea); - sea.chmod(0755); - - var activate = path.join('bin', 'activate.bash'); - fs.path(system.prefix).join('bin', 'activate.bash') - .copy(activate); - activate.relative().symlink(activate.resolve('activate')); - - path.join('README').touch(); - path.join('narwhal.conf') - .write('NARWHAL_DEFAULT_PLATFORM=' + system.platform); - var packagePath = path.join('package.json'); - if (packagePath.isFile()) - util.complete( - packageInfo, - json.decode(packagePath.read({charset:'utf-8'})) - ); - packagePath.write( - json.encode(packageInfo, null, 4), - {charset:'utf-8'} - ); -}); - diff --git a/utils/lib/narwhal/tusk/install.js b/utils/lib/narwhal/tusk/install.js deleted file mode 100755 index 9d024dd..0000000 --- a/utils/lib/narwhal/tusk/install.js +++ /dev/null @@ -1,215 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var fs = require("file"); -var json = require("json"); -var http = require("http"); -var zip = require("zip"); -var packages = require("packages"); - -var parser = exports.parser = new args.Parser(); - -parser.help('downloads and installs a package and its dependencies'); - -parser.action(function (options) { - exports.install.call(this, options, options.args); -}); - -exports.install = function (options, names) { - - if (!tusk.getCatalogPath().isFile()) { - if (options.simulate) { - this.print("Run 'tusk update' or 'tusk create-catalog' to get a catalog."); - return; - } - tusk.update.call(this, options); - } - - var parser = this; - var catalog = tusk.readCatalog(); - - // download a catalog if the current catalog - // does not have a version label. - if (!catalog.version) { - this.print("Run 'tusk update' or 'tusk create-catalog' to get a catalog."); - this.print("Your catalog version is no longer supported."); - return; - } - - // validate the requested names against those - // in the catalog of downloadable packages. - var names = names.filter(function (name) { - if (!util.has(catalog.packages, name)) { - parser.print("ERROR: Package not found: " + util.enquote(name)); - return false; - } - return true; - }); - - // load the notes on user-requested and dependency packages - // for book keeping. - var notes = tusk.readNotes(); - names.forEach(function (name) { - if (!notes[name]) { - notes[name] = {}; - } - notes[name].requester = "user"; - }); - tusk.writeNotes(notes); - - // note broken dependency chains - var errors = []; - var dependencies = exports.dependencies(catalog.packages, names, errors); - if (errors.length) { - print('The following dependencies could not be found in the catalog:'); - printUl(errors.map(function (ancestry) { - return ancestry.join(' <- '); - })); - print('Please notify the package system maintainers.'); - this.exit(); - } - - // notify of packages already installed - var already = exports.already(packages.catalog, names); - if (already.length) { - print('The following packages are already installed:'); - printUl(already); - } - - // note missing packages - var missing = exports.missing(packages.catalog, dependencies); - if (!missing.length) { - print('No new packages to install.'); - this.exit(); - } - print('The following packages will be downloaded and installed:'); - printUl(missing); - - // download missing packages - var zipsDirectory = tusk.getZipsDirectory(); - zipsDirectory.mkdirs(); - missing.forEach(function (name) { - var info = catalog.packages[name]; - print('Downloading: ' + info.location); - if (options.simulate) - return; - var zipFile = zipsDirectory.join(name + '.zip') - if (options.resume && zipFile.isFile()) - return; - var targetPath = tusk.getDirectory().join('packages', name); - var zipData = http.read(info.location, 'b'); - zipFile.write(zipData, 'b'); - }); - - // install missing packages - missing.forEach(function (name) { - if (!notes[name]) - notes[name] = {} - if (!notes[name].files) - notes[name].files = []; - if (!notes[name].requester) - notes[name].requester = "module"; - try { - var zipFile = zipsDirectory.join(name + '.zip') - print('Unzipping: ' + zipFile); - if (options.simulate) - return; - var targetPath = tusk.getDirectory().join('packages', name); - - // unzip - new zip.Unzip(zipFile).forEach(function (entry) { - if (entry.isDirectory()) - return; - var parts = fs.split(entry.getName()); - parts.shift(); // name-project-comment ref dirname - var path = targetPath.join(fs.join.apply(null, parts)); - path.dirname().mkdirs(); - notes[name].files.push(path); - print(path); - path.write(entry.read('b'), 'b'); - }); - - // write package.json if it was not in the - // archive - var packageJson = targetPath.join('package.json'); - if (!packageJson.isFile()) - packageJson.write( - json.encode(catalog.packages[name], null, 4), - {'charset': 'UTF-8'} - ); - - // make bins executable and make symlinks - // in $SEA/bin - var bin = targetPath.join('bin'); - if (bin.isDirectory()) - bin.list().forEach(function (name) { - var target = targetPath.join('bin', name); - target.chmod(0755); - var sea = tusk.getDirectory().join('bin'); - var source = sea.join(name); - var relative = sea.to(target); - if (!source.linkExists()) { - target.symlink(source); - } - }); - - notes[name].finished = true; - } catch (exception) { - var packageJsonPath = tusk.getDirectory().join('packages', name, 'package.json'); - if (packageJsonPath.isFile()) - packageJsonPath.remove(); - throw exception; - } finally { - tusk.writeNotes(notes); - /* - if (zipFile.isFile()) - zipFile.remove(); - */ - } - }); - - print('Done.'); - -}; - -function printUl(lines) { - lines.forEach(function (line) { - print(' * ' + line); - }); -}; - -exports.dependencies = function (catalog, names, errors) { - var dependencies = {}; - names.forEach(function (name) { - scan(catalog, dependencies, name, [], errors); - }); - return Object.keys(dependencies); -}; - -var scan = function (catalog, dependencies, name, ancestry, errors) { - if (util.has(dependencies, name)) - return; - ancestry = [name].concat(ancestry); - if (!util.has(catalog, name)) { - errors.push(ancestry); - return; - } - dependencies[name] = true; - (catalog[name].dependencies || []).forEach(function (child) { - scan(catalog, dependencies, child, ancestry, errors); - }); -}; - -exports.already = function (catalog, names) { - return names.filter(function (packageName) { - return util.has(catalog, packageName); - }); -}; - -exports.missing = function (catalog, names) { - return names.filter(function (packageName) { - return !util.has(catalog, packageName); - }); -}; - diff --git a/utils/lib/narwhal/tusk/list.js b/utils/lib/narwhal/tusk/list.js deleted file mode 100755 index 3eab4ad..0000000 --- a/utils/lib/narwhal/tusk/list.js +++ /dev/null @@ -1,20 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var packages = require("packages"); - -var parser = exports.parser = new args.Parser(); - -parser.help('lists all installed packages'); - -parser.action(function (options) { - var self = this; - Object.keys(packages.catalog).forEach(function (name) { - self.print( - name + ' \0magenta(' + - packages.catalog[name].directory + '\0)' - ); - }); -}); - diff --git a/utils/lib/narwhal/tusk/orphans.js b/utils/lib/narwhal/tusk/orphans.js deleted file mode 100755 index e69de29..0000000 --- a/utils/lib/narwhal/tusk/orphans.js +++ /dev/null diff --git a/utils/lib/narwhal/tusk/platform.js b/utils/lib/narwhal/tusk/platform.js deleted file mode 100755 index 48ac58c..0000000 --- a/utils/lib/narwhal/tusk/platform.js +++ /dev/null @@ -1,33 +0,0 @@ - -var os = require('os'); -var util = require('util'); -var tusk = require('../tusk'); -var args = require('args'); - -var parser = exports.parser = new args.Parser(); - -parser.help('selects a platform for the current "sea"'); - -parser.arg('platform').optional(); - -parser.action(function (options) { - var self = this; - var directory = tusk.getDirectory(); - var platformsDirectory = directory.join('platforms'); - if (options.args.length == 0) { - platformsDirectory.list().forEach(function (platformName) { - self.print(platformName); - }); - } else { - var platform = options.args.shift(); - if (!util.has(platformsDirectory.list(), platform)) - throw new Error("No such platform"); - var narwhalConf = directory.join('narwhal.conf'); - narwhalConf.write( - 'NARWHAL_DEFAULT_PLATFORM=' + - os.enquote(platform) - ); - } -}); - - diff --git a/utils/lib/narwhal/tusk/reheat.js b/utils/lib/narwhal/tusk/reheat.js deleted file mode 100755 index b1dd510..0000000 --- a/utils/lib/narwhal/tusk/reheat.js +++ /dev/null @@ -1,15 +0,0 @@ - -var tusk = require("../tusk"); -var install = require('./install'); -var util = require("util"); -var args = require("args"); -var packages = require('packages'); -var parser = exports.parser = new args.Parser(); - -parser.help('reconsistutes the exact versions of all dependencies from a frozen project'); - -parser.action(function (options, name) { - var names = packages.root.dependencies || []; - install.install.call(this, options, names); -}); - diff --git a/utils/lib/narwhal/tusk/remove.js b/utils/lib/narwhal/tusk/remove.js deleted file mode 100755 index c8329bd..0000000 --- a/utils/lib/narwhal/tusk/remove.js +++ /dev/null @@ -1,15 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var parser = exports.parser = new args.Parser(); - -parser.help('removes the local copy of package'); - -parser.action(function (options) { - var names = options.args; -}); - -exports.remove = function () { -}; - diff --git a/utils/lib/narwhal/tusk/search.js b/utils/lib/narwhal/tusk/search.js deleted file mode 100755 index e69de29..0000000 --- a/utils/lib/narwhal/tusk/search.js +++ /dev/null diff --git a/utils/lib/narwhal/tusk/update.js b/utils/lib/narwhal/tusk/update.js deleted file mode 100755 index ea05d1a..0000000 --- a/utils/lib/narwhal/tusk/update.js +++ /dev/null @@ -1,21 +0,0 @@ - -var tusk = require("../tusk"); -var util = require("util"); -var args = require("args"); -var http = require("http"); - -var parser = exports.parser = new args.Parser(); - -parser.help('downloads the newest package catalog'); - -parser.action(function (options) { - exports.update.call(this, options); -}); - -exports.update = function (options) { - this.print('\0blue(Downloading catalog.\0)'); - var catalogData = http.read('http://github.com/tlrobinson/narwhal/raw/master/catalog.json'); - this.print('\0green(Saving catalog.\0)'); - tusk.getCatalogPath().write(catalogData, 'b'); -}; - diff --git a/utils/lib/narwhal/tusk/upgrade.js b/utils/lib/narwhal/tusk/upgrade.js deleted file mode 100755 index e69de29..0000000 --- a/utils/lib/narwhal/tusk/upgrade.js +++ /dev/null diff --git a/utils/lib/os.js b/utils/lib/os.js deleted file mode 100755 index 7bffef7..0000000 --- a/utils/lib/os.js +++ /dev/null @@ -1,29 +0,0 @@ - -var platform = require('os-platform'); -for (var name in platform) { - if (Object.prototype.hasOwnProperty.call(platform, name)) { - exports[name] = platform[name]; - } -} - -exports.system = function (command, options) { - var process = exports.popen(command, options); - return process.communicate( - '', - system.stdout, - system.stderr - ).code; -}; - -exports.command = function (command) { - var process = exports.popen(command); - var result = process.communicate(); - if (result.code !== 0) - throw new Error(result.stderr.read()); - return result.stdout.read(); -}; - -exports.enquote = function (word) { - return "'" + String(word).replace(/'/g, "'\"'\"'") + "'"; -}; - diff --git a/utils/lib/packages.js b/utils/lib/packages.js deleted file mode 100755 index 976f991..0000000 --- a/utils/lib/packages.js +++ /dev/null @@ -1,336 +0,0 @@ - -var util = require('./util'); -var json = require('./json'); -var fs = require('./file'); - -exports.main = function main() { - // finds, reads, and analyzes packages, - // then applies its findings (synthesizes) - // to the loader and system. - // this involves a breadth first search for packages - // and packages within packages (readPackages), - // and performing platform-specific analysis and - // synthesis. - - if (system.packagePrefixes === undefined) - throw new Error( - "system.packagePrefix is undefined in packages loader. " + - "(platform=" + system.platform + ")" - ); - - exports.load(system.packagePrefixes); - -}; - -exports.load = function (packagePrefixes) { - - // the packages platform module, if it exists, - // performs platform-specific actions on each package. - var packagesPlatform; - try { - packagesPlatform = require('packages-platform'); - } catch (exception) { - } - - // depth first search of the packages tree and roots - var catalog = {}; - var root = exports.readPackages(packagePrefixes, catalog); - - exports.verify(catalog); - - // a topological sort of the packages based on their - // stated dependencies and contained platform-specific - // components - var packageOrder = exports.sortedPackages(catalog); - - // analysis - var analysis = {}; - exports.analyze(analysis, packageOrder); - // platform-specific analysis - if (packagesPlatform) - packagesPlatform.analyze(analysis, packageOrder); - - // synthesis - exports.synthesize(analysis); - // platform-specific synthesis - if (packagesPlatform) - packagesPlatform.synthesize(analysis); - - // preload modules - analysis.preloadModules.forEach(function(id) { - system.log.debug("Preloading module: "+id); - try { - require(id); - } catch (e) { - system.log.warn("Error preloading module: "+e); - } - }); - - // record results - exports.catalog = catalog; - exports.packageOrder = packageOrder; - exports.root = root; - exports.analysis = analysis; - return exports; -}; - -/*** readPackages - recursively loads all package data from package.json files - and packages/ directories, starting with the given directory, - usually the system.packagePrefix. -*/ -exports.readPackages = function readPackages(prefixes, catalog) { - // construct an object graph from package json files - // through a breadth first search of the root package and - // its transitive packages/ directories. - - if (!catalog) - throw new Error("must pass a package data object as the second argument to readPackages."); - - var visitedPackages = {}; - var root; - - prefixes = util.copy(prefixes); - if (typeof prefixes == 'string') - prefixes = [prefixes]; - - // queue-based breadth-first-search of the package - // tree starting with the "root", usually - // system.packagePrefix - while (prefixes.length) { - var queue = [fs.path(prefixes.shift())]; - while (queue.length) { - - var packageDirectory = queue.shift(); - var name = packageDirectory.basename(); - - // check for cyclic symbolic linkage - var canonicalPackageDirectory = packageDirectory.canonical(); - if (Object.prototype.hasOwnProperty.call(visitedPackages, canonicalPackageDirectory)) - continue; - visitedPackages[canonicalPackageDirectory] = true; - - // check for duplicate package names - if (Object.prototype.hasOwnProperty.call(catalog, name)) { - continue; - } - - if (!packageDirectory.join('package.json').isFile()) { - //system.log.warn('No package.json in ' + packageDirectory); - continue; - } - - var packageDatum; - try { - var packageDatumJson = packageDirectory.join('package.json').read().toString(); - packageDatum = json.parse(packageDatumJson || '{}'); - - // look for local, user overrides - var local = packageDirectory.join('local.json'); - if (local.isFile()) { - local = json.parse(local.read().toString()); - for (var name in local) { - if (Object.prototype.hasOwnProperty.call(local, name)) { - packageDatum[name] = local[name]; - } - } - } - - name = packageDatum.name || name; - catalog[name] = packageDatum; - packageDatum.directory = packageDirectory.join(''); - - // enqueue sub packages - var packagesDirectories = packageDatum.packages; - if (typeof packagesDirectories == "string") - packagesDirectories = [packagesDirectories]; - if (packagesDirectories === undefined) - packagesDirectories = ["packages"]; - packagesDirectories.forEach(function (packagesDirectory) { - packagesDirectory = packageDirectory.join(packagesDirectory); - if (packagesDirectory.isDirectory()) { - packagesDirectory.listPaths().forEach(function (packageDirectory) { - if (packageDirectory.isDirectory()) { - queue.push(packageDirectory); - } - }); - } - }); - - // enqueue parent package root - var parents = packageDatum.parent; - if (parents !== null) { - if (typeof parents == "string") - parents = [parents]; - if (parents === undefined) - parents = ["parent"]; - parents.forEach(function (parent) { - parent = packageDirectory.join('').resolve(parent); - if (parent.isDirectory()) { - prefixes.push(parent); - } - }); - } - - // the first package we encounter gets - // top-billing, the root package - if (!root) - root = packageDatum; - - } catch (exception) { - system.log.error("Could not load package '" + name + "'. " + exception); - } - - } - } - - return root; -}; - -/*** verify - scans a package object for missing dependencies and throws away - any package that has unmet dependencies. -*/ -exports.verify = function verify(catalog) { - for (var name in catalog) { - if (Object.prototype.hasOwnProperty.call(catalog, name)) { - try { - scan(catalog, name); - } catch (exception) { - if (typeof exception == "string") { - } else { - throw exception; - } - } - } - } -}; - -var scan = function scan(catalog, name) { - var packageDatum = catalog[name]; - if (!packageDatum) - throw name; - try { - if (packageDatum.dependencies) { - packageDatum.dependencies.forEach(function (dependency) { - scan(catalog, dependency); - }); - } - } catch (exception) { - if (typeof exception == "string") - system.log.error( - 'Threw away package ' + name + - ' because it depends on ' + exception + - '.' - ); - delete catalog[name]; - throw name; - } -}; - -/*** sortedPackages - returns an array of packages in order from the most - dependent to least dependent, sorted based on - their transitive dependencies. -*/ -exports.sortedPackages = function sortedPackages(packageData) { - var order = topo(packageData); - var sorted = []; - for (var i = 0; i < order.length; i++) - sorted[i] = packageData[order[i]]; - return sorted; -}; - -var topo = function topo(graph) { - var sorted = [], - visited = {}; - for (var name in graph) { - if ( - Object.prototype.hasOwnProperty.call(graph, name) && - !Object.prototype.hasOwnProperty.call(visited, name) - ) { - sorted.push.apply(sorted, _topo(graph, name, visited)); - } - } - return sorted; -}; - -var _topo = function _topo(graph, name, visited) { - var node = graph[name]; - if (Object.prototype.hasOwnProperty.call(visited, node)) - return []; - visited[name] = true; - var sorted = []; - if (graph[name] === undefined) { - system.log.error('"' + name + '" package does not exist.'); - } - var dependencies = graph[name].dependencies || []; - for (var i = 0; i < dependencies.length; i++) { - var dependency = dependencies[i]; - if (Object.prototype.hasOwnProperty.call(visited, dependency)) - continue; - visited[dependency] = true; - sorted.push.apply(sorted, _topo(graph, dependency, visited)); - } - sorted.push(name); - return sorted; -}; - -/*** analyze - constructs prioritized top-level module paths - based on the given sorted package array. -*/ -exports.analyze = function analyze(analysis, catalog) { - analysis.libPaths = []; - analysis.preloadModules = []; - catalog.forEach(function (packageData) { - - // libraries - if (typeof packageData.lib == 'string') - packageData.lib = [packageData.lib]; - if (!packageData.lib) - packageData.lib = ['lib']; - - // platforms - var platforms = 'platforms'; - var platformLibs = []; - if (packageData.platforms) - platforms = packageData.platforms; - system.platforms.forEach(function (platform) { - var platformDir = packageData.directory.join(platforms, platform, 'lib'); - if (platformDir.isDirectory()) - platformLibs.push(platformDir); - }); - - packageData.lib = platformLibs.concat(packageData.lib); - for (var i = 0; i < packageData.lib.length; i++) { - packageData.lib[i] = packageData.directory.resolve(packageData.lib[i]); - } - - analysis.libPaths.unshift.apply(analysis.libPaths, packageData.lib); - - // add any preload librarys to analysis - if (packageData.preload) - analysis.preloadModules.unshift.apply(analysis.preloadModules, packageData.preload); - }); -}; - -/*** synthesize - applies the results of the analysis on the current - execution environment. -*/ -exports.synthesize = function synthesize(analysis) { - exports.addJsPaths(analysis.libPaths); -}; - -/*** addJsPaths -*/ -exports.addJsPaths = function addJsPaths(jsPaths) { - // add package paths to the loader - if (require.paths) - require.paths.splice.apply( - require.paths, - [0, require.paths.length].concat(jsPaths) - ); -}; - diff --git a/utils/lib/promise.js b/utils/lib/promise.js deleted file mode 100755 index 4539c14..0000000 --- a/utils/lib/promise.js +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found - * at http://www.opensource.org/licenses/mit-license.html - * - * ref_send.js version: 2009-05-11 - */ -"use strict"; - -var enqueue = require('reactor').enqueue; - -/** - * Enqueues a task to be run in a future turn. - * @param task function to invoke later - */ -exports.run = enqueue; - -/** - * Constructs a rejected promise. - * @param reason value describing the failure - */ -exports.reject = reject; - -/** - * Constructs a promise for an immediate reference. - * @param value immediate reference - */ -exports.ref = ref; - -/** - * Constructs a ( promise, resolver ) pair. - * - * The resolver is a callback to invoke with a more resolved value for - * the promise. To fulfill the promise, simply invoke the resolver with - * an immediate reference. To reject the promise, invoke the resolver - * with the return from a call to reject(). To put the promise in the - * same state as another promise, invoke the resolver with that other - * promise. - */ -exports.defer = defer; - -/** - * Gets the current value of a promise. - * @param value promise or immediate reference to evaluate - */ -exports.near = function (value) { - return ('function' === typeof value) ? value() : value; -}; - -/** - * Registers an observer on a promise. - * @param value promise or immediate reference to observe - * @param fulfilled function to be called with the resolved value - * @param rejected function to be called with the rejection reason - * @return promise for the return value from the invoked callback - */ -exports.when = function (value, fulfilled, rejected) { - var r = defer(); - var done = false; // ensure the untrusted promise makes at most a - // single call to one of the callbacks - forward(promise(value), 'WHEN', function (x) { - if (done) { throw new Error(); } - done = true; - r.resolve(ref(x)('WHEN', fulfilled, rejected)); - }, function (reason) { - if (done) { throw new Error(); } - done = true; - r.resolve(rejected ? rejected(reason) : reject(reason)); - }); - return r.promise; -}; - -/** - * Gets the value of a property in a future turn. - * @param target promise or immediate reference for target object - * @param noun name of property to get - * @return promise for the property value - */ -exports.get = function (target, noun) { - var r = defer(); - forward(promise(target), 'GET', r.resolve, noun); - return r.promise; -}; - -/** - * Invokes a method in a future turn. - * @param target promise or immediate reference for target object - * @param verb name of method to invoke - * @param argv array of invocation arguments - * @return promise for the return value - */ -exports.post = function (target, verb, argv) { - var r = defer(); - forward(promise(target), 'POST', r.resolve, verb, argv); - return r.promise; -}; - -/** - * Sets the value of a property in a future turn. - * @param target promise or immediate reference for target object - * @param noun name of property to set - * @param value new value of property - * @return promise for the return value - */ -exports.put = function (target, noun, value) { - var r = defer(); - forward(promise(target), 'PUT', r.resolve, noun, value); - return r.promise; -}; - -/** - * Deletes a property in a future turn. - * @param target promise or immediate reference for target object - * @param noun name of property to delete - * @return promise for the return value - */ -exports.remove = function (target, noun) { - var r = defer(); - forward(promise(target), 'DELETE', r.resolve, noun); - return r.promise; -}; - -function reject(reason) { - return function (op, arg1, arg2, arg3) { - if (undefined === op) { - return { '!' : reason }; - } - if ('WHEN' === op) { return arg2 ? arg2(reason) : reject(reason); } - return arg1 ? arg1(reject(reason)) : reject(reason); - }; -} - -function ref(value) { - if (null === value || undefined === value) { - return reject({ $: [ 'NaO' ] }); - } - if ('number' === typeof value && !isFinite(value)) { - return reject({ $: [ 'NaN' ] }); - } - return function (op, arg1, arg2, arg3) { - if (undefined === op) { return value; } - - var r; - switch (op) { - case 'WHEN': - r = value; - break; - case 'GET': - r = (undefined === arg2) ? value : value[arg2]; - break; - case 'POST': - if (undefined === arg2) { - r = reject({}); - } else { - r = value[arg2](arg3); - } - break; - case 'PUT': - if (undefined === arg2) { - r = reject({}); - } else { - value[arg2] = arg3; - r = {}; - } - break; - case 'DELETE': - if (undefined === arg2) { - r = reject({}); - } else { - delete value[arg2]; - r = {}; - } - break; - default: - r = reject({}); - } - return arg1 ? arg1(r) : r; - }; -} - -/** - * Enqueues a promise operation. - * - * The above functions, reject() and ref(), each construct a kind of - * promise. Other libraries can provide other kinds of promises by - * implementing the same API. A promise is a function with signature: - * function (op, arg1, arg2, arg3). The first argument determines the - * interpretation of the remaining arguments. The following cases must be - * handled: - * - * 'op' is undefined: - * Return the most resolved current value of the promise. - * - * 'op' is "WHEN": - * 'arg1': callback to invoke with the fulfilled value of the promise - * 'arg2': callback to invoke with the rejection reason for the promise - * - * 'op' is "GET": - * 'arg1': callback to invoke with the value of the named property - * 'arg2': name of the property to read - * - * 'op' is "POST": - * 'arg1': callback to invoke with the return value from the invocation - * 'arg2': name of the method to invoke - * 'arg3': array of invocation arguments - * - * 'op' is "PUT": - * 'arg1': callback to invoke with the return value from the operation - * 'arg2': name of the property to set - * 'arg3': new value of property - * - * 'op' is "DELETE": - * 'arg1': callback to invoke with the return value from the operation - * 'arg2': name of the property to delete - * - * 'op' is unrecognized: - * 'arg1': callback to invoke with a rejected promise - */ -function forward(p, op, arg1, arg2, arg3) { - enqueue(function () { p(op, arg1, arg2, arg3); }); -} - -/** - * Gets the corresponding promise for a given reference. - */ -function promise(value) { - return ('function' === typeof value) ? value : ref(value); -} - -function defer() { - var value; - var pending = []; - var tail = function (op, arg1, arg2, arg3) { - if (undefined === op) { return pending ? tail : value(); } - if (pending) { - pending.push({ op: op, arg1: arg1, arg2: arg2, arg3: arg3 }); - } else { - forward(value, op, arg1, arg2, arg3); - } - }; - return { - promise: tail, - resolve: function (p) { - if (!pending) { return; } - - var todo = pending; - pending = null; - value = promise(p); - - var i, len = todo.length, task; - for (i = 0; i < len; ++i) { - task = todo[i]; - forward(value, task.op, task.arg1, task.arg2, task.arg3); - } - } - }; -} - diff --git a/utils/lib/regexp.js b/utils/lib/regexp.js deleted file mode 100755 index f9dca58..0000000 --- a/utils/lib/regexp.js +++ /dev/null @@ -1,12 +0,0 @@ -// RegExp - -/*** RegExp.escape - accepts a string; returns the string with regex metacharacters escaped. - the returned string can safely be used within a regex to match a literal - string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \, ^, $, - |, #, [comma], and whitespace. -*/ -RegExp.escape = function (str) { - return str.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); -}; - diff --git a/utils/lib/sandbox.js b/utils/lib/sandbox.js deleted file mode 100755 index 93b77e0..0000000 --- a/utils/lib/sandbox.js +++ /dev/null @@ -1,394 +0,0 @@ - -// NOTE: this file is used is the bootstrapping process, -// so any "requires" must be accounted for in narwhal.js - -exports.Loader = function (options) { - var loader = {}; - var factories = options.factories || {}; - var paths = options.paths; - var extensions = options.extensions || ["", ".js"]; - var timestamps = {}; - - loader.resolve = exports.resolve; - - loader.find = function (topId) { - for (var j = 0; j < extensions.length; j++) { - var extension = extensions[j]; - if (system.fs.isAbsolute(topId)) { - var path = topId + extension; - if (system.fs.isFile(path)) { - return path; - } - } - else { - for (var i = 0; i < paths.length; i++) { - var path = system.fs.join(paths[i], topId + extension); - if (system.fs.isFile(path)) - return path; - } - } - } - throw new Error("require error: couldn't find \"" + topId + '"'); - }; - - loader.fetch = function (topId, path) { - if (!path) - path = loader.find(topId); - if (typeof system.fs.mtime === "function") - timestamps[path] = system.fs.mtime(path); - var text = system.fs.read(path, { - 'charset': 'utf-8' - }); - // we leave the endline so the error line numbers align - text = text.replace(/^#[^\n]+\n/, "\n"); - return text; - }; - - loader.evaluate = function (text, topId) { - if (system.evaluate) { - var fileName = loader.find(topId); - var factory = system.evaluate(text, fileName, 1); - factory.path = fileName; - return factory; - } else { - return new Function("require", "exports", "module", "system", "print", text); - } - }; - - loader.load = function (topId) { - if (!Object.prototype.hasOwnProperty.call(factories, topId)) { - loader.reload(topId); - } else if (typeof system.fs.mtime === "function") { - var filePath = loader.find(topId); - if (!Object.prototype.hasOwnProperty.call(timestamps, filePath) || - system.fs.mtime(filePath) > timestamps[filePath]) - loader.reload(topId); - } - return factories[topId]; - }; - - loader.reload = function (topId, path) { - factories[topId] = loader.evaluate(loader.fetch(topId, path), topId); - }; - - loader.isLoaded = function (topId) { - return Object.prototype.hasOwnProperty.call(factories, topId); - }; - - loader.paths = paths; - loader.extensions = extensions; - - return loader; -}; - -exports.MultiLoader = function (options) { - - var factories = options.factories || {}; - - var self = {}; - self.paths = options.paths || []; - self.loader = options.loader || exports.Loader(options); - self.loaders = options.loaders || [ - ["", self.loader], - [".js", self.loader] - ]; - - self.resolve = exports.resolve; - - self.find = function (topId) { - for (var j = 0; j < self.loaders.length; j++) { - var pair = self.loaders[j]; - var extension = pair[0]; - var loader = pair[1]; - if (system.fs.isAbsolute(topId)) { - var path = topId + extension; - if (system.fs.isFile(path)) { - return [loader, path]; - } - } - else { - for (var i = 0; i < self.paths.length; i++) { - var path = system.fs.join(self.paths[i], topId + extension); - if (system.fs.isFile(path)) { - return [loader, path]; - } - } - } - } - throw "require error: couldn't find \"" + topId + '"'; - }; - - self.load = function (topId) { - if (!Object.prototype.hasOwnProperty.call(factories, topId)) - self.reload(topId); - return factories[topId]; - }; - - self.reload = function (topId) { - var pair = self.find(topId); - var loader = pair[0]; - var path = pair[1]; - loader.reload(topId, path); - factories[topId] = loader.load(topId, path); - }; - - self.isLoaded = function (topId) { - return Object.prototype.hasOwnProperty.call(factories, topId); - }; - - return self; -}; - -exports.AttenuatedLoader = function (loader) { - var self = {}; - - self.resolve = Object.freeze(function (id, baseId) { - return loader.resolve(id, baseId); - }); - - self.fetch = Object.freeze(function (topId) { - if (/\./.test(topId)) - throw new Error("Invalid module identifier"); - return loader.fetch(topId); - }); - - self.load = Object.freeze(function (topId, path) { - if (/\./.test(topId)) - throw new Error("Invalid module identifier"); - return loader.load(topId, path); - }); - - self.reload = Object.freeze(function (topId) { - if (/\./.test(topId)) - throw new Error("Invalid module identifier"); - return loader.reload(topId, path); - }); - - return Object.freeze(self); -}; - -exports.Sandbox = function (options) { - options = options || {}; - var loader = options.loader; - var sandboxSystem = options.system || system; - var modules = options.modules || {}; - var debug = options.debug !== undefined ? !!options.debug : system.debug; - - // managed print free variable in the sandbox forwards - // to system.print - var print = options.print || function () { - return sandboxSystem.print.apply(sandboxSystem, arguments); - }; - - var debugDepth = 0; - var mainId; - - var sandbox = function (id, baseId, force, reload) { - id = loader.resolve(id, baseId); - - /* populate memo with module instance */ - if (!Object.prototype.hasOwnProperty.call(modules, id) || force) { - - if (sandbox.debug) { - debugDepth++; - var debugAcc = ""; - for (var i = 0; i < debugDepth; i++) debugAcc += "+"; - system.print(debugAcc + " " + id, 'module'); - } - - var globals = {}; - if (sandbox.debug) { - // record globals - for (var name in global) - globals[name] = true; - } - - if (!Object.prototype.hasOwnProperty.call(modules, id) || reload) - modules[id] = {}; - var exports = modules[id]; - if (reload) - loader.reload(id); - - var factory = null; - try { - factory = loader.load(id); - } finally { - // poor man's catch and rethrow (Rhino sets file/line to where the exception is thrown, not created) - if (!factory) { - delete modules[id]; - if (sandbox.debug) - debugDepth--; - } - } - var require = Require(id, factory.path); - var module = { - 'id': id, - 'path': factory.path - }; - factory(require, exports, module, sandboxSystem, print); - - if (sandbox.debug) { - // check for new globals - for (var name in global) - if (!globals[name]) - system.log.warn("NEW GLOBAL: " + name); - } - - if (sandbox.debug) { - var debugAcc = ""; - for (var i = 0; i < debugDepth; i++) debugAcc += "-"; - system.print(debugAcc + " " + id, 'module'); - debugDepth--; - } - - } - - /* support curryId for modules in which it is requested */ - var exports = modules[id]; - var imports = {}; - var importsUsed = false; - var curryUsed = false; - for (var name in exports) { - try { - // This try/catch block is needed to handle wrapped Java - // objects in Rhino. - curryUsed = ( - typeof exports[name] == "function" && - exports[name].xNarwhalCurryId - ); - } catch (exception) {}; - - if (curryUsed) { - importsUsed = true; - imports[name] = (function (callback) { - var curried = function () { - return callback.apply( - this, - [baseId].concat(Array.prototype.slice.call(arguments, 0)) - ); - }; - curried.xNarwhalCurryId = callback; - return curried; - })(exports[name].xNarwhalCurryId); - } else { - imports[name] = exports[name]; - } - } - - if (!importsUsed) - imports = exports; - - return imports; - - }; - - var Require = function (baseId, fileName) { // XXX deprecated fileName - var require = function (id) { - //try { - return sandbox(id, baseId); - //} catch (exception) { - // if (exception.message) - // exception.message += ' in ' + baseId; - // throw exception; - //} - }; - require.id = baseId; // XXX deprecated - require.loader = loader; - require.fileName = fileName; // XXX deprecated - require.main = mainId; // XXX deprecated - require.paths = loader.paths; - require.extensions = loader.extensions; - /* offers a facility to request the module id - * in which a function was imported */ - // XXX deprecated (will need to be moved to module object) - require.xNarwhalCurryId = function (callback) { - var curried = function () { - return callback.apply( - this, - [baseId].concat(Array.prototype.slice.call(arguments)) - ); - }; - curried.curryId = callback; - return curried; - }; - return require; - }; - - sandbox.force = function (id) { - return sandbox(id, '', true); - }; - - sandbox.main = function (id) { - mainId = id; - return sandbox(id); - }; - - sandbox.loader = loader; - sandbox.system = system; - sandbox.paths = loader.paths; - sandbox.extensions = loader.extensions; - sandbox.debug = debug; - - return sandbox; -}; - -exports.PrefixLoader = function (prefix, loader) { - var self = this || {}; - - self.resolve = function (id, baseId) { - return loader.resolve(id, baseId); - }; - - /**** evaluate - */ - self.evaluate = function (text, topId) { - return loader.evaluate(text, prefix + topId); - }; - - /**** fetch - */ - self.fetch = function (topId) { - return loader.fetch(prefix + topId); - }; - - /**** load - */ - self.load = function (topId) { - return loader.load(prefix + topId); - }; - - return self; -}; - -exports.sandbox = function(main, system, options) { - options = options || {}; - var prefix = options['prefix']; - var loader = options['loader'] || require.loader; - var modules = options['modules'] || {}; - var print = options['print']; - var debug = options['debug']; - if (!loader) throw new Error( - "sandbox cannot operate without a loader, either explicitly " + - "provided as an option, or implicitly provided by the current " + - "sandbox's 'loader' object." - ); - if (prefix) - loader = exports.PrefixLoader(prefix, loader); - var sandbox = exports.Sandbox({ - modules: modules, - loader: loader, - system: system, - print: print, - debug: debug - }); - return sandbox.main(main); -}; - -exports.resolve = function (id, baseId) { - if (typeof id != "string") - throw new Error("module id '" + id + "' is not a String"); - if (id.charAt(0) == ".") { - id = system.fs.dirname(baseId) + "/" + id; - } - return system.fs.normal(id); -}; diff --git a/utils/lib/sha.js b/utils/lib/sha.js deleted file mode 100755 index d9ce79f..0000000 --- a/utils/lib/sha.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - - A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined - in FIPS PUB 180-1 - Version 2.1a Copyright Paul Johnston 2000 - 2002. - Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - Distributed under the BSD License - See http://pajhome.org.uk/crypt/md5 for details. - -*/ -var util = require('./util'); -var struct = require('./struct'); - -/*** hash -*/ -exports.hash = function (s, _characterSize) { - if (util.no(_characterSize)) _characterSize = struct.characterSize; - return struct.binb2bin(core_sha(struct.str2binb(s), s.length * _characterSize)); -}; - -/* Perform a simple self-test to see if the VM is working */ -exports.test = function () { - assert.eq("a9993e364706816aba3e25717850c26c9cd0d89d", exports.hash("abc").toString(16)); -}; - -/* Calculate the SHA-1 of an array of big-endian words, and a bit length */ -var core_sha = function (x, len) { - /* append padding */ - x[len >> 5] |= 0x80 << (24 - len % 32); - x[((len + 64 >> 9) << 4) + 15] = len; - - var w = []; - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - var e = -1009589776; - - for(var i = 0; i < x.length; i += 16) { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - var olde = e; - - for(var j = 0; j < 80; j++) { - if(j < 16) w[j] = x[i + j]; - else w[j] = struct.rolU32(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); - var t = struct.addU32(struct.rolU32(a, 5), sha_ft(j, b, c, d), e, w[j], sha_kt(j)); - e = d; - d = c; - c = struct.rolU32(b, 30); - b = a; - a = t; - } - - a = struct.addU32(a, olda); - b = struct.addU32(b, oldb); - c = struct.addU32(c, oldc); - d = struct.addU32(d, oldd); - e = struct.addU32(e, olde); - } - return [a, b, c, d, e]; - -}; - -/* - * Perform the appropriate triplet combination function for the current - * iteration - */ -var sha_ft = function (t, b, c, d) { - if(t < 20) return (b & c) | ((~b) & d); - if(t < 40) return b ^ c ^ d; - if(t < 60) return (b & c) | (b & d) | (c & d); - return b ^ c ^ d; -}; - -/* - * Determine the appropriate additive constant for the current iteration - */ -var sha_kt = function (t) { - return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : - (t < 60) ? -1894007588 : -899497514; -}; - -/* - * Calculate the HMAC-SHA1 of a key and some data - */ -var core_hmac_sha = function (key, data, _characterSize) { - if (util.no(_characterSize)) _characterSize = struct.characterSize; - var bkey = struct.str2binb(key); - if(bkey.length > 16) bkey = core_sha(bkey, key.length * _characterSize); - - var ipad = [], opad = []; - for(var i = 0; i < 16; i++) { - ipad[i] = bkey[i] ^ 0x36363636; - opad[i] = bkey[i] ^ 0x5C5C5C5C; - } - - var hash = core_sha(ipad.concat(struct.str2binb(data)), 512 + data.length * _characterSize); - return core_sha(opad.concat(hash), 512 + 160); -}; - -if (module.id == require.main) { - var assert = require("./test/assert"); - require("os").exit(require("test/runner").run(exports)); -} - diff --git a/utils/lib/sha256.js b/utils/lib/sha256.js deleted file mode 100755 index 4f19670..0000000 --- a/utils/lib/sha256.js +++ /dev/null @@ -1,102 +0,0 @@ -/*file chiron src/crypt/sha256.js */ - -var struct = require('./struct'); -var util = require('./util'); - -/*** hash -*/ -exports.hash = function (s, _characterSize) { - if (util.no(_characterSize)) _characterSize = struct.characterSize; - return struct.binb2bin(core(struct.str2binb(s, _characterSize), s.length * _characterSize)); -}; - -var S = function (X, n) { return ( X >>> n ) | (X << (32 - n)); } -var R = function (X, n) { return ( X >>> n ); } -var Ch = function (x, y, z) { return ((x & y) ^ ((~x) & z)); } -var Maj = function (x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); } -var Sigma0256 = function (x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); } -var Sigma1256 = function (x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); } -var Gamma0256 = function (x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); } -var Gamma1256 = function (x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); } - -var K = [ - 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, - 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, - 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, - 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, - 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, - 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, - 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, - 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, - 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, - 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, - 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, - 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, - 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, - 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, - 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, - 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 -]; - -var HASH = [ - 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, - 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 -]; - -var core = function (m, l) { - var W = []; - var a, b, c, d, e, f, g, h, i, j; - var T1, T2; - - m[l >> 5] |= 0x80 << (24 - l % 32); - m[((l + 64 >> 9) << 4) + 15] = l; - - for ( var i = 0; i> 16) + (x >> 16) + (lsw >> 16); - acc = (msw << 16) | (lsw & 0xFFFF); - } - return acc; -}; - -/* undocumented rolU32 - Bitwise rotate a 32-bit number to the left. -*/ -exports.rolU32 = function (num, cnt) { - return (num << cnt) | (num >>> (32 - cnt)); -}; - -/* undocumented str2binl - Convert a string to an array of little-endian words - If characterSize is ASCII, characters >255 have their hi-byte silently ignored. -*/ -exports.str2binl = function (str, _characterSize) { - if (util.no(_characterSize)) - _characterSize = exports.characterSize; - var bin = []; - var mask = (1 << _characterSize) - 1; - for (var i = 0; i < str.length * _characterSize; i += _characterSize) - bin[i>>5] |= (str.charCodeAt(i / _characterSize) & mask) << (i % 32); - return bin; -}; - -/* undocumented str2binb - Convert an 8-bit or 16-bit string to an array of big-endian words - In 8-bit function, characters >255 have their hi-byte silently ignored. -*/ -exports.str2binb = function (str, _characterSize) { - if (util.no(_characterSize)) - _characterSize = exports.characterSize; - var bin = []; - var mask = (1 << _characterSize) - 1; - for (var i = 0; i < str.length * _characterSize; i += _characterSize) - bin[i>>5] |= ( - (str.charCodeAt(i / _characterSize) & mask) << - (32 - _characterSize - i % 32) - ); - return bin; -}; - -/* undocumented binl2str - Convert an array of little-endian words to a string -*/ -exports.binl2str = function (bin, _characterSize) { - return exports.binl2bin(bin, _characterSize).decodeToString('ascii'); -}; - -/* undocumented binl2bin - Convert an array of little-endian words to a string -*/ -exports.binl2bin = function (bin, _characterSize) { - if (util.no(_characterSize)) - _characterSize = exports.characterSize; - var str = []; - var mask = (1 << _characterSize) - 1; - for (var i = 0; i < bin.length * 32; i += _characterSize) - str.push((bin[i>>5] >>> (i % 32)) & mask); - return binary.ByteString(str); -}; - -/* undocumented binb2str - Convert an array of big-endian words to a string -*/ -exports.binb2str = function (bin, _characterSize) { - return exports.binb2bin(bin, _characterSize).decodeToString('ascii'); -}; - -/* undocumented binb2bin - Convert an array of big-endian words to a string -*/ -exports.binb2bin = function (bin, _characterSize) { - if (util.no(_characterSize)) - _characterSize = exports.characterSize; - var str = []; - var mask = (1 << _characterSize) - 1; - for (var i = 0; i < bin.length * 32; i += _characterSize) - str.push((bin[i>>5] >>> (32 - _characterSize - i % 32)) & mask); - return binary.ByteString(str); -}; - -/* undocumented binl2hex - Convert an array of little-endian words to a hex string. -*/ -exports.binl2hex = function (binarray, _alphabet16) { - if (util.no(_alphabet16)) - _alphabet16 = exports.alphabet16; - var str = ""; - for (var i = 0; i < binarray.length * 4; i++) { - str += _alphabet16.charAt((binarray[i>>2] >> ((i % 4) * 8 + 4)) & 0xF) + - _alphabet16.charAt((binarray[i>>2] >> ((i % 4) * 8)) & 0xF); - } - return str; -}; - -/* undocumented binb2hex - Convert an array of big-endian words to a hex string. -*/ -exports.binb2hex = function (binarray, _alphabet16) { - if (util.no(_alphabet16)) - _alphabet16 = exports.alphabet16; - var str = ""; - for (var i = 0; i < binarray.length * 4; i++) { - str += _alphabet16.charAt((binarray[i>>2] >> ((3 - i % 4)*8+4)) & 0xF) + - _alphabet16.charAt((binarray[i>>2] >> ((3 - i % 4) * 8)) & 0xF); - } - return str; -}; - -/* undocumented binl2base64 - Convert an array of little-endian words to a base-64 string -*/ -exports.binl2base64 = function (binarray) { - var str = ""; - for (var i = 0; i < binarray.length * 4; i += 3) { - var triplet = ( - (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) | - (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8) | - ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF) - ); - for (var j = 0; j < 4; j++) { - if (i * 8 + j * 6 > binarray.length * 32) - str += exports.padBase64; - else str += exports.alphabet64.charAt((triplet >> 6*(3-j)) & 0x3F); - } - } - return str; -}; - -/* undocumented binb2base64 - Convert an array of big-endian words to a base-64 string -*/ -exports.binb2base64 = function (binarray) { - var str = ""; - for (var i = 0; i < binarray.length * 4; i += 3) { - var triplet = ( - (((binarray[i >> 2] >> 8 * (3 - i % 4)) & 0xFF) << 16) | - (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 ) | - ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF) - ); - for (var j = 0; j < 4; j++) { - if (i * 8 + j * 6 > binarray.length * 32) - str += exports.padBase64; - else str += exports.alphabet64.charAt((triplet >> 6*(3-j)) & 0x3F); - } - } - return str; -}; - diff --git a/utils/lib/term.js b/utils/lib/term.js deleted file mode 100755 index 6e60ebe..0000000 --- a/utils/lib/term.js +++ /dev/null @@ -1,166 +0,0 @@ - -var util = require('util'); - -var terms = [ - 'ansi', - 'vt100', - 'xtermc', - 'xterm-color', - 'gnome-terminal' -]; - -exports.Stream = function (system) { - var self = Object.create(system.stdout); - var output = system.stdout; - var errput = system.stderr; - var env = system.env || {}; - var fore = ""; - var back = ""; - var bold = "0"; - var stack = []; - var enabled = util.has(terms, env.TERM); - - self.writeCode = function (code) { - if (enabled) { - output.flush(); - errput.write(code).flush(); - } - return self; - }; - - self.print = function () { - // todo recordSeparator, fieldSeparator - self.write(Array.prototype.join.call(arguments, " ") + "\n"); - self.flush(); - return self; - }; - - self.write = function (string) { - var at = 0; - self.update(bold, fore, back); - while (at < string.length) { - var pos = string.indexOf("\0", at); - if (pos == -1) { - // no additional marks, advanced to end - output.write(string.substring(at, string.length)); - at = string.length; - } else { - output.write(string.substring(at, pos)); - at = pos + 1; - if (string.charAt(at) == ")") { - if (!stack.length) - throw new Error("No colors on the stack at " + at); - var pair = stack.pop(); - bold = pair[0]; - fore = pair[1]; - at = at + 1; - self.update(bold, fore, back); - } else { - var paren = string.indexOf("(", at); - stack.push([bold, fore, back]); - var command = string.substring(at, paren); - if (command == "bold") { - bold = "1"; - } else if (Object.prototype.hasOwnProperty.call(exports.colors, command)) { - fore = exports.colors[command]; - } else if ( - /^:/.test(command) && - Object.prototype.hasOwnProperty.call(exports.colors, command.substring(1)) - ) { - back = exports.colors[command.substring(1)]; - } else { - throw new Error("No such command: " + command); - } - self.update(bold, fore, back); - at = paren + 1; - } - } - } - self.update("0", "", ""); - }; - - self.update = function (bold, fore, back) { - return self.writeCode( - "\033[" + [ - bold, - (fore.length ? "3" + fore : ""), - (back.length ? "4" + back : ""), - ].filter(function (string) { - return string.length; - }).join(";") + "m" - ); - }; - - self.moveTo = function (y, x) { - return self.writeCode("\033[" + y + ";" + x + "H"); - }; - - self.moveBy = function (y, x) { - if (y == 0) { - } else if (y < 0) { - self.writeCode("\033[" + (-y) + "A"); - } else { - self.writeCode("\033[" + y + "B"); - } - if (x == 0) { - } else if (x > 0) { - self.writeCode("\033[" + x + "C"); - } else { - self.writeCode("\033[" + (-x) + "D"); - } - errput.flush(); - return self; - }; - - self.home = function () { - return self.writeCode("\033[H"); - }; - - self.clear = function () { - return self.writeCode("\033[2J"); - }; - self.clearUp = function () { - return self.writeCode("\033[1J"); - }; - self.cearDown = function () { - return self.writeCode("\033[J"); - }; - self.clearLine = function () { - return self.writeCode("\033[2K"); - }; - self.clearLeft = function () { - return self.writeCode("\033[1K"); - }; - self.clearRight = function () { - return self.writeCode("\033[K"); - }; - - self.update(bold, fore, back); - - return self; -}; - -exports.colors = { - "black": "0", - "red": "1", - "green": "2", - "orange": "3", - "yellow": "3", - "blue": "4", - "violet": "5", - "magenta": "5", - "purple": "5", - "cyan": "6", - "white": "7" -} - -exports.stream = new exports.Stream(system); - -if (module.id == require.main) { - exports.stream.print("white\0red(red\0blue(blue\0)red\0)white"); - Object.keys(exports.colors).forEach(function (name) { - exports.stream.print("\0" + name + "(" + name + "\0)"); - exports.stream.print("\0bold(\0" + name + "(" + name + "\0)\0)"); - }); -} - diff --git a/utils/lib/test/assert.js b/utils/lib/test/assert.js deleted file mode 100755 index dde0d2d..0000000 --- a/utils/lib/test/assert.js +++ /dev/null @@ -1,91 +0,0 @@ -var equiv = require("./equiv").equiv, - jsDump = require("./jsdump").jsDump, - util = require("../util"); - -var assert = exports; - -function fail(message) { - throw new AssertionError(message); -} - -assert.isTrue = function(assertion, message) { - if (assertion !== true) - fail((message || "") + "\nExpected true." + - "\nActual = " + assertion); -} - -assert.isFalse = function(assertion, message) { - if (assertion !== false) - fail((message || "") + "\nExpected false." + - "\nActual = " + assertion); -} - -assert.isNull = function(assertion, message) { - if (assertion !== null) - fail((message || "") + "\nExpected null." + - "\nActual = " + assertion); -} - -assert.isNaN = function(assertion, message) { - if (!isNaN(assertion)) - fail((message || "") + "\nExpected NaN." + - "\nActual = " + assertion); -} - -assert.isEqual = function(expected, actual, message) { - if (expected !== actual) - fail((message || "") + "\nExpected equal to = " + jsDump.parse(expected) + - "\nActual = " + jsDump.parse(actual)); -} - -assert.is = function (expected, actual, message) { - if (!util.is(expected, actual)) - fail((message || "") + "\nExpected identical = " + jsDump.parse(expected) + - "\nActual = " + jsDump.parse(actual)); -}; - -assert.isSame = function(expected, actual, message) { - if (!equiv(expected, actual)) - fail((message || "") + "\nExpected same as = " + jsDump.parse(expected) + - "\nActual = " + jsDump.parse(actual)); -} - -assert.eq = function (expected, actual, message) { - if (!util.eq(expected, actual)) - fail((message || "") + "\nExpected equal = " + jsDump.parse(expected) + - "\nActual = " + jsDump.parse(actual)); -}; - - -assert.isDiff = function(expected, actual, message) { - if (equiv(expected, actual)) - fail((message || "") + "\nExpected different than = " + jsDump.parse(expected) + - "\nActual = " + jsDump.parse(actual)); -} - -assert.throwsError = function(block, type, message) { - var threw = false, - exception = null; - - try { - block(); - } catch (e) { - threw = true; - exception = e; - } - - if (!threw) - fail("Expected exception" + (message ? ": " + message : "")); - - if (type !== undefined && !(exception instanceof type)) - fail("Expected exception type '"+type+ - "', actually '"+exception+"'" + (message ? ": " + message : "")); -} - - -var AssertionError = exports.AssertionError = function(message) { - this.name = "AssertionError"; - this.message = message; -} - -AssertionError.prototype = new Error(); diff --git a/utils/lib/test/equiv.js b/utils/lib/test/equiv.js deleted file mode 100755 index 9628119..0000000 --- a/utils/lib/test/equiv.js +++ /dev/null @@ -1,188 +0,0 @@ -// Hoozit -// Determine what is o. -function hoozit(o) { - if (typeof o === "string") { - return "string"; - - } else if (typeof o === "boolean") { - return "boolean"; - - } else if (typeof o === "number") { - - if (isNaN(o)) { - return "nan"; - } else { - return "number"; - } - - } else if (typeof o === "undefined") { - return "undefined"; - - // consider: typeof null === object - } else if (o === null) { - return "null"; - - // consider: typeof [] === object - } else if (o instanceof Array) { - return "array"; - - // consider: typeof new Date() === object - } else if (o instanceof Date) { - return "date"; - - // consider: /./ instanceof Object; - // /./ instanceof RegExp; - // typeof /./ === "function"; // => false in IE and Opera, - // true in FF and Safari - } else if (o instanceof RegExp) { - return "regexp"; - - } else if (typeof o === "object") { - return "object"; - - } else if (o instanceof Function) { - return "function"; - } -} - -// Call the o related callback with the given arguments. -function bindCallbacks(o, callbacks, args) { - var prop = hoozit(o); - if (prop) { - if (hoozit(callbacks[prop]) === "function") { - return callbacks[prop].apply(callbacks, args); - } else { - return callbacks[prop]; // or undefined - } - } -} - -// Equiv -// Test for equality any JavaScript type. -// Discussions and reference: http://philrathe.com/articles/equiv -// Test suites: http://philrathe.com/tests/equiv -// Author: Philippe Rathé -var equiv = exports.equiv = function () { - - var innerEquiv; // the real equiv function - var callers = []; // stack to decide between skip/abort functions - - - var callbacks = function () { - - // for string, boolean, number and null - function useStrictEquality(b, a) { - return a === b; - } - - return { - "string": useStrictEquality, - "boolean": useStrictEquality, - "number": useStrictEquality, - "null": useStrictEquality, - "undefined": useStrictEquality, - - "nan": function (b) { - return isNaN(b); - }, - - "date": function (b, a) { - return hoozit(b) === "date" && a.valueOf() === b.valueOf(); - }, - - "regexp": function (b, a) { - return hoozit(b) === "regexp" && - a.source === b.source && // the regex itself - a.global === b.global && // and its modifers (gmi) ... - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline; - }, - - // - skip when the property is a method of an instance (OOP) - // - abort otherwise, - // initial === would have catch identical references anyway - "function": function () { - var caller = callers[callers.length - 1]; - return caller !== Object && - typeof caller !== "undefined"; - }, - - "array": function (b, a) { - var i; - var len; - - // b could be an object literal here - if ( ! (hoozit(b) === "array")) { - return false; - } - - len = a.length; - if (len !== b.length) { // safe and faster - return false; - } - for (i = 0; i < len; i++) { - if( ! innerEquiv(a[i], b[i])) { - return false; - } - } - return true; - }, - - "object": function (b, a) { - var i; - var eq = true; // unless we can proove it - var aProperties = [], bProperties = []; // collection of strings - - // comparing constructors is more strict than using instanceof - if ( a.constructor !== b.constructor) { - return false; - } - - // stack constructor before traversing properties - callers.push(a.constructor); - - for (i in a) { // be strict: don't ensures hasOwnProperty and go deep - - aProperties.push(i); // collect a's properties - - if ( ! innerEquiv(a[i], b[i])) { - eq = false; - } - } - - callers.pop(); // unstack, we are done - - for (i in b) { - bProperties.push(i); // collect b's properties - } - - // Ensures identical properties name - return eq && innerEquiv(aProperties.sort(), bProperties.sort()); - } - }; - }(); - - innerEquiv = function () { // can take multiple arguments - var args = Array.prototype.slice.apply(arguments); - if (args.length < 2) { - return true; // end transition - } - - return (function (a, b) { - if (a === b) { - return true; // catch the most you can - - } else if (typeof a !== typeof b || a === null || b === null || typeof a === "undefined" || typeof b === "undefined") { - return false; // don't lose time with error prone cases - - } else { - return bindCallbacks(a, callbacks, [b, a]); - } - - // apply transition with (1..n) arguments - })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1)); - }; - - return innerEquiv; - -}(); \ No newline at end of file diff --git a/utils/lib/test/jsdump.js b/utils/lib/test/jsdump.js deleted file mode 100755 index c0d4aed..0000000 --- a/utils/lib/test/jsdump.js +++ /dev/null @@ -1,165 +0,0 @@ -/** - * jsDump - * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) - * Date: 5/15/2008 - * @projectDescription Advanced and extensible data dumping for Javascript. - * @version 1.0.0 - * @author Ariel Flesler - */ -var jsDump; - -(function(){ - function quote( str ){ - return '"' + str.toString().replace(/"/g, '\\"') + '"'; - }; - function literal( o ){ - return o + ''; - }; - function join( pre, arr, post ){ - var s = jsDump.separator(), - base = jsDump.indent(), - inner = jsDump.indent(1); - if( arr.join ) - arr = arr.join( ',' + s + inner ); - if( !arr ) - return pre + post; - return [ pre, inner + arr, base + post ].join(s); - }; - function array( arr ){ - var i = arr.length, ret = Array(i); - this.up(); - while( i-- ) - ret[i] = this.parse( arr[i] ); - this.down(); - return join( '[', ret, ']' ); - }; - - var reName = /^function (\w+)/; - - jsDump = { - parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance - var parser = this.parsers[ type || this.typeOf(obj) ]; - type = typeof parser; - - return type == 'function' ? parser.call( this, obj ) : - type == 'string' ? parser : - this.parsers.error; - }, - typeOf:function( obj ){ - var type = typeof obj, - f = 'function';//we'll use it 3 times, save it - return type != 'object' && type != f ? type : - !obj ? 'null' : - obj.exec ? 'regexp' :// some browsers (FF) consider regexps functions - obj.getHours ? 'date' : - obj.scrollBy ? 'window' : - obj.nodeName == '#document' ? 'document' : - obj.nodeName ? 'node' : - obj.item ? 'nodelist' : // Safari reports nodelists as functions - obj.callee ? 'arguments' : - obj.call || obj.constructor != Array && //an array would also fall on this hack - (obj+'').indexOf(f) != -1 ? f : //IE reports functions like alert, as objects - 'length' in obj ? 'array' : - type; - }, - separator:function(){ - return this.multiline ? this.HTML ? '
' : '\n' : this.HTML ? ' ' : ' '; - }, - indent:function( extra ){// extra can be a number, shortcut for increasing-calling-decreasing - if( !this.multiline ) - return ''; - var chr = this.indentChar; - if( this.HTML ) - chr = chr.replace(/\t/g,' ').replace(/ /g,' '); - return Array( this._depth_ + (extra||0) ).join(chr); - }, - up:function( a ){ - this._depth_ += a || 1; - }, - down:function( a ){ - this._depth_ -= a || 1; - }, - setParser:function( name, parser ){ - this.parsers[name] = parser; - }, - // The next 3 are exposed so you can use them - quote:quote, - literal:literal, - join:join, - // - _depth_: 1, - // This is the list of parsers, to modify them, use jsDump.setParser - parsers:{ - window: '[Window]', - document: '[Document]', - error:'[ERROR]', //when no parser is found, shouldn't happen - unknown: '[Unknown]', - 'null':'null', - undefined:'undefined', - 'function':function( fn ){ - var ret = 'function', - name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE - if( name ) - ret += ' ' + name; - ret += '('; - - ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join(''); - return join( ret, this.parse(fn,'functionCode'), '}' ); - }, - array: array, - nodelist: array, - arguments: array, - object:function( map ){ - var ret = [ ]; - this.up(); - for( var key in map ) - ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) ); - this.down(); - return join( '{', ret, '}' ); - }, - node:function( node ){ - var open = this.HTML ? '<' : '<', - close = this.HTML ? '>' : '>'; - - var tag = node.nodeName.toLowerCase(), - ret = open + tag; - - for( var a in this.DOMAttrs ){ - var val = node[this.DOMAttrs[a]]; - if( val ) - ret += ' ' + a + '=' + this.parse( val, 'attribute' ); - } - return ret + close + open + '/' + tag + close; - }, - functionArgs:function( fn ){//function calls it internally, it's the arguments part of the function - var l = fn.length; - if( !l ) return ''; - - var args = Array(l); - while( l-- ) - args[l] = String.fromCharCode(97+l);//97 is 'a' - return ' ' + args.join(', ') + ' '; - }, - key:quote, //object calls it internally, the key part of an item in a map - functionCode:'[code]', //function calls it internally, it's the content of the function - attribute:quote, //onode calls it internally, it's an html attribute value - string:quote, - date:quote, - regexp:literal, //regex - number:literal, - 'boolean':literal - }, - DOMAttrs:{//attributes to dump from nodes, name=>realName - id:'id', - name:'name', - 'class':'className' - }, - HTML:false,//if true, entities are escaped ( <, >, \t, space and \n ) - indentChar:' ',//indentation unit - multiline:true //if true, items in a collection, are separated by a \n, else just a space. - }; - -})(); - -exports.jsDump = jsDump; diff --git a/utils/lib/test/runner.js b/utils/lib/test/runner.js deleted file mode 100755 index 1bdb43c..0000000 --- a/utils/lib/test/runner.js +++ /dev/null @@ -1,80 +0,0 @@ -var util = require('util'); -var assert = require("./assert"); - -exports.run = function(objectOrModule, context) { - - if (typeof objectOrModule === "string") - objectOrModule = require(objectOrModule); - - if (!objectOrModule) - throw "Nothing to run"; - - var localContext = context || { passed : 0, failed : 0, error : 0, depth : 0 }; - localContext.depth++; - - for (var spaces=""; spaces.length < localContext.depth * 2; spaces += " "); - - for (var property in objectOrModule) { - if (property.match(/^test/)) { - print(spaces + "+ Running "+property); - if (typeof objectOrModule[property] == "function") { - if (typeof objectOrModule.setup === "function") - objectOrModule.setup(); - - var globals = {}; - for (var name in system.global) { - globals[name] = true; - } - - try { - try { - objectOrModule[property](); - } finally { - if (!objectOrModule.isMonkey) { - for (var name in system.global) { - if (!globals[name]) { - delete system.global[name]; - throw new assert.AssertionError("New global introduced: " + util.enquote(name)); - } - } - } - } - - localContext.passed++; - } catch (e) { - if (e.name === "AssertionError") { - print("Assertion Failed in "+property+": " + e); - - if (e.rhinoException) - e.rhinoException.printStackTrace(); - else if (e.javaException) - e. javaException.printStackTrace(); - - localContext.failed++; - } else { - print("Exception in "+property+": " + e); - - if (e.rhinoException) - e.rhinoException.printStackTrace(); - else if (e.javaException) - e. javaException.printStackTrace(); - - localContext.error++; - } - } finally { - if (typeof objectOrModule.teardown === "function") - objectOrModule.teardown(); - } - } else { - exports.run(objectOrModule[property], localContext); - } - } - } - - localContext.depth--; - - if (context === undefined) - print("Passed "+localContext.passed+"; Failed "+localContext.failed+"; Error "+localContext.error+";"); - - return localContext.failed + localContext.error; -}; diff --git a/utils/lib/tusk.js b/utils/lib/tusk.js deleted file mode 100755 index b14428d..0000000 --- a/utils/lib/tusk.js +++ /dev/null @@ -1,202 +0,0 @@ - -var fs = require("file"); -var packages = require("packages"); -var util = require("util"); -var json = require("json"); -var http = require("http"); - -exports.getDirectory = function () { - return fs.path(system.packagePrefixes[0]); -}; - -exports.getPackagesDirectory = function () { - return exports.getDirectory().join('packages'); -}; - -exports.getTuskDirectory = function () { - var tuskDirectory = exports.getDirectory().join('.tusk'); - tuskDirectory.mkdirs(); - return tuskDirectory; -} - -exports.getZipsDirectory = function () { - return exports.getDirectory().join('zips'); -}; - -exports.getCatalogPath = function () { - return exports.getTuskDirectory().join('catalog.json'); -}; - -exports.readCatalog = function () { - return json.decode(exports.getCatalogPath().read( - {charset: 'utf-8'} - )); -}; - -exports.writeCatalog = function (catalog) { - var catalogPath = exports.getCatalogPath(); - print('Writing ' + catalogPath); - return catalogPath.write( - json.encode(catalog, null, 4), - {charset: 'utf-8'} - ); -}; - -exports.getSourcesPath = function () { - return exports.getDirectory().join('sources.json'); -}; - -exports.readSources = function () { - return json.decode(exports.getSourcesPath().read( - {charset: 'utf-8'} - )); -}; - -exports.writeSources = function (sources) { - return exports.getSourcesPath().write( - json.encode(sources, null, 4), - {charset: 'utf-8'} - ); -}; - -exports.getNotesPath = function () { - return exports.getTuskDirectory().join('notes.json'); -}; - -exports.readNotes = function () { - var notesPath = exports.getNotesPath(); - if (!notesPath.isFile()) - return {}; - return json.decode(notesPath.read( - {charset: 'utf-8'} - )); -}; - -exports.writeNotes = function (notes) { - return exports.getNotesPath().write( - json.encode(notes, null, 4), - {charset: 'utf-8'} - ); -}; - -// commands -// - -exports.update = function (options) { - print('Downloading catalog.'); - var catalogData = http.read('http://github.com/tlrobinson/narwhal/raw/master/catalog.json'); - print('Saving catalog.'); - exports.getCatalogPath().write(catalogData, 'b'); -}; - -exports.createCatalog = function (options) { - var sources = exports.readSources(); - var catalog = {}; - catalog.version = util.copy(sources.version); - var packages = catalog.packages = {}; - util.forEachApply( - util.items(sources.packages || {}), - function (name, source) { - var info; - print(name); - if (source.type == "inline") { - info = util.copy(source['package.json']); - } else if (source.type == "github") { - var githubName = source.name || name; - if (!source.user) - throw new Error("package source " + util.enquote(name) + " did not have a github user name"); - var project = source.user + '/' + githubName; - var url = "http://github.com/" + project + "/raw/master/package.json"; - var text = http.read(url).toString('utf-8'); - info = json.decode(text); - info.type = "zip"; - info.location = 'http://github.com/' + source.user + '/' + githubName + '/zipball/master'; - } else { - throw new Error( - "Project " + exports.enquote(name) + - " has an urecognized type: " + - exports.enquote(source.type) - ); - } - packages[name] = info; - } - ); - exports.writeCatalog(catalog); -}; - -exports.list = function (options) { - var self = this; - Object.keys(packages.catalog).forEach(function (name) { - self.print( - name + ' \0magenta(' + - packages.catalog[name].directory + '\0)' - ); - }); -}; - -exports.catalog = function (options) { - Object.keys(exports.readCatalog().packages).forEach(print); -}; - - -var args = require("args"); -var parser = exports.parser = new args.Parser(); - -parser.help('A Narwhal project package manager.'); - -// parser.option('sources', exports.sources); - -parser.command('list', exports.list) - .help('lists all installed packages'); - -parser.command('install', module.id + '/install'); - -parser.command('upgrade', exports.upgrade) - .help('downloads the latest version of a package'); - -parser.command('remove', exports.remove) - .help('removes the local copy of package'); - -parser.command('update', exports.update) - .help('downloads the newest package catalog'); - -parser.command('search', exports.search) - .help('searches the package catalog'); - -parser.command('init', module.id + '/init'); - -parser.command('platform', module.id + '/platform'); - -parser.command('freeze', exports.freeze) - .help('writes a freeze.json file'); - -parser.command('reheat', exports.reheat) - .help('reconsistutes the exact versions of all dependencies from a frozen site.'); - -parser.command('clone', module.id + '/clone'); - -parser.command('catalog', exports.catalog) - .help('lists all packages in the catalog'); - -parser.command('create-catalog', exports.createCatalog) - .help('creates a catalog of packages from sources.json'); - -parser.command('update-sources') - .help('downloads the newest list of package sources') - -parser.command('orphans') - .help('lists packages that are no longer wanted by the user or other packages.') - -parser.command('consolidate', module.id + '/consolidate'); - -parser.helpful(); - -exports.main = function (args) { - var options = parser.parse(args); - if (!options.acted) - parser.printHelp(options); -}; - -if (module.id == require.main) - return exports.main(system.args); - diff --git a/utils/lib/unload.js b/utils/lib/unload.js deleted file mode 100755 index fde1948..0000000 --- a/utils/lib/unload.js +++ /dev/null @@ -1,13 +0,0 @@ - -var observers = []; - -exports.when = function (observer) { - observers.unshift(observer); -}; - -exports.send = function () { - observers.forEach(function (observer) { - observer(); - }); -}; - diff --git a/utils/lib/uri.js b/utils/lib/uri.js deleted file mode 100755 index 24a76d0..0000000 --- a/utils/lib/uri.js +++ /dev/null @@ -1,55 +0,0 @@ -// original code: http://code.google.com/p/js-uri/ - -// Based on the regex in RFC2396 Appendix B. -var URI_RE = /^(?:([^:\/?\#]+):)?(?:\/\/([^\/?\#]*))?([^?\#]*)(?:\?([^\#]*))?(?:\#(.*))?/; - -/** - * Uniform Resource Identifier (URI) - RFC3986 - */ -var URI = exports.URI = function(str) { - if (!str) str = ""; - var result = str.match(URI_RE); - this.scheme = result[1] || null; - this.authority = result[2] || null; - this.path = result[3] || null; - this.query = result[4] || null; - this.fragment = result[5] || null; -} - -/** - * Convert the URI to a String. - */ -URI.prototype.toString = function () { - var str = ""; - - if (this.scheme) - str += this.scheme + ":"; - - if (this.authority) - str += "//" + this.authority; - - if (this.path) - str += this.path; - - if (this.query) - str += "?" + this.query; - - if (this.fragment) - str += "#" + this.fragment; - - return str; -} - -URI.parse = function(uri) { - return new URI(uri); -} - -URI.unescape = function(str, plus) { - return decodeURI(str).replace(/\+/g, " "); -} - -URI.unescapeComponent = function(str, plus) { - return decodeURIComponent(str).replace(/\+/g, " "); -} - - diff --git a/utils/lib/url.js b/utils/lib/url.js deleted file mode 100755 index 897ebc1..0000000 --- a/utils/lib/url.js +++ /dev/null @@ -1,323 +0,0 @@ - -/**** keys - members of a parsed URI object. -*/ -exports.keys = [ - "url", - "protocol", - "authorityRoot", - "authority", - "userInfo", - "user", - "password", - "domain", - "domains", - "port", - "path", - "root", - "directory", - "directories", - "file", - "query", - "anchor" -]; - -/**** expressionKeys - members of a parsed URI object that you get - from evaluting the strict regular expression. -*/ -exports.expressionKeys = [ - "url", - "protocol", - "authorityRoot", - "authority", - "userInfo", - "user", - "password", - "domain", - "port", - "path", - "root", - "directory", - "file", - "query", - "anchor" -]; - -/**** strictExpression -*/ -exports.strictExpression = new RegExp( /* url */ - "^" + - "(?:" + - "([^:/?#]+):" + /* protocol */ - ")?" + - "(?:" + - "(//)" + /* authorityRoot */ - "(" + /* authority */ - "(?:" + - "(" + /* userInfo */ - "([^:@]*)" + /* user */ - ":?" + - "([^:@]*)" + /* password */ - ")?" + - "@" + - ")?" + - "([^:/?#]*)" + /* domain */ - "(?::(\\d*))?" + /* port */ - ")" + - ")?" + - "(" + /* path */ - "(/?)" + /* root */ - "((?:[^?#/]*/)*)" + - "([^?#]*)" + /* file */ - ")" + - "(?:\\?([^#]*))?" + /* query */ - "(?:#(.*))?" /*anchor */ -); - -/**** Parser - returns a URI parser function given - a regular expression that renders - `expressionKeys` and returns an `Object` - mapping all `keys` to values. -*/ -exports.Parser = function (expression) { - return function (url) { - if (typeof url == "undefined") - throw new Error("HttpError: URL is undefined"); - if (typeof url != "string") return new Object(url); - - var items = {}; - var parts = expression.exec(url); - - for (var i = 0; i < parts.length; i++) { - items[exports.expressionKeys[i]] = parts[i] ? parts[i] : ""; - } - - items.root = (items.root || items.authorityRoot) ? '/' : ''; - - items.directories = items.directory.split("/"); - if (items.directories[items.directories.length - 1] == "") { - items.directories.pop(); - } - - /* normalize */ - var directories = []; - for (var i = 0; i < items.directories.length; i++) { - var directory = items.directories[i]; - if (directory == '.') { - } else if (directory == '..') { - if (directories.length && directories[directories.length - 1] != '..') - directories.pop(); - else - directories.push('..'); - } else { - directories.push(directory); - } - } - items.directories = directories; - - items.domains = items.domain.split("."); - - return items; - }; -}; - -/**** parse - a strict URI parser. -*/ -exports.parse = exports.Parser(exports.strictExpression); - -/**** format - accepts a parsed URI object and returns - the corresponding string. -*/ -exports.format = function (object) { - if (typeof(object) == 'undefined') - throw new Error("UrlError: URL undefined for urls#format"); - if (object instanceof String || typeof(object) == 'string') - return object; - var domain = - object.domains ? - object.domains.join(".") : - object.domain; - var userInfo = ( - object.user || - object.password - ) ? - ( - (object.user || "") + - (object.password ? ":" + object.password : "") - ) : - object.userInfo; - var authority = ( - userInfo || - domain || - object.port - ) ? ( - (userInfo ? userInfo + "@" : "") + - (domain || "") + - (object.port ? ":" + object.port : "") - ) : - object.authority; - var directory = - object.directories ? - object.directories.join("/") : - object.directory; - var path = - directory || object.file ? - ( - (directory ? directory + "/" : "") + - (object.file || "") - ) : - object.path; - return ( - (object.protocol ? object.protocol + ":" : "") + - (authority ? "//" + authority : "") + - (object.root || (authority && path) ? "/" : "") + - (path ? path : "") + - (object.query ? "?" + object.query : "") + - (object.anchor ? "#" + object.anchor : "") - ) || object.url || ""; -}; - -/**** resolveObject - returns an object representing a URL resolved from - a relative location and a source location. -*/ -exports.resolveObject = function (source, relative) { - if (!source) - return relative; - - source = exports.parse(source); - relative = exports.parse(relative); - - if (relative.url == "") - return source; - - delete source.url; - delete source.authority; - delete source.domain; - delete source.userInfo; - delete source.path; - delete source.directory; - - if ( - relative.protocol && relative.protocol != source.protocol || - relative.authority && relative.authority != source.authority - ) { - source = relative; - } else { - if (relative.root) { - source.directories = relative.directories; - } else { - - var directories = relative.directories; - for (var i = 0; i < directories.length; i++) { - var directory = directories[i]; - if (directory == ".") { - } else if (directory == "..") { - if (source.directories.length) { - source.directories.pop(); - } else { - source.directories.push('..'); - } - } else { - source.directories.push(directory); - } - } - - if (relative.file == ".") { - relative.file = ""; - } else if (relative.file == "..") { - source.directories.pop(); - relative.file = ""; - } - } - } - - if (relative.root) - source.root = relative.root; - if (relative.protcol) - source.protocol = relative.protocol; - if (!(!relative.path && relative.anchor)) - source.file = relative.file; - source.query = relative.query; - source.anchor = relative.anchor; - - return source; -}; - -/**** relativeObject - returns an object representing a relative URL to - a given target URL from a source URL. -*/ -exports.relativeObject = function (source, target) { - target = exports.parse(target); - source = exports.parse(source); - - delete target.url; - - if ( - target.protocol == source.protocol && - target.authority == source.authority - ) { - delete target.protocol; - delete target.authority; - delete target.userInfo; - delete target.user; - delete target.password; - delete target.domain; - delete target.domains; - delete target.port; - if ( - !!target.root == !!source.root && !( - target.root && - target.directories[0] != source.directories[0] - ) - ) { - delete target.path; - delete target.root; - delete target.directory; - while ( - source.directories.length && - target.directories.length && - target.directories[0] == source.directories[0] - ) { - target.directories.shift(); - source.directories.shift(); - } - while (source.directories.length) { - source.directories.shift(); - target.directories.unshift('..'); - } - - if (!target.root && !target.directories.length && !target.file && source.file) - target.directories.push('.'); - - if (source.file == target.file) - delete target.file; - if (source.query == target.query) - delete target.query; - if (source.anchor == target.anchor) - delete target.anchor; - } - } - - return target; -}; - -/**** resolve - returns a URL resovled to a relative URL from a source URL. -*/ -exports.resolve = function (source, relative) { - return exports.format(exports.resolveObject(source, relative)); -}; - -/**** relative - returns a relative URL to a target from a source. -*/ -exports.relative = function (source, target) { - return exports.format(exports.relativeObject(source, target)); -}; - diff --git a/utils/lib/utf8.js b/utils/lib/utf8.js deleted file mode 100755 index e1c742d..0000000 --- a/utils/lib/utf8.js +++ /dev/null @@ -1,64 +0,0 @@ - -var binary = require('./binary'); - -/*** encode - converts a Unicode character string into a UTF-8 - character stream. -*/ -exports.encode = function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = []; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext.push(c); - } - else if((c > 127) && (c < 2048)) { - utftext.push((c >> 6) | 192); - utftext.push((c & 63) | 128); - } - else { - utftext.push((c >> 12) | 224); - utftext.push(((c >> 6) & 63) | 128); - utftext.push((c & 63) | 128); - } - - } - - return binary.ByteString(utftext); -}; - -/*** decode - Converts a UTF-8 character string into a - Unicode character string. -*/ -exports.decode = function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while (i < utftext.length) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } else if ((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - } - - return string; -}; - diff --git a/utils/lib/util.js b/utils/lib/util.js deleted file mode 100755 index 510e322..0000000 --- a/utils/lib/util.js +++ /dev/null @@ -1,864 +0,0 @@ - -// a decorator for functions that curry "polymorphically", -// that is, that return a function that can be tested -// against various objects if they're only "partially -// completed", or fewer arguments than needed are used. -// -// this enables the idioms: -// [1, 2, 3].every(lt(4)) eq true -// [1, 2, 3].map(add(1)) eq [2, 3, 4] -// [{}, {}, {}].forEach(set('a', 10)) -// -exports.operator = function (name, length, block) { - var operator = function () { - var args = exports.array(arguments); - var completion = function (object) { - if ( - typeof object == "object" && - object !== null && // seriously? typeof null == "object" - name in object && // would throw if object === null - // not interested in literal objects: - !Object.prototype.hasOwnProperty.call(object, name) - ) - return object[name].apply(object, args); - return block.apply( - this, - [object].concat(args) - ); - }; - if (arguments.length < length) { - // polymoprhic curry, delayed completion - return completion; - } else { - // immediate completion - return completion.call(this, args.shift()); - } - }; - operator.name = name; - operator.displayName = name; - operator.length = length; - operator.operator = block; - return operator; -}; - -exports.no = function (value) { - return value === null || value === undefined; -}; - -// object - -exports.object = exports.operator('object', 1, function (object) { - var items = object; - if (!items.length) - items = exports.items(object); - var copy = {}; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = item[0]; - var value = item[1]; - copy[key] = value; - } - return copy; -}); - -exports.object.copy = function (object) { - var copy = {}; - exports.object.keys(object).forEach(function (key) { - copy[key] = object[key]; - }); - return copy; -}; - -exports.object.deepCopy = function (object) { - var copy = {}; - exports.object.keys(object).forEach(function (key) { - copy[key] = exports.deepCopy(object[key]); - }); - return copy; -}; - -exports.object.eq = function (a, b, stack) { - return ( - !exports.no(a) && !exports.no(b) && - exports.array.eq( - exports.sort(exports.object.keys(a)), - exports.sort(exports.object.keys(b)) - ) && - exports.object.keys(a).every(function (key) { - return exports.eq(a[key], b[key], stack); - }) - ); -}; - -exports.object.len = function (object) { - return exports.object.keys(object).length; -}; - -exports.object.has = function (object, key) { - return Object.prototype.hasOwnProperty.call(object, key); -}; - -exports.object.keys = function (object) { - var keys = []; - for (var key in object) { - if (exports.object.has(object, key)) - keys.push(key); - } - return keys; -}; - -exports.object.values = function (object) { - var values = []; - exports.object.keys(object).forEach(function (key) { - values.push(object[key]); - }); - return values; -}; - -exports.object.items = function (object) { - var items = []; - exports.object.keys(object).forEach(function (key) { - items.push([key, object[key]]); - }); - return items; -}; - -exports.object.update = function (target, source) { - for (var key in source) { - if (exports.object.has(source, key)) { - target[key] = source[key]; - } - } -}; - -exports.object.complete = function (target, source) { - for (var key in source) { - if ( - exports.object.has(source, key) && - !exports.object.has(target, key) - ) { - target[key] = source[key]; - } - } -}; - -exports.object.repr = function (object) { - return "{" + - exports.object.keys(object) - .map(function (key) { - return exports.enquote(key) + ": " + - exports.repr(object[key]); - }).join(", ") + - "}"; -}; - -// array - -exports.array = function (array) { - if (!exports.isArrayLike(array)) - return exports.items(array); - return Array.prototype.slice.call(array); -}; - -exports.isArrayLike = function(object) { - return object && - typeof object === "object" && - ( - object.constructor === Array || - typeof object.callee !== "undefined" - ); -}; - -exports.array.copy = exports.array; - -exports.array.deepCopy = function (array) { - return array.map(exports.deepCopy); -}; - -exports.array.len = function (array) { - return array.length; -}; - -exports.array.has = function (array, value) { - return Array.prototype.indexOf.call(array, value) >= 0; -}; - -exports.array.put = function (array, key, value) { - array.splice(key, 0, value); - return array; -}; - -exports.array.del = function (array, begin, end) { - array.splice(begin, end === undefined ? 1 : (end - begin)); - return array; -}; - -exports.array.eq = function (a, b, stack) { - return exports.isArrayLike(b) && - a.length == b.length && - exports.zip(a, b).every(exports.apply(function (a, b) { - return exports.eq(a, b, stack); - })); -}; - -exports.array.lt = function (a, b) { - var length = Math.max(a.length, b.length); - for (var i = 0; i < length; i++) - if (!exports.eq(a[i], b[i])) - return exports.lt(a[i], b[i]); - return false; -}; - -exports.array.repr = function (array) { - return "[" + exports.map(array, exports.repr).join(', ') + "]"; -}; - -exports.apply = exports.operator('apply', 2, function (args, block) { - return block.apply(this, args); -}); - -exports.copy = exports.operator('copy', 1, function (object) { - if (exports.no(object)) - return object; - if (exports.isArrayLike(object)) - return exports.array.copy(object); - if (typeof object == 'object') - return exports.object.copy(object); - return object; -}); - -exports.deepCopy = exports.operator('deepCopy', 1, function (object) { - if (exports.no(object)) - return object; - if (exports.isArrayLike(object)) - return exports.array.deepCopy(object); - if (typeof object == 'object') - return exports.object.deepCopy(object); - return object; -}); - -exports.repr = exports.operator('repr', 1, function (object) { - if (exports.no(object)) - return String(object); - if (exports.isArrayLike(object)) - return exports.array.repr(object); - if (typeof object == 'object') - return exports.object.repr(object); - if (typeof object == 'string') - return exports.enquote(object); - return object.toString(); -}); - -exports.keys = exports.operator('keys', 1, function (object) { - if (exports.isArrayLike(object)) - return exports.range(object.length); - else if (typeof object == 'object') - return exports.object.keys(object); - return []; -}); - -exports.values = exports.operator('values', 1, function (object) { - if (exports.isArrayLike(object)) - return exports.array(object); - else if (typeof object == 'object') - return exports.object.values(object); - return []; -}); - -exports.items = exports.operator('items', 1, function (object) { - if (exports.isArrayLike(object) || typeof object == "string") - return exports.enumerate(object); - else if (typeof object == 'object') - return exports.object.items(object); - return []; -}); - -exports.len = exports.operator('len', 1, function (object) { - if (exports.isArrayLike(object)) - return exports.array.len(object); - else if (typeof object == 'object') - return exports.object.len(object); -}); - -exports.has = exports.operator('has', 2, function (object, value) { - if (exports.isArrayLike(object)) - return exports.array.has(object, value); - else if (typeof object == 'object') - return exports.object.has(object, value); - return false; -}); - -exports.get = exports.operator('get', 2, function (object, key, value) { - if (typeof object == "string") { - if (!typeof key == "number") - throw new Error("TypeError: String keys must be numbers"); - if (!exports.has(exports.range(object.length), key)) { - if (arguments.length == 3) - return value; - throw new Error("KeyError: " + exports.repr(key)); - } - return items.charAt(object); - } - if (typeof object == "object") { - if (!exports.object.has(object, key)) { - if (arguments.length == 3) - return value; - throw new Error("KeyError: " + exports.repr(key)); - } - return object[key]; - } - throw new Error("Object does not have keys: " + exports.repr(object)); -}); - -exports.set = exports.operator('set', 3, function (object, key, value) { - object[key] = value; - return object; -}); - -exports.getset = exports.operator('getset', 3, function (object, key, value) { - if (!exports.has(object, key)) - exports.set(object, key, value); - return exports.get(object, key); -}); - -exports.del = exports.operator('del', 2, function (object, begin, end) { - if (exports.isArrayLike(object)) - return exports.array.del(object, begin, end); - delete object[begin]; - return object; -}); - -exports.cut = exports.operator('cut', 2, function (object, key) { - var result = exports.get(object, key); - exports.del(object, key); - return result; -}); - -exports.put = exports.operator('put', 2, function (object, key, value) { - if (exports.isArrayLike(object)) - return exports.array.put(object, key, value); - return exports.set(object, key, value); -}); - -exports.update = exports.operator('update', 2, function (target, source) { - exports.object.update(target, source); -}); - -exports.complete = exports.operator('complete', 2, function (target, source) { - exports.object.complete(target, source); -}); - -// TODO insert -// TODO remove -// TODO discard - -exports.range = function () { - var start = 0, stop = 0, step = 1; - if (arguments.length == 1) { - stop = arguments[0]; - } else if (arguments.length == 2) { - start = arguments[0]; - stop = arguments[1]; - } else if (arguments.length == 3) { - start = arguments[0]; - stop = arguments[1]; - step = arguments[2]; - } - var range = []; - for (var i = start; i < stop; i += step) - range.push(i); - return range; -}; - -exports.forEach = function (array, block) { - Array.prototype.forEach.call(array, block); -}; - -exports.forEachApply = function (array, block) { - Array.prototype.forEach.call(array, exports.apply(block)); -}; - -exports.map = function (array, block, context) { - return Array.prototype.map.call(array, block, context); -}; - -exports.mapApply = function (array, block) { - return Array.prototype.map.call(array, exports.apply(block)); -}; - -exports.every = exports.operator('every', 2, function (array, block, context) { - return exports.all(exports.map(array, block, context)); -}); - -exports.some = exports.operator('some', 2, function (array, block, context) { - return exports.any(exports.map(array, block, context)); -}); - -exports.all = exports.operator('all', 1, function (array) { - for (var i = 0; i < array.length; i++) - if (!array[i]) - return false; - return true; -}); - -exports.any = exports.operator('all', 1, function (array) { - for (var i = 0; i < array.length; i++) - if (array[i]) - return true; - return false; -}); - -exports.reduce = exports.operator('reduce', 2, function (array, block, basis) { - return array.reduce.apply(array, arguments); -}); - -exports.reduceRight = exports.operator('reduceRight', 2, function (array, block, basis) { - return array.reduceRight.apply(array, arguments); -}); - -exports.zip = function () { - return exports.transpose(arguments); -}; - -exports.transpose = function (array) { - var transpose = []; - for (var i = 0; i < array.length; i++) { - var row = array[i]; - for (var j = 0; j < row.length; j++) { - var cell = row[j]; - if (!transpose[j]) - transpose[j] = []; - transpose[j][i] = cell; - } - } - return transpose; -}; - -exports.enumerate = function (array, start) { - if (exports.no(start)) - start = 0; - return exports.zip( - exports.range(start, start + array.length), - array - ); -}; - -// arithmetic, transitive, and logical operators - -exports.is = function (a, b) { - return a === b; -}; - -exports.eq = exports.operator('eq', 2, function (a, b, stack) { - if (!stack) - stack = []; - if (a === b) - return true; - if (typeof a !== typeof b) - return false; - if (exports.no(a)) - return exports.no(b); - if (typeof a == "date") - return a.valueOf() == b.valueOf(); - if (typeof a == "regexp") - return a.source == b.source && - a.global == b.global && - a.ignoreCase == b.ignoreCase && - a.multiline == b.multiline; - if (typeof a == "function") { - var caller = stack[stack.length - 1]; - return caller !== Object && - typeof caller != "undefined"; - } - if (exports.isArrayLike(a)) - return exports.array.eq( - a, b, - stack.concat([a.constructor]) - ); - if (typeof a == 'object') - return exports.object.eq( - a, b, - stack.concat([a.constructor]) - ); - return a == b; -}); - -exports.ne = exports.operator('ne', 2, function (a, b) { - return !exports.eq(a, b); -}); - -exports.lt = exports.operator('lt', 2, function (a, b) { - if (exports.no(a) != exports.no(b)) - return exports.no(a) > exports.no(b); - if (exports.isArrayLike(a) && exports.isArrayLike(b)) - return exports.array.lt(a, b); - return a < b; -}); - -exports.gt = exports.operator('gt', 2, function (a, b) { - return !(exports.lt(a, b) || exports.eq(a, b)); -}); - -exports.le = exports.operator(2, 'le', function (a, b) { - return exports.lt(a, b) || exports.eq(a, b); -}); - -exports.ge = exports.operator(2, 'ge', function (a, b) { - return !exports.lt(a, b); -}); - -/*** by - returns a `comparator` that compares - values based on the values resultant from - a given `relation`. - accepts a `relation` and an optional comparator. - - To sort a list of objects based on their - "a" key:: - - objects.sort(by(get("a"))) - - To get those in descending order:: - - objects.sort(by(get("a")), desc) - - `by` returns a comparison function that also tracks - the arguments you used to construct it. This permits - `sort` and `sorted` to perform a Schwartzian transform - which can increase the performance of the sort - by a factor of 2. -*/ -exports.by = function (relation) { - var compare = arguments[1]; - if (exports.no(compare)) - compare = exports.compare; - var comparator = function (a, b) { - a = relation(a); - b = relation(b); - return compare(a, b); - }; - comparator.by = relation; - comparator.compare = compare; - return comparator; -}; - -exports.compare = exports.operator(2, 'compare', function (a, b) { - if (exports.no(a) != exports.no(b)) - return exports.no(b) - exports.no(a); - if (typeof a == "number" && typeof b == "number") - return a - b; - return exports.eq(a, b) ? 0 : exports.lt(a, b) ? -1 : 1; -}); - -/*** sort - an in-place array sorter that uses a deep comparison - function by default (compare), and improves performance if - you provide a comparator returned by "by", using a - Schwartzian transform. -*/ -exports.sort = function (array, compare) { - if (exports.no(compare)) - compare = exports.compare; - if (compare.by) { - /* schwartzian transform */ - array.splice.apply( - array, - [0, array.length].concat( - array.map(function (value) { - return [compare.by(value), value]; - }).sort(function (a, b) { - return exports.compare(a[0], b[0]); - }).map(function (pair) { - return pair[1]; - }) - ) - ); - } else { - array.sort(compare); - } - return array; -}; - -/*** sorted - returns a sorted copy of an array using a deep - comparison function by default (compare), and - improves performance if you provide a comparator - returned by "by", using a Schwartzian transform. -*/ -exports.sorted = function (array, compare) { - return exports.sort(exports.array.copy(array), compare); -}; - -// string - -/*** escape - escapes all characters of a string that are - special to JavaScript and many other languages. - Recognizes all of the relevant - control characters and formats all other - non-printable characters as Hex byte escape - sequences or Unicode escape sequences depending - on their size. - - Pass ``true`` as an optional second argument and - ``escape`` produces valid contents for escaped - JSON strings, wherein non-printable-characters are - all escaped with the Unicode ``\u`` notation. -*/ -/* more Steve Levithan flagrence */ -var escapeExpression = /[^ !#-[\]-~]/g; -/* from Doug Crockford's JSON library */ -var escapePatterns = { - '\b': '\\b', '\t': '\\t', - '\n': '\\n', '\f': '\\f', '\r': '\\r', - '"' : '\\"', '\\': '\\\\' -}; -exports.escape = function (value, strictJson) { - if (typeof value != "string") - throw new Error( - module.path + - "#escape: requires a string. got " + - exports.repr(value) - ); - return value.replace( - escapeExpression, - function (match) { - if (escapePatterns[match]) - return escapePatterns[match]; - match = match.charCodeAt(); - if (!strictJson && match < 256) - return "\\x" + exports.padBegin(match.toString(16), 2); - return '\\u' + exports.padBegin(match.toString(16), 4); - } - ); -}; - -/*** enquote - transforms a string into a string literal, escaping - all characters of a string that are special to - JavaScript and and some other languages. - - ``enquote`` uses double quotes to be JSON compatible. - - Pass ``true`` as an optional second argument to - be strictly JSON compliant, wherein all - non-printable-characters are represented with - Unicode escape sequences. -*/ -exports.enquote = function (value, strictJson) { - return '"' + exports.escape(value, strictJson) + '"'; -}; - -/*** expand - transforms tabs to an equivalent number of spaces. -*/ -// TODO special case for \r if it ever matters -exports.expand = function (str, tabLength) { - str = String(str); - tabLength = tabLength || 4; - var output = [], - tabLf = /[\t\n]/g, - lastLastIndex = 0, - lastLfIndex = 0, - charsAddedThisLine = 0, - tabOffset, match; - while (match = tabLf.exec(str)) { - if (match[0] == "\t") { - tabOffset = ( - tabLength - 1 - - ( - (match.index - lastLfIndex) + - charsAddedThisLine - ) % tabLength - ); - charsAddedThisLine += tabOffset; - output.push( - str.slice(lastLastIndex, match.index) + - operator.mul(" ", tabOffset + 1) - ); - } else if (match[0] === "\n") { - output.push(str.slice(lastLastIndex, tabLf.lastIndex)); - lastLfIndex = tabLf.lastIndex; - charsAddedThisLine = 0; - } - lastLastIndex = tabLf.lastIndex; - } - return output.join("") + str.slice(lastLastIndex); -}; - -var trimBeginExpression = /^\s\s*/g; -exports.trimBegin = function (value) { - return String(value).replace(trimBeginExpression, ""); -}; - -var trimEndExpression = /\s\s*$/g; -exports.trimEnd = function (value) { - return String(value).replace(trimEndExpression, ""); -}; - -exports.trim = function (value) { - return String(value).replace(trimBeginExpression, "").replace(trimEndExpression, ""); -}; - -/* generates padBegin and padEnd */ -var augmentor = function (augment) { - return function (value, length, pad) { - if (exports.no(pad)) pad = '0'; - if (exports.no(length)) length = 2; - value = String(value); - while (value.length < length) { - value = augment(value, pad); - } - return value; - }; -}; - -/*** padBegin - - accepts: - - a `String` or `Number` value - - a minimum length of the resultant `String`: - by default, 2 - - a pad string: by default, ``'0'``. - - returns a `String` of the value padded up to at least - the minimum length. adds the padding to the begining - side of the `String`. - -*/ -exports.padBegin = augmentor(function (value, pad) { - return pad + value; -}); - -/*** padEnd - - accepts: - - a `String` or `Number` value - - a minimum length of the resultant `String`: - by default, 2 - - a pad string: by default, ``'0'``. - - returns a `String` of the value padded up to at least - the minimum length. adds the padding to the end - side of the `String`. - -*/ -exports.padEnd = augmentor(function (value, pad) { - return value + pad; -}); - -/*** splitName - splits a string into a `List` of words from an origin - string. -*/ -var splitNameExpression = /[a-z]+|[A-Z](?:[a-z]+|[A-Z]*(?![a-z]))|[.\d]+/g; -exports.splitName = function (value) { - return String(value).match(splitNameExpression); -}; - -/*** joinName - joins a list of words with a given delimiter - between alphanumeric words. -*/ -exports.joinName = function (delimiter, parts) { - if (exports.no(delimiter)) delimiter = '_'; - parts.unshift([]); - return parts.reduce(function (parts, part) { - if ( - part.match(/\d/) && - exports.len(parts) && parts[parts.length-1].match(/\d/) - ) { - return parts.concat([delimiter + part]); - } else { - return parts.concat([part]); - } - }).join(''); -}; - -/*** upper - converts a name to ``UPPER CASE`` using - a given delimiter between numeric words. - - see: - - `lower` - - `camel` - - `title` - -*/ -exports.upper = function (value, delimiter) { - if (exports.no(delimiter)) - return value.toUpperCase(); - return exports.splitName(value).map(function (part) { - return part.toUpperCase(); - }).join(delimiter); -}; - -/*** lower - converts a name to a ``lower case`` using - a given delimiter between numeric words. - - see: - - `upper` - - `camel` - - `title` - -*/ -exports.lower = function (value, delimiter) { - if (exports.no(delimiter)) - return String(value).toLowerCase(); - return exports.splitName(value).map(function (part) { - return part.toLowerCase(); - }).join(delimiter); -}; - -/*** camel - converts a name to ``camel Case`` using - a given delimiter between numeric words. - - see: - - `lower` - - `upper` - - `title` - -*/ -exports.camel = function (value, delimiter) { - return exports.joinName( - delimiter, - exports.mapApply( - exports.enumerate(exports.splitName(value)), - function (n, part) { - if (n) { - return ( - part.substring(0, 1).toUpperCase() + - part.substring(1).toLowerCase() - ); - } else { - return part.toLowerCase(); - } - } - ) - ); -}; - -/*** title - converts a name to ``Title Case`` using - a given delimiter between numeric words. - - see: - - `lower` - - `upper` - - `camel` - -*/ -exports.title = function (value, delimiter) { - return exports.joinName( - delimiter, - exports.splitName(value).map(function (part) { - return ( - part.substring(0, 1).toUpperCase() + - part.substring(1).toLowerCase() - ); - }) - ); -}; - diff --git a/utils/lib/xregexp.js b/utils/lib/xregexp.js deleted file mode 100755 index 4b67fd0..0000000 --- a/utils/lib/xregexp.js +++ /dev/null @@ -1,521 +0,0 @@ -// RegExp - -/** provides an augmented, cross-browser implementation of regular expressions - including support for additional modifiers and syntax. several convenience - methods and a recursive-construct parser are also included. -*/ - -/*preamble-steven-levithan - XRegExp 0.6.1 - Copyright (c) 2007-2008 Steven Levithan - MIT license - Based on XRegExp 0.5.1 -*/ -/*preamble-kris-kowal - Copyright (c) 2002-2008 Kris Kowal - MIT License - Migrated to module system -*/ - -/** provides an augmented, cross-browser implementation of regular expressions - including support for additional modifiers and syntax. several convenience - methods and a recursive-construct parser are also included. -*/ - -// copy various native globals for reference. can't use the name ``native`` -// because it's a reserved JavaScript keyword. -var real = { - exec: RegExp.prototype.exec, - match: String.prototype.match, - replace: String.prototype.replace, - split: String.prototype.split - }, - /* regex syntax parsing with support for all the necessary cross- - browser and context issues (escapings, character classes, etc.) */ - lib = { - part: /(?:[^\\([#\s.]+|\\(?!k<[\w$]+>|[pP]{[^}]+})[\S\s]?|\((?=\?(?!#|<[\w$]+>)))+|(\()(?:\?(?:(#)[^)]*\)|<([$\w]+)>))?|\\(?:k<([\w$]+)>|[pP]{([^}]+)})|(\[\^?)|([\S\s])/g, - replaceVar: /(?:[^$]+|\$(?![1-9$&`']|{[$\w]+}))+|\$(?:([1-9]\d*|[$&`'])|{([$\w]+)})/g, - extended: /^(?:\s+|#.*)+/, - quantifier: /^(?:[?*+]|{\d+(?:,\d*)?})/, - classLeft: /&&\[\^?/g, - classRight: /]/g - }, - indexOf = function (array, item, from) { - for (var i = from || 0; i < array.length; i++) - if (array[i] === item) return i; - return -1; - }, - brokenExecUndef = /()??/.exec("")[1] !== undefined, - plugins = {}; - -/*** XRegExp - accepts a pattern and flags, returns a new, extended RegExp object. - differs from a native regex in that additional flags and syntax are - supported and browser inconsistencies are ameliorated. -*/ -XRegExp = function (pattern, flags) { - if (pattern instanceof RegExp) { - if (flags !== undefined) - throw TypeError("can't supply flags when constructing one RegExp from another"); - return pattern.addFlags(); // new copy - } - - var flags = flags || "", - singleline = flags.indexOf("s") > -1, - extended = flags.indexOf("x") > -1, - hasNamedCapture = false, - captureNames = [], - output = [], - part = lib.part, - match, cc, len, index, regex; - - part.lastIndex = 0; // in case the last XRegExp compilation threw an error (unbalanced character class) - - while (match = real.exec.call(part, pattern)) { - // comment pattern. this check must come before the capturing group check, - // because both match[1] and match[2] will be non-empty. - if (match[2]) { - // keep tokens separated unless the following token is a quantifier - if (!lib.quantifier.test(pattern.slice(part.lastIndex))) - output.push("(?:)"); - // capturing group - } else if (match[1]) { - captureNames.push(match[3] || null); - if (match[3]) - hasNamedCapture = true; - output.push("("); - // named backreference - } else if (match[4]) { - index = indexOf(captureNames, match[4]); - // keep backreferences separate from subsequent literal numbers - // preserve backreferences to named groups that are undefined at this point as literal strings - output.push(index > -1 ? - "\\" + (index + 1) + (isNaN(pattern.charAt(part.lastIndex)) ? "" : "(?:)") : - match[0] - ); - // unicode element (requires plugin) - } else if (match[5]) { - output.push(plugins.unicode ? - plugins.unicode.get(match[5], match[0].charAt(1) === "P") : - match[0] - ); - // character class opening delimiter ("[" or "[^") - // (non-native unicode elements are not supported within character classes) - } else if (match[6]) { - if (pattern.charAt(part.lastIndex) === "]") { - // for cross-browser compatibility with ECMA-262 v3 behavior, - // convert [] to (?!) and [^] to [\S\s]. - output.push(match[6] === "[" ? "(?!)" : "[\\S\\s]"); - part.lastIndex++; - } else { - // parse the character class with support for inner escapes and - // ES4's infinitely nesting intersection syntax ([&&[^&&[]]]). - cc = XRegExp.matchRecursive("&&" + pattern.slice(match.index), lib.classLeft, lib.classRight, "", {escapeChar: "\\"})[0]; - output.push(match[6] + cc + "]"); - part.lastIndex += cc.length + 1; - } - // dot ("."), pound sign ("#"), or whitespace character - } else if (match[7]) { - if (singleline && match[7] === ".") { - output.push("[\\S\\s]"); - } else if (extended && lib.extended.test(match[7])) { - len = real.exec.call(lib.extended, pattern.slice(part.lastIndex - 1))[0].length; - // keep tokens separated unless the following token is a quantifier - if (!lib.quantifier.test(pattern.slice(part.lastIndex - 1 + len))) - output.push("(?:)"); - part.lastIndex += len - 1; - } else { - output.push(match[7]); - } - } else { - output.push(match[0]); - } - } - - regex = RegExp(output.join(""), real.replace.call(flags, /[sx]+/g, "")); - regex._x = { - source: pattern, - captureNames: hasNamedCapture ? captureNames : null - }; - return regex; -}; - -// barebones plugin support for now (intentionally undocumented) -XRegExp.addPlugin = function (name, o) { - plugins[name] = o; -}; - -/*** RegExp.prototype.exec - adds named capture support, with values returned as ``result.name``. - also fixes two cross-browser issues, following the ECMA-262 v3 spec: - - captured values for non-participating capturing groups should be returned - as ``undefined``, rather than the empty string. - - the regex's ``lastIndex`` should not be incremented after zero-length - matches. -*/ -RegExp.prototype.exec = function (str) { - var match = real.exec.call(this, str), - name, i, r2; - if (match) { - // fix browsers whose exec methods don't consistently return - // undefined for non-participating capturing groups - if (brokenExecUndef && match.length > 1) { - // r2 doesn't need /g or /y, but they shouldn't hurt - r2 = new RegExp("^" + this.source + "$(?!\\s)", this.getNativeFlags()); - real.replace.call(match[0], r2, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } - // attach named capture properties - if (this._x && this._x.captureNames) { - for (i = 1; i < match.length; i++) { - name = this._x.captureNames[i - 1]; - if (name) match[name] = match[i]; - } - } - // fix browsers that increment lastIndex after zero-length matches - if (this.global && this.lastIndex > (match.index + match[0].length)) - this.lastIndex--; - } - return match; -}; - -/*** String.prototype.match - run the altered ``exec`` when called with a non-global regex. -*/ -String.prototype.match = function (regex) { - if (!(regex instanceof RegExp)) - regex = new XRegExp(regex); - if (regex.global) - return real.match.call(this, regex); - return regex.exec(this); // run the altered exec -}; - -/*** String.prototype.replace - add named capture support to replacement strings using the syntax - ``${name}``, and to replacement functions as ``arguments[0].name``. -*/ -String.prototype.replace = function (search, replacement) { - var captureNames = (search._x || {}).captureNames; - - // if search is not a regex which uses named capture, use the native replace method - if (!(search instanceof RegExp && captureNames)) - return real.replace.apply(this, arguments); - - if (typeof replacement === "function") { - return real.replace.call(this, search, function () { - // change the arguments[0] string primitive to a String object which can store properties - arguments[0] = new String(arguments[0]); - // store named backreferences on arguments[0] before calling replacement - for (var i = 0; i < captureNames.length; i++) { - if (captureNames[i]) - arguments[0][captureNames[i]] = arguments[i + 1]; - } - return replacement.apply(window, arguments); - }); - } else { - return real.replace.call(this, search, function () { - var args = arguments; - return real.replace.call(replacement, lib.replaceVar, function ($0, $1, $2) { - // numbered backreference or special variable - if ($1) { - switch ($1) { - case "$": return "$"; - case "&": return args[0]; - case "`": return args[args.length - 1].slice(0, args[args.length - 2]); - case "'": return args[args.length - 1].slice(args[args.length - 2] + args[0].length); - // numbered backreference - default: - /* what does "$10" mean? - - backreference 10, if 10 or more capturing groups exist - - backreference 1 followed by "0", if 1-9 capturing groups exist - - otherwise, it's the string "$10" - */ - var literalNumbers = ""; - $1 = +$1; // type-convert - while ($1 > captureNames.length) { - literalNumbers = real.split.call($1, "").pop() + literalNumbers; - $1 = Math.floor($1 / 10); // drop the last digit - } - return ($1 ? args[$1] : "$") + literalNumbers; - } - // named backreference - } else if ($2) { - /* what does "${name}" mean? - - backreference to named capture "name", if it exists - - otherwise, it's the string "${name}" - */ - var index = indexOf(captureNames, $2); - return index > -1 ? args[index + 1] : $0; - } else { - return $0; - } - }); - }); - } -}; - -/*** String.prototype.split - a consistent cross-browser, ECMA-262 v3 compliant split method -*/ -String.prototype.split = function (s /* separator */, limit) { - // if separator is not a regex, use the native split method - if (!(s instanceof RegExp)) - return real.split.apply(this, arguments); - - var output = [], - origLastIndex = s.lastIndex, - lastLastIndex = 0, - i = 0, match, lastLength; - - /* behavior for limit: if it's... - - undefined: no limit - - NaN or zero: return an empty array - - a positive number: use limit after dropping any decimal - - a negative number: no limit - - other: type-convert, then use the above rules - */ - if (limit === undefined || +limit < 0) { - limit = false; - } else { - limit = Math.floor(+limit); - if (!limit) - return []; - } - - if (s.global) - s.lastIndex = 0; - else - s = s.addFlags("g"); - - while ((!limit || i++ <= limit) && (match = s.exec(this))) { // run the altered exec! - if (s.lastIndex > lastLastIndex) { - output = output.concat(this.slice(lastLastIndex, match.index)); - if (1 < match.length && match.index < this.length) - output = output.concat(match.slice(1)); - lastLength = match[0].length; // only needed if s.lastIndex === this.length - lastLastIndex = s.lastIndex; - } - if (!match[0].length) - s.lastIndex++; // avoid an infinite loop - } - - // since this uses test(), output must be generated before restoring lastIndex - output = lastLastIndex === this.length ? - (s.test("") && !lastLength ? output : output.concat("")) : - (limit ? output : output.concat(this.slice(lastLastIndex))); - s.lastIndex = origLastIndex; // only needed if s.global, else we're working with a copy of the regex - return output; -}; - -// intentionally undocumented -RegExp.prototype.getNativeFlags = function () { - return (this.global ? "g" : "") + - (this.ignoreCase ? "i" : "") + - (this.multiline ? "m" : "") + - (this.extended ? "x" : "") + - (this.sticky ? "y" : ""); -}; - -/*** RegExp.prototype.addFlags - accepts flags; returns a new XRegExp object generated by recompiling - the regex with the additional flags (may include non-native flags). - the original regex object is not altered. -*/ -RegExp.prototype.addFlags = function (flags) { - var regex = new XRegExp(this.source, (flags || "") + this.getNativeFlags()); - if (this._x) { - regex._x = { - source: this._x.source, - captureNames: this._x.captureNames ? this._x.captureNames.slice(0) : null - }; - } - return regex; -}; - -/*** RegExp.prototype.call - accepts a context object and string; returns the result of calling - ``exec`` with the provided string. the context is ignored but is - accepted for congruity with ``Function.prototype.call``. -*/ -RegExp.prototype.call = function (context, str) { - return this.exec(str); -}; - -/*** RegExp.prototype.apply - accepts a context object and arguments array; returns the result of - calling ``exec`` with the first value in the arguments array. the context - is ignored but is accepted for congruity with ``Function.prototype.apply``. -*/ -RegExp.prototype.apply = function (context, args) { - return this.exec(args[0]); -}; - -/*** XRegExp.cache - accepts a pattern and flags; returns an XRegExp object. if the pattern - and flag combination has previously been cached, the cached copy is - returned, otherwise the new object is cached. -*/ -XRegExp.cache = function (pattern, flags) { - var key = "/" + pattern + "/" + (flags || ""); - return XRegExp.cache[key] || (XRegExp.cache[key] = new XRegExp(pattern, flags)); -}; - -/*** XRegExp.escape - accepts a string; returns the string with regex metacharacters escaped. - the returned string can safely be used within a regex to match a literal - string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \, ^, $, - |, #, [comma], and whitespace. -*/ -XRegExp.escape = function (str) { - return str.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); -}; - -/*** XRegExp.matchRecursive - accepts a string to search, left and right delimiters as regex pattern - strings, optional regex flags (may include non-native s, x, and y flags), - and an options object which allows setting an escape character and changing - the return format from an array of matches to a two-dimensional array of - string parts with extended position data. returns an array of matches - (optionally with extended data), allowing nested instances of left and right - delimiters. use the g flag to return all matches, otherwise only the first - is returned. if delimiters are unbalanced within the subject data, an error - is thrown. - - this function admittedly pushes the boundaries of what can be accomplished - sensibly without a "real" parser. however, by doing so it provides flexible - and powerful recursive parsing capabilities with minimal code weight. - - warning: the ``escapeChar`` option is considered experimental and might be - changed or removed in future versions of XRegExp. - - unsupported features: - - backreferences within delimiter patterns when using ``escapeChar``. - - although providing delimiters as regex objects adds the minor feature of - independent delimiter flags, it introduces other limitations and is only - intended to be done by the ``XRegExp`` constructor (which can't call - itself while building a regex). -*/ -XRegExp.matchRecursive = function (str, left, right, flags, options) { - var options = options || {}, - escapeChar = options.escapeChar, - vN = options.valueNames, - flags = flags || "", - global = flags.indexOf("g") > -1, - ignoreCase = flags.indexOf("i") > -1, - multiline = flags.indexOf("m") > -1, - sticky = flags.indexOf("y") > -1, - /* sticky mode has its own handling in this function, which means you - can use flag "y" even in browsers which don't support it natively */ - flags = flags.replace(/y/g, ""), - left = left instanceof RegExp ? (left.global ? left : left.addFlags("g")) : new XRegExp(left, "g" + flags), - right = right instanceof RegExp ? (right.global ? right : right.addFlags("g")) : new XRegExp(right, "g" + flags), - output = [], - openTokens = 0, - delimStart = 0, - delimEnd = 0, - lastOuterEnd = 0, - outerStart, innerStart, leftMatch, rightMatch, escaped, esc; - - if (escapeChar) { - if (escapeChar.length > 1) throw SyntaxError("can't supply more than one escape character"); - if (multiline) throw TypeError("can't supply escape character when using the multiline flag"); - escaped = XRegExp.escape(escapeChar); - /* Escape pattern modifiers: - /g - not needed here - /i - included - /m - **unsupported**, throws error - /s - handled by XRegExp when delimiters are provided as strings - /x - handled by XRegExp when delimiters are provided as strings - /y - not needed here; supported by other handling in this function - */ - esc = new RegExp( - "^(?:" + escaped + "[\\S\\s]|(?:(?!" + left.source + "|" + right.source + ")[^" + escaped + "])+)+", - ignoreCase ? "i" : "" - ); - } - - while (true) { - /* advance the starting search position to the end of the last delimiter match. - a couple special cases are also covered: - - if using an escape character, advance to the next delimiter's starting position, - skipping any escaped characters - - first time through, reset lastIndex in case delimiters were provided as regexes - */ - left.lastIndex = right.lastIndex = delimEnd + - (escapeChar ? (esc.exec(str.slice(delimEnd)) || [""])[0].length : 0); - - leftMatch = left.exec(str); - rightMatch = right.exec(str); - - // only keep the result which matched earlier in the string - if (leftMatch && rightMatch) { - if (leftMatch.index <= rightMatch.index) - rightMatch = null; - else leftMatch = null; - } - - /* paths*: - leftMatch | rightMatch | openTokens | result - 1 | 0 | 1 | ... - 1 | 0 | 0 | ... - 0 | 1 | 1 | ... - 0 | 1 | 0 | throw - 0 | 0 | 1 | throw - 0 | 0 | 0 | break - * - does not include the sticky mode special case - - the loop ends after the first completed match if not in global mode - */ - - if (leftMatch || rightMatch) { - delimStart = (leftMatch || rightMatch).index; - delimEnd = (leftMatch ? left : right).lastIndex; - } else if (!openTokens) { - break; - } - - if (sticky && !openTokens && delimStart > lastOuterEnd) - break; - - if (leftMatch) { - if (!openTokens++) { - outerStart = delimStart; - innerStart = delimEnd; - } - } else if (rightMatch && openTokens) { - if (!--openTokens) { - if (vN) { - if (vN[0] && outerStart > lastOuterEnd) - output.push([vN[0], str.slice(lastOuterEnd, outerStart), lastOuterEnd, outerStart]); - if (vN[1]) output.push([vN[1], str.slice(outerStart, innerStart), outerStart, innerStart]); - if (vN[2]) output.push([vN[2], str.slice(innerStart, delimStart), innerStart, delimStart]); - if (vN[3]) output.push([vN[3], str.slice(delimStart, delimEnd), delimStart, delimEnd]); - } else { - output.push(str.slice(innerStart, delimStart)); - } - lastOuterEnd = delimEnd; - if (!global) - break; - } - } else { - // reset lastIndex in case delimiters were provided as regexes - left.lastIndex = right.lastIndex = 0; - throw Error("subject data contains unbalanced delimiters"); - } - - // if the delimiter matched an empty string, advance delimEnd to avoid an infinite loop - if (delimStart === delimEnd) - delimEnd++; - } - - if (global && !sticky && vN && vN[0] && str.length > lastOuterEnd) - output.push([vN[0], str.slice(lastOuterEnd), lastOuterEnd, str.length]); - - // reset lastIndex in case delimiters were provided as regexes - left.lastIndex = right.lastIndex = 0; - - return output; -}; - diff --git a/utils/local.json.template b/utils/local.json.template deleted file mode 100755 index 2b0d0ae..0000000 --- a/utils/local.json.template +++ /dev/null @@ -1 +0,0 @@ -{"packages": ["packages", ".."]} diff --git a/utils/narwhal.conf.template b/utils/narwhal.conf.template deleted file mode 100755 index 0d42bb9..0000000 --- a/utils/narwhal.conf.template +++ /dev/null @@ -1,9 +0,0 @@ - -# Rhino -NARWHAL_DEFAULT_PLATFORM="rhino" - -# k7 -#NARWHAL_DEFAULT_PLATFORM="k7" - -#NARWHAL_PLATFORM_HOME="." - diff --git a/utils/narwhal.gemspec b/utils/narwhal.gemspec deleted file mode 100755 index 25ed8ba..0000000 --- a/utils/narwhal.gemspec +++ /dev/null @@ -1,105 +0,0 @@ -# -*- encoding: utf-8 -*- -Gem::Specification.new do |s| - s.name = %q{Narwhal} - s.version = "0.0.1" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Tom Robinson", "Kris Kowal", "George Moschovitis", "Kevin Dangoor", "Hannes Wallnöfer"] - s.date = %q{2009-05-30} - s.description = %q{An implementation of the ServerJS standard library} - s.email = %q{jack-js@googlegroups.com} - s.homepage = %q{http://narwhaljs.org} - s.executables = ["narwhal"] - s.files = [ - "bin", - "bin/js", - "bin/narwhal", - "bin/sea", - "bin/tusk", - "lib", - "lib/args.js", - "lib/codec", - "lib/codec/base64.js", - "lib/file.js", - "lib/hash.js", - "lib/hashp.js", - "lib/http.js", - "lib/io.js", - "lib/json.js", - "lib/logger.js", - "lib/mime.js", - "lib/narwhal", - "lib/narwhal/repl.js", - "lib/narwhal/tusk-init.js", - "lib/narwhal/tusk.js", - "lib/narwhal.js", - "lib/packages.js", - "lib/ref_send.js", - "lib/regexp.js", - "lib/sandbox.js", - "lib/string.js", - "lib/test", - "lib/test/assert.js", - "lib/test/equiv.js", - "lib/test/jsdump.js", - "lib/test/runner.js", - "lib/unload.js", - "lib/uri.js", - "lib/util.js", - "lib/xregexp.js", - "platforms", - "platforms/browser", - "platforms/browser/lib", - "platforms/browser/lib/reactor.js", - "platforms/default", - "platforms/default/lib", - "platforms/default/lib/array.js", - "platforms/default/lib/file-platform.js", - "platforms/default/lib/function.js", - "platforms/default/lib/global.js", - "platforms/default/lib/io-platform.js", - "platforms/default/lib/object.js", - "platforms/default/lib/reactor.js", - "platforms/default/lib/system.js", - "platforms/k7", - "platforms/k7/bin", - "platforms/k7/bin/narwhal-k7", - "platforms/k7/bootstrap.js", - "platforms/k7/lib", - "platforms/k7/lib/file-platform.js", - "platforms/k7/lib/system.js", - "platforms/rhino", - "platforms/rhino/bin", - "platforms/rhino/bin/narwhal-rhino", - "platforms/rhino/bootstrap.js", - "platforms/rhino/jars", - "platforms/rhino/jars/jline.jar", - "platforms/rhino/jars/js.jar", - "platforms/rhino/lib", - "platforms/rhino/lib/binary.js", - "platforms/rhino/lib/file-platform.js", - "platforms/rhino/lib/http-platform.js", - "platforms/rhino/lib/io-platform.js", - "platforms/rhino/lib/os.js", - "platforms/rhino/lib/packages-platform.js", - "platforms/rhino/lib/process.js", - "platforms/rhino/lib/sandbox-platform.js", - "platforms/rhino/lib/system.js", - "platforms/rhino/lib/zip.js", - "platforms/secure", - "platforms/secure/lib", - "platforms/secure/lib/file.js", - "platforms/secure/lib/system.js", - "platforms/template", - "platforms/template/bin", - "platforms/template/bin/narwhal-platform-name", - "platforms/template/bootstrap.js", - "platforms/template/lib", - "platforms/template/lib/file-platform.js", - "platforms/template/lib/system.js", - "platforms/v8cgi", - "platforms/v8cgi/bootstrap.js" - ] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.3} - s.summary = %q{Implementation of the ServerJS standard library} -end diff --git a/utils/narwhal.js b/utils/narwhal.js deleted file mode 100755 index 4967afb..0000000 --- a/utils/narwhal.js +++ /dev/null @@ -1,208 +0,0 @@ -(function (system) { - -// global reference -global = system.global; -global.global = global; -global.system = system; -global.print = system.print; - -// logger shim -var logFake = function () { - if (system.debug) { - system.print(Array.prototype.join.apply(arguments, [" "])); - } -}; -var log = {fatal:logFake, error:logFake, warn:logFake, info:logFake, debug:logFake}; -system.log = log; - -// this only works for modules with no dependencies and a known absolute path -var requireFake = function(id, path, modules) { - modules = modules || {}; - var exports = {}; - var module = {id: id, path: path}; - - var factory = system.evaluate(system.fs.read(path), path, 1); - factory( - function(id) { return modules[id]; }, // require - exports, // exports - module, // module - system, // system - system.print // print - ); - - return exports; -} - -// bootstrap sandbox module -var sandbox = requireFake("sandbox", system.prefix + "/lib/sandbox.js"); - -// bootstrap file module -var fs = {}; -requireFake("sandbox", system.prefix + "/lib/file-bootstrap.js", { "file" : fs }); -for (var name in system.fs) { - if (Object.prototype.hasOwnProperty.call(system.fs, name)) { - fs[name] = system.fs[name]; - } -} -system.fs = fs; - -// construct the initial paths -var paths = []; -for (var i = 0; i < system.platforms.length; i++) { - var platform = system.platforms[i]; - paths.push(system.prefix + '/platforms/' + platform + '/lib'); -} -paths.push(system.prefix + '/lib'); - -// create the primary Loader and Sandbox: -var loader = sandbox.MultiLoader({ - paths: paths, - debug: system.verbose -}); -if (system.loaders) { - loader.loaders.unshift.apply(loader.loaders, system.loaders); - delete system.loaders; -} -var modules = {system: system, sandbox: sandbox}; -global.require = sandbox.Sandbox({ - loader: loader, - modules: modules, - debug: system.verbose -}); - -// patch the primordials (or: save the whales) -// to bring them up to at least the neighborhood of ES5 compliance. -try { - require("global"); -} catch (e) { - system.log.error("Couldn't load global/primordial patches ("+e+")"); -} - -// load the complete system module -global.require.force("system"); - -// augment the path search array with those provided in -// environment variables -paths.push([ - system.env.JS_PATH || '', - system.env.NARWHAL_PATH || '' -].join(':').split(':').filter(function (path) { - return !!path; -})); - -// parse command line options -var parser = require("narwhal").parser; -var options = parser.parse(system.args); -system.packagePrefixes = system.packagePrefixes || - [system.prefix]; -if (options.debug !== undefined) - system.debug = options.debug; -var wasVerbose = system.verbose; -if (options.verbose !== undefined) { - system.verbose = options.verbose; - require.verbose = system.verbose; -} - -// enable loader tracing -global.require.debug = options.verbose; -// in verbose mode, list all the modules that are -// already loaded -if (!wasVerbose && system.verbose) { - Object.keys(modules).forEach(function (name) { - print('@ ' + name); - }); -} - -// find the program module and its prefix -var program; -if (system.args.length && !options.interactive && !options.main) { - if (!program) - program = system.fs.path(system.args[0]).canonical(); - - // add package prefixes for all of the packages - // containing the program, from specific to general - var parts = system.fs.split(program); - for (var i = 0; i < parts.length; i++) { - var path = system.fs.join.apply(null, parts.slice(0, i)); - var packageJson = system.fs.join(path, 'package.json'); - if (system.fs.isFile(packageJson)) - system.packagePrefixes.unshift(path); - } - - if (program.isDirectory()) { - if (!program.join('package.json').isFile()) - throw new Error("Program directory does not contain a package.json"); - system.packagePrefixes.unshift(program); - } -} - -// user package prefixes -if (system.env.PACKAGE_HOME) - system.packagePrefixes.unshift(system.env.PACKAGE_HOME); -system.packagePrefixes.unshift.apply(system.packagePrefixes, options.packagePrefixes); - -// load packages -var packages; -if (!options.noPackages) { - try { - packages = require("packages"); - packages.main(); - } catch (e) { - system.log.error("Warning: Couldn't load packages. Packages won't be available. ("+e+")"); - } -} else { - packages = { - catalog: {}, - packageOrder: [] - } -} - -// run command options -// -I, --include lib -// -r, --require module -// -e, -c , --command command -// -:, --path delimiter -options.todo.forEach(function (item) { - var action = item[0]; - var value = item[1]; - if (action == "include") { - require.paths.unshift(value); - } else if (action == "require") { - require(value); - } else if (action == "eval") { - system.evalGlobal(value); - } else if (action == "path") { - var paths = packages.packageOrder.map(function (pkg) { - return pkg.directory.join('bin'); - }).filter(function (path) { - return path.isDirectory(); - }); - var oldPaths = system.env.PATH.split(value); - while (oldPaths.length) { - var path = oldPaths.shift(); - if (paths.indexOf(path) < 0) - paths.push(path); - } - print(paths.join(value)); - } -}); - -// load the program module -if (options.interactive) { - require('narwhal/repl'); -} else if (options.main) { - require.main(options.main); -} else if (program) { - if (program.isDirectory()) { - require.main(packages.root.directory.resolve(packages.root.main || 'main').toString()); - } else { - require.main(program.toString()); - } -} - -// send an unload event if that module has been required -if (require.loader.isLoaded('unload')) { - require('unload').send(); -} - -}) diff --git a/utils/package.json b/utils/package.json deleted file mode 100755 index ea4c58c..0000000 --- a/utils/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "narwhal", - "author": "Tom Robinson", - "contributors": [ - "Kris Kowal", - "George Mosochovitis", - "Kevin Dangoor", - "Hannes Wallnöfer" - ], - "main": "examples/narwhal", - "lib": ["lib"] -} diff --git a/utils/platforms/browser/inline.js b/utils/platforms/browser/inline.js deleted file mode 100755 index 16d8b11..0000000 --- a/utils/platforms/browser/inline.js +++ /dev/null @@ -1,56 +0,0 @@ -(function (ids, id, path) { - - var factories = {}; - var pending; - - var require = this.require = function (id, baseId) { - // defer to require set later from the sandbox module - require(id, baseId); - }; - - require.register = function (id, factory) { - factories[id] = factory; - if (!--pending) - main(); - }; - - var pending = ids.length; - var head = document.getElementsByTagName('head')[0]; - for (var i = 0; i < pending; i++) { - var script = document.createElement('script'); - script.src = path + ids[i] + '.js'; - head.appendChild(script); - }; - - function main() { - - var system = {}; - system.print = function () { - if (typeof console != "undefined") { - console.log(Array.prototype.join.call(arguments, ' ')); - } - }; - - var loader = {}; - loader.reload = function (topId) { - return factories[topId]; - }; - loader.load = function (topId) { - return loader.reload(topId); - }; - - var sandbox = {}; - loader.load('sandbox')( - null, - sandbox, - {}, - system, - system.print - ); - require = sandbox.Sandbox({loader: loader}); - loader.resolve = sandbox.resolve; - require(id); - - } - -}) diff --git a/utils/platforms/browser/lib/binary.js b/utils/platforms/browser/lib/binary.js deleted file mode 100755 index 23b5104..0000000 --- a/utils/platforms/browser/lib/binary.js +++ /dev/null @@ -1,2 +0,0 @@ -exports.ByteString = String; -exports.ByteArray = Array; diff --git a/utils/platforms/browser/lib/modules.js b/utils/platforms/browser/lib/modules.js deleted file mode 100755 index db89b93..0000000 --- a/utils/platforms/browser/lib/modules.js +++ /dev/null @@ -1,1449 +0,0 @@ -/*preamble-kriskowal - Copyright (c) 2002-2009 Kris Kowal - MIT License -*/ - -/* - isolate the module loader in an enclosure by creating an - annonymous function and then--at the end of this file-- - calling it. - - also, take the evalGlobal function as an argument so that it can be - declared in global scope. this prevents the eval function - from inheriting variables from the modulesjs enclosure scope. -*/ -(function (evalGlobal) { - - /* - kernel module factory functions. this module bootstrapper script - can also be used as a module, since it contains module - factory functions that can be used to bootstrap platform-specific - modules. to that end, we export the module factory functions if - there is an ambient "exports" object - */ - var factories = typeof exports == "undefined" ? {} : exports; - /* kernel module instances */ - var modules = {}; - - /* - a rudimentary require function to jumpstart - the module system - */ - var require = function (id) { - if (!Object.prototype.hasOwnProperty.call(modules, id)) { - var exports = {}; - modules[id] = exports; - factories[id](require, exports, system); - } - return modules[id]; - }; - - /* a permissive system for kernel modules */ - var system = { - window: window, - evalGlobal: evalGlobal - }; - - factories.main = function (require, exports, system) { - - var FILE = 'modules'; /* used to find the corresponding