Frequently Asked Questions


What Does The Bridge Do? Why Use This Bridge? or What Is So Great About SpiderMonkey? Is The Delphi Code Stable? What Classes Are Available And How Do They Help Me? What Support Options Do I Have? What Platforms Does The Bridge Work On? How Do I Start?


What Does The Bridge Do? The bridge connects an application written in Delphi with scriptability. Why Use This Bridge? or What Is So Great About SpiderMonkey? Let me first acknowledge the other great scripting products out there. Products such as Innerfuse Pascal Script III by Carlo Kok; PaxScript by Alexander Baranovsky (which supports multiple scripting languages); Delphi Web Script, and others.

The reason SpiderMonkey is a good choice is due to its stability. It is the oldest, most heavily tuned engine available. It is also supported by dozens of engineers in the open source community. Mozilla releases new versions of the engine regularly which improve speed, reliability, and conformability to the ECMA-262 Edition 3 standard.
Is The Delphi Code Stable? This is, of course, use-at-your-own-risk code, but before each public release I test the code using a performance tuner and memory leak evaluator. I make every effort to eliminate memory leaks. Unfortunately I can't certify the code or provide any guarantees as to its reliability. I can only tell you that I would use each release in my own applications. What Classes Are Available And How Do They Help Me? There are several classes included in this package, designed to integrate Delphi and SpiderMonkey as tightly as possible. These are:
  • TJSEngine    All scripting interactivity begins with this component. All of the other classes depend on this. If your application is multithreaded, you'll create a new instance of TJSEngine for each thread.

  • TJSScript    This class provides methods for compilation, execution, serialization, and deserialization of JavaScript code. Methods are also available for loading, saving, and streaming both raw and compiled code.

  • TJSBridge    This class is intended to extend existing TObject descendents (or classes with no explicit inheritance) with instant script interactivity. Declare any Delphi object as a descendent of TJSBridge, then publish all the properties and methods you want scriptable, and then connect it to a TJSEngine.

  • TJSObject    Most of your Delphi-to-script code will deal with TJSObject's. These essentially expose JavaScript objects to Delphi code. From here you can call functions, evaluate object-scope code, get and set properties, etc.

  • TJSString    This creates a string that is interactive with both Delphi and script. Any change to the string will be reflected in the other codespace.

  • TJSInteger    This creates an integer that is interactive with both Delphi and script. Any changes to this integer are reflected in the other codespace.

  • TJSDouble    Exactly like TJSInteger, except as a floating point number.

  • TJSBoolean    Exactly like TJSInteger, but now the value is a boolean.

  • TJSArray    This class is still in the beta stage -- it isn't quite there yet. If you can help stabilize it, then please do so. In the meantime, play with it, but don't depend your application on it.

  • TJSFunction    I'm putting this class at the end because it's kinda flaky. A TJSFunction is not retrievable when it goes out of scope. You may create one, but the TJSFunction instance can not be recovered by another scope. The good news is your function will not disappear -- it remains callable from the scope you specified, it's only the TJSFunction instance that gets "lost".
What Support Options Do I Have? Since this is a free-time-only project we don't have plans to spend a lot of time helping people out. At the same time, if you post to the mailing list we'll do our best to help. What Platforms Does The Bridge Work On? The bridge code presently works on Windows and Linux. If Borland ever ports Delphi to another platform then it's very likely that this code will work there as well. We are also considering a FreePascal version which would support several additional platforms. How Do I Start? Start by including the path to the bridge classes in your IDE's Library Path. (Tools | Environment Options | Library | Library Path) If you are using Windows, you will need MSVCR70.DLL and JS3215R.DLL in your Windows' Search Path or the directory where your application is run. Linux users will need libjs.so in their path or their application directory. To use the classes in a unit, you need to include jsintf in the uses clause. See the documentation on the bridge classes to understand what's available. Start with TJSEngine, the central component of your JavaScript interaction.