Delphi
| projects: | Home Articles JavaScript Bridge |
|---|---|
| resources: | Bugs Mailing List Source Code Sidebar |
Bridge Classes: TJSFunction
An object of this class wraps a JavaScript function which was added via TJSObject.AddMethod.
This object currently cannot be retrieved dynamically from the bridge APIs, though the JavaScript function
remains declared. We hope to have this fixed soon.
Properties
- Connected: Boolean
When true the object is connected to an instance ofTJSEngine, permitting interaction with script code. - Destroying: Boolean
Developers should not need to access this property. It is used when an instance ofTJSEngineis shut down. - Engine: TJSEngine
Use this property to access the engine to which theTJSFunctionis connected. - JScriptVal: jsval
Only advanced developers should use this property. It can be used in SpiderMonkey callback functions, or API calls, for instance. - JSName: string
This is the name associated with the variable in JavaScript. - JSObject: PJSObject
Only advanced users should use this property. A developer can use this value when working with the SpiderMonkey API. - Parent: TJSObject
The parent is the scope from which the currentTJSFunctionis accessible. If no parent was assigned when theTJSFunctionwas created it will default toTJSEngine.Global.
Methods
- constructor Create(AValue: PJSObject; AEngine: TJSEngine; const AName: string);
Developers should not create instances ofTJSFunctionat this time. - constructor Create(AValue: PJSObject; AEngine: TJSEngine; const AName: string; AParent: TJSObject);
Developers should not create instances ofTJSFunctionat this time. - function Call(params: array of TJSBase; var str: string): Boolean;
function Call(params: array of TJSBase; var int: Integer): Boolean;
function Call(params: array of TJSBase; var dbl: Double): Boolean;
function Call(params: array of TJSBase; var res: TJSObject): Boolean;
function Call(params: array of TJSBase; var bool: Boolean): Boolean;
These methods call the JavaScript function wrapped by this object with parametersparams, and attempts to return a value into the second parameter. If the method returnsfalsethe call, or the return value conversion, failed. - function Call(var str: string): Boolean;
function Call(var int: Integer): Boolean;
function Call(var dbl: Double): Boolean;
function Call(var res: TJSObject): Boolean;
function Call(var bool: Boolean): Boolean;
These methods call the JavaScript function wrapped by this object with no parameters, and attempts to return a value into the given parameter. If the method returnsfalsethe call, or the return value conversion, failed. - procedure Connect(AEngine: TJSEngine; AName: string; AParent: TJSObject);
procedure Connect(AEngine: TJSEngine; AName: string);
Connects theTJSFunctionto the engine. The first declaration will assign the JavaScript object to the specified scope, while the second will default the scope to global.