This is a tutorial for writing node.js modules in C++. It is the base and reference for my talk on writing node.js modules with V8 at JSConf 2011 in Berlin.
Further references:
Guide for writing C++ node.js extensions
Home Page: http://kkaefer.github.com/node-cpp-modules/
This is a tutorial for writing node.js modules in C++. It is the base and reference for my talk on writing node.js modules with V8 at JSConf 2011 in Berlin.
Further references:
I have some work to do in AsyncWork, like transforming c struct into v8::Object. So I have to write v8 code in AsyncWork.
How can I manage this?
in 06_objects/run.js , if I change:
var obj = new modulename.MyObject(42);
to:
var obj = modulename.MyObject(42);
I get:
Assertion failed: (handle->InternalFieldCount() > 0), function Wrap, file ../src/node_object_wrap.h, line 62.
naturally, this is not the intended usage, but a Javascript error would be nicer than a c++ assertion failure
https://strongloop.com/strongblog/node-js-v0-12-c-apis-breaking/
If the examples will not be fixed for this the main readme should at least have a link there.
shouldn't we close the scope in AsyncAfter since we also opened one?
Why assign the baton to baton.request when you can also assign the baton to you uv_workt_t request? Or is this just convention?
I really appreciate this tutorial, excellent work, and so necessary.
It'd be helpful to have a folder with a complete module template including:
And provide limited comments to document where the user should add further definitions and logic.
If you like the idea, I'd be glad to submit patches...
Problem 1)
You call ObjectWrap::Unwrap, which grabs the original pointer from This().
Shouldn't it be using Holder() and not This() ?
Problem 2)
Your 06_objects example is missing a critical part of the example - v8::Signature for type safety.
see line 489 here:
https://github.com/laverdet/node-fibers/blob/master/src/fibers.cc
Problem 3)
You create a Persistent global handle for constructor, and then do nothing with it.
This example also won't work for other v8 embedders who might be using v8 in multiple Isolates and threads.
Instead, it should be a plain Local handle (no global constructor handle), and use the Signature technique to ensure type safety.
I see your node-blend, and it use a eio_req instead what you presentation said uv_work_t, I want to know what's the different between them.
Thanks a lot.
The README.md files for the examples say to run:
npm build
Doing this does nothing on node.js 0.10.26. However, if you do:
node-gyp configure
node-gyp build
It builds the C++ and then do:
node run.js
You are able to use the examples. You may want to update the docs since in general the people using these examples are total newbs to building native C++ extensions for node (like me!). Thanks a lot for contributing these examples.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.