Skip to content

Commit

Permalink
Merge pull request #230 from Algunenano/node10
Browse files Browse the repository at this point in the history
Node10 compatibility
  • Loading branch information
brianreavis authored Jun 28, 2018
2 parents d25c9fb + 32addbd commit d8fb97b
Show file tree
Hide file tree
Showing 39 changed files with 129 additions and 89 deletions.
79 changes: 58 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
language: cpp

dist: precise

compiler:
- gcc

os:
- linux
- osx

addons:
apt:
sources:
Expand All @@ -17,21 +11,65 @@ addons:
- g++-4.8
- libc6-dev # for libiconv which is needed by libgdal

env:
matrix:
- NODE_NVM_VERSION="9" TARGET=STATIC
- NODE_NVM_VERSION="9" TARGET=SHARED
- NODE_NVM_VERSION="9" TARGET=TRUNK
- NODE_NVM_VERSION="8" TARGET=STATIC
- NODE_NVM_VERSION="8" TARGET=SHARED
- NODE_NVM_VERSION="6" TARGET=STATIC
- NODE_NVM_VERSION="6" TARGET=SHARED
- NODE_NVM_VERSION="4" TARGET=STATIC
- NODE_NVM_VERSION="4" TARGET=SHARED

matrix:
include:
- os: osx
env: NODE_NVM_VERSION="10" TARGET=STATIC
- os: linux
dist: precise
env: NODE_NVM_VERSION="10" TARGET=STATIC
- os: osx
env: NODE_NVM_VERSION="10" TARGET=SHARED
- os: linux
dist: trusty
env: NODE_NVM_VERSION="10" TARGET=SHARED
- os: osx
env: NODE_NVM_VERSION="10" TARGET=TRUNK
- os: linux
dist: trusty
env: NODE_NVM_VERSION="10" TARGET=TRUNK
- os: osx
env: NODE_NVM_VERSION="9" TARGET=STATIC
- os: linux
dist: precise
env: NODE_NVM_VERSION="9" TARGET=STATIC
- os: osx
env: NODE_NVM_VERSION="9" TARGET=SHARED
- os: linux
dist: trusty
env: NODE_NVM_VERSION="9" TARGET=SHARED
- os: osx
env: NODE_NVM_VERSION="8" TARGET=STATIC
- os: linux
dist: precise
env: NODE_NVM_VERSION="8" TARGET=STATIC
- os: osx
env: NODE_NVM_VERSION="8" TARGET=SHARED
- os: linux
dist: trusty
env: NODE_NVM_VERSION="8" TARGET=SHARED
- os: osx
env: NODE_NVM_VERSION="6" TARGET=STATIC
- os: linux
dist: precise
env: NODE_NVM_VERSION="6" TARGET=STATIC
- os: osx
env: NODE_NVM_VERSION="6" TARGET=SHARED
- os: linux
dist: trusty
env: NODE_NVM_VERSION="6" TARGET=SHARED
- os: osx
env: NODE_NVM_VERSION="4" TARGET=STATIC
- os: linux
dist: precise
env: NODE_NVM_VERSION="4" TARGET=STATIC
- os: osx
env: NODE_NVM_VERSION="4" TARGET=SHARED
- os: linux
dist: trusty
env: NODE_NVM_VERSION="4" TARGET=SHARED
allow_failures:
- env: NODE_NVM_VERSION="9" TARGET=TRUNK
- env: NODE_NVM_VERSION="10" TARGET=TRUNK

before_install:
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
Expand All @@ -52,8 +90,7 @@ before_install:

install:
- if [[ "${TARGET}" == "TRUNK" ]]; then ./scripts/gdal-trunk.sh; fi;
- if [[ "${TARGET}" == "SHARED" && "$(uname -s)" == "Linux" ]]; then sudo apt-get -qq update; sudo apt-get --force-yes -qq install libgdal-dev libgdal1-dev libgdal1h=1.10.0-1~precise1; fi;
- if [[ "${TARGET}" == "SHARED" && "$(uname -s)" == "Darwin" ]]; then brew update; brew uninstall --ignore-dependencies gdal; brew install gdal; fi;
- if [[ "${TARGET}" == "SHARED" && "$(uname -s)" == "Linux" ]]; then sudo apt-get -qq update; sudo apt-get --force-yes -qq install libgdal-dev libc6-dev; fi;
- if [[ "${TARGET}" == "SHARED" || "${TARGET}" == "TRUNK" ]]; then npm install --build-from-source --shared_gdal; fi;
- if [[ "${TARGET}" == "SHARED" || "${TARGET}" == "TRUNK" ]]; then gdal-config --version --version; fi;
- if [[ "${TARGET}" == "STATIC" ]]; then npm install --build-from-source > /dev/null; fi;
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ environment:
msvs_toolset: 14
- nodejs_version: 9
msvs_toolset: 14
- nodejs_version: 10
msvs_toolset: 14

install:
- ps: Start-FileDownload 'https://github.com/mapbox/ci-scripts/raw/v1.1.0/node/ci-cpp.bat' -FileName ci.bat
Expand Down
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{
"target_name": "gdal",
"type": "loadable_module",
"win_delay_load_hook": "false",
"product_prefix": "",
"product_extension": "node",
"sources": [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"publish-yuidoc": "npm run yuidoc && node ./scripts/publish-docs.js"
},
"dependencies": {
"nan": "~2.7.0",
"node-pre-gyp": "~0.6.39"
"nan": "~2.10.0",
"node-pre-gyp": "~0.10.0"
},
"bundledDependencies": [
"node-pre-gyp"
Expand Down
2 changes: 1 addition & 1 deletion src/collections/dataset_bands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Local<Value> DatasetBands::New(Local<Value> ds_obj)
DatasetBands *wrapped = new DatasetBands();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(DatasetBands::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(DatasetBands::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), ds_obj);

return scope.Escape(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/collections/dataset_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Local<Value> DatasetLayers::New(Local<Value> ds_obj)
DatasetLayers *wrapped = new DatasetLayers();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(DatasetLayers::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(DatasetLayers::constructor)->GetFunction(), 1, &ext).ToLocalChecked();

Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), ds_obj);

Expand Down
2 changes: 1 addition & 1 deletion src/collections/feature_defn_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Local<Value> FeatureDefnFields::New(Local<Value> feature_defn)
FeatureDefnFields *wrapped = new FeatureDefnFields();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(FeatureDefnFields::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(FeatureDefnFields::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), feature_defn);

return scope.Escape(obj);
Expand Down
4 changes: 2 additions & 2 deletions src/collections/feature_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Local<Value> FeatureFields::New(Local<Value> layer_obj)
FeatureFields *wrapped = new FeatureFields();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(FeatureFields::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(FeatureFields::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), layer_obj);

return scope.Escape(obj);
Expand Down Expand Up @@ -171,7 +171,7 @@ NAN_METHOD(FeatureFields::set)

//skip value if field name doesnt exist
//both in the feature definition and the passed object
if (field_index == -1 || !values->HasOwnProperty(Nan::New(field_name).ToLocalChecked())) {
if (field_index == -1 || !Nan::HasOwnProperty(values, Nan::New(field_name).ToLocalChecked()).FromMaybe(false)) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/collections/gdal_drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Local<Value> GDALDrivers::New()
GDALDrivers *wrapped = new GDALDrivers();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(GDALDrivers::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(GDALDrivers::constructor)->GetFunction(), 1, &ext).ToLocalChecked();

return scope.Escape(obj);
}
Expand Down
2 changes: 1 addition & 1 deletion src/collections/geometry_collection_children.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Local<Value> GeometryCollectionChildren::New(Local<Value> geom)
GeometryCollectionChildren *wrapped = new GeometryCollectionChildren();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(GeometryCollectionChildren::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(GeometryCollectionChildren::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), geom);

return scope.Escape(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/collections/layer_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Local<Value> LayerFeatures::New(Local<Value> layer_obj)
LayerFeatures *wrapped = new LayerFeatures();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(LayerFeatures::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(LayerFeatures::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), layer_obj);

return scope.Escape(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/collections/layer_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Local<Value> LayerFields::New(Local<Value> layer_obj)
LayerFields *wrapped = new LayerFields();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(LayerFields::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(LayerFields::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), layer_obj);

return scope.Escape(obj);
Expand Down
8 changes: 4 additions & 4 deletions src/collections/linestring_points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Local<Value> LineStringPoints::New(Local<Value> geom)
LineStringPoints *wrapped = new LineStringPoints();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(LineStringPoints::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(LineStringPoints::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), geom);

return scope.Escape(obj);
Expand Down Expand Up @@ -210,7 +210,7 @@ NAN_METHOD(LineStringPoints::set)
NODE_DOUBLE_FROM_OBJ(obj, "y", y);

Local<String> z_prop_name = Nan::New("z").ToLocalChecked();
if (obj->HasOwnProperty(z_prop_name)) {
if (Nan::HasOwnProperty(obj, z_prop_name).FromMaybe(false)) {
Local<Value> z_val = obj->Get(z_prop_name);
if (!z_val->IsNumber()) {
Nan::ThrowError("z property must be number");
Expand Down Expand Up @@ -304,7 +304,7 @@ NAN_METHOD(LineStringPoints::add)
NODE_DOUBLE_FROM_OBJ(element_obj, "y", y);

Local<String> z_prop_name = Nan::New("z").ToLocalChecked();
if (element_obj->HasOwnProperty(z_prop_name)) {
if (Nan::HasOwnProperty(element_obj, z_prop_name).FromMaybe(false)) {
Local<Value> z_val = element_obj->Get(z_prop_name);
if (!z_val->IsNumber()) {
Nan::ThrowError("z property must be number");
Expand All @@ -324,7 +324,7 @@ NAN_METHOD(LineStringPoints::add)
NODE_DOUBLE_FROM_OBJ(obj, "y", y);

Local<String> z_prop_name = Nan::New("z").ToLocalChecked();
if (obj->HasOwnProperty(z_prop_name)) {
if (Nan::HasOwnProperty(obj, z_prop_name).FromMaybe(false)) {
Local<Value> z_val = obj->Get(z_prop_name);
if (!z_val->IsNumber()) {
Nan::ThrowError("z property must be number");
Expand Down
2 changes: 1 addition & 1 deletion src/collections/polygon_rings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Local<Value> PolygonRings::New(Local<Value> geom)
PolygonRings *wrapped = new PolygonRings();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(PolygonRings::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(PolygonRings::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), geom);

return scope.Escape(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/collections/rasterband_overviews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Local<Value> RasterBandOverviews::New(Local<Value> band_obj)
RasterBandOverviews *wrapped = new RasterBandOverviews();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(RasterBandOverviews::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(RasterBandOverviews::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), band_obj);

return scope.Escape(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/collections/rasterband_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Local<Value> RasterBandPixels::New(Local<Value> band_obj)
RasterBandPixels *wrapped = new RasterBandPixels();

v8::Local<v8::Value> ext = Nan::New<External>(wrapped);
v8::Local<v8::Object> obj = Nan::New(RasterBandPixels::constructor)->GetFunction()->NewInstance(1, &ext);
v8::Local<v8::Object> obj = Nan::NewInstance(Nan::New(RasterBandPixels::constructor)->GetFunction(), 1, &ext).ToLocalChecked();
Nan::SetPrivate(obj, Nan::New("parent_").ToLocalChecked(), band_obj);

return scope.Escape(obj);
Expand Down
6 changes: 3 additions & 3 deletions src/gdal_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ NAN_METHOD(Algorithms::contourGenerate)
NODE_INT_FROM_OBJ_OPT(obj, "elevField", elev_field);
NODE_DOUBLE_FROM_OBJ_OPT(obj, "interval", interval);
NODE_DOUBLE_FROM_OBJ_OPT(obj, "offset", base);
if(obj->HasOwnProperty(Nan::New("fixedLevels").ToLocalChecked())){
if(Nan::HasOwnProperty(obj, Nan::New("fixedLevels").ToLocalChecked()).FromMaybe(false)){
if(fixed_level_array.parse(obj->Get(Nan::New("fixedLevels").ToLocalChecked()))){
return; //error parsing double list
} else {
fixed_levels = fixed_level_array.get();
n_fixed_levels = fixed_level_array.length();
}
}
if(obj->HasOwnProperty(Nan::New("nodata").ToLocalChecked())){
if(Nan::HasOwnProperty(obj, Nan::New("nodata").ToLocalChecked()).FromMaybe(false)){
prop = obj->Get(Nan::New("nodata").ToLocalChecked());
if(prop->IsNumber()){
use_nodata = 1;
Expand Down Expand Up @@ -273,7 +273,7 @@ NAN_METHOD(Algorithms::polygonize)
}

CPLErr err;
if(obj->HasOwnProperty(Nan::New("useFloats").ToLocalChecked()) && obj->Get(Nan::New("useFloats").ToLocalChecked())->BooleanValue()){
if(Nan::HasOwnProperty(obj, Nan::New("useFloats").ToLocalChecked()).FromMaybe(false) && obj->Get(Nan::New("useFloats").ToLocalChecked())->BooleanValue()){
err = GDALFPolygonize(src->get(), mask ? mask->get() : NULL, reinterpret_cast<OGRLayerH>(dst->get()), pix_val_field, papszOptions, NULL, NULL);
} else {
err = GDALPolygonize(src->get(), mask ? mask->get() : NULL, reinterpret_cast<OGRLayerH>(dst->get()), pix_val_field, papszOptions, NULL, NULL);
Expand Down
Loading

0 comments on commit d8fb97b

Please sign in to comment.