Discussion:
[nodejs] Embedded node, call c++ -> js
Al Izi
2018-07-03 14:54:23 UTC
Permalink
Let's say there is embedded node engine inside a C++ application. What is
the right way to call a js function from native code? I don't see any
exposed v8 interfaces (for instance v8::Isolate). Also how to start node in
this case? node::Start(argc, argv) starts node command loop and most
probably I even don't need one.
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0429a603-dde2-4568-a6e0-6f076a23639a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'sbusch' via nodejs
2018-07-04 08:54:13 UTC
Permalink
Hi,

you might be interested to have a look at this fork of node.js:
https://github.com/hpicgs/node

This was a student project last year, where the students created a library
interface for node.js for exactly that purpose. In short, you have much
more control over how you embed node.js into your C++ application, e.g.,
you can initialize node and just run a script, without invoking the main
loop at all, invoke the main loop later, or just call a function from a
node.js module from your C++ code. In general, you have fine-grained
control over the embedding and do not need to work with the node::Start()
function.

Usage examples can also be found here:
https://github.com/hpicgs/node-embed

There was also a pull request for this, which has been closed:
https://github.com/nodejs/node/pull/19005

I still think it would be a great step forward for node.js, if the
embedding interface would be improved to make it easier to integrate
node.js into C++-applications, and this questions pretty much exemplifies
this. There are more projects out there now, which embed node.js into their
applications, and right now the interface for that is pretty hard to use,
making it necessary to "hack your way around". The student project tried to
improve on that situation, and I think they have done a terrific job
(disclaimer: I was the supervisor for their project).

So maybe we could have another look at their proposal or at least at the
general idea of improving the interface for embedders?

Stefan
Post by Al Izi
Let's say there is embedded node engine inside a C++ application. What is
the right way to call a js function from native code? I don't see any
exposed v8 interfaces (for instance v8::Isolate). Also how to start node in
this case? node::Start(argc, argv) starts node command loop and most
probably I even don't need one.
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/3b72cd9f-f0ec-4cbf-bb9e-be17b6becff2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...