0

I need to expose C++ classes (packed as shared libraries) to the magic world of JavaScript.

The most obvious solution is to use Node.js/v8. Problem is that it has to run on PowerPC (please no comments on this...) and - alas! - v8 doesn't run on PowerPC (the v8-powerpc project seems to be dead).

I'm trying to understand if there's any other viable solution, at the moment some possibilities are:

  1. emscripten, which converts LLVM bitcode into JavaScript;
  2. WebKit's JavaScriptCore, although I'm not sure it will work (I'll have WebKit on the PowerPC anyway)

I'm not a JavaScript expert and I actually feel quite lost, so these are my questions:

  1. Is emscripten a valid solution? (have you ever used it?)
  2. Can anyone point me to any documentation on how to expose C++ to JavaScript using JavaScriptCore?
  3. Is there any other option, and/or which one would you adopt?

Many thanks,

Rippel

rippeltippel
  • 369
  • 1
  • 7
  • 15
  • Just for clarity, the objective is to write a JavaScript application (running on a JS engine) using the C++ libraries. – rippeltippel Jun 22 '12 at 14:17

4 Answers4

1

Qt has a port of webkit that runs on powerpc and it has a javascript engine that allows you to call C++ code.

Qt: Making Applications Scriptable

jlunavtgrad
  • 997
  • 1
  • 11
  • 21
0

You can use Emscripten. And I have used it and am using it. Problems are:

  • The JS/C community is IMO kind of suspicious/vary about Emscripten so you might not get much support there (usually the #emscripten IRC channel is pretty helpful).
  • Emscripten compiles code fairly easy/well but you need to have a decend understanding of C to get a working solution. You will probably have to rewrite certain parts of your code to get it working as expected by your JavaScript engine (stuff like using main_loop, callbacks, etc.).
  • Using Node.js you could also try to use the synchronous file api (see http://nodejs.org/api/fs.html) - but I fear you would have to change the Emscripten file access emulation, as it is mostly coded for Browser usage, right now.
abergmeier
  • 13,224
  • 13
  • 64
  • 120
0

JavaScriptCore has JSObjectMakeFunctionWithCallback(). It looks like this potentially involves a lot of boilerplate code to convert arguments in and exceptions out, though.

tc.
  • 33,468
  • 5
  • 78
  • 96
0

Now Node.js DOES run on PowerPC. See this github link (I think it runs on any system with a powerpc processor that runs linux.

alexcat3
  • 11
  • 1