Browse Source

src: unexport node_isolate

Commit 0bba5902 accidentally (or maybe erroneously) added node_isolate
to src/node.h and src/node_object_wrap.h.

Undo that, said variable is not for public consumption. Add-on authors
should use v8::Isolate::GetCurrent() instead.

I missed that while reviewing. Mea culpa.

Fixes #5639.
v0.11.3-release
Ben Noordhuis 12 years ago
parent
commit
4bb4f734b3
  1. 13
      src/node.h
  2. 29
      src/node_object_wrap.h

13
src/node.h

@ -86,8 +86,6 @@
namespace node { namespace node {
extern v8::Isolate* node_isolate;
NODE_EXTERN extern bool no_deprecation; NODE_EXTERN extern bool no_deprecation;
NODE_EXTERN int Start(int argc, char *argv[]); NODE_EXTERN int Start(int argc, char *argv[]);
@ -98,7 +96,8 @@ void Load(v8::Handle<v8::Object> process);
void EmitExit(v8::Handle<v8::Object> process); void EmitExit(v8::Handle<v8::Object> process);
#define NODE_PSYMBOL(s) \ #define NODE_PSYMBOL(s) \
v8::Persistent<v8::String>::New(node_isolate, v8::String::NewSymbol(s)) v8::Persistent<v8::String>::New(v8::Isolate::GetCurrent(), \
v8::String::NewSymbol(s))
/* Converts a unixtime to V8 Date */ /* Converts a unixtime to V8 Date */
#define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t)) #define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
@ -152,10 +151,10 @@ NODE_EXTERN ssize_t DecodeWrite(char *buf,
v8::Local<v8::Object> BuildStatsObject(const uv_stat_t* s); v8::Local<v8::Object> BuildStatsObject(const uv_stat_t* s);
static inline v8::Persistent<v8::Function>* cb_persist( static inline v8::Persistent<v8::Function>* cb_persist(v8::Local<v8::Value> v) {
const v8::Local<v8::Value> &v) {
v8::Persistent<v8::Function>* fn = new v8::Persistent<v8::Function>(); v8::Persistent<v8::Function>* fn = new v8::Persistent<v8::Function>();
*fn = v8::Persistent<v8::Function>::New(node_isolate, v8::Local<v8::Function>::Cast(v)); *fn = v8::Persistent<v8::Function>::New(v8::Isolate::GetCurrent(),
v.As<v8::Function>());
return fn; return fn;
} }
@ -167,7 +166,7 @@ static inline v8::Persistent<v8::Function>* cb_unwrap(void *data) {
} }
static inline void cb_destroy(v8::Persistent<v8::Function> * cb) { static inline void cb_destroy(v8::Persistent<v8::Function> * cb) {
cb->Dispose(node_isolate); cb->Dispose(v8::Isolate::GetCurrent());
delete cb; delete cb;
} }

29
src/node_object_wrap.h

@ -37,8 +37,6 @@
namespace node { namespace node {
extern v8::Isolate* node_isolate;
class NODE_EXTERN ObjectWrap { class NODE_EXTERN ObjectWrap {
public: public:
ObjectWrap ( ) { ObjectWrap ( ) {
@ -48,10 +46,11 @@ class NODE_EXTERN ObjectWrap {
virtual ~ObjectWrap ( ) { virtual ~ObjectWrap ( ) {
if (!handle_.IsEmpty()) { if (!handle_.IsEmpty()) {
assert(handle_.IsNearDeath(node_isolate)); v8::Isolate* isolate = v8::Isolate::GetCurrent();
handle_.ClearWeak(node_isolate); assert(handle_.IsNearDeath(isolate));
handle_.ClearWeak(isolate);
handle_->SetAlignedPointerInInternalField(0, 0); handle_->SetAlignedPointerInInternalField(0, 0);
handle_.Dispose(node_isolate); handle_.Dispose(isolate);
handle_.Clear(); handle_.Clear();
} }
} }
@ -71,15 +70,17 @@ class NODE_EXTERN ObjectWrap {
inline void Wrap (v8::Handle<v8::Object> handle) { inline void Wrap (v8::Handle<v8::Object> handle) {
assert(handle_.IsEmpty()); assert(handle_.IsEmpty());
assert(handle->InternalFieldCount() > 0); assert(handle->InternalFieldCount() > 0);
handle_ = v8::Persistent<v8::Object>::New(node_isolate, handle); v8::Isolate* isolate = v8::Isolate::GetCurrent();
handle_ = v8::Persistent<v8::Object>::New(isolate, handle);
handle_->SetAlignedPointerInInternalField(0, this); handle_->SetAlignedPointerInInternalField(0, this);
MakeWeak(); MakeWeak();
} }
inline void MakeWeak (void) { inline void MakeWeak (void) {
handle_.MakeWeak(node_isolate, this, WeakCallback); v8::Isolate* isolate = v8::Isolate::GetCurrent();
handle_.MarkIndependent(node_isolate); handle_.MakeWeak(isolate, this, WeakCallback);
handle_.MarkIndependent(isolate);
} }
/* Ref() marks the object as being attached to an event loop. /* Ref() marks the object as being attached to an event loop.
@ -89,7 +90,7 @@ class NODE_EXTERN ObjectWrap {
virtual void Ref() { virtual void Ref() {
assert(!handle_.IsEmpty()); assert(!handle_.IsEmpty());
refs_++; refs_++;
handle_.ClearWeak(node_isolate); handle_.ClearWeak(v8::Isolate::GetCurrent());
} }
/* Unref() marks an object as detached from the event loop. This is its /* Unref() marks an object as detached from the event loop. This is its
@ -103,7 +104,7 @@ class NODE_EXTERN ObjectWrap {
*/ */
virtual void Unref() { virtual void Unref() {
assert(!handle_.IsEmpty()); assert(!handle_.IsEmpty());
assert(!handle_.IsWeak(node_isolate)); assert(!handle_.IsWeak(v8::Isolate::GetCurrent()));
assert(refs_ > 0); assert(refs_ > 0);
if (--refs_ == 0) { MakeWeak(); } if (--refs_ == 0) { MakeWeak(); }
} }
@ -113,18 +114,18 @@ class NODE_EXTERN ObjectWrap {
private: private:
static void WeakCallback(v8::Isolate* env, static void WeakCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value> value, v8::Persistent<v8::Value> value,
void* data) { void* data) {
v8::HandleScope scope(node_isolate); v8::HandleScope scope(isolate);
ObjectWrap *obj = static_cast<ObjectWrap*>(data); ObjectWrap *obj = static_cast<ObjectWrap*>(data);
assert(value == obj->handle_); assert(value == obj->handle_);
assert(!obj->refs_); assert(!obj->refs_);
assert(value.IsNearDeath(env)); assert(value.IsNearDeath(isolate));
delete obj; delete obj;
} }
}; };
} // namespace node } // namespace node
#endif // object_wrap_h #endif // object_wrap_h

Loading…
Cancel
Save