core: rename mbgl namespace to mln (#4487)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Bart Louwers
2026-08-14 23:25:20 +02:00
committed by GitHub
parent 836b862984
commit 550f64be22
1970 changed files with 8931 additions and 8967 deletions

View File

@@ -10,7 +10,7 @@
#include <mbgl/style/conversion/geojson.hpp>
#include <mbgl/style/conversion_impl.hpp>
namespace mbgl {
namespace mln {
namespace style {
namespace conversion {
@@ -159,4 +159,4 @@ std::optional<T> convert(const v8::Local<v8::Value>& value, Error& error, Args&&
} // namespace conversion
} // namespace style
} // namespace mbgl
} // namespace mln

View File

@@ -9,8 +9,8 @@
#include <mbgl/util/geojson.hpp>
#include <nan.h>
using namespace mbgl::style;
using namespace mbgl::style::expression;
using namespace mln::style;
using namespace mln::style::expression;
namespace node_mbgl {
@@ -113,10 +113,10 @@ void NodeExpression::Parse(const Nan::FunctionCallbackInfo<v8::Value>& info) {
auto expr = info[0];
try {
mbgl::style::conversion::Convertible convertible(expr);
mln::style::conversion::Convertible convertible(expr);
if (expr->IsObject() && !expr->IsArray() && expected) {
mbgl::style::conversion::Error error;
mln::style::conversion::Error error;
auto func = convertFunctionToExpression(*expected, convertible, error, false);
if (func) {
return success(std::move(*func));
@@ -125,7 +125,7 @@ void NodeExpression::Parse(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
ParsingContext ctx = expected ? ParsingContext(*expected) : ParsingContext();
ParseResult parsed = ctx.parseLayerPropertyExpression(mbgl::style::conversion::Convertible(expr));
ParseResult parsed = ctx.parseLayerPropertyExpression(mln::style::conversion::Convertible(expr));
if (parsed) {
assert(ctx.getErrors().empty());
return success(std::move(*parsed));
@@ -145,7 +145,7 @@ void NodeExpression::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
struct ToValue {
v8::Local<v8::Value> operator()(mbgl::NullValue) {
v8::Local<v8::Value> operator()(mln::NullValue) {
Nan::EscapableHandleScope scope;
return scope.Escape(Nan::Null());
}
@@ -185,27 +185,27 @@ struct ToValue {
v8::Local<v8::Value> operator()(const Formatted& formatted) {
// This mimics the internal structure of the Formatted class in formatted.js
// A better approach might be to use the explicit serialized form
// both here and on the JS side? e.g. toJS(fromExpressionValue<mbgl::Value>(formatted))
std::unordered_map<std::string, mbgl::Value> serialized;
std::vector<mbgl::Value> sections;
// both here and on the JS side? e.g. toJS(fromExpressionValue<mln::Value>(formatted))
std::unordered_map<std::string, mln::Value> serialized;
std::vector<mln::Value> sections;
for (const auto& section : formatted.sections) {
std::unordered_map<std::string, mbgl::Value> serializedSection;
std::unordered_map<std::string, mln::Value> serializedSection;
serializedSection.emplace("text", section.text);
if (section.fontScale) {
serializedSection.emplace("scale", *section.fontScale);
} else {
serializedSection.emplace("scale", mbgl::NullValue());
serializedSection.emplace("scale", mln::NullValue());
}
if (section.fontStack) {
std::string fontStackString;
serializedSection.emplace("fontStack", mbgl::fontStackToString(*section.fontStack));
serializedSection.emplace("fontStack", mln::fontStackToString(*section.fontStack));
} else {
serializedSection.emplace("fontStack", mbgl::NullValue());
serializedSection.emplace("fontStack", mln::NullValue());
}
if (section.textColor) {
serializedSection.emplace("textColor", section.textColor->toObject());
} else {
serializedSection.emplace("textColor", mbgl::NullValue());
serializedSection.emplace("textColor", mln::NullValue());
}
sections.emplace_back(serializedSection);
}
@@ -214,14 +214,14 @@ struct ToValue {
return toJS(serialized);
}
v8::Local<v8::Value> operator()(const mbgl::Color& color) {
v8::Local<v8::Value> operator()(const mln::Color& color) {
return operator()(std::vector<Value>{static_cast<double>(color.r),
static_cast<double>(color.g),
static_cast<double>(color.b),
static_cast<double>(color.a)});
}
v8::Local<v8::Value> operator()(const mbgl::Padding& padding) {
v8::Local<v8::Value> operator()(const mln::Padding& padding) {
return operator()(std::vector<Value>{static_cast<double>(padding.top),
static_cast<double>(padding.right),
static_cast<double>(padding.bottom),
@@ -240,12 +240,12 @@ struct ToValue {
v8::Local<v8::Value> operator()(const Image& image) { return toJS(image.toValue()); }
v8::Local<v8::Value> operator()(const mbgl::VariableAnchorOffsetCollection& variableAnchorOffsets) {
v8::Local<v8::Value> operator()(const mln::VariableAnchorOffsetCollection& variableAnchorOffsets) {
std::vector<Value> components;
components.reserve(variableAnchorOffsets.size() * 2);
for (const auto& variableAnchorOffset : variableAnchorOffsets) {
components.emplace_back(
std::string(mbgl::Enum<mbgl::style::SymbolAnchorType>::toString(variableAnchorOffset.anchorType)));
std::string(mln::Enum<mln::style::SymbolAnchorType>::toString(variableAnchorOffset.anchorType)));
components.emplace_back(std::vector<Value>{static_cast<double>(variableAnchorOffset.offset[0]),
static_cast<double>(variableAnchorOffset.offset[1])});
}
@@ -279,7 +279,7 @@ void NodeExpression::Evaluate(const Nan::FunctionCallbackInfo<v8::Value>& info)
Nan::JSON NanJSON;
conversion::Error conversionError;
std::optional<mbgl::GeoJSON> geoJSON = conversion::convert<mbgl::GeoJSON>(info[1], conversionError);
std::optional<mln::GeoJSON> geoJSON = conversion::convert<mln::GeoJSON>(info[1], conversionError);
if (!geoJSON) {
Nan::ThrowTypeError(conversionError.message.c_str());
return;
@@ -326,7 +326,7 @@ void NodeExpression::Serialize(const Nan::FunctionCallbackInfo<v8::Value>& info)
auto* nodeExpr = ObjectWrap::Unwrap<NodeExpression>(info.Holder());
const std::unique_ptr<Expression>& expression = nodeExpr->expression;
const mbgl::Value serialized = expression->serialize();
const mln::Value serialized = expression->serialize();
info.GetReturnValue().Set(toJS(serialized));
}

View File

@@ -13,14 +13,14 @@
namespace node_mbgl {
v8::Local<v8::Value> toJS(const mbgl::style::expression::Value&);
v8::Local<v8::Value> toJS(const mln::style::expression::Value&);
class NodeExpression : public Nan::ObjectWrap {
public:
static void Init(v8::Local<v8::Object>);
private:
NodeExpression(std::unique_ptr<mbgl::style::expression::Expression> expression_)
NodeExpression(std::unique_ptr<mln::style::expression::Expression> expression_)
: expression(std::move(expression_)) {};
static void New(const Nan::FunctionCallbackInfo<v8::Value>&);
@@ -34,7 +34,7 @@ private:
static Nan::Persistent<v8::Function> constructor;
std::unique_ptr<mbgl::style::expression::Expression> expression;
std::unique_ptr<mln::style::expression::Expression> expression;
};
} // namespace node_mbgl

View File

@@ -4,12 +4,12 @@ namespace node_mbgl {
using namespace mapbox::geometry;
using Value = mbgl::Value;
using Feature = mbgl::Feature;
using FeatureIdentifier = mbgl::FeatureIdentifier;
using Geometry = mbgl::Feature::geometry_type;
using Value = mln::Value;
using Feature = mln::Feature;
using FeatureIdentifier = mln::FeatureIdentifier;
using Geometry = mln::Feature::geometry_type;
using GeometryCollection = mapbox::geometry::geometry_collection<double>;
using Properties = mbgl::PropertyMap;
using Properties = mln::PropertyMap;
template <class T>
struct ToType {
@@ -64,7 +64,7 @@ public:
};
struct ToValue {
v8::Local<v8::Value> operator()(mbgl::NullValue) {
v8::Local<v8::Value> operator()(mln::NullValue) {
Nan::EscapableHandleScope scope;
return scope.Escape(Nan::Null());
}
@@ -88,7 +88,7 @@ struct ToValue {
return scope.Escape(Nan::New(t).ToLocalChecked());
}
v8::Local<v8::Value> operator()(const std::vector<mbgl::Value>& array) {
v8::Local<v8::Value> operator()(const std::vector<mln::Value>& array) {
Nan::EscapableHandleScope scope;
v8::Local<v8::Array> result = Nan::New<v8::Array>();
for (std::size_t i = 0; i < array.size(); i++) {
@@ -97,7 +97,7 @@ struct ToValue {
return scope.Escape(result);
}
v8::Local<v8::Value> operator()(const std::unordered_map<std::string, mbgl::Value>& map) { return toJS(map); }
v8::Local<v8::Value> operator()(const std::unordered_map<std::string, mln::Value>& map) { return toJS(map); }
};
v8::Local<v8::Object> toJS(const Geometry& geometry) {
@@ -138,7 +138,7 @@ v8::Local<v8::Object> toJS(const Feature& feature) {
Nan::Set(result, Nan::New("geometry").ToLocalChecked(), toJS(feature.geometry));
Nan::Set(result, Nan::New("properties").ToLocalChecked(), toJS(feature.properties));
if (!feature.id.is<mbgl::NullValue>()) {
if (!feature.id.is<mln::NullValue>()) {
Nan::Set(result, Nan::New("id").ToLocalChecked(), FeatureIdentifier::visit(feature.id, ToValue()));
}

View File

@@ -10,9 +10,9 @@
namespace node_mbgl {
v8::Local<v8::Value> toJS(const mbgl::Value&);
v8::Local<v8::Object> toJS(const mbgl::Feature&);
v8::Local<v8::Object> toJS(const mbgl::Feature::geometry_type&);
v8::Local<v8::Object> toJS(const mbgl::PropertyMap&);
v8::Local<v8::Value> toJS(const mln::Value&);
v8::Local<v8::Object> toJS(const mln::Feature&);
v8::Local<v8::Object> toJS(const mln::Feature::geometry_type&);
v8::Local<v8::Object> toJS(const mln::PropertyMap&);
} // namespace node_mbgl

View File

@@ -5,12 +5,12 @@
namespace node_mbgl {
struct NodeLogObserver::LogMessage {
mbgl::EventSeverity severity;
mbgl::Event event;
mln::EventSeverity severity;
mln::Event event;
int64_t code;
std::string text;
LogMessage(mbgl::EventSeverity severity_, mbgl::Event event_, int64_t code_, std::string text_)
LogMessage(mln::EventSeverity severity_, mln::Event event_, int64_t code_, std::string text_)
: severity(severity_),
event(event_),
code(code_),
@@ -25,11 +25,11 @@ NodeLogObserver::NodeLogObserver(v8::Local<v8::Object> target)
Nan::Set(msg,
Nan::New("class").ToLocalChecked(),
Nan::New(mbgl::Enum<mbgl::Event>::toString(message.event)).ToLocalChecked());
Nan::New(mln::Enum<mln::Event>::toString(message.event)).ToLocalChecked());
Nan::Set(msg,
Nan::New("severity").ToLocalChecked(),
Nan::New(mbgl::Enum<mbgl::EventSeverity>::toString(message.severity)).ToLocalChecked());
Nan::New(mln::Enum<mln::EventSeverity>::toString(message.severity)).ToLocalChecked());
if (message.code != -1) {
Nan::Set(msg, Nan::New("code").ToLocalChecked(), Nan::New<v8::Number>(message.code));
@@ -56,7 +56,7 @@ NodeLogObserver::~NodeLogObserver() {
queue->stop();
}
bool NodeLogObserver::onRecord(mbgl::EventSeverity severity, mbgl::Event event, int64_t code, const std::string &text) {
bool NodeLogObserver::onRecord(mln::EventSeverity severity, mln::Event event, int64_t code, const std::string &text) {
queue->send({severity, event, code, text});
return true;
}

View File

@@ -17,13 +17,13 @@ template <typename T>
class AsyncQueue;
}
class NodeLogObserver : public mbgl::Log::Observer {
class NodeLogObserver : public mln::Log::Observer {
public:
NodeLogObserver(v8::Local<v8::Object> target);
~NodeLogObserver() override;
// Log::Observer implementation
bool onRecord(mbgl::EventSeverity severity, mbgl::Event event, int64_t code, const std::string& text) override;
bool onRecord(mln::EventSeverity severity, mln::Event event, int64_t code, const std::string& text) override;
private:
Nan::Persistent<v8::Object> module;

View File

@@ -38,16 +38,16 @@ namespace node_mbgl {
struct NodeMap::RenderOptions {
double zoom = 0;
double bearing = 0;
mbgl::style::Light light;
mln::style::Light light;
double pitch = 0;
double latitude = 0;
double longitude = 0;
mbgl::Size size = {512, 512};
mln::Size size = {512, 512};
bool axonometric = false;
double xSkew = 0;
double ySkew = 1;
std::vector<std::string> classes;
mbgl::MapDebugOptions debugOptions = mbgl::MapDebugOptions::NoDebug;
mln::MapDebugOptions debugOptions = mln::MapDebugOptions::NoDebug;
};
Nan::Persistent<v8::Function> NodeMap::constructor;
@@ -57,9 +57,9 @@ static const char* releasedMessage() {
return "Map resources have already been released";
}
void NodeMapObserver::onDidFailLoadingMap(mbgl::MapLoadError error, const std::string& description) {
void NodeMapObserver::onDidFailLoadingMap(mln::MapLoadError error, const std::string& description) {
switch (error) {
case mbgl::MapLoadError::StyleParseError:
case mln::MapLoadError::StyleParseError:
Nan::ThrowError(NodeMap::ParseError(description.c_str()));
break;
default:
@@ -207,9 +207,9 @@ void NodeMap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
if (Nan::Has(options, Nan::New("request").ToLocalChecked()).FromJust() &&
Nan::Get(options, Nan::New("request").ToLocalChecked()).ToLocalChecked()->IsFunction()) {
mbgl::FileSourceManager::get()->registerFileSourceFactory(
mbgl::FileSourceType::ResourceLoader,
[](const mbgl::ResourceOptions& resourceOptions, const mbgl::ClientOptions&) {
mln::FileSourceManager::get()->registerFileSourceFactory(
mln::FileSourceType::ResourceLoader,
[](const mln::ResourceOptions& resourceOptions, const mln::ClientOptions&) {
return std::make_unique<node_mbgl::NodeFileSource>(
reinterpret_cast<node_mbgl::NodeMap*>(resourceOptions.platformContext()));
});
@@ -269,7 +269,7 @@ void NodeMap::Load(const Nan::FunctionCallbackInfo<v8::Value>& info) {
try {
nodeMap->map->getStyle().loadJSON(style);
} catch (const mbgl::util::StyleParseException& ex) {
} catch (const mln::util::StyleParseException& ex) {
return Nan::ThrowError(ParseError(ex.what()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
@@ -333,8 +333,8 @@ NodeMap::RenderOptions NodeMap::ParseOptions(v8::Local<v8::Object> obj) {
if (Nan::Has(obj, Nan::New("light").ToLocalChecked()).FromJust()) {
auto lightObj = Nan::Get(obj, Nan::New("light").ToLocalChecked()).ToLocalChecked();
mbgl::style::conversion::Error conversionError;
if (auto light = mbgl::style::conversion::convert<mbgl::style::Light>(lightObj, conversionError)) {
mln::style::conversion::Error conversionError;
if (auto light = mln::style::conversion::convert<mln::style::Light>(lightObj, conversionError)) {
options.light = *light;
} else {
throw std::move(conversionError);
@@ -399,27 +399,27 @@ NodeMap::RenderOptions NodeMap::ParseOptions(v8::Local<v8::Object> obj) {
Nan::To<v8::Object>(Nan::Get(obj, Nan::New("debug").ToLocalChecked()).ToLocalChecked()).ToLocalChecked();
if (Nan::Has(debug, Nan::New("tileBorders").ToLocalChecked()).FromJust()) {
if (Nan::To<bool>(Nan::Get(debug, Nan::New("tileBorders").ToLocalChecked()).ToLocalChecked()).ToChecked()) {
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::TileBorders;
options.debugOptions = options.debugOptions | mln::MapDebugOptions::TileBorders;
}
}
if (Nan::Has(debug, Nan::New("parseStatus").ToLocalChecked()).FromJust()) {
if (Nan::To<bool>(Nan::Get(debug, Nan::New("parseStatus").ToLocalChecked()).ToLocalChecked()).ToChecked()) {
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::ParseStatus;
options.debugOptions = options.debugOptions | mln::MapDebugOptions::ParseStatus;
}
}
if (Nan::Has(debug, Nan::New("timestamps").ToLocalChecked()).FromJust()) {
if (Nan::To<bool>(Nan::Get(debug, Nan::New("timestamps").ToLocalChecked()).ToLocalChecked()).ToChecked()) {
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::Timestamps;
options.debugOptions = options.debugOptions | mln::MapDebugOptions::Timestamps;
}
}
if (Nan::Has(debug, Nan::New("collision").ToLocalChecked()).FromJust()) {
if (Nan::To<bool>(Nan::Get(debug, Nan::New("collision").ToLocalChecked()).ToLocalChecked()).ToChecked()) {
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::Collision;
options.debugOptions = options.debugOptions | mln::MapDebugOptions::Collision;
}
}
if (Nan::Has(debug, Nan::New("overdraw").ToLocalChecked()).FromJust()) {
if (Nan::To<bool>(Nan::Get(debug, Nan::New("overdraw").ToLocalChecked()).ToLocalChecked()).ToChecked()) {
options.debugOptions = mbgl::MapDebugOptions::Overdraw;
options.debugOptions = mln::MapDebugOptions::Overdraw;
}
}
}
@@ -489,11 +489,11 @@ void NodeMap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info) {
nodeMap->startRender(options);
}
} catch (const mbgl::style::conversion::Error& err) {
} catch (const mln::style::conversion::Error& err) {
return Nan::ThrowTypeError(err.message.c_str());
} catch (const mbgl::util::StyleParseException& ex) {
} catch (const mln::util::StyleParseException& ex) {
return Nan::ThrowError(ParseError(ex.what()));
} catch (const mbgl::util::Exception& ex) {
} catch (const mln::util::Exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -525,14 +525,14 @@ void NodeMap::startRender(const NodeMap::RenderOptions& options) {
frontend->setSize(options.size);
map->setSize(options.size);
mbgl::CameraOptions camera;
camera.center = mbgl::LatLng{options.latitude, options.longitude};
mln::CameraOptions camera;
camera.center = mln::LatLng{options.latitude, options.longitude};
camera.zoom = options.zoom;
camera.bearing = options.bearing;
camera.pitch = options.pitch;
auto projectionOptions =
mbgl::ProjectionMode().withAxonometric(options.axonometric).withXSkew(options.xSkew).withYSkew(options.ySkew);
mln::ProjectionMode().withAxonometric(options.axonometric).withXSkew(options.xSkew).withYSkew(options.ySkew);
map->setProjectionMode(projectionOptions);
@@ -587,7 +587,7 @@ void NodeMap::renderFinished() {
try {
std::rethrow_exception(error);
assert(false);
} catch (const mbgl::util::StyleParseException& ex) {
} catch (const mln::util::StyleParseException& ex) {
err = ParseError(ex.what());
} catch (const std::exception& ex) {
err = Nan::Error(ex.what());
@@ -643,7 +643,7 @@ void NodeMap::Release(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::release() {
if (!map) throw mbgl::util::Exception(releasedMessage());
if (!map) throw mln::util::Exception(releasedMessage());
uv_close(reinterpret_cast<uv_handle_t*>(async), [](uv_handle_t* h) { delete reinterpret_cast<uv_async_t*>(h); });
@@ -686,16 +686,16 @@ void NodeMap::cancel() {
uv_async_init(
uv_default_loop(), async, [](uv_async_t* h) { reinterpret_cast<NodeMap*>(h->data)->renderFinished(); });
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{512, 512}, pixelRatio);
map = std::make_unique<mbgl::Map>(*frontend,
mapObserver,
mbgl::MapOptions()
.withSize(frontend->getSize())
.withPixelRatio(pixelRatio)
.withMapMode(mode)
.withCrossSourceCollisions(crossSourceCollisions),
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)),
mbgl::ClientOptions());
frontend = std::make_unique<mln::HeadlessFrontend>(mln::Size{512, 512}, pixelRatio);
map = std::make_unique<mln::Map>(*frontend,
mapObserver,
mln::MapOptions()
.withSize(frontend->getSize())
.withPixelRatio(pixelRatio)
.withMapMode(mode)
.withCrossSourceCollisions(crossSourceCollisions),
mln::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)),
mln::ClientOptions());
// FIXME: Reload the style after recreating the map. We need to find
// a better way of canceling an ongoing rendering on the core level
@@ -707,8 +707,8 @@ void NodeMap::cancel() {
}
void NodeMap::AddSource(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -737,8 +737,8 @@ void NodeMap::AddSource(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::RemoveSource(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -755,8 +755,8 @@ void NodeMap::RemoveSource(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::AddLayer(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -776,8 +776,8 @@ void NodeMap::AddLayer(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::RemoveLayer(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -794,8 +794,8 @@ void NodeMap::RemoveLayer(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
@@ -861,15 +861,15 @@ void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(imageLength);
std::copy(imageDataBuffer, imageDataBuffer + imageLength, data.get());
mbgl::UnassociatedImage cImage({imageWidth, imageHeight}, std::move(data));
mbgl::PremultipliedImage cPremultipliedImage = mbgl::util::premultiply(std::move(cImage));
nodeMap->map->getStyle().addImage(std::make_unique<mbgl::style::Image>(
mln::UnassociatedImage cImage({imageWidth, imageHeight}, std::move(data));
mln::PremultipliedImage cPremultipliedImage = mln::util::premultiply(std::move(cImage));
nodeMap->map->getStyle().addImage(std::make_unique<mln::style::Image>(
*Nan::Utf8String(info[0]), std::move(cPremultipliedImage), pixelRatio, sdf));
}
void NodeMap::RemoveImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -886,7 +886,7 @@ void NodeMap::RemoveImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::SetLayerZoomRange(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mln::style;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -903,7 +903,7 @@ void NodeMap::SetLayerZoomRange(const Nan::FunctionCallbackInfo<v8::Value>& info
return Nan::ThrowTypeError("Second and third arguments must be numbers");
}
mbgl::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0]));
mln::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0]));
if (!layer) {
return Nan::ThrowTypeError("layer not found");
}
@@ -913,8 +913,8 @@ void NodeMap::SetLayerZoomRange(const Nan::FunctionCallbackInfo<v8::Value>& info
}
void NodeMap::SetLayerProperty(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -927,7 +927,7 @@ void NodeMap::SetLayerProperty(const Nan::FunctionCallbackInfo<v8::Value>& info)
return Nan::ThrowTypeError("First argument must be a string");
}
mbgl::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0]));
mln::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0]));
if (!layer) {
return Nan::ThrowTypeError("layer not found");
}
@@ -945,8 +945,8 @@ void NodeMap::SetLayerProperty(const Nan::FunctionCallbackInfo<v8::Value>& info)
}
void NodeMap::SetFilter(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -959,7 +959,7 @@ void NodeMap::SetFilter(const Nan::FunctionCallbackInfo<v8::Value>& info) {
return Nan::ThrowTypeError("First argument must be a string");
}
mbgl::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0]));
mln::style::Layer* layer = nodeMap->map->getStyle().getLayer(*Nan::Utf8String(info[0]));
if (!layer) {
return Nan::ThrowTypeError("layer not found");
}
@@ -1026,7 +1026,7 @@ void NodeMap::SetCenter(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->jumpTo(mbgl::CameraOptions().withCenter(mbgl::LatLng{latitude, longitude}));
nodeMap->map->jumpTo(mln::CameraOptions().withCenter(mln::LatLng{latitude, longitude}));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1043,7 +1043,7 @@ void NodeMap::SetZoom(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->jumpTo(mbgl::CameraOptions().withZoom(Nan::To<double>(info[0]).ToChecked()));
nodeMap->map->jumpTo(mln::CameraOptions().withZoom(Nan::To<double>(info[0]).ToChecked()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1060,7 +1060,7 @@ void NodeMap::SetBearing(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->jumpTo(mbgl::CameraOptions().withBearing(Nan::To<double>(info[0]).ToChecked()));
nodeMap->map->jumpTo(mln::CameraOptions().withBearing(Nan::To<double>(info[0]).ToChecked()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1077,7 +1077,7 @@ void NodeMap::SetPitch(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->jumpTo(mbgl::CameraOptions().withPitch(Nan::To<double>(info[0]).ToChecked()));
nodeMap->map->jumpTo(mln::CameraOptions().withPitch(Nan::To<double>(info[0]).ToChecked()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1086,8 +1086,8 @@ void NodeMap::SetPitch(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::SetLight(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -1098,7 +1098,7 @@ void NodeMap::SetLight(const Nan::FunctionCallbackInfo<v8::Value>& info) {
try {
Error conversionError;
if (auto light = convert<mbgl::style::Light>(info[0], conversionError)) {
if (auto light = convert<mln::style::Light>(info[0], conversionError)) {
nodeMap->map->getStyle().setLight(std::make_unique<Light>(*light));
} else {
return Nan::ThrowTypeError(conversionError.message.c_str());
@@ -1119,7 +1119,7 @@ void NodeMap::SetAxonometric(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->setProjectionMode(mbgl::ProjectionMode().withAxonometric(Nan::To<bool>(info[0]).ToChecked()));
nodeMap->map->setProjectionMode(mln::ProjectionMode().withAxonometric(Nan::To<bool>(info[0]).ToChecked()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1136,7 +1136,7 @@ void NodeMap::SetXSkew(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->setProjectionMode(mbgl::ProjectionMode().withXSkew(Nan::To<double>(info[0]).ToChecked()));
nodeMap->map->setProjectionMode(mln::ProjectionMode().withXSkew(Nan::To<double>(info[0]).ToChecked()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1153,7 +1153,7 @@ void NodeMap::SetYSkew(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->setProjectionMode(mbgl::ProjectionMode().withYSkew(Nan::To<double>(info[0]).ToChecked()));
nodeMap->map->setProjectionMode(mln::ProjectionMode().withYSkew(Nan::To<double>(info[0]).ToChecked()));
} catch (const std::exception& ex) {
return Nan::ThrowError(ex.what());
}
@@ -1162,8 +1162,8 @@ void NodeMap::SetYSkew(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::SetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl;
using namespace mbgl::style::conversion;
using namespace mln;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -1313,7 +1313,7 @@ void NodeMap::GetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info)
return Nan::ThrowTypeError("GetFeatureState: Requires feature.id property");
}
mbgl::FeatureState state;
mln::FeatureState state;
try {
nodeMap->frontend->getRenderer()->getFeatureState(state, sourceID, sourceLayerID, featureID);
} catch (const std::exception& ex) {
@@ -1402,8 +1402,8 @@ void NodeMap::DumpDebugLogs(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
void NodeMap::QueryRenderedFeatures(const Nan::FunctionCallbackInfo<v8::Value>& info) {
using namespace mbgl::style;
using namespace mbgl::style::conversion;
using namespace mln::style;
using namespace mln::style::conversion;
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
if (!nodeMap->map) return Nan::ThrowError(releasedMessage());
@@ -1417,7 +1417,7 @@ void NodeMap::QueryRenderedFeatures(const Nan::FunctionCallbackInfo<v8::Value>&
return Nan::ThrowTypeError("First argument must have two components");
}
mbgl::RenderedQueryOptions queryOptions;
mln::RenderedQueryOptions queryOptions;
if (!info[1]->IsNull() && !info[1]->IsUndefined()) {
if (!info[1]->IsObject()) {
return Nan::ThrowTypeError("options argument must be an object");
@@ -1452,23 +1452,23 @@ void NodeMap::QueryRenderedFeatures(const Nan::FunctionCallbackInfo<v8::Value>&
}
try {
std::vector<mbgl::Feature> optional;
std::vector<mln::Feature> optional;
if (Nan::Get(posOrBox, 0).ToLocalChecked()->IsArray()) {
auto pos0 = Nan::Get(posOrBox, 0).ToLocalChecked().As<v8::Array>();
auto pos1 = Nan::Get(posOrBox, 1).ToLocalChecked().As<v8::Array>();
optional = nodeMap->frontend->getRenderer()->queryRenderedFeatures(
mbgl::ScreenBox{{Nan::To<double>(Nan::Get(pos0, 0).ToLocalChecked()).ToChecked(),
Nan::To<double>(Nan::Get(pos0, 1).ToLocalChecked()).ToChecked()},
{Nan::To<double>(Nan::Get(pos1, 0).ToLocalChecked()).ToChecked(),
Nan::To<double>(Nan::Get(pos1, 1).ToLocalChecked()).ToChecked()}},
mln::ScreenBox{{Nan::To<double>(Nan::Get(pos0, 0).ToLocalChecked()).ToChecked(),
Nan::To<double>(Nan::Get(pos0, 1).ToLocalChecked()).ToChecked()},
{Nan::To<double>(Nan::Get(pos1, 0).ToLocalChecked()).ToChecked(),
Nan::To<double>(Nan::Get(pos1, 1).ToLocalChecked()).ToChecked()}},
queryOptions);
} else {
optional = nodeMap->frontend->getRenderer()->queryRenderedFeatures(
mbgl::ScreenCoordinate{Nan::To<double>(Nan::Get(posOrBox, 0).ToLocalChecked()).ToChecked(),
Nan::To<double>(Nan::Get(posOrBox, 1).ToLocalChecked()).ToChecked()},
mln::ScreenCoordinate{Nan::To<double>(Nan::Get(posOrBox, 0).ToLocalChecked()).ToChecked(),
Nan::To<double>(Nan::Get(posOrBox, 1).ToLocalChecked()).ToChecked()},
queryOptions);
}
@@ -1496,9 +1496,9 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
if (std::string(*v8::String::Utf8Value(
v8::Isolate::GetCurrent(), Nan::Get(options, Nan::New("mode").ToLocalChecked()).ToLocalChecked())) ==
"tile") {
return mbgl::MapMode::Tile;
return mln::MapMode::Tile;
} else {
return mbgl::MapMode::Static;
return mln::MapMode::Static;
}
}()),
crossSourceCollisions([&] {
@@ -1510,16 +1510,16 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
: true;
}()),
mapObserver(NodeMapObserver()),
frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{512, 512}, pixelRatio)),
map(std::make_unique<mbgl::Map>(*frontend,
mapObserver,
mbgl::MapOptions()
.withSize(frontend->getSize())
.withPixelRatio(pixelRatio)
.withMapMode(mode)
.withCrossSourceCollisions(crossSourceCollisions),
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)),
mbgl::ClientOptions())),
frontend(std::make_unique<mln::HeadlessFrontend>(mln::Size{512, 512}, pixelRatio)),
map(std::make_unique<mln::Map>(*frontend,
mapObserver,
mln::MapOptions()
.withSize(frontend->getSize())
.withPixelRatio(pixelRatio)
.withMapMode(mode)
.withCrossSourceCollisions(crossSourceCollisions),
mln::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)),
mln::ClientOptions())),
async(new uv_async_t) {
async->data = this;
uv_async_init(
@@ -1533,12 +1533,12 @@ NodeMap::~NodeMap() {
try {
if (map) release();
} catch (...) {
mbgl::Log::Error(mbgl::Event::General, "Error release the map object when destroying NodeMap");
mln::Log::Error(mln::Event::General, "Error release the map object when destroying NodeMap");
}
}
std::unique_ptr<mbgl::AsyncRequest> NodeFileSource::request(const mbgl::Resource& resource,
mbgl::FileSource::Callback callback_) {
std::unique_ptr<mln::AsyncRequest> NodeFileSource::request(const mln::Resource& resource,
mln::FileSource::Callback callback_) {
assert(nodeMap);
Nan::HandleScope scope;
@@ -1561,23 +1561,23 @@ std::unique_ptr<mbgl::AsyncRequest> NodeFileSource::request(const mbgl::Resource
return asyncRequest;
}
bool NodeFileSource::canRequest(const mbgl::Resource&) const {
bool NodeFileSource::canRequest(const mln::Resource&) const {
return true;
}
void NodeFileSource::setResourceOptions(mbgl::ResourceOptions options) {
void NodeFileSource::setResourceOptions(mln::ResourceOptions options) {
this->_resourceOptions = std::move(options);
}
mbgl::ResourceOptions NodeFileSource::getResourceOptions() {
mln::ResourceOptions NodeFileSource::getResourceOptions() {
return this->_resourceOptions.clone();
}
void NodeFileSource::setClientOptions(mbgl::ClientOptions options) {
void NodeFileSource::setClientOptions(mln::ClientOptions options) {
this->_clientOptions = std::move(options);
}
mbgl::ClientOptions NodeFileSource::getClientOptions() {
mln::ClientOptions NodeFileSource::getClientOptions() {
return this->_clientOptions.clone();
}

View File

@@ -15,14 +15,14 @@
#include <nan.h>
#pragma GCC diagnostic pop
namespace mbgl {
namespace mln {
class HeadlessFrontend;
} // namespace mbgl
} // namespace mln
namespace node_mbgl {
struct NodeMapObserver : public mbgl::MapObserver {
void onDidFailLoadingMap(mbgl::MapLoadError, const std::string&) final;
struct NodeMapObserver : public mln::MapObserver {
void onDidFailLoadingMap(mln::MapLoadError, const std::string&) final;
};
class RenderRequest;
@@ -83,14 +83,14 @@ public:
static RenderOptions ParseOptions(v8::Local<v8::Object>);
const float pixelRatio;
mbgl::MapMode mode;
mln::MapMode mode;
bool crossSourceCollisions;
NodeMapObserver mapObserver;
std::unique_ptr<mbgl::HeadlessFrontend> frontend;
std::unique_ptr<mbgl::Map> map;
std::unique_ptr<mln::HeadlessFrontend> frontend;
std::unique_ptr<mln::Map> map;
std::exception_ptr error;
mbgl::PremultipliedImage image;
mln::PremultipliedImage image;
std::unique_ptr<RenderRequest> req;
// Async for delivering the notifications of render completion.
@@ -99,19 +99,19 @@ public:
bool loaded = false;
};
struct NodeFileSource : public mbgl::FileSource {
struct NodeFileSource : public mln::FileSource {
NodeFileSource(NodeMap* nodeMap_)
: nodeMap(nodeMap_) {}
~NodeFileSource() override = default;
std::unique_ptr<mbgl::AsyncRequest> request(const mbgl::Resource&, mbgl::FileSource::Callback) final;
bool canRequest(const mbgl::Resource&) const override;
void setResourceOptions(mbgl::ResourceOptions) override;
mbgl::ResourceOptions getResourceOptions() override;
void setClientOptions(mbgl::ClientOptions) override;
mbgl::ClientOptions getClientOptions() override;
std::unique_ptr<mln::AsyncRequest> request(const mln::Resource&, mln::FileSource::Callback) final;
bool canRequest(const mln::Resource&) const override;
void setResourceOptions(mln::ResourceOptions) override;
mln::ResourceOptions getResourceOptions() override;
void setClientOptions(mln::ClientOptions) override;
mln::ClientOptions getClientOptions() override;
NodeMap* nodeMap;
mbgl::ResourceOptions _resourceOptions;
mbgl::ClientOptions _clientOptions;
mln::ResourceOptions _resourceOptions;
mln::ClientOptions _clientOptions;
};
} // namespace node_mbgl

View File

@@ -28,7 +28,7 @@ void RegisterModule(v8::Local<v8::Object> target, v8::Local<v8::Object> module)
// a) Ensuring that the static local variable is initialized before any
// thread contention. b) unreffing an async handle, which otherwise would
// keep the default loop running.
static mbgl::util::RunLoop nodeRunLoop;
static mln::util::RunLoop nodeRunLoop;
nodeRunLoop.stop();
Nan::SetMethod(target, "setBackendType", SetBackendType);
@@ -40,19 +40,19 @@ void RegisterModule(v8::Local<v8::Object> target, v8::Local<v8::Object> module)
// Exports Resource constants.
v8::Local<v8::Object> resource = Nan::New<v8::Object>();
Nan::Set(resource, Nan::New("Unknown").ToLocalChecked(), Nan::New(mbgl::Resource::Unknown));
Nan::Set(resource, Nan::New("Unknown").ToLocalChecked(), Nan::New(mln::Resource::Unknown));
Nan::Set(resource, Nan::New("Style").ToLocalChecked(), Nan::New(mbgl::Resource::Style));
Nan::Set(resource, Nan::New("Style").ToLocalChecked(), Nan::New(mln::Resource::Style));
Nan::Set(resource, Nan::New("Source").ToLocalChecked(), Nan::New(mbgl::Resource::Source));
Nan::Set(resource, Nan::New("Source").ToLocalChecked(), Nan::New(mln::Resource::Source));
Nan::Set(resource, Nan::New("Tile").ToLocalChecked(), Nan::New(mbgl::Resource::Tile));
Nan::Set(resource, Nan::New("Tile").ToLocalChecked(), Nan::New(mln::Resource::Tile));
Nan::Set(resource, Nan::New("Glyphs").ToLocalChecked(), Nan::New(mbgl::Resource::Glyphs));
Nan::Set(resource, Nan::New("Glyphs").ToLocalChecked(), Nan::New(mln::Resource::Glyphs));
Nan::Set(resource, Nan::New("SpriteImage").ToLocalChecked(), Nan::New(mbgl::Resource::SpriteImage));
Nan::Set(resource, Nan::New("SpriteImage").ToLocalChecked(), Nan::New(mln::Resource::SpriteImage));
Nan::Set(resource, Nan::New("SpriteJSON").ToLocalChecked(), Nan::New(mbgl::Resource::SpriteJSON));
Nan::Set(resource, Nan::New("SpriteJSON").ToLocalChecked(), Nan::New(mln::Resource::SpriteJSON));
Nan::Set(target, Nan::New("Resource").ToLocalChecked(), resource);
@@ -71,7 +71,7 @@ void RegisterModule(v8::Local<v8::Object> target, v8::Local<v8::Object> module)
Nan::SetPrototype(target, Nan::Get(EventEmitter, Nan::New("prototype").ToLocalChecked()).ToLocalChecked());
Nan::CallAsFunction(EventEmitter, target, 0, nullptr);
mbgl::Log::setObserver(std::make_unique<node_mbgl::NodeLogObserver>(target));
mln::Log::setObserver(std::make_unique<node_mbgl::NodeLogObserver>(target));
}
NODE_MODULE(mapbox_gl_native, RegisterModule)

View File

@@ -7,7 +7,7 @@
namespace node_mbgl {
NodeRequest::NodeRequest(mbgl::FileSource::Callback callback_, NodeAsyncRequest* asyncRequest_)
NodeRequest::NodeRequest(mln::FileSource::Callback callback_, NodeAsyncRequest* asyncRequest_)
: callback(std::move(callback_)),
asyncRequest(asyncRequest_) {
asyncRequest->request = this;
@@ -42,7 +42,7 @@ void NodeRequest::Init(v8::Local<v8::Object> target) {
void NodeRequest::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
auto target = reinterpret_cast<NodeMap*>(info[0].As<v8::External>()->Value());
auto callback = reinterpret_cast<mbgl::FileSource::Callback*>(info[1].As<v8::External>()->Value());
auto callback = reinterpret_cast<mln::FileSource::Callback*>(info[1].As<v8::External>()->Value());
auto asyncRequest = reinterpret_cast<NodeAsyncRequest*>(info[2].As<v8::External>()->Value());
auto request = new NodeRequest(*callback, asyncRequest);
@@ -71,7 +71,7 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf
return info.GetReturnValue().SetUndefined();
}
mbgl::Response response;
mln::Response response;
if (info.Length() < 1) {
response.noContent = true;
@@ -80,12 +80,12 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf
auto msg = Nan::New("message").ToLocalChecked();
if (Nan::Has(err, msg).FromJust()) {
response.error = std::make_unique<mbgl::Response::Error>(
mbgl::Response::Error::Reason::Other, *Nan::Utf8String(Nan::Get(err, msg).ToLocalChecked()));
response.error = std::make_unique<mln::Response::Error>(
mln::Response::Error::Reason::Other, *Nan::Utf8String(Nan::Get(err, msg).ToLocalChecked()));
}
} else if (info[0]->IsString()) {
response.error = std::make_unique<mbgl::Response::Error>(mbgl::Response::Error::Reason::Other,
*Nan::Utf8String(info[0]));
response.error = std::make_unique<mln::Response::Error>(mln::Response::Error::Reason::Other,
*Nan::Utf8String(info[0]));
} else if (info.Length() < 2 || !info[1]->IsObject()) {
request->unrefRequest();
return Nan::ThrowTypeError("Second argument must be a response object");
@@ -96,7 +96,7 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf
const double modified =
Nan::To<double>(Nan::Get(res, Nan::New("modified").ToLocalChecked()).ToLocalChecked()).FromJust();
if (!std::isnan(modified)) {
response.modified = mbgl::Timestamp{mbgl::Seconds(static_cast<mbgl::Seconds::rep>(modified / 1000))};
response.modified = mln::Timestamp{mln::Seconds(static_cast<mln::Seconds::rep>(modified / 1000))};
}
}
@@ -104,7 +104,7 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf
const double expires =
Nan::To<double>(Nan::Get(res, Nan::New("expires").ToLocalChecked()).ToLocalChecked()).FromJust();
if (!std::isnan(expires)) {
response.expires = mbgl::Timestamp{mbgl::Seconds(static_cast<mbgl::Seconds::rep>(expires / 1000))};
response.expires = mln::Timestamp{mln::Seconds(static_cast<mln::Seconds::rep>(expires / 1000))};
}
}

View File

@@ -14,7 +14,7 @@ namespace node_mbgl {
class NodeRequest;
struct NodeAsyncRequest : public mbgl::AsyncRequest {
struct NodeAsyncRequest : public mln::AsyncRequest {
NodeAsyncRequest();
~NodeAsyncRequest() override;
NodeRequest* request = nullptr;
@@ -22,7 +22,7 @@ struct NodeAsyncRequest : public mbgl::AsyncRequest {
class NodeRequest : public Nan::ObjectWrap {
public:
NodeRequest(mbgl::FileSource::Callback, NodeAsyncRequest*);
NodeRequest(mln::FileSource::Callback, NodeAsyncRequest*);
~NodeRequest() override;
static Nan::Persistent<v8::Function> constructor;
@@ -34,7 +34,7 @@ public:
void unrefRequest();
mbgl::FileSource::Callback callback;
mln::FileSource::Callback callback;
NodeAsyncRequest* asyncRequest;
Nan::AsyncResource* asyncResource = new Nan::AsyncResource("mbgl:execute");
};