@@ -3,54 +3,22 @@ Node.js Addon Examples
33
44See the Node.js C++ [ addons page] ( http://nodejs.org/docs/latest/api/addons.html ) for details of the examples here.
55
6- In each directory, run :
6+ Each directory contains a subdirectory for :
77
8- ``` sh
9- $ node-gyp rebuild
10- $ node ./
11- ```
12-
13- ** See the [ v0.11] ( https://github.com/rvagg/node-addon-examples/tree/v0.11/ ) branch for updated examples applicable to Node v0.11 and above.**
8+ * ** Node 0.10** : Mostly compatible with Node 0.8 and even 0.6, older style V8 programming
9+ * ** Node 0.12** : Newer style V8 programming, compatible with Node 0.11+
10+ * ** NAN** : The example rewritten using [ NAN] ( https://github.com/rvagg/nan/ ) for compatibility with Node 0.8 -> 0.11+
1411
15- ## Compatibility notes
12+ You will need [ node-gyp ] ( https://github.com/TooTallNate/node-gyp/ ) installed as a global:
1613
17- ### Node v0.11: V8 requires current isolate
18-
19- The V8 upgrade that occured when v0.11 was released requires that the current * isolate* be passed to scope creation calls and most ` New() ` calls.
20-
21- ``` c++
22- Isolate* isolate = Isolate::GetCurrent();
23- // ...
24- HandleScope scope (isolate);
25- // ...
26- Persistent<Function > constructor = Persistent<Function >::New(isolate, tpl->GetFunction());
14+ ``` text
15+ $ sudo npm install node-gyp -g
2716```
2817
29- Omission of the current isolate will only trigger a compile-time warning at this stage but addon authors wishing to remove those warnings and remain backward-compatible with v0.10 and prior may need to get creative with macros:
30-
31- ```c++
32- // NODE_MODULE_VERSION was incremented for v0.11
18+ In each example directory, run:
3319
34- #if NODE_MODULE_VERSION > 0x000B
35- # define MY_NODE_ISOLATE_DECL Isolate* isolate = Isolate::GetCurrent();
36- # define MY_NODE_ISOLATE isolate
37- # define MY_NODE_ISOLATE_PRE isolate,
38- # define MY_NODE_ISOLATE_POST , isolate
39- # define MY_HANDLESCOPE v8::HandleScope scope(MY_NODE_ISOLATE);
40- #else
41- # define MY_NODE_ISOLATE_DECL
42- # define MY_NODE_ISOLATE
43- # define MY_NODE_ISOLATE_PRE
44- # define MY_NODE_ISOLATE_POST
45- # define MY_HANDLESCOPE v8::HandleScope scope;
46- #endif
47-
48- MY_NODE_ISOLATE_DECL
49- MY_HANDLESCOPE
50-
51- // ...
52-
53- Persistent<Function> constructor = Persistent<Function>::New(MY_NODE_ISOLATE_PRE tpl->GetFunction());
20+ ``` text
21+ $ npm install
22+ $ node-gyp rebuild
23+ $ node ./
5424```
55-
56- ----------------------------------------------------
0 commit comments