Bridge Classes: TJSBridge

Native Delphi/Kylix classes can inherit from this base type to become seamlessly available to javascript. All that is required is an instance of TJSEngine, and a name, passed to the constructor. If you do not want to connect to javascript at creation time, simply pass the TJSEngine instance and name to the Connect method whenever it is convenient to do so.

Properties
  • _FConnected: Boolean When true the object is connected to an instance of TJSEngine, permitting interaction with script code.
  • _FContext: PJSContext Only advanced developers should use this property. It can be used with SpiderMonkey API calls.
  • _FEngine: TJSEngine Use this property to access the engine to which the TJSBridge is connected.
  • _FParent: TJSObject Accesses the parent javascript object containing the bridge instance.
  • _FJSObject: PJSObject Only advanced developers should use this property. It can be used with SpiderMonkey API calls.
Methods
  • function _GetMethodResult(const AName: TBridgeString): TResultType; Developers should not use this method. Returns the stored result type for the method AName, if available.
  • function _GetParamCount(const AName: TBridgeString): Integer; Developers should not use this method. Returns the stored number of parameters for the method AName, if available.
  • function _GetProperty(AName: PChar): jsval; Developers should not use this method. It is used by SpiderMonkey callback routines in jsbridge_pvt.pas.
  • function _HasMethodInfo(const AName: TBridgeString): Boolean; Developers should not use this method. Returns true if method information is available for the method AName.
  • procedure _SetMethodInfo(const AName: TBridgeString; ParamCount: Integer; ResultType: TResultType); Allows developers to set the number of parameters and the return type, if any, for the method name. Note: This method must be called for each function callable by javascript.
  • function _SetProperty(AName, AValue: PChar): JSBool; Developers should not use this method. It is used by SpiderMonkey callback routines in jsbridge_pvt.pas.
  • function Connect(AEngine: TJSEngine; const AInstanceName: string): Boolean; Connects the bridge object to the TJSEngine instance. The bridge is attached to the global javascript object.
  • function Connect(AEngine: TJSEngine; const AInstanceName: string; AParent: TJSObject): Boolean; Connects the bridge object to the TJSEngine instance. The bridge is attached to the specified parent javascript object.
  • constructor Create; overload; virtual; Creates a default, disconnected instance of a bridge object.
  • constructor Create(AEngine: TJSEngine; const AInstanceName: string); overload; virtual; Creates a connected bridge object, and attaches it to the global javascript scope.
  • constructor Create(AEngine: TJSEngine; AParent: TJSObject; const AInstanceName: string); overload; virtual; Creates a connected bridge object, and attaches it to the specified parent javascript object.
  • procedure Disconnect; Disconnects the object from the live javascript connection. A new connection can be made at any time following a disconnection.