Skip to content

Commit

Permalink
[nan2] Ensure we return when ReturnValue is set
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesboeufs committed Aug 27, 2015
1 parent 06262d5 commit 28038f0
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 68 deletions.
12 changes: 6 additions & 6 deletions src/xml_attribute.cc
Expand Up @@ -8,7 +8,7 @@ Nan::Persistent<v8::FunctionTemplate> XmlAttribute::constructor_template;
NAN_METHOD(XmlAttribute::New) {
Nan::HandleScope scope;

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

v8::Local<v8::Object>
Expand Down Expand Up @@ -47,7 +47,7 @@ NAN_METHOD(XmlAttribute::Name) {
XmlAttribute *attr = Nan::ObjectWrap::Unwrap<XmlAttribute>(info.Holder());
assert(attr);

info.GetReturnValue().Set(attr->get_name());
return info.GetReturnValue().Set(attr->get_name());
}

NAN_METHOD(XmlAttribute::Value) {
Expand All @@ -58,27 +58,27 @@ NAN_METHOD(XmlAttribute::Value) {
// attr.value('new value');
if (info.Length() > 0) {
attr->set_value(*v8::String::Utf8Value(info[0]));
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

// attr.value();
info.GetReturnValue().Set(attr->get_value());
return info.GetReturnValue().Set(attr->get_value());
}

NAN_METHOD(XmlAttribute::Node) {
Nan::HandleScope scope;
XmlAttribute *attr = Nan::ObjectWrap::Unwrap<XmlAttribute>(info.Holder());
assert(attr);

info.GetReturnValue().Set(attr->get_element());
return info.GetReturnValue().Set(attr->get_element());
}

NAN_METHOD(XmlAttribute::Namespace) {
Nan::HandleScope scope;
XmlAttribute *attr = Nan::ObjectWrap::Unwrap<XmlAttribute>(info.Holder());
assert(attr);

info.GetReturnValue().Set(attr->get_namespace());
return info.GetReturnValue().Set(attr->get_namespace());
}

v8::Local<v8::Value>
Expand Down
8 changes: 4 additions & 4 deletions src/xml_comment.cc
Expand Up @@ -21,7 +21,7 @@ NAN_METHOD(XmlComment::New) {
// to create a new node on the document
if (info.Length() == 0)
{
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

XmlDocument* document = Nan::ObjectWrap::Unwrap<XmlDocument>(info[0]->ToObject());
Expand All @@ -47,7 +47,7 @@ NAN_METHOD(XmlComment::New) {
// this prevents the document from going away
info.Holder()->Set(Nan::New<v8::String>("document").ToLocalChecked(), info[0]);

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlComment::Text) {
Expand All @@ -56,12 +56,12 @@ NAN_METHOD(XmlComment::Text) {
assert(comment);

if (info.Length() == 0) {
info.GetReturnValue().Set(comment->get_content());
return info.GetReturnValue().Set(comment->get_content());
} else {
comment->set_content(*v8::String::Utf8Value(info[0]));
}

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

void
Expand Down
34 changes: 17 additions & 17 deletions src/xml_document.cc
Expand Up @@ -27,11 +27,11 @@ NAN_METHOD(XmlDocument::Encoding)
// if no args, get the encoding
if (info.Length() == 0 || info[0]->IsUndefined()) {
if (document->xml_obj->encoding)
info.GetReturnValue().Set(Nan::New<v8::String>(
return info.GetReturnValue().Set(Nan::New<v8::String>(
(const char *)document->xml_obj->encoding,
xmlStrlen((const xmlChar*)document->xml_obj->encoding)).ToLocalChecked());

info.GetReturnValue().Set(Nan::Null());
return info.GetReturnValue().Set(Nan::Null());
}

// set the encoding otherwise
Expand All @@ -41,7 +41,7 @@ NAN_METHOD(XmlDocument::Encoding)
}

document->xml_obj->encoding = xmlStrdup((const xmlChar*)*encoding);
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlDocument::Version)
Expand All @@ -51,10 +51,10 @@ NAN_METHOD(XmlDocument::Version)
assert(document);

if (document->xml_obj->version)
info.GetReturnValue().Set(Nan::New<v8::String>((const char *)document->xml_obj->version,
return info.GetReturnValue().Set(Nan::New<v8::String>((const char *)document->xml_obj->version,
xmlStrlen((const xmlChar*)document->xml_obj->version)).ToLocalChecked());

info.GetReturnValue().Set(Nan::Null());
return info.GetReturnValue().Set(Nan::Null());
}

NAN_METHOD(XmlDocument::Root)
Expand All @@ -68,9 +68,9 @@ NAN_METHOD(XmlDocument::Root)
if (info.Length() == 0 || info[0]->IsUndefined())
{
if (!root) {
info.GetReturnValue().Set(Nan::Null());
return info.GetReturnValue().Set(Nan::Null());
}
info.GetReturnValue().Set(XmlElement::New(root));
return info.GetReturnValue().Set(XmlElement::New(root));
}

if (root != NULL) {
Expand All @@ -82,7 +82,7 @@ NAN_METHOD(XmlDocument::Root)
XmlElement* element = Nan::ObjectWrap::Unwrap<XmlElement>(info[0]->ToObject());
assert(element);
xmlDocSetRootElement(document->xml_obj, element->xml_obj);
info.GetReturnValue().Set(info[0]);
return info.GetReturnValue().Set(info[0]);
}

NAN_METHOD(XmlDocument::GetDtd)
Expand All @@ -94,7 +94,7 @@ NAN_METHOD(XmlDocument::GetDtd)
xmlDtdPtr dtd = xmlGetIntSubset(document->xml_obj);

if (!dtd) {
info.GetReturnValue().Set(Nan::Null());
return info.GetReturnValue().Set(Nan::Null());
}

const char* name = (const char *)dtd->name;
Expand Down Expand Up @@ -125,7 +125,7 @@ NAN_METHOD(XmlDocument::GetDtd)

Nan::Set(dtdObj, Nan::New<v8::String>("systemId").ToLocalChecked(), sysValue);

info.GetReturnValue().Set(dtdObj);
return info.GetReturnValue().Set(dtdObj);

}

Expand Down Expand Up @@ -162,7 +162,7 @@ NAN_METHOD(XmlDocument::SetDtd)

xmlCreateIntSubset(document->xml_obj, (const xmlChar *) *name, (const xmlChar *) extId, (const xmlChar *) sysId);

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlDocument::ToString)
Expand All @@ -178,7 +178,7 @@ NAN_METHOD(XmlDocument::ToString)
v8::Local<v8::String> str = Nan::New<v8::String>((const char*)buffer, len).ToLocalChecked();
xmlFree(buffer);

info.GetReturnValue().Set(str);
return info.GetReturnValue().Set(str);
}

// not called from node
Expand Down Expand Up @@ -265,7 +265,7 @@ NAN_METHOD(XmlDocument::FromHtml)
Nan::Set(doc_handle, Nan::New<v8::String>("errors").ToLocalChecked(), errors);

// create the xml document handle to return
info.GetReturnValue().Set(doc_handle);
return info.GetReturnValue().Set(doc_handle);
}

int getXmlParserOption2(v8::Local<v8::Object> props, const char *key, int value) {
Expand Down Expand Up @@ -348,7 +348,7 @@ NAN_METHOD(XmlDocument::FromXml)
}

// create the xml document handle to return
info.GetReturnValue().Set(doc_handle);
return info.GetReturnValue().Set(doc_handle);
}

NAN_METHOD(XmlDocument::Validate)
Expand Down Expand Up @@ -380,7 +380,7 @@ NAN_METHOD(XmlDocument::Validate)
xmlSetStructuredErrorFunc(NULL, NULL);
info.Holder()->Set(Nan::New<v8::String>("validationErrors").ToLocalChecked(), errors);

info.GetReturnValue().Set(Nan::New<v8::Boolean>(valid));
return info.GetReturnValue().Set(Nan::New<v8::Boolean>(valid));
}

NAN_METHOD(XmlDocument::RngValidate)
Expand Down Expand Up @@ -414,7 +414,7 @@ NAN_METHOD(XmlDocument::RngValidate)
xmlSetStructuredErrorFunc(NULL, NULL);
info.Holder()->Set(Nan::New<v8::String>("validationErrors").ToLocalChecked(), errors);

info.GetReturnValue().Set(Nan::New<v8::Boolean>(valid));
return info.GetReturnValue().Set(Nan::New<v8::Boolean>(valid));
}

/// this is a blank object with prototype methods
Expand All @@ -429,7 +429,7 @@ NAN_METHOD(XmlDocument::New)
XmlDocument* document = new XmlDocument(doc);
document->Wrap(info.Holder());

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

XmlDocument::XmlDocument(xmlDoc* doc)
Expand Down
40 changes: 20 additions & 20 deletions src/xml_element.cc
Expand Up @@ -23,7 +23,7 @@ NAN_METHOD(XmlElement::New) {
// to create a new node on the document
if (info.Length() == 0)
{
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

XmlDocument* document = Nan::ObjectWrap::Unwrap<XmlDocument>(info[0]->ToObject());
Expand Down Expand Up @@ -53,7 +53,7 @@ NAN_METHOD(XmlElement::New) {
// this prevents the document from going away
info.Holder()->Set(Nan::New<v8::String>("document").ToLocalChecked(), info[0]);

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlElement::Name) {
Expand All @@ -62,11 +62,11 @@ NAN_METHOD(XmlElement::Name) {
assert(element);

if (info.Length() == 0)
info.GetReturnValue().Set(element->get_name());
return info.GetReturnValue().Set(element->get_name());

v8::String::Utf8Value name(info[0]->ToString());
element->set_name(*name);
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlElement::Attr) {
Expand All @@ -78,23 +78,23 @@ NAN_METHOD(XmlElement::Attr) {
if (info.Length() == 1)
{
v8::String::Utf8Value name(info[0]);
info.GetReturnValue().Set(element->get_attr(*name));
return info.GetReturnValue().Set(element->get_attr(*name));
}

// setter
v8::String::Utf8Value name(info[0]->ToString());
v8::String::Utf8Value value(info[1]->ToString());
element->set_attr(*name, *value);

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlElement::Attrs) {
Nan::HandleScope scope;
XmlElement *element = Nan::ObjectWrap::Unwrap<XmlElement>(info.Holder());
assert(element);

info.GetReturnValue().Set(element->get_attrs());
return info.GetReturnValue().Set(element->get_attrs());
}

NAN_METHOD(XmlElement::AddChild) {
Expand All @@ -112,7 +112,7 @@ NAN_METHOD(XmlElement::AddChild) {
}

element->add_child(child);
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlElement::AddCData) {
Expand All @@ -132,7 +132,7 @@ NAN_METHOD(XmlElement::AddCData) {
xmlStrlen((const xmlChar*)content));

element->add_cdata(elem);
info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlElement::Find) {
Expand Down Expand Up @@ -162,23 +162,23 @@ NAN_METHOD(XmlElement::Find) {
}
}

info.GetReturnValue().Set(ctxt.evaluate((const xmlChar*)*xpath));
return info.GetReturnValue().Set(ctxt.evaluate((const xmlChar*)*xpath));
}

NAN_METHOD(XmlElement::NextElement) {
Nan::HandleScope scope;
XmlElement *element = Nan::ObjectWrap::Unwrap<XmlElement>(info.Holder());
assert(element);

info.GetReturnValue().Set(element->get_next_element());
return info.GetReturnValue().Set(element->get_next_element());
}

NAN_METHOD(XmlElement::PrevElement) {
Nan::HandleScope scope;
XmlElement *element = Nan::ObjectWrap::Unwrap<XmlElement>(info.Holder());
assert(element);

info.GetReturnValue().Set(element->get_prev_element());
return info.GetReturnValue().Set(element->get_prev_element());
}

NAN_METHOD(XmlElement::Text) {
Expand All @@ -187,12 +187,12 @@ NAN_METHOD(XmlElement::Text) {
assert(element);

if (info.Length() == 0) {
info.GetReturnValue().Set(element->get_content());
return info.GetReturnValue().Set(element->get_content());
} else {
element->set_content(*v8::String::Utf8Value(info[0]));
}

info.GetReturnValue().Set(info.Holder());
return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlElement::Child) {
Expand All @@ -206,7 +206,7 @@ NAN_METHOD(XmlElement::Child) {
}

const int32_t idx = info[0]->Int32Value();
info.GetReturnValue().Set(element->get_child(idx));
return info.GetReturnValue().Set(element->get_child(idx));
}

NAN_METHOD(XmlElement::ChildNodes) {
Expand All @@ -215,17 +215,17 @@ NAN_METHOD(XmlElement::ChildNodes) {
assert(element);

if (info[0]->IsInt32())
info.GetReturnValue().Set(element->get_child(info[0]->Int32Value()));
return info.GetReturnValue().Set(element->get_child(info[0]->Int32Value()));

info.GetReturnValue().Set(element->get_child_nodes());
return info.GetReturnValue().Set(element->get_child_nodes());
}

NAN_METHOD(XmlElement::Path) {
Nan::HandleScope scope;
XmlElement *element = Nan::ObjectWrap::Unwrap<XmlElement>(info.Holder());
assert(element);

info.GetReturnValue().Set(element->get_path());
return info.GetReturnValue().Set(element->get_path());
}

NAN_METHOD(XmlElement::AddPrevSibling) {
Expand All @@ -240,7 +240,7 @@ NAN_METHOD(XmlElement::AddPrevSibling) {

element->add_prev_sibling(new_sibling);

info.GetReturnValue().Set(info[0]);
return info.GetReturnValue().Set(info[0]);
}

NAN_METHOD(XmlElement::AddNextSibling) {
Expand All @@ -255,7 +255,7 @@ NAN_METHOD(XmlElement::AddNextSibling) {

element->add_next_sibling(new_sibling);

info.GetReturnValue().Set(info[0]);
return info.GetReturnValue().Set(info[0]);
}

void
Expand Down

0 comments on commit 28038f0

Please sign in to comment.