Skip to content

Commit

Permalink
Support node v0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
hideo55 committed Apr 20, 2013
1 parent 200a707 commit 9f832dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node_kytea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void NodeKytea::Init(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "getTags", getTags);
NODE_SET_PROTOTYPE_METHOD(t, "getAllTags", getAllTags);

Persistent < Function > constructor = Persistent < Function > ::New(t->GetFunction());
Persistent < Function > constructor = Persistent < Function > ::New(__GET_ISOLATE_FOR_NEW t->GetFunction());
target->Set(String::NewSymbol("Kytea"), constructor);
}

Expand Down
12 changes: 10 additions & 2 deletions src/node_kytea.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#include <kytea/kytea-struct.h>
#include <kytea/string-util.h>

#if NODE_VERSION_AT_LEAST(0,11,0)
#define __GET_ISOLATE_FOR_NEW v8::Isolate::GetCurrent(),
#define __GET_ISOLATE_FOR_DISPOSE v8::Isolate::GetCurrent()
#else
#define __GET_ISOLATE_FOR_NEW
#define __GET_ISOLATE_FOR_DISPOSE
#endif

namespace node_kytea {

class NodeKytea: node::ObjectWrap {
Expand Down Expand Up @@ -46,11 +54,11 @@ class NodeKytea: node::ObjectWrap {
status(ST_OK), kt(kt_) {
kt->Ref();
request.data = this;
callback = v8::Persistent<v8::Function>::New(cb_);
callback = v8::Persistent<v8::Function>::New(__GET_ISOLATE_FOR_NEW cb_);
}
virtual ~Baton() {
kt->Unref();
callback.Dispose();
callback.Dispose(__GET_ISOLATE_FOR_DISPOSE);
}
};

Expand Down

0 comments on commit 9f832dd

Please sign in to comment.