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. I hope to have this fixed soon.

Properties
  • Connected: Boolean When true the object is connected to an instance of TJSEngine, permitting interaction with script code.
  • Destroying: Boolean Developers should not need to access this property. It is used when an instance of TJSEngine is shut down.
  • Engine: TJSEngine Use this property to access the engine to which the TJSFunction is 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 current TJSFunction is accessible. If no parent was assigned when the TJSFunction was created it will default to TJSEngine.Global.
Methods
  • constructor Create(AValue: PJSObject; AEngine: TJSEngine; const AName: string); Developers should not create instances of TJSFunction at this time.
  • constructor Create(AValue: PJSObject; AEngine: TJSEngine; const AName: string; AParent: TJSObject); Developers should not create instances of TJSFunction at 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 parameters params, and attempts to return a value into the second parameter. If the method returns false the 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 returns false the call, or the return value conversion, failed.
  • procedure Connect(AEngine: TJSEngine; AName: string; AParent: TJSObject); procedure Connect(AEngine: TJSEngine; AName: string); Connects the TJSFunction to the engine. The first declaration will assign the javascript object to the specified scope, while the second will default the scope to global.