Remember isolate in Wrappable
This commit is contained in:
parent
f310222ce1
commit
0586822808
2 changed files with 7 additions and 1 deletions
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace mate {
|
||||
|
||||
Wrappable::Wrappable() {
|
||||
Wrappable::Wrappable() : isolate_(NULL) {
|
||||
}
|
||||
|
||||
Wrappable::~Wrappable() {
|
||||
|
@ -21,6 +21,8 @@ void Wrappable::Wrap(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) {
|
|||
if (!wrapper_.IsEmpty())
|
||||
return;
|
||||
|
||||
isolate_ = isolate;
|
||||
|
||||
MATE_SET_INTERNAL_FIELD_POINTER(wrapper, 0, this);
|
||||
MATE_PERSISTENT_ASSIGN(v8::Object, isolate, wrapper_, wrapper);
|
||||
MATE_PERSISTENT_SET_WEAK(wrapper_, this, WeakCallback);
|
||||
|
|
|
@ -66,6 +66,9 @@ class Wrappable {
|
|||
Wrappable();
|
||||
virtual ~Wrappable();
|
||||
|
||||
// Returns the Isolate this object is created in.
|
||||
v8::Isolate* isolate() const { return isolate_; }
|
||||
|
||||
virtual ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate);
|
||||
|
||||
// Called after the "_init" method gets called in JavaScript.
|
||||
|
@ -74,6 +77,7 @@ class Wrappable {
|
|||
private:
|
||||
static MATE_WEAK_CALLBACK(WeakCallback, v8::Object, Wrappable);
|
||||
|
||||
v8::Isolate* isolate_;
|
||||
v8::UniquePersistent<v8::Object> wrapper_; // Weak
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Wrappable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue