开发者

Communication between C++ and JavaScript

I need help on implementing an interprocess communication mechanism between JavaScript and C++ code. Basicall开发者_开发技巧y 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.


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.


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.


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜