How to execute Javascript function in C ++

Please tell me how to include a javascript header file or javascript function in C ++ code. C ++ code written in Linux (UBUNTU)?

Although I need to perform the action just described, but let me tell you about my goal to do this, because I intend to implement CTI (Computer Telephony Integration) integration.

(Help will be appreciated) Thanks a lot in advance

+4
source share
4 answers

Calling script functions from C ++

http://clipp.sourceforge.net/Tutorial/back_calling.html

JavaScript calls from C ++ - CodeGuru

http://www.codeguru.com/cpp/in/ieprogram/article.php/c4399/JavaScript-Calls-from-C.htm

JavaScript call from C ++ - CodeProject

http://www.codeproject.com/KB/COM/jscalls.aspx

javascript call from C ++ code - JavaScript / Ajax / DHTML answers

http://bytes.com/topic/javascript/answers/759793-calling-javascript-c-code

Try it all above.

+9
source

You might want to port your JS to C ++; this should be a fairly simple task, as these two languages ​​are moderate.

A simple function transfer is likely to be much simpler than actually trying to use the JS parsing library and is probably less error prone.

+6
source

JavaScript is not a compiled language and, for any part of the imagination, it is not compatible with C ++, so #include has no chance to import JavaScript code. Actually the concept of a header file does not even exist in JavaScript.

There are several JavaScript engines that can be integrated into a compiled language, including:

+6
source

A detailed guide on embedding JS in C ++ using Mozilla SpiderMonkey can be found here . Basically you need to enable jsapi.h, create / configure / clear the JS engine, as the tutorial describes (filling the char * script with your JS_EvaluateScript source code), and then a link to the SpiderMonkey library when creating the executable for your system. Note that this guide explains how to call C functions from JS and how to call specific JS functions from C, which is also interesting and perhaps more suitable for the OP situation.

+2
source

Source: https://habr.com/ru/post/1308020/


All Articles