views:

211

answers:

3

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

Although i need to perform the above action only, but let me tell u my purpose of doing it, as i am intending to implement CTI (Computer Telephony Integration) operation.

(Help will be appreciated) Thanks a lot in advance

+4  A: 

You might want to port your JS to C++; this should be a fairly simple task, as the two languages are moderately alike.

Simply porting the functionality is likely to be far simpler than actually trying to use a JS parsing library, and likely less error prone.

Williham Totland
That's a good suggestion... also C# 4.0 is scarily close to JavaScript - just make all functions return a 'dynamic' and you're almost there.. see http://channel9.msdn.com/pdc2008/TL16/
JBRWilkinson
+4  A: 

Calling Scripting functions from C++

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

JavaScript Calls from C++ - CodeGuru

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

JavaScript call from C++ - CodeProject

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

calling javascript from c++ code - JavaScript / Ajax / DHTML answers

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

Try All of above this.

ratty
@gf ya i converted
ratty
+4  A: 

JavaScript is not a compiled language and it is not, by any stretch of the imagination, compatible with C++, so #include doesn't stand a chance of importing JavaScript code. In fact, the notion of a header file doesn't even exist in JavaScript.

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

  1. The Mozilla project's SpiderMonkey.
  2. Google Chrome's V8.
  3. A whole bunch of others.
Marcelo Cantos