Node.js Addon Examples with V8 Version 3.22

294 views
Skip to first unread message

blazs

unread,
Sep 23, 2014, 3:48:26 AM9/23/14
to nod...@googlegroups.com
Hi,

I am looking for Node.js C++ Addon examples, written for v0.12 version of the Node.js --- the one that uses V8 version 3.22. There are major changes between V8 3.14 and V8 3.22, and I'd like to update my code for V8 3.22 as soon as possible.  Examples on the official GitHub repository are very simple and don't cover scenarios where, for instance, I would like to wrap a C++ object, say a vector, then expose functions on it that would allows one to create copies of that vector, etc.

Are there any Node.js v0.12 C++ Addon examples available?

Blaz.

Matt

unread,
Sep 23, 2014, 10:35:01 AM9/23/14
to nod...@googlegroups.com
Have you looked into using Nan? https://github.com/rvagg/nan

--
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+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/ec4dc460-b824-491f-a179-5a508ff76684%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fedor Indutny

unread,
Sep 23, 2014, 10:35:16 AM9/23/14
to nod...@googlegroups.com

blazs

unread,
Sep 23, 2014, 11:06:25 AM9/23/14
to nod...@googlegroups.com, fe...@indutny.com
Thanks, this is helpful! Dramatic changes in the V8 API are giving me a headache.

Suppose I have the following scenario. I wrapped a C++ object v of type NodeJsVec and I want an operation shuffle() so that var w = v.shuffle(); gives me a new vector w, which is a randomly shuffled vector v. How do I return a new instance from C++ callback? (Just to be clear: I want w and v to be different vectors, and I want the C++ callback for v.shuffle() to create the new vector.)

Fedor Indutny

unread,
Sep 23, 2014, 1:20:19 PM9/23/14
to blazs, nod...@googlegroups.com
I'd certainly recommend using nan.

However, in the new V8 API it'll look this way:

args.GetReturnValue().Set(...)

blazs

unread,
Sep 25, 2014, 6:08:26 AM9/25/14
to nod...@googlegroups.com, blaz....@gmail.com, fe...@indutny.com
Thanks, I'll keep that in mind. And there is no documentation like Addons v0.10 for the 0.12 version? 

Rod Vagg

unread,
Sep 25, 2014, 11:24:56 PM9/25/14
to nod...@googlegroups.com, blaz....@gmail.com, fe...@indutny.com

Switch to the v0.12 branch and you'll find up to date docs: https://github.com/joyent/node/blob/v0.12/doc/api/addons.markdown

Note also that I only recently updated the node-addon-examples repo so it now has these examples implemented in parallel for v0.10, v0.12 and nan: https://github.com/rvagg/node-addon-examples

I removed the async example but will be working on putting a new one up some time.

 -- Rod

blazs

unread,
Sep 26, 2014, 4:54:33 AM9/26/14
to nod...@googlegroups.com, blaz....@gmail.com, fe...@indutny.com
Rod, thanks, this is exactly what I was looking for.
Reply all
Reply to author
Forward
0 new messages