The Environment provides base functions for all script interpreters. It is automatically loaded by any interpreter upon startup.
Method | Description |
---|---|
execute() | Execute script code. |
exit() | Terminates script execution immediately. |
getScriptEngine() | Get the current script engine instance. |
help() | Open help page on addressed topic. |
include() | Include and execute a script file. |
loadJar() | Add a jar file to the classpath. |
wrap() | Creates wrapper functions for a given java instance. |
Execute script code. This method executes script code directly in the running interpreter. Execution is done in the same thread as the caller thread.
Parameter | Type | Description |
---|---|---|
data | Object | code to be interpreted |
Returns:Object ... result of code execution
void exit([Object value])
Terminates script execution immediately. Code following this command will not be executed anymore.
Parameter | Type | Description |
---|---|---|
value | Object | return code Optional: defaults to <null>. |
IScriptEngine getScriptEngine()
Get the current script engine instance.
Returns:IScriptEngine ... IScriptEngine instance
void help([String topic])
Open help page on addressed topic. If the given topic matches a method or field from a loaded module, the definition will be opened. If the topic is unknown, a search in the whole eclipse help will be launched.
Parameter | Type | Description |
---|---|---|
topic | String | help topic to open (typically a function name) Optional: defaults to <null>. |
Object include(String filename)
Include and execute a script file. Quite similar to eval(Object) a source file is opened and its content is executed. Multiple sources are available: "workspace://" opens a file relative to the workspace root, "project://" opens a file relative to the current project, "file://" opens a file from the file system. All other types of URIs are supported too (like http:// ...). You may also use absolute and relative paths as defined by your local file system.
Parameter | Type | Description |
---|---|---|
filename | String | name of file to be included |
Returns:Object ... result of include operation
void loadJar(Object location)
Add a jar file to the classpath. Contents of the jar can be accessed right after loading. location can be an URI, a path, a File or an IFile instance.
Parameter | Type | Description |
---|---|---|
location | Object | URI, Path, File or IFile |
void wrap(Object toBeWrapped)
Creates wrapper functions for a given java instance. Searches for members and methods annotated with WrapToScript and creates wrapping code in the target script language. A method named <instance>.myMethod() will be made available by calling myMethod().
Parameter | Type | Description |
---|---|---|
toBeWrapped | Object | instance to be wrapped |