Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-toml
Expand All @@ -19,25 +19,25 @@ repos:
exclude: '(platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/(location/LocationIndicatorLayer|style/layers/PropertyFactory)\.java$)|(platform/windows/vendor/.*)|(platform/ios/vendor/.*)'

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8
rev: v21.1.6
hooks:
- id: clang-format
files: '.*\.(hpp|cpp|h)'
exclude: 'vendor/.*'

- repo: https://github.com/keith/pre-commit-buildifier
rev: 8.2.0
rev: 8.2.1
hooks:
- id: buildifier

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.7.7.23
rev: v1.7.9.24
hooks:
- id: actionlint
additional_dependencies: [ shellcheck-py ]

- repo: https://github.com/nicklockwood/SwiftFormat
rev: "0.57.2"
rev: "0.58.7"
hooks:
- id: swiftformat
args: [ --swiftversion, "5.8" ]
Expand Down
14 changes: 6 additions & 8 deletions include/mbgl/platform/gl_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
// initialized by the platform at linking time.

#ifndef NDEBUG
#define MBGL_CHECK_ERROR(cmd) \
([&]() { \
struct __MBGL_CHECK_ERROR { \
~__MBGL_CHECK_ERROR() noexcept(false) { \
mbgl::platform::glCheckError(#cmd, __FILE__, __LINE__); \
} \
} __MBGL_CHECK_ERROR; \
return cmd; \
#define MBGL_CHECK_ERROR(cmd) \
([&]() { \
struct __MBGL_CHECK_ERROR { \
~__MBGL_CHECK_ERROR() noexcept(false) { mbgl::platform::glCheckError(#cmd, __FILE__, __LINE__); } \
} __MBGL_CHECK_ERROR; \
return cmd; \
}())
#else
#define MBGL_CHECK_ERROR(cmd) (cmd)
Expand Down
20 changes: 10 additions & 10 deletions include/mbgl/renderer/change_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ChangeRequest {
public:
virtual ~ChangeRequest() = default;

virtual void execute(RenderOrchestrator &) = 0;
virtual void execute(RenderOrchestrator&) = 0;
};

/**
Expand All @@ -44,7 +44,7 @@ class RefChangeRequest : public ChangeRequest {
protected:
RefChangeRequest(util::SimpleIdentity id_)
: id(id_) {}
RefChangeRequest(const RefChangeRequest &) = default;
RefChangeRequest(const RefChangeRequest&) = default;

util::SimpleIdentity id;
};
Expand All @@ -55,9 +55,9 @@ class RefChangeRequest : public ChangeRequest {
class AddLayerGroupRequest : public ChangeRequest {
public:
AddLayerGroupRequest(LayerGroupBasePtr layerGroup_);
AddLayerGroupRequest(AddLayerGroupRequest &&other);
AddLayerGroupRequest(AddLayerGroupRequest&& other);

void execute(RenderOrchestrator &) override;
void execute(RenderOrchestrator&) override;

protected:
LayerGroupBasePtr layerGroup;
Expand All @@ -70,9 +70,9 @@ class RemoveLayerGroupRequest : public ChangeRequest {
public:
RemoveLayerGroupRequest(LayerGroupBasePtr layerGroup_)
: layerGroup(std::move(layerGroup_)) {}
RemoveLayerGroupRequest(const RemoveLayerGroupRequest &) = default;
RemoveLayerGroupRequest(const RemoveLayerGroupRequest&) = default;

void execute(RenderOrchestrator &) override;
void execute(RenderOrchestrator&) override;

protected:
LayerGroupBasePtr layerGroup;
Expand All @@ -81,9 +81,9 @@ class RemoveLayerGroupRequest : public ChangeRequest {
class UpdateLayerGroupIndexRequest : public ChangeRequest {
public:
UpdateLayerGroupIndexRequest(LayerGroupBasePtr, int32_t newLayerIndex_);
UpdateLayerGroupIndexRequest(const UpdateLayerGroupIndexRequest &) = delete;
UpdateLayerGroupIndexRequest(const UpdateLayerGroupIndexRequest&) = delete;

void execute(RenderOrchestrator &) override;
void execute(RenderOrchestrator&) override;

protected:
LayerGroupBasePtr layerGroup;
Expand All @@ -97,7 +97,7 @@ class AddRenderTargetRequest : public ChangeRequest {
public:
AddRenderTargetRequest(RenderTargetPtr renderTarget_);

void execute(RenderOrchestrator &) override;
void execute(RenderOrchestrator&) override;

protected:
RenderTargetPtr renderTarget;
Expand All @@ -110,7 +110,7 @@ class RemoveRenderTargetRequest : public ChangeRequest {
public:
RemoveRenderTargetRequest(RenderTargetPtr renderTarget_);

void execute(RenderOrchestrator &) override;
void execute(RenderOrchestrator&) override;

protected:
RenderTargetPtr renderTarget;
Expand Down
4 changes: 1 addition & 3 deletions include/mbgl/style/conversion_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ class Convertible {
[](const Storage& s) { return Traits::toDouble(reinterpret_cast<const T&>(s)); },
[](const Storage& s) { return Traits::toString(reinterpret_cast<const T&>(s)); },
[](const Storage& s) { return Traits::toValue(reinterpret_cast<const T&>(s)); },
[](const Storage& s, Error& err) {
return Traits::toGeoJSON(reinterpret_cast<const T&>(s), err);
}};
[](const Storage& s, Error& err) { return Traits::toGeoJSON(reinterpret_cast<const T&>(s), err); }};
return &vtable;
}

Expand Down
18 changes: 9 additions & 9 deletions include/mbgl/text/glyph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ union GlyphID {

operator char16_t() { return complex.code; }
operator char32_t() { return hash; }
bool operator<(const GlyphID &other) const { return hash < other.hash; }
bool operator>(const GlyphID &other) const { return hash > other.hash; }
bool operator<(const GlyphID& other) const { return hash < other.hash; }
bool operator>(const GlyphID& other) const { return hash > other.hash; }

bool operator<(const uint16_t &other) const { return hash < other; }
bool operator>(const uint16_t &other) const { return hash > other; }
bool operator<(const uint16_t& other) const { return hash < other; }
bool operator>(const uint16_t& other) const { return hash > other; }
};

using GlyphIDs = std::set<GlyphID>;
Expand All @@ -65,7 +65,7 @@ struct GlyphMetrics {
uint32_t advance = 0;
};

inline bool operator==(const GlyphMetrics &lhs, const GlyphMetrics &rhs) {
inline bool operator==(const GlyphMetrics& lhs, const GlyphMetrics& rhs) {
return lhs.width == rhs.width && lhs.height == rhs.height && lhs.left == rhs.left && lhs.top == rhs.top &&
lhs.advance == rhs.advance;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ class Shaping {
float right = 0;
WritingModeType writingMode;
explicit operator bool() const {
return std::ranges::any_of(positionedLines, [](const auto &line) { return !line.positionedGlyphs.empty(); });
return std::ranges::any_of(positionedLines, [](const auto& line) { return !line.positionedGlyphs.empty(); });
}
// The y offset *should* be part of the font metadata.
static constexpr int32_t yOffset = -17;
Expand All @@ -170,13 +170,13 @@ struct FontFace {
std::vector<Range> ranges; // unicode ranges

FontFace() = default;
FontFace(const std::string &name_, const std::string &url_, const std::vector<Range> &ranges_)
FontFace(const std::string& name_, const std::string& url_, const std::vector<Range>& ranges_)
: type(FontPBF),
name(name_),
url(url_),
ranges(ranges_) {}

FontFace(const std::string &name_, const std::string &url_, std::vector<Range> &&ranges_)
FontFace(const std::string& name_, const std::string& url_, std::vector<Range>&& ranges_)
: type(FontPBF),
name(name_),
url(url_),
Expand All @@ -192,7 +192,7 @@ struct HBShapeRequest {
FontStack fontStack;
GlyphIDType type;

HBShapeRequest(const std::u16string &str_, const FontStack &fontStack_, GlyphIDType type_)
HBShapeRequest(const std::u16string& str_, const FontStack& fontStack_, GlyphIDType type_)
: str(str_),
fontStack(fontStack_),
type(type_) {}
Expand Down
12 changes: 6 additions & 6 deletions include/mbgl/text/glyph_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ enum GlyphIDType : uint16_t {
FontPBF = 0x00,
};

GlyphIDType genNewGlyphIDType(const std::string &url,
const FontStack &fontStack,
const std::vector<std::pair<uint32_t, uint32_t>> &pairs);
GlyphIDType genNewGlyphIDType(const std::string& url,
const FontStack& fontStack,
const std::vector<std::pair<uint32_t, uint32_t>>& pairs);

class GlyphRange {
public:
Expand All @@ -25,8 +25,8 @@ class GlyphRange {

GlyphRange(uint32_t first_, uint32_t second_, GlyphIDType type_ = FontPBF);

bool operator==(const GlyphRange &other) const;
bool operator<(const GlyphRange &other) const;
bool operator==(const GlyphRange& other) const;
bool operator<(const GlyphRange& other) const;
};

constexpr uint32_t GLYPHS_PER_GLYPH_RANGE = 256;
Expand All @@ -40,7 +40,7 @@ namespace std {

template <>
struct hash<mbgl::GlyphRange> {
std::size_t operator()(const mbgl::GlyphRange &range) const { return mbgl::util::hash(range.first, range.second); }
std::size_t operator()(const mbgl::GlyphRange& range) const { return mbgl::util::hash(range.first, range.second); }
};

} // namespace std
2 changes: 1 addition & 1 deletion include/mbgl/util/chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ std::string iso8601(Timestamp);
// YYYY-mm-ddTHH:MM:SS.MS e.g. "2015-11-26T16:11:23.324Z"
std::string iso8601(std::chrono::time_point<std::chrono::system_clock, Milliseconds>);

Timestamp parseTimestamp(const char *);
Timestamp parseTimestamp(const char*);

Timestamp parseTimestamp(int32_t timestamp);

Expand Down
2 changes: 1 addition & 1 deletion include/mbgl/util/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct EventPermutation {
const EventSeverity severity;
const Event event;

constexpr bool operator==(const EventPermutation &rhs) const {
constexpr bool operator==(const EventPermutation& rhs) const {
return severity == rhs.severity && event == rhs.event;
}
};
Expand Down
24 changes: 12 additions & 12 deletions include/mbgl/util/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@ namespace mbgl {
namespace util {

struct Exception : std::runtime_error {
Exception(const char *msg)
Exception(const char* msg)
: std::runtime_error(msg) {}
Exception(const std::string &msg)
Exception(const std::string& msg)
: std::runtime_error(msg) {}
};

struct StyleImageException : Exception {
StyleImageException(const char *msg)
StyleImageException(const char* msg)
: Exception(msg) {}
StyleImageException(const std::string &msg)
StyleImageException(const std::string& msg)
: Exception(msg) {}
};

struct MisuseException : Exception {
MisuseException(const char *msg)
MisuseException(const char* msg)
: Exception(msg) {}
MisuseException(const std::string &msg)
MisuseException(const std::string& msg)
: Exception(msg) {}
};

struct StyleParseException : Exception {
StyleParseException(const char *msg)
StyleParseException(const char* msg)
: Exception(msg) {}
StyleParseException(const std::string &msg)
StyleParseException(const std::string& msg)
: Exception(msg) {}
};

struct StyleLoadException : Exception {
StyleLoadException(const char *msg)
StyleLoadException(const char* msg)
: Exception(msg) {}
StyleLoadException(const std::string &msg)
StyleLoadException(const std::string& msg)
: Exception(msg) {}
};

struct NotFoundException : Exception {
NotFoundException(const char *msg)
NotFoundException(const char* msg)
: Exception(msg) {}
NotFoundException(const std::string &msg)
NotFoundException(const std::string& msg)
: Exception(msg) {}
};

Expand Down
20 changes: 10 additions & 10 deletions include/mbgl/util/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,44 @@ template <class T>
using Geometry = mapbox::geometry::geometry<T>;

template <class S, class T>
Point<S> convertPoint(const Point<T> &p) {
Point<S> convertPoint(const Point<T>& p) {
return Point<S>(static_cast<S>(p.x), static_cast<S>(p.y));
}

struct ToFeatureType {
FeatureType operator()(const EmptyGeometry &) const { return FeatureType::Unknown; }
FeatureType operator()(const EmptyGeometry&) const { return FeatureType::Unknown; }
template <class T>
FeatureType operator()(const Point<T> &) const {
FeatureType operator()(const Point<T>&) const {
return FeatureType::Point;
}
template <class T>
FeatureType operator()(const MultiPoint<T> &) const {
FeatureType operator()(const MultiPoint<T>&) const {
return FeatureType::Point;
}
template <class T>
FeatureType operator()(const LineString<T> &) const {
FeatureType operator()(const LineString<T>&) const {
return FeatureType::LineString;
}
template <class T>
FeatureType operator()(const MultiLineString<T> &) const {
FeatureType operator()(const MultiLineString<T>&) const {
return FeatureType::LineString;
}
template <class T>
FeatureType operator()(const Polygon<T> &) const {
FeatureType operator()(const Polygon<T>&) const {
return FeatureType::Polygon;
}
template <class T>
FeatureType operator()(const MultiPolygon<T> &) const {
FeatureType operator()(const MultiPolygon<T>&) const {
return FeatureType::Polygon;
}
template <class T>
FeatureType operator()(const mapbox::geometry::geometry_collection<T> &) const {
FeatureType operator()(const mapbox::geometry::geometry_collection<T>&) const {
return FeatureType::Unknown;
}
};

template <class T, typename F>
auto forEachPoint(const Geometry<T> &g, F f) {
auto forEachPoint(const Geometry<T>& g, F f) {
mapbox::geometry::for_each_point(g, f);
}

Expand Down
6 changes: 3 additions & 3 deletions include/mbgl/util/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace platform {
class Request;

/// Uppercase a string, potentially using platform-specific routines.
std::string uppercase(const std::string &string);
std::string uppercase(const std::string& string);

/// Lowercase a string, potentially using platform-specific routines.
std::string lowercase(const std::string &string);
std::string lowercase(const std::string& string);

/// Gets the name of the current thread.
std::string getCurrentThreadName();

/// Set the name of the current thread, truncated at 15.
void setCurrentThreadName(const std::string &name);
void setCurrentThreadName(const std::string& name);

/// Makes the current thread low priority.
void makeThreadLowPriority();
Expand Down
Loading
Loading