Skip to content

Commit 633c47d

Browse files
author
Gabriel Schulhof
committed
Provide alternative for v8::Private and backport NODE_RELEASE
Fixes: #116 PR-URL: #115 Reviewed-By: Michael Dawson <[email protected]>
1 parent ca92548 commit 633c47d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/node_internals.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,10 @@ NO_RETURN void FatalError(const char* location, const char* message) {
9595
}
9696

9797
} // namespace node
98+
99+
#if NODE_MAJOR_VERSION < 6
100+
v8::Local<v8::Name> v8::Private::ForApi(v8::Isolate* isolate,
101+
v8::Local<v8::String> key) {
102+
return v8::Symbol::ForApi(isolate, key);
103+
}
104+
#endif // NODE_MAJOR_VERSION < 6

src/node_internals.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// This is a stripped down shim to allow node_api.cc to build outside of the node source tree.
66
//
77

8+
#include "node_version.h"
89
#include "util-inl.h"
910
#include <stdio.h>
1011

@@ -52,6 +53,10 @@
5253
#define NO_RETURN
5354
#endif
5455

56+
#ifndef NODE_RELEASE
57+
#define NODE_RELEASE "node"
58+
#endif
59+
5560
namespace node {
5661

5762
// The slightly odd function signature for Assert() is to ease
@@ -67,4 +72,18 @@ NO_RETURN void FatalError(const char* location, const char* message);
6772

6873
} // namespace node
6974

75+
#if NODE_MAJOR_VERSION < 6
76+
namespace v8 {
77+
namespace Private {
78+
v8::Local<v8::Name> ForApi(v8::Isolate* isolate, v8::Local<v8::String> key);
79+
}
80+
}
81+
#define GetPrivate(context, key) Get((context), (key))
82+
#define SetPrivate(context, key, value) \
83+
DefineOwnProperty((context), (key), (value), \
84+
static_cast<v8::PropertyAttribute>(v8::DontEnum | \
85+
v8::DontDelete | \
86+
v8::ReadOnly))
87+
#endif // NODE_MAJOR_VERSION < 6
88+
7089
#endif // SRC_NODE_INTERNALS_H_

0 commit comments

Comments
 (0)