Skip to content

Commit

Permalink
Update for Node,js 12.x support (#552)
Browse files Browse the repository at this point in the history
* Fix travis build instructions

* Update for Node.js 12.x support
  • Loading branch information
tomhughes authored and rchipka committed Aug 15, 2019
1 parent 1897e59 commit 5131a38
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 163 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ node_js:
- 8
- 9
- 10
- 11
- 12

addons:
apt:
Expand All @@ -24,8 +26,6 @@ addons:
sudo: false
before_install:
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then export CXX=clang; fi
# related: https://github.com/travis-ci/travis-ci/issues/6307#issuecomment-350725425
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; command curl -sSL https://rvm.io/mpapis.asc | gpg --import -; then rvm get stable; fi
- $CXX --version

- PUBLISH_BINARY=false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"bindings": "~1.3.0",
"nan": "~2.10.0",
"nan": "~2.14.0",
"node-pre-gyp": "~0.11.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/html_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
namespace libxmljs {

void
HtmlDocument::Initialize(v8::Handle<v8::Object> target) {
HtmlDocument::Initialize(v8::Local<v8::Object> target) {
}
} // namespcae libxmljs
2 changes: 1 addition & 1 deletion src/html_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HtmlDocument : public XmlDocument {
public:

explicit HtmlDocument(xmlDoc* doc) : XmlDocument(doc) {}
static void Initialize(v8::Handle<v8::Object> target);
static void Initialize(v8::Local<v8::Object> target);
};

} // namespace libxmljs
Expand Down
2 changes: 1 addition & 1 deletion src/libxmljs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,6 @@ NAN_MODULE_INIT(init)
Nan::SetMethod(target, "xmlNodeCount", XmlNodeCount);
}

NODE_MODULE(xmljs, init)
NAN_MODULE_WORKER_ENABLED(xmljs, init)

} // namespace libxmljs
10 changes: 5 additions & 5 deletions src/xml_attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ XmlAttribute::New(xmlNode* xml_obj, const xmlChar* name, const xmlChar* value)
}

XmlAttribute* attribute = new XmlAttribute(attr);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(constructor_template)->GetFunction()).ToLocalChecked();
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::GetFunction(Nan::New(constructor_template)).ToLocalChecked()).ToLocalChecked();
attribute->Wrap(obj);
return scope.Escape(obj);
}
Expand All @@ -39,7 +39,7 @@ XmlAttribute::New(xmlAttr* attr)
}

XmlAttribute* attribute = new XmlAttribute(attr);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(constructor_template)->GetFunction()).ToLocalChecked();
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::GetFunction(Nan::New(constructor_template)).ToLocalChecked()).ToLocalChecked();
attribute->Wrap(obj);
return scope.Escape(obj);
}
Expand All @@ -59,7 +59,7 @@ NAN_METHOD(XmlAttribute::Value) {

// attr.value('new value');
if (info.Length() > 0) {
attr->set_value(*v8::String::Utf8Value(info[0]));
attr->set_value(*Nan::Utf8String(info[0]));
return info.GetReturnValue().Set(info.Holder());
}

Expand Down Expand Up @@ -153,7 +153,7 @@ XmlAttribute::get_namespace() {
}

void
XmlAttribute::Initialize(v8::Handle<v8::Object> target) {
XmlAttribute::Initialize(v8::Local<v8::Object> target) {
Nan::HandleScope scope;
v8::Local<v8::FunctionTemplate> tmpl =
Nan::New<v8::FunctionTemplate>(XmlAttribute::New);
Expand All @@ -167,7 +167,7 @@ XmlAttribute::Initialize(v8::Handle<v8::Object> target) {
Nan::SetPrototypeMethod(tmpl, "namespace", XmlAttribute::Namespace);

Nan::Set(target, Nan::New<v8::String>("Attribute").ToLocalChecked(),
tmpl->GetFunction());
Nan::GetFunction(tmpl).ToLocalChecked());
}

} // namespace libxmljs
2 changes: 1 addition & 1 deletion src/xml_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class XmlAttribute : public XmlNode {
explicit XmlAttribute(xmlAttr* node) :
XmlNode(reinterpret_cast<xmlNode*>(node)) {}

static void Initialize(v8::Handle<v8::Object> target);
static void Initialize(v8::Local<v8::Object> target);
static Nan::Persistent<v8::FunctionTemplate> constructor_template;

static v8::Local<v8::Object> New(xmlNode* xml_obj,
Expand Down
14 changes: 7 additions & 7 deletions src/xml_comment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ NAN_METHOD(XmlComment::New) {
return info.GetReturnValue().Set(info.Holder());
}

XmlDocument* document = Nan::ObjectWrap::Unwrap<XmlDocument>(info[0]->ToObject());
XmlDocument* document = Nan::ObjectWrap::Unwrap<XmlDocument>(Nan::To<v8::Object>(info[0]).ToLocalChecked());
assert(document);

v8::Local<v8::Value> contentOpt;
if (info[1]->IsString()) {
contentOpt = info[1];
}
v8::String::Utf8Value contentRaw(contentOpt);
Nan::Utf8String contentRaw(contentOpt);
const char* content = (contentRaw.length()) ? *contentRaw : NULL;

xmlNode* comm = xmlNewDocComment(document->xml_obj, (xmlChar *) content);
Expand All @@ -40,7 +40,7 @@ NAN_METHOD(XmlComment::New) {
comment->Wrap(info.Holder());

// this prevents the document from going away
info.Holder()->Set(Nan::New<v8::String>("document").ToLocalChecked(), info[0]);
Nan::Set(info.Holder(), Nan::New<v8::String>("document").ToLocalChecked(), info[0]);

return info.GetReturnValue().Set(info.Holder());
}
Expand All @@ -53,7 +53,7 @@ NAN_METHOD(XmlComment::Text) {
if (info.Length() == 0) {
return info.GetReturnValue().Set(comment->get_content());
} else {
comment->set_content(*v8::String::Utf8Value(info[0]));
comment->set_content(*Nan::Utf8String(info[0]));
}

return info.GetReturnValue().Set(info.Holder());
Expand Down Expand Up @@ -87,7 +87,7 @@ XmlComment::New(xmlNode* node)
}

XmlComment* comment = new XmlComment(node);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(constructor_template)->GetFunction()).ToLocalChecked();
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::GetFunction(Nan::New(constructor_template)).ToLocalChecked()).ToLocalChecked();
comment->Wrap(obj);
return scope.Escape(obj);
}
Expand All @@ -98,7 +98,7 @@ XmlComment::XmlComment(xmlNode* node)
}

void
XmlComment::Initialize(v8::Handle<v8::Object> target)
XmlComment::Initialize(v8::Local<v8::Object> target)
{
Nan::HandleScope scope;
v8::Local<v8::FunctionTemplate> t = Nan::New<v8::FunctionTemplate>(static_cast<NAN_METHOD((*))>(New));
Expand All @@ -111,7 +111,7 @@ XmlComment::Initialize(v8::Handle<v8::Object> target)
XmlComment::Text);

Nan::Set(target, Nan::New<v8::String>("Comment").ToLocalChecked(),
t->GetFunction());
Nan::GetFunction(t).ToLocalChecked());
}

} // namespace libxmljs
2 changes: 1 addition & 1 deletion src/xml_comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class XmlComment : public XmlNode {

explicit XmlComment(xmlNode* node);

static void Initialize(v8::Handle<v8::Object> target);
static void Initialize(v8::Local<v8::Object> target);

static Nan::Persistent<v8::FunctionTemplate> constructor_template;

Expand Down
Loading

0 comments on commit 5131a38

Please sign in to comment.