mozdev.org

Delphi 

projects:
resources:
<- Back

Frequently Asked Questions

What Does The Bridge Do? The bridge connects an application written in Delphi with the Mozilla Foundation's JavaScript engine thus providing scriptability.

Why Use This Bridge? or What Is So Great About SpiderMonkey?
Let us first acknowledge the other great scripting products out there. Products such as Innerfuse Pascal Script 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. The Mozilla Foundation 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 the code is tested using a performance tuner and memory leak evaluator. Unfortunately we can't certify the code or provide any guarantees as to its reliability. We can only tell you that we would use each release in our 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 script interactivity begins with this component and all of the other classes depend on it. 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, 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 JavaScript. Any change to the string will be reflected in the other codespace.
  • TJSInteger
    This creates an integer that is interactive with both Delphi and JavaScript. Any changes to this integer are reflected in the other codespace.
  • TJSDouble
    Exactly like TJSInteger and TJSString, except as a floating point number.
  • TJSBoolean
    Exactly like TJSInteger and TJSString but now the value is a boolean.
  • TJSArray
    This class is still in the beta stage. If you can help stabilize it, please do so. In the meantime, play with it, but don't depend your application on it.
  • TJSFunction
    This class is listed last 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 Compilers Does The Bridge Work With? The bridge code works with Borland Delphi and Borland Kylix. We are working on FreePascal support and hope to be fully compatible soon (requires a 1.9.x compiler).

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 working on FreePascal support which will add 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.

The delphi project can be contacted through the mailing list or the member list.
Copyright © 2000-2017. All rights reserved. Terms of Use & Privacy Policy.