Skip to content

Commit c779cc0

Browse files
committed
fix 0.11 compat c++ example
1 parent f521177 commit c779cc0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,27 @@ Persistent<Function> constructor = Persistent<Function>::New(isolate, tpl->GetFu
2929
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:
3030
3131
```c++
32-
// node::node_isolate can be used to fetch a reference to Node's Isolate
3332
// NODE_MODULE_VERSION was incremented for v0.11
3433
3534
#if NODE_MODULE_VERSION > 0x000B
3635
# define MY_NODE_ISOLATE_DECL Isolate* isolate = Isolate::GetCurrent();
37-
# define MY_NODE_ISOLATE node::node_isolate
38-
# define MY_NODE_ISOLATE_PRE node::node_isolate,
39-
# define MY_NODE_ISOLATE_POST , node::node_isolate
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);
4040
#else
4141
# define MY_NODE_ISOLATE_DECL
4242
# define MY_NODE_ISOLATE
4343
# define MY_NODE_ISOLATE_PRE
4444
# define MY_NODE_ISOLATE_POST
45+
# define MY_HANDLESCOPE v8::HandleScope scope;
4546
#endif
4647
4748
MY_NODE_ISOLATE_DECL
48-
HandleScope scope(MY_NODE_ISOLATE);
49+
MY_HANDLESCOPE
50+
4951
// ...
52+
5053
Persistent<Function> constructor = Persistent<Function>::New(MY_NODE_ISOLATE_PRE tpl->GetFunction());
5154
```
5255

0 commit comments

Comments
 (0)