Stale
This page has gone stale. It's not completely old and out of date but some of the ideas expressed here have been changed in favor of other ideas.
This document is here to outline the details of a conforming implementation of a monkeyscript environment.
A conforming implementation should build a monkeyscript or monkeyscript.exe (on MSWIN) binary. Considerations should be made that this is not the only environment that monkeyscript should be implemented in; An Apache mod_monkeyscript is planned for the near future after the initial coding of the project is stable, and monkeyscript should be available to be embedded into another program. Thus the source for the main binary should put the monkeyscript environment portions in a common area and the binary source should focus on the actual loading and execution of the environment from it's pov.
MonkeyScript's target platform is SpiderMonkey 1.8+, the spidermonkey for MonkeyScript should be built with the same options defined in JS_VERSION = 180 with the exception that JS_HAS_STR_HTML_HELPERS should be disabled. (JS_HAS_SCRIPT_OBJECT is a discussion point)
A few additional requirements over the normal JavaScript requirements are made:
- A read-only property global should be defined in the global scope refering to the global object (like window).
- undefined, NaN, and Infinite should be made read only. (see jslibs for implementation hints)
A _native property should be defined in the global scope containing:
- getEnv(name): A function which gets the string value of an environment variable.
- setEnv(name, value): A function which sets the string value of an environment variable.
exec(script, compile=true): A function which will execute a .js script within the current context and return the value of the last evaluated statement in the file. This should throw a LoadError if it could not find the script. Unless compile is set to false it should try to compile a script and save it to the disk, or make use of an already compiled script (provided it's timestamp is newer than the script file's). This can be done initially using XDR. No errors should be thrown if the user does not have permissions to save to the directory.
- currentWorkingDirectory: The working directory the binary was executed from. This should be setable and should change the working directory by doing so.
- libraryExt: The extension .so or .dll which library files use.
execLibrary(dll): Load a shared .so or .dll library. The compiled library should define functions and properties on the called this. So obj = {}; _native.execLibrary.call(obj, 'foo') would load all the stuff defined inside the library into obj.