Skip to content

Commit

Permalink
Add Nodejs 6/7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
syndbg committed May 23, 2017
1 parent 399f229 commit 235983e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Node v4.x.x/5.x.x Now Supported
Node v6.x.x/7.x.x Now Supported
---------------------------

Many thanks to [Mário Freitas/imkira](https://github.com/imkira) for his work.
Expand All @@ -15,7 +15,9 @@ Works/worked with NodeJS versions:
* 0.8.x,
* 0.10.x,
* 4.x.x,
* 5.x.x
* 5.x.x,
* 6.x.x,
* 7.x.x

To install, just type:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"test": "node test/unittest.js"
},
"dependencies": {
"nan": "~2.1.0"
"nan": "~2.5.1"
}
}
6 changes: 3 additions & 3 deletions protobuf_for_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace protobuf_for_node {
}

Local<Object> NewObject(Local<Value> properties) const {
return Constructor()->NewInstance(1, &properties);
return Nan::NewInstance(Constructor(), 1, &properties).ToLocalChecked();
}

Type(Schema* schema, const Descriptor* descriptor, Local<Object> self)
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace protobuf_for_node {

Local<Function> constructor =
Script::Compile(Nan::New<String>(from.str()).ToLocalChecked())->Run().As<Function>();
constructor->SetHiddenValue(Nan::New<String>("type").ToLocalChecked(), self);
Nan::SetPrivate(constructor, Nan::New<String>("type").ToLocalChecked(), self);

Local<Function> bind =
Script::Compile(Nan::New<String>(
Expand Down Expand Up @@ -427,7 +427,7 @@ namespace protobuf_for_node {

Local<FunctionTemplate> typeTemplate = Nan::New(TypeTemplate);
result = types_[descriptor] =
new Type(this, descriptor, typeTemplate->GetFunction()->NewInstance());
new Type(this, descriptor, Nan::NewInstance(typeTemplate->GetFunction()).ToLocalChecked());

// managed schema->[type] link
//
Expand Down

0 comments on commit 235983e

Please sign in to comment.