Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Stash continued attempt. Now builds. Some warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
matburnham committed Jul 27, 2020
1 parent d8eb02c commit 197b45f
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 49 deletions.
8 changes: 4 additions & 4 deletions src/basic_reader_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace node_osmium {
Nan::SetPrototypeMethod(lcons, "close", close);
Nan::SetPrototypeMethod(lcons, "read", read);
Nan::SetPrototypeMethod(lcons, "read_all", read_all);
target->Set(Nan::New(symbol_BasicReader), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_BasicReader), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand All @@ -52,7 +52,7 @@ namespace node_osmium {
Nan::ThrowTypeError(Nan::New("Second argument to BasicReader constructor must be object").ToLocalChecked());
return;
}
read_which_entities = object_to_entity_bits(info[1]->ToObject());
read_which_entities = object_to_entity_bits(info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
}
if (info[0]->IsString()) {
Nan::Utf8String filename { info[0] };
Expand All @@ -61,8 +61,8 @@ namespace node_osmium {
reader_wrap->Wrap(info.This());
info.GetReturnValue().Set(info.This());
return;
} else if (info[0]->IsObject() && Nan::New(FileWrap::constructor)->HasInstance(info[0]->ToObject())) {
v8::Local<v8::Object> file_obj = info[0]->ToObject();
} else if (info[0]->IsObject() && Nan::New(FileWrap::constructor)->HasInstance(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked())) {
v8::Local<v8::Object> file_obj = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
BasicReaderWrap* reader_wrap = new BasicReaderWrap(unwrap<FileWrap>(file_obj), read_which_entities);
reader_wrap->Wrap(info.This());
info.GetReturnValue().Set(info.This());
Expand Down
12 changes: 6 additions & 6 deletions src/flex_reader_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace node_osmium {
Nan::SetPrototypeMethod(lcons, "close", close);
Nan::SetPrototypeMethod(lcons, "read", read);
Nan::SetPrototypeMethod(lcons, "read_all", read_all);
target->Set(Nan::New(symbol_FlexReader), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_FlexReader), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand All @@ -49,11 +49,11 @@ namespace node_osmium {
Nan::ThrowTypeError(Nan::New("Third argument to FlexReader constructor must be object").ToLocalChecked());
return;
}
read_which_entities = object_to_entity_bits(info[2]->ToObject());
read_which_entities = object_to_entity_bits(info[2]->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
}

if (info[1]->IsObject() && Nan::New(LocationHandlerWrap::constructor)->HasInstance(info[1]->ToObject())) {
v8::Local<v8::Object> location_handler_obj = info[1]->ToObject();
if (info[1]->IsObject() && Nan::New(LocationHandlerWrap::constructor)->HasInstance(info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked())) {
v8::Local<v8::Object> location_handler_obj = info[1]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
location_handler_type& location_handler = unwrap<LocationHandlerWrap>(location_handler_obj);
if (info[0]->IsString()) {
Nan::Utf8String filename { info[0] };
Expand All @@ -62,8 +62,8 @@ namespace node_osmium {
reader_wrap->Wrap(info.This());
info.GetReturnValue().Set(info.This());
return;
} else if (info[0]->IsObject() && Nan::New(FileWrap::constructor)->HasInstance(info[0]->ToObject())) {
v8::Local<v8::Object> file_obj = info[0]->ToObject();
} else if (info[0]->IsObject() && Nan::New(FileWrap::constructor)->HasInstance(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked())) {
v8::Local<v8::Object> file_obj = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
FlexReaderWrap* reader_wrap = new FlexReaderWrap(unwrap<FileWrap>(file_obj), location_handler, read_which_entities);
reader_wrap->Wrap(info.This());
info.GetReturnValue().Set(info.This());
Expand Down
10 changes: 5 additions & 5 deletions src/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace node_osmium {
Nan::SetPrototypeMethod(lcons, "on", on);
Nan::SetPrototypeMethod(lcons, "options", options);
Nan::SetPrototypeMethod(lcons, "end", stream_end);
target->Set(Nan::New(symbol_Handler), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_Handler), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);

}
Expand Down Expand Up @@ -90,9 +90,9 @@ namespace node_osmium {
return;
}

v8::Local<v8::Value> tagged_nodes_only = info[0]->ToObject()->Get(Nan::New("tagged_nodes_only").ToLocalChecked());
v8::Local<v8::Value> tagged_nodes_only = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked()->Get(Nan::GetCurrentContext(), Nan::New("tagged_nodes_only").ToLocalChecked()).ToLocalChecked();
if (tagged_nodes_only->IsBoolean()) {
unwrap<JSHandler>(info.This()).node_callback_for_tagged_only = tagged_nodes_only->BooleanValue();
unwrap<JSHandler>(info.This()).node_callback_for_tagged_only = Nan::To<bool>(tagged_nodes_only).ToChecked();
}

info.GetReturnValue().Set(Nan::Undefined());
Expand Down Expand Up @@ -160,15 +160,15 @@ namespace node_osmium {
return;
}
v8::Local<v8::Value> argv[1] = { new_external<TWrapped>(entity) };
Nan::New(function)->Call(Nan::GetCurrentContext()->Global(), 1, argv);
Nan::Call(Nan::New(function), Nan::GetCurrentContext()->Global(), 1, argv);
}

void call_callback(const Nan::Persistent<v8::Function>& function) {
Nan::HandleScope scope;
if (function.IsEmpty()) {
return;
}
Nan::New(function)->Call(Nan::GetCurrentContext()->Global(), 0, nullptr);
Nan::Call(Nan::New(function), Nan::GetCurrentContext()->Global(), 0, nullptr);
}

void JSHandler::dispatch_entity(const osmium::OSMEntity& entity) const {
Expand Down
2 changes: 1 addition & 1 deletion src/location_handler_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace node_osmium {
Nan::SetPrototypeMethod(lcons, "clear", clear);
Nan::SetPrototypeMethod(lcons, "ignoreErrors", ignoreErrors);
Nan::SetPrototypeMethod(lcons, "end", stream_end);
target->Set(Nan::New(symbol_LocationHandler), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_LocationHandler), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down
14 changes: 7 additions & 7 deletions src/multipolygon_collector_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace node_osmium {
lcons->SetClassName(Nan::New(symbol_MultipolygonCollector));
Nan::SetPrototypeMethod(lcons, "read_relations", read_relations);
Nan::SetPrototypeMethod(lcons, "handler", handler);
target->Set(Nan::New(symbol_MultipolygonCollector), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_MultipolygonCollector), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down Expand Up @@ -56,11 +56,11 @@ namespace node_osmium {
return;
}
try {
if (Nan::New(BasicReaderWrap::constructor)->HasInstance(info[0]->ToObject())) {
osmium::io::Reader& reader = unwrap<BasicReaderWrap>(info[0]->ToObject());
if (Nan::New(BasicReaderWrap::constructor)->HasInstance(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked())) {
osmium::io::Reader& reader = unwrap<BasicReaderWrap>(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
unwrap<MultipolygonCollectorWrap>(info.This()).read_relations(reader);
} else if (Nan::New(BufferWrap::constructor)->HasInstance(info[0]->ToObject())) {
osmium::memory::Buffer& buffer = unwrap<BufferWrap>(info[0]->ToObject());
} else if (Nan::New(BufferWrap::constructor)->HasInstance(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked())) {
osmium::memory::Buffer& buffer = unwrap<BufferWrap>(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
unwrap<MultipolygonCollectorWrap>(info.This()).read_relations(buffer.begin(), buffer.end());
} else {
Nan::ThrowError(Nan::New("call MultipolygonCollector.read_relation() with BasicReader or Buffer object").ToLocalChecked());
Expand All @@ -78,12 +78,12 @@ namespace node_osmium {

NAN_METHOD(MultipolygonCollectorWrap::handler) {
INSTANCE_CHECK(MultipolygonCollectorWrap, "MultipolygonCollector", "handler");
if (info.Length() != 1 || !info[0]->IsObject() || !Nan::New(JSHandler::constructor)->HasInstance(info[0]->ToObject())) {
if (info.Length() != 1 || !info[0]->IsObject() || !Nan::New(JSHandler::constructor)->HasInstance(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked())) {
Nan::ThrowError(Nan::New("call MultipolygonCollector.handler() with Handler object").ToLocalChecked());
return;
}
try {
JSHandler& handler = unwrap<JSHandler>(info[0]->ToObject());
JSHandler& handler = unwrap<JSHandler>(info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
auto& mc_handler = unwrap<MultipolygonCollectorWrap>(info.This()).handler([&handler](const osmium::memory::Buffer& area_buffer) {
for (const osmium::OSMEntity& entity : area_buffer) {
handler.dispatch_entity(entity);
Expand Down
2 changes: 1 addition & 1 deletion src/multipolygon_handler_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace node_osmium {
lcons->InstanceTemplate()->SetInternalFieldCount(1);
lcons->SetClassName(Nan::New(symbol_MultipolygonHandler));
Nan::SetPrototypeMethod(lcons, "end", stream_end);
target->Set(Nan::New(symbol_MultipolygonHandler), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_MultipolygonHandler), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down
2 changes: 1 addition & 1 deletion src/osm_area_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace node_osmium {
Nan::SetPrototypeMethod(lcons, "wkb", wkb);
Nan::SetPrototypeMethod(lcons, "wkt", wkt);
Nan::SetPrototypeMethod(lcons, "coordinates", coordinates);
target->Set(Nan::New(symbol_Area), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_Area), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down
2 changes: 1 addition & 1 deletion src/osm_changeset_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace node_osmium {
ATTR(lcons, "closed", get_closed);
ATTR(lcons, "bounds", get_bounds);
Nan::SetPrototypeMethod(lcons, "tags", tags);
target->Set(Nan::New(symbol_Changeset), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_Changeset), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down
2 changes: 1 addition & 1 deletion src/osm_entity_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace node_osmium {
v8::Local<v8::FunctionTemplate> lcons = Nan::New<v8::FunctionTemplate>(OSMEntityWrap::New);
lcons->InstanceTemplate()->SetInternalFieldCount(1);
lcons->SetClassName(Nan::New(symbol_OSMEntity));
target->Set(Nan::New(symbol_OSMEntity), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_OSMEntity), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down
6 changes: 3 additions & 3 deletions src/osm_node_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace node_osmium {
ATTR(lcons, "coordinates", get_coordinates);
ATTR(lcons, "lon", get_lon);
ATTR(lcons, "lat", get_lat);
target->Set(Nan::New(symbol_Node), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_Node), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand All @@ -51,7 +51,7 @@ namespace node_osmium {
if (!location) {
Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(v8::Local<v8::Function>::Cast(cf));
if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Buffer instance");
info.GetReturnValue().Set(maybe_local.ToLocalChecked()->ToObject());
info.GetReturnValue().Set(maybe_local.ToLocalChecked());
return;
}

Expand All @@ -60,7 +60,7 @@ namespace node_osmium {
v8::Local<v8::Value> argv[2] = { lon, lat };
Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(v8::Local<v8::Function>::Cast(cf),2,argv);
if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Buffer instance");
info.GetReturnValue().Set(maybe_local.ToLocalChecked()->ToObject());
info.GetReturnValue().Set(maybe_local.ToLocalChecked());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/osm_object_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace node_osmium {
ATTR(lcons, "uid", get_uid);
ATTR(lcons, "user", get_user);
Nan::SetPrototypeMethod(lcons, "tags", tags);
target->Set(Nan::New(symbol_OSMObject), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_OSMObject), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down
4 changes: 2 additions & 2 deletions src/osm_relation_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace node_osmium {
ATTR(lcons, "type", get_type);
ATTR(lcons, "members_count", get_members_count);
Nan::SetPrototypeMethod(lcons, "members", members);
target->Set(Nan::New(symbol_Relation), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_Relation), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down Expand Up @@ -61,7 +61,7 @@ namespace node_osmium {
Nan::ThrowTypeError(Nan::New("call members() without parameters or the index of the member you want").ToLocalChecked());
return;
}
uint32_t n = info[0]->Uint32Value();;
uint32_t n = info[0]->Uint32Value(Nan::GetCurrentContext()).ToChecked();
if (n < relation.members().size()) {
auto it = relation.members().begin();
std::advance(it, n);
Expand Down
10 changes: 5 additions & 5 deletions src/osm_way_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace node_osmium {
Nan::SetPrototypeMethod(lcons, "node_coordinates", node_coordinates);
Nan::SetPrototypeMethod(lcons, "wkb", wkb);
Nan::SetPrototypeMethod(lcons, "wkt", wkt);
target->Set(Nan::New(symbol_Way), lcons->GetFunction());
target->Set(Nan::GetCurrentContext(), Nan::New(symbol_Way), Nan::GetFunction(lcons).ToLocalChecked());
constructor.Reset(lcons);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ namespace node_osmium {
Nan::ThrowTypeError(Nan::New("call node_refs() without parameters or the index of the node you want").ToLocalChecked());
return;
}
uint32_t n = info[0]->Uint32Value();
uint32_t n = info[0]->Uint32Value(Nan::GetCurrentContext()).ToChecked();
if (n < way.nodes().size()) {
info.GetReturnValue().Set(Nan::New<v8::Number>(way.nodes()[n].ref()));
return;
Expand Down Expand Up @@ -130,7 +130,7 @@ namespace node_osmium {
v8::Local<v8::Value> argv[2] = { Nan::New(location.lon()), Nan::New<v8::Number>(location.lat()) };
Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(v8::Local<v8::Function>::Cast(cf), 2, argv);
if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Node instance");
nodes->Set(i, maybe_local.ToLocalChecked()->ToObject());
nodes->Set(i, maybe_local.ToLocalChecked());
++i;
last_location = location;
}
Expand All @@ -151,14 +151,14 @@ namespace node_osmium {
Nan::ThrowTypeError(Nan::New("call node_coordinates() without parameters or the index of the node you want").ToLocalChecked());
return;
}
uint32_t n = info[0]->Uint32Value();
uint32_t n = info[0]->Uint32Value(Nan::GetCurrentContext()).ToChecked();
if (n < way.nodes().size()) {
const osmium::Location location = way.nodes()[n].location();
if (location.valid()) {
v8::Local<v8::Value> argv[2] = { Nan::New(location.lon()), Nan::New<v8::Number>(location.lat()) };
Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(v8::Local<v8::Function>::Cast(cf), 2, argv);
if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Node instance");
info.GetReturnValue().Set(maybe_local.ToLocalChecked()->ToObject());
info.GetReturnValue().Set(maybe_local.ToLocalChecked());
return;
} else {
info.GetReturnValue().Set(Nan::Undefined());
Expand Down
16 changes: 8 additions & 8 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,46 @@ namespace node_osmium {

Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(v8::Local<v8::Function>::Cast(cf),2,argv_bl);
if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Box instance");
auto bottom_left = maybe_local.ToLocalChecked()->ToObject();
auto bottom_left = maybe_local.ToLocalChecked()->ToObject(Nan::GetCurrentContext()).ToLocalChecked();

v8::Local<v8::Value> argv_tr[2] = { Nan::New(box.top_right().lon()), Nan::New<v8::Number>(box.top_right().lat()) };
Nan::MaybeLocal<v8::Object> maybe_local2 = Nan::NewInstance(v8::Local<v8::Function>::Cast(cf),2,argv_tr);
if (maybe_local2.IsEmpty()) Nan::ThrowError("Could not create new Box instance");
auto top_right = maybe_local2.ToLocalChecked()->ToObject();
auto top_right = maybe_local2.ToLocalChecked()->ToObject(Nan::GetCurrentContext()).ToLocalChecked();

v8::Local<v8::Value> argv_box[2] = { bottom_left, top_right };

Nan::MaybeLocal<v8::Object> maybe_local3 = Nan::NewInstance(v8::Local<v8::Function>::Cast(bf),2,argv_box);
if (maybe_local3.IsEmpty()) Nan::ThrowError("Could not create new Box instance");

return scope.Escape(maybe_local3.ToLocalChecked()->ToObject());
return scope.Escape(maybe_local3.ToLocalChecked()->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
}

osmium::osm_entity_bits::type object_to_entity_bits(v8::Local<v8::Object> options) {
osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nothing;

v8::Local<v8::Value> want_nodes = options->Get(Nan::New(symbol_node));
if (want_nodes->IsBoolean() && want_nodes->BooleanValue()) {
if (want_nodes->IsBoolean() && Nan::To<bool>(want_nodes).ToChecked()) {
entities |= osmium::osm_entity_bits::node;
}

v8::Local<v8::Value> want_ways = options->Get(Nan::New(symbol_way));
if (want_ways->IsBoolean() && want_ways->BooleanValue()) {
if (want_ways->IsBoolean() && Nan::To<bool>(want_ways).ToChecked()) {
entities |= osmium::osm_entity_bits::way;
}

v8::Local<v8::Value> want_relations = options->Get(Nan::New(symbol_relation));
if (want_relations->IsBoolean() && want_relations->BooleanValue()) {
if (want_relations->IsBoolean() && Nan::To<bool>(want_relations).ToChecked()) {
entities |= osmium::osm_entity_bits::relation;
}

v8::Local<v8::Value> want_areas = options->Get(Nan::New(symbol_area));
if (want_areas->IsBoolean() && want_areas->BooleanValue()) {
if (want_areas->IsBoolean() && Nan::To<bool>(want_areas).ToChecked()) {
entities |= osmium::osm_entity_bits::area;
}

v8::Local<v8::Value> want_changesets = options->Get(Nan::New(symbol_changeset));
if (want_changesets->IsBoolean() && want_changesets->BooleanValue()) {
if (want_changesets->IsBoolean() && Nan::To<bool>(want_changesets).ToChecked()) {
entities |= osmium::osm_entity_bits::changeset;
}

Expand Down
Loading

0 comments on commit 197b45f

Please sign in to comment.