user718517
user718517

Reputation: 11

Communication between C++ and JavaScript

I need help on implementing an interprocess communication mechanism between JavaScript and C++ code. Basically I need to make a bidirectional communication. So JavaScript should be able to send and receive message from C++ (Win 32) code and vice versa.

Upvotes: 1

Views: 3711

Answers (4)

aeon
aeon

Reputation: 1069

I presume you are doing this on a Windows OS. Does any kind of IPC help or are you specific on anything? Try named pipes; or shared memory with a sync object; or try a common file system memory, such as a binary file with a sync object to access it (although this is not recommended but is sure an option). You may also create COM objects / ActiveX controls and access this from JavaScript (browser).

Upvotes: 0

maerics
maerics

Reputation: 156434

You should look at Google's V8 JavaScript runtime, which powers their Chrome browser, it is implemented in C++. JSON libraries will simplify de/serialization.

Upvotes: 2

Tamás Szelei
Tamás Szelei

Reputation: 23921

If you have the option of using Qt, I strongly recommend it. It's comprehensive and well tested. QtScript module. QtScript is a superset of javascript. The implementation uses Webkit's javascript core.

Upvotes: 1

Greg Hewgill
Greg Hewgill

Reputation: 993095

Qt contains the QtScript module, which is a native C++ implementation of JavaScript. I've used this successfully to script a C++ application, with communication in both directions.

If you're curious, the code is part of my HP 15C simulator project.

Upvotes: 1

Related Questions