Skip to content

Commit 5d9e2bc

Browse files
committed
N-API call Map::release() in OnWorkComplete(..) + cleanups (WIP)
1 parent 98f2069 commit 5d9e2bc

15 files changed

+58
-89
lines changed

src/blend.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ struct AsyncBlend : Napi::AsyncWorker
490490
Base::SetError(err);
491491
}
492492

493-
//private:
494493
Images images_;
495494
int quality_;
496495
int width_;
@@ -512,7 +511,7 @@ static void Blend_Encode(AsyncBlend* worker, mapnik::image_rgba8 const& image, b
512511
if (worker->format_ == BLEND_FORMAT_JPEG)
513512
{
514513
#if defined(HAVE_JPEG)
515-
//if (worker->quality_ == 0) worker->quality_ = 85;
514+
if (worker->quality_ == 0) worker->quality_ = 85;
516515
mapnik::save_as_jpeg(stream, worker->quality_, image);
517516
#else
518517
worker->SetError("Mapnik not built with jpeg support");
@@ -914,7 +913,8 @@ Napi::Value blend(Napi::CallbackInfo const& info)
914913

915914
if (image->buffer.IsEmpty() && !image->im_obj)
916915
{
917-
Napi::TypeError::New(env, "All elements must be Buffers or RGBA Mapnik Image objects or objects with a 'buffer' property.").ThrowAsJavaScriptException();
916+
Napi::TypeError::New(env, "All elements must be Buffers or RGBA Mapnik Image objects or objects with a 'buffer' property.")
917+
.ThrowAsJavaScriptException();
918918
return env.Undefined();
919919
}
920920
if (!image->im_obj)

src/ds_emitter.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void get_fields(Napi::Env env, Napi::Object & fields, mapnik::datasource_
2525
else if (field_type == mapnik::Float) type = "Number";
2626
else if (field_type == mapnik::Double) type = "Number";
2727
else if (field_type == mapnik::String) type = "String";
28-
/* LCOV_EXCL_START */
28+
// LCOV_EXCL_START
2929
// Not currently possible to author these values in mapnik core
3030
// Should likely be considered for removing in mapnik
3131
else if (field_type == mapnik::Boolean) type = "Boolean";
@@ -34,8 +34,7 @@ static void get_fields(Napi::Env env, Napi::Object & fields, mapnik::datasource_
3434
else type = "Unknown";
3535
std::string const& name = attr_info.get_name();
3636
fields.Set(name, type);
37-
//fields.Set(name, Napi::String::New(env, type)); <== FIXME: duplicate?
38-
/* LCOV_EXCL_STOP */
37+
// LCOV_EXCL_STOP
3938
}
4039
}
4140

src/mapnik_cairo_surface.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,5 @@ Napi::Value CairoSurface::getData(Napi::CallbackInfo const& info)
6262
Napi::EscapableHandleScope scope(env);
6363
if (!data_.empty()) return scope.Escape(Napi::String::New(env, data_));
6464
std::string str = stream_.str();
65-
//return scope.Escape(Napi::Buffer<char>::Copy(env, const_cast<char*>(str.data()), str.size()));
6665
return scope.Escape(Napi::String::New(env, str));
6766
}

src/mapnik_cairo_surface.hpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22

33
#include <napi.h>
4-
5-
//#include <string>
4+
// stl
65
#include <sstream>
76
// cairo
87
#if defined(HAVE_CAIRO)
@@ -15,7 +14,6 @@
1514
class CairoSurface : public Napi::ObjectWrap<CairoSurface>
1615
{
1716
public:
18-
//typedef std::stringstream i_stream;
1917
// initializer
2018
static Napi::Object Initialize(Napi::Env env, Napi::Object exports);
2119
// ctor
@@ -24,12 +22,6 @@ class CairoSurface : public Napi::ObjectWrap<CairoSurface>
2422
Napi::Value getData(Napi::CallbackInfo const& info);
2523
Napi::Value width(Napi::CallbackInfo const& info);
2624
Napi::Value height(Napi::CallbackInfo const& info);
27-
28-
//using Napi::ObjectWrap::Ref;
29-
//using Napi::ObjectWrap::Unref;
30-
31-
//CairoSurface(std::string const& format, unsigned int width, unsigned int height);
32-
3325
static cairo_status_t write_callback(void * stream,
3426
const unsigned char *data,
3527
unsigned int length)

src/mapnik_color.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#include "mapnik_color.hpp"
2-
// stl
3-
#include <exception>
4-
52

63
Napi::FunctionReference Color::constructor;
74

src/mapnik_datasource.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
// mapnik
77
#include <mapnik/attribute_descriptor.hpp> // for attribute_descriptor
8-
#include <mapnik/geometry/box2d.hpp> // for box2d
9-
#include <mapnik/datasource.hpp> // for datasource, datasource_ptr, etc
10-
#include <mapnik/datasource_cache.hpp> // for datasource_cache
11-
#include <mapnik/feature_layer_desc.hpp> // for layer_descriptor
12-
#include <mapnik/params.hpp> // for parameters
13-
#include <mapnik/query.hpp> // for query
8+
#include <mapnik/geometry/box2d.hpp> // for box2d
9+
#include <mapnik/datasource.hpp> // for datasource, datasource_ptr, etc
10+
#include <mapnik/datasource_cache.hpp> // for datasource_cache
11+
#include <mapnik/feature_layer_desc.hpp> // for layer_descriptor
12+
#include <mapnik/params.hpp> // for parameters
13+
#include <mapnik/query.hpp> // for query
1414

1515
// stl
1616
#include <exception>
@@ -134,10 +134,10 @@ Napi::Value Datasource::extent(Napi::CallbackInfo const& info)
134134
// where a plugin dynamically calculated extent such as
135135
// postgis plugin. Therefore this makes this difficult
136136
// to add to testing. Therefore marking it with exclusion
137-
/* LCOV_EXCL_START */
137+
// LCOV_EXCL_START
138138
Napi::Error::New(env, ex.what()).ThrowAsJavaScriptException();
139139
return env.Undefined();
140-
/* LCOV_EXCL_STOP */
140+
// LCOV_EXCL_STOP
141141
}
142142

143143
Napi::Array arr = Napi::Array::New(env, 4);
@@ -172,10 +172,10 @@ Napi::Value Datasource::describe(Napi::CallbackInfo const& info)
172172
// where a plugin dynamically calculated extent such as
173173
// postgis plugin. Therefore this makes this difficult
174174
// to add to testing. Therefore marking it with exclusion
175-
/* LCOV_EXCL_START */
175+
// LCOV_EXCL_START
176176
Napi::Error::New(env, ex.what()).ThrowAsJavaScriptException();
177177
return env.Undefined();
178-
/* LCOV_EXCL_STOP */
178+
// LCOV_EXCL_STOP
179179
}
180180
return scope.Escape(description);
181181
}

src/mapnik_feature.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ Napi::Object Feature::Initialize(Napi::Env env, Napi::Object exports)
3131
return exports;
3232
}
3333

34-
//Feature::Feature(mapnik::feature_ptr f) : Napi::ObjectWrap<Feature>(),
35-
// this_(f) {}
36-
37-
//Feature::Feature(int id) : Napi::ObjectWrap<Feature>(),
38-
// this_() {
39-
// // TODO - accept/require context object to reused
40-
// ctx_ = std::make_shared<mapnik::context_type>();
41-
// this_ = mapnik::feature_factory::create(ctx_,id);
42-
//}
43-
4434
/**
4535
* **`mapnik.Feature`**
4636
*

src/mapnik_feature.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
class Feature : public Napi::ObjectWrap<Feature>
1212
{
13-
//friend class Featureset;
14-
//friend class Expression;
15-
//friend class VectorTile;
1613
public:
1714
// initialiser
1815
static Napi::Object Initialize(Napi::Env env, Napi::Object exports);

src/mapnik_image_copy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct AsyncCopy : Napi::AsyncWorker
3737
{
3838
Napi::Value arg = Napi::External<image_ptr>::New(env, &image_out_);
3939
Napi::Object obj = Image::constructor.New({arg});
40-
return {env.Null(), napi_value(obj)};
40+
return {env.Undefined(), napi_value(obj)};
4141
}
4242
return Base::GetResult(env);
4343
}

src/mapnik_image_view.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,6 @@ ImageView::ImageView(Napi::CallbackInfo const& info)
105105
Napi::Error::New(env, "Cannot create this object from Javascript").ThrowAsJavaScriptException();
106106
}
107107

108-
/*
109-
typedef struct {
110-
uv_work_t request;
111-
ImageView* im;
112-
Napi::FunctionReference cb;
113-
bool error;
114-
std::string error_name;
115-
bool result;
116-
} is_solid_image_view_baton_t;
117-
*/
118-
119-
120108
Napi::Value ImageView::isSolid(Napi::CallbackInfo const& info)
121109
{
122110
if (info.Length() == 0)

src/mapnik_logger.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class Logger : public Napi::ObjectWrap<Logger>
1616
// Are these the only methods available in logger?
1717
static Napi::Value get_severity(Napi::CallbackInfo const& info);
1818
static Napi::Value set_severity(Napi::CallbackInfo const& info);
19-
//Napi::Value evoke_error(Napi::CallbackInfo const& info);
2019
private:
2120
static Napi::FunctionReference constructor;
2221
};

src/mapnik_map.cpp

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
#include "mapnik_map.hpp"
22
#include "utils.hpp"
33
#include "mapnik_color.hpp" // for Color, Color::constructor
4-
//#include "mapnik_featureset.hpp" // for Featureset
54
#include "mapnik_image.hpp" // for Image, Image::constructor
65
#include "mapnik_layer.hpp" // for Layer, Layer::constructor
76
#include "mapnik_palette.hpp" // for palette_ptr, Palette, etc
8-
//#include "mapnik_vector_tile.hpp"
9-
10-
// mapnik-vector-tile
11-
//#include "vector_tile_processor.hpp"
12-
137
// mapnik
14-
#include <mapnik/featureset.hpp> // for featureset_ptr
8+
#include <mapnik/map.hpp>
159
#include <mapnik/layer.hpp> // for layer
1610
#include <mapnik/save_map.hpp> // for save_map, etc
17-
#include <mapnik/image_scaling.hpp>
18-
#include <mapnik/request.hpp>
19-
#if defined(HAVE_CAIRO)
20-
#include <mapnik/cairo_io.hpp>
21-
#endif
22-
2311
// stl
24-
//#include <exception> // for exception
25-
//#include <iosfwd> // for ostringstream, ostream
26-
//#include <ostream> // for operator<<, basic_ostream, etc
2712
#include <sstream> // for basic_ostringstream, etc
2813

29-
// boost
30-
#include <boost/optional/optional.hpp> // for optional
31-
3214
Napi::FunctionReference Map::constructor;
3315

3416
Napi::Object Map::Initialize(Napi::Env env, Napi::Object exports)

0 commit comments

Comments
 (0)