Binding with Javascript C ++?

I have C ++ code that I want to open on the client side of a web application. Ideally, I want to write Javascript shell objects for my C ++ classes so that I can use their clientide.

Was this done before ?. Does anyone have a link to show how this can be achieved?

+7
source share
9 answers

There is a library for converting C ++ code to javascript, this may help: emscripten

+2
source

Libjspp C ++ templated shell for embedding and expanding Jaidcript engine spidermonkey 1. 8. 5 and more

Spidermonkey this is Mozilla Project Javascript / ECMAScript.

Libjspp allows C ++ developers to embed SpiderMonkey? simple and easy in their applications. Libjspp allows you to run multiple Javascript engines in the same process, which fits one engine per thread in ten, which is useful for achieving true parallisim. In addition, Libjspp in no way stops the user from starting multiple threads inside the engine.

http://code.google.com/p/libjspp/

+1
source

This is an old swamp, but I was in the exact situation right now, and all the solutions that I found on the network were complicated or outdated.

Recently, I came across a library that supports the V8 engine (including the new isolation API, which accounts for 90% of the libraries I found obsolete) and provides an excellent interaction and interaction API.

https://github.com/QuartzTechnologies/v8bridge

I hope my solution will help anyone.

+1
source

There's a relatively new library for this called nbind . Maybe this will suit you? It looks very good to me, and I'm about to start using it.

+1
source

I think you need a single C ++ JSON. You should find it here http://www.json.org/ . It may not do everything you need, because it just serializes and deserializes C ++ objects without any behavior, but it should be good enough. See https://stackoverflow.com/questions/245973/whats-the-best-c-json-parser for a discussion.

0
source

If C ++ code should be on the client, then there is no easy way to do this for a web application. The solution may include coding plugins for the browsers you want to support, which can then be accessed from javascript code.

If, for example, it is necessary for a client application, this is a different case. This was done and associated with binding your application to (or running from the outside), for example, using the chrome library or any other JavaScript execution mechanism. This way you can create bindings to C ++ classes and use such objects from javascript and vice versa. Please note that this is also not a trivial solution and may require a lot of effort (additional resources are also required).

0
source

You can, for example, wrap C ++ classes in PHP or Python, and then implement the API via HTTP to access the required functions.

Or, if you insist on exposing JavaScript functions, you can try using Node.js and create a C ++ add-on to port classes. See Node.js Documentation: http://nodejs.org/api/addons.html#addons_wrapping_c_objects

But in any case, I don’t think that you need to create some kind of API (HTTP SOAP, XML RPC) to access the functions on your server.

0
source

I think RPC is what you want. You will need to wrap your functions on the server side using some kind of structure. I haven't used it yet, but this one looks promising.

On the client side, you use proxy objects to send function calls. Communication is usually processed either through XML-RPC or JSON-RPC. I used this client structure and was quite satisfied, but I am sure that you will find many others .

0
source

Although QML is not exactly Javascript, Qt is not simple C ++, but what they do together seems to be what you need.

0
source

All Articles