wxjs
generated from ../src/engine/engine.cppwxjs is the global object of the JavaScript runtime. Each script is run with its own global object named script. This is done to make sure that variables don't polute the global object. The global object of the runtime can be reached by using 'wxjs' like in 'wxjs.print'. The script global object contains properties like 'root'.
Constants
Methods
construct
construct(Class,
...) : Object
| Name | Type | Default | Description |
|---|---|---|---|
| Class | String | The name of the class | |
| ... | Arguments to pass to the original constructor |
Use this to dynamically construct an object at run-time giving a classname as a string. Some examples:
// Samples with wxJavaScript classes
var dlg = construct("wxDialog", null, -1, "test");
var db = construct("sqlite.Database", "test.db");
// A sample with a simple JavaScript object
function test(arg)
{
this.prop = arg;
}
var t = construct("test", "propertyValue");
// A sample with a namespace object created in JavaScript
var ns = new Object();
ns.Database = function(name)
{
this.name = name;
}
var db1 = new ns.Database("test1");
var db2 = construct("ns.Database", "test1"); // Is the same as above.
exit
exit()
Exit the script
include
include(File,
Encoding = UTF-8) : Script
| Name | Type | Default | Description |
|---|---|---|---|
| File | String | The name of the file that contains the script | |
| Encoding | String | UTF-8 |
include(Obj,
File,
Encoding = UTF-8)
| Name | Type | Default | Description |
|---|---|---|---|
| Obj | Object | Functions and variables are attached to this object | |
| File | String | The name of the file that contains the script | |
| Encoding | String | UTF-8 |
Executes the given script. It returns the SpiderMonkey build-in Script object.
All local values defined in the script are properties of this script object. Variables
that are defined without the 'var' keyword, are defined on the global object.
When the filename is relative, the file will be searched in the path of the current
executed script.
namespace
namespace(Name)
| Name | Type | Default | Description |
|---|---|---|---|
| Name | String | A namespace |
This method provides a way of using namespaces in JavaScript. A namespace is actually a simple Object instance. An hierarchy is defined using the dot in the names. For example: db.client will define the 'db' namespace and 'client' as the child namespace of 'db'. Be careful in the names used, because reserved keywords are not allowed.
print()
Use this function to print information to stdout. An example:
var i = 1;
print("Test: ", i);
© 2002 - 2007 Franky Braem.