18

I'd like to embed the V8 JavaScript interpreter that ships with Google Chrome within my Delphi application. I'm aware of the chromium embedded open-source project from Google, but I'd like to know if anyone was aware of any Pascal/Delphi wrappers?

There is an example project included with the zip file on the site I linked, which is written in C++. If nothing else, I'll slowly and painfully work to convert it.

UPDATE:
I just want to embed the V8 JavaScript interpreter, not the Chromium browser.

3
  • 1
    Do you want to embed the Chronium browser or just the V8 javascript engine? Commented Feb 24, 2010 at 4:04
  • I just want to embed the V8 JavaScript engine...not the browser. Commented Feb 24, 2010 at 13:46
  • One year later: Did you get this to work? Commented May 10, 2011 at 2:39

6 Answers 6

3

The most ideal solution would be to create a wrapper, preferably which consumes the original source unmodified, and compile that wrapper to an OBJ file (using C++) which then is linked into Delphi, where another "wrapper" exposes the engine via a more standard object pascal syntax. This approach would then allow for changes in the engine without the need for a complete conversion each time new functionality or additional performance is added. The only disadvantage of this approach is that there will be some performance lost while navigating the layers...but I would expect it to be minimal.

Sign up to request clarification or add additional context in comments.

Comments

2

For the record: hgourvest has posted Delphi Chromium Embedded to Google Code.

Edit 2013-01-15:

Another project by the same author this time wrapping CEF3: DCEF3

Comments

2

Start from Jun 1, 2016, we have v8delphiwrapper, kudos to the developer @zolagiggszhou. And I'd like to show you some code example:

Run js code and return result as string:

Memo2.Text := FEngine.eval(Memo1.Text);

Accessing Delphi object from js:

1 - Assuming you have a Delphi class like this:

  TJsAccessableClass = class
  public
    function add(a,b: Double): Double;
    function httpEncode(const s: string): string;
  end;

2 - You register it with the v8 js engine:

  FObjectTemplate2 := FEngine.RegisterRttiClass(TJsAccessableClass);
  FJsAccessableObject := FObjectTemplate2.CreateInstance(TJsAccessableClass.Create);
  Fv8GlobalObject.SetObject('delphiObj', FJsAccessableObject);

3 - Now you can call your Delphi method from js:

var s = delphiObj.httpEncode('/~!f234');

Very cool! More example please check v8delphiwrapper sample project

Comments

1

If it is in fact Chrome as a browser you want to embed into your application, you should check out Google Chrome Frame, it exposes COM interfaces, primarily to integrate into Internet Explorer, but in theory we should be able to access them also.

(I'm not sure because I would like to have a go at this myself, but it's on a (long) list of really neat things to try when I get around to them.) Update: I've had a quick go at it, got a "No interface supported" error, and posted it here.

3 Comments

I think he is talking about the V8 interpreter not about the chrome frame. V8 can be used independly in any application, but we need a wrapper for Delphi.
Francis: I was really hoping he is talking about the V8 interpreter, and also that someone posts a better answer than mine... Does anyone know japanese? google.com/…
I am referring to the V8 interpreter.
1

1 Comment

Good info! I considered the SpiderMonkey Bridge (Malzilla uses it), but it is a few years old and I want something that'll work with the new unicode enabled versions of Delphi (2009 and 2010).
1

I've been using the SpiderMonkey bridge also, without any problems. Runs reasonably fast, without a huge footprint, and have had no Unicode issues yet!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.