rajat
rajat

Reputation: 3553

Calling JavaScript from C++

I have a JavaScript class, that I don't want to port to C++ as it is too huge and complicated. Is Is there any way in which I could call JavaScript functions from inside my C++ code.

Upvotes: 0

Views: 1528

Answers (4)

jli
jli

Reputation: 6623

You could embed a JavaScript engine, such as V8. It's a pretty (very) big overhead though. Unless you have a specific need, it would probably be better to just port your code.

Upvotes: 2

Puppy
Puppy

Reputation: 147028

You can use the V8 library to call JavaScript code from C++.

Upvotes: 1

xxbbcc
xxbbcc

Reputation: 17346

Unless you have a very specific requirement that forces you to do this, this would be a very bad idea. It'll have a terrible overhead (in terms of execution speed and memory usage). You should seriously consider porting your Javascript code to C++.

Upvotes: 1

fat
fat

Reputation: 5579

I suggest you to check out Google's V8 a C++ Javascript Engine used in Chrome http://code.google.com/p/v8/

Upvotes: 2

Related Questions