From 3ceabcd3ec91dbd9458d3c5b78fb12c3182636e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 3 Apr 2019 12:27:14 +0200 Subject: [core] clang-tidy fixes --- .clang-tidy | 3 +- bin/offline.cpp | 2 +- circle.yml | 4 +- include/mbgl/style/layers/background_layer.hpp | 12 +- include/mbgl/style/layers/circle_layer.hpp | 44 ++--- include/mbgl/style/layers/fill_extrusion_layer.hpp | 32 +-- include/mbgl/style/layers/fill_layer.hpp | 28 +-- include/mbgl/style/layers/heatmap_layer.hpp | 20 +- include/mbgl/style/layers/hillshade_layer.hpp | 24 +-- include/mbgl/style/layers/layer.hpp.ejs | 8 +- include/mbgl/style/layers/line_layer.hpp | 60 +++--- include/mbgl/style/layers/raster_layer.hpp | 32 +-- include/mbgl/style/layers/symbol_layer.hpp | 212 ++++++++++---------- .../src/mbgl/storage/default_file_source.cpp | 3 +- platform/default/src/mbgl/storage/offline.cpp | 3 +- platform/default/src/mbgl/text/bidi.cpp | 2 +- platform/node/src/node_expression.cpp | 12 +- platform/node/src/node_feature.cpp | 4 +- platform/node/src/node_map.cpp | 6 +- scripts/clang-tidy-diff.py | 201 +++++++++++++++++++ scripts/clang-tools.sh | 65 ++----- src/mbgl/actor/mailbox.cpp | 3 +- src/mbgl/annotation/annotation_tile.cpp | 2 +- src/mbgl/annotation/line_annotation_impl.cpp | 2 +- src/mbgl/layout/symbol_instance.cpp | 5 +- src/mbgl/layout/symbol_instance.hpp | 2 +- src/mbgl/layout/symbol_layout.cpp | 3 +- src/mbgl/map/map.cpp | 2 +- src/mbgl/renderer/buckets/symbol_bucket.cpp | 4 +- src/mbgl/renderer/layers/render_custom_layer.cpp | 2 +- .../layers/render_fill_extrusion_layer.cpp | 2 +- src/mbgl/renderer/layers/render_fill_layer.cpp | 2 +- .../renderer/layers/render_hillshade_layer.cpp | 2 +- src/mbgl/renderer/layers/render_line_layer.cpp | 2 +- src/mbgl/renderer/layers/render_raster_layer.cpp | 2 +- src/mbgl/renderer/layers/render_symbol_layer.cpp | 2 +- src/mbgl/renderer/render_source.cpp | 3 +- src/mbgl/renderer/renderer_impl.cpp | 2 +- .../renderer/sources/render_geojson_source.cpp | 2 +- src/mbgl/renderer/sources/render_image_source.cpp | 6 +- .../renderer/sources/render_raster_dem_source.cpp | 6 +- src/mbgl/storage/file_source.cpp | 2 +- src/mbgl/style/conversion/filter.cpp | 2 +- src/mbgl/style/conversion/function.cpp | 4 +- src/mbgl/style/custom_tile_loader.cpp | 24 +-- src/mbgl/style/expression/boolean_operator.cpp | 8 +- src/mbgl/style/expression/case.cpp | 2 +- src/mbgl/style/expression/coercion.cpp | 2 +- src/mbgl/style/expression/comparison.cpp | 3 +- src/mbgl/style/expression/dsl.cpp | 4 +- src/mbgl/style/expression/format_expression.cpp | 2 +- src/mbgl/style/expression/formatted.cpp | 2 +- src/mbgl/style/expression/let.cpp | 4 +- src/mbgl/style/expression/match.cpp | 2 +- src/mbgl/style/expression/step.cpp | 6 +- src/mbgl/style/expression/value.cpp | 2 +- src/mbgl/style/layers/background_layer.cpp | 14 +- src/mbgl/style/layers/circle_layer.cpp | 46 ++--- src/mbgl/style/layers/fill_extrusion_layer.cpp | 34 ++-- src/mbgl/style/layers/fill_layer.cpp | 30 +-- src/mbgl/style/layers/heatmap_layer.cpp | 22 +-- src/mbgl/style/layers/hillshade_layer.cpp | 26 +-- src/mbgl/style/layers/layer.cpp.ejs | 12 +- src/mbgl/style/layers/line_layer.cpp | 64 +++--- src/mbgl/style/layers/raster_layer.cpp | 34 ++-- src/mbgl/style/layers/symbol_layer.cpp | 216 ++++++++++----------- src/mbgl/style/sources/raster_source.cpp | 2 +- src/mbgl/style/sources/vector_source.cpp | 2 +- src/mbgl/text/cross_tile_symbol_index.cpp | 5 +- src/mbgl/text/language_tag.cpp | 4 +- src/mbgl/text/placement.cpp | 5 +- src/mbgl/tile/custom_geometry_tile.cpp | 3 +- src/mbgl/tile/geometry_tile_worker.cpp | 5 +- src/mbgl/tile/geometry_tile_worker.hpp | 2 +- src/mbgl/util/string.cpp | 2 +- src/mbgl/util/tile_cover.cpp | 4 +- src/mbgl/util/tile_cover_impl.cpp | 4 +- test/actor/actor.test.cpp | 2 +- test/api/custom_layer.test.cpp | 8 +- test/map/map.test.cpp | 2 +- test/src/mbgl/test/sqlite3_test_fs.cpp | 50 ++--- test/storage/offline_database.test.cpp | 2 +- test/style/filter.test.cpp | 8 +- test/text/glyph_manager.test.cpp | 4 +- test/util/merge_lines.test.cpp | 2 +- test/util/peer.test.cpp | 12 +- test/util/tile_cover.test.cpp | 12 +- 87 files changed, 856 insertions(+), 684 deletions(-) create mode 100755 scripts/clang-tidy-diff.py diff --git a/.clang-tidy b/.clang-tidy index 356748ec11..97600637ed 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,2 +1,3 @@ Checks: 'modernize-*,misc-static-assert,llvm-namespace-comment,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-core.StackAddressEscape,-clang-analyzer-core.CallAndMessage,-clang-diagnostic-unused-command-line-argument,-clang-analyzer-core.uninitialized.*,-clang-analyzer-core.NullDereference,-clang-analyzer-core.NonNullParamChecker' -HeaderFilterRegex: '\/mbgl\/' +WarningsAsErrors: '*' +FormatStyle: file diff --git a/bin/offline.cpp b/bin/offline.cpp index 5cd43adfe3..a82e2b5aa5 100644 --- a/bin/offline.cpp +++ b/bin/offline.cpp @@ -197,7 +197,7 @@ int main(int argc, char *argv[]) { : region(region_), fileSource(fileSource_), loop(loop_), - mergePath(mergePath_), + mergePath(std::move(mergePath_)), start(util::now()) { } diff --git a/circle.yml b/circle.yml index 3d261cf798..7a37777e01 100644 --- a/circle.yml +++ b/circle.yml @@ -488,8 +488,8 @@ jobs: - image: mbgl/linux-clang-7:a5a3c52107 working_directory: /src environment: - LIBSYSCONFCPUS: 2 - JOBS: 2 + LIBSYSCONFCPUS: 4 + JOBS: 4 BUILDTYPE: Debug steps: - install-dependencies: { ccache: false } diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp index f0efa7acba..1e1f4b78a8 100644 --- a/include/mbgl/style/layers/background_layer.hpp +++ b/include/mbgl/style/layers/background_layer.hpp @@ -25,20 +25,20 @@ public: // Paint properties static PropertyValue getDefaultBackgroundColor(); - PropertyValue getBackgroundColor() const; - void setBackgroundColor(PropertyValue); + const PropertyValue& getBackgroundColor() const; + void setBackgroundColor(const PropertyValue&); void setBackgroundColorTransition(const TransitionOptions&); TransitionOptions getBackgroundColorTransition() const; static PropertyValue getDefaultBackgroundPattern(); - PropertyValue getBackgroundPattern() const; - void setBackgroundPattern(PropertyValue); + const PropertyValue& getBackgroundPattern() const; + void setBackgroundPattern(const PropertyValue&); void setBackgroundPatternTransition(const TransitionOptions&); TransitionOptions getBackgroundPatternTransition() const; static PropertyValue getDefaultBackgroundOpacity(); - PropertyValue getBackgroundOpacity() const; - void setBackgroundOpacity(PropertyValue); + const PropertyValue& getBackgroundOpacity() const; + void setBackgroundOpacity(const PropertyValue&); void setBackgroundOpacityTransition(const TransitionOptions&); TransitionOptions getBackgroundOpacityTransition() const; diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp index 08ec686ff2..4095bc8fe7 100644 --- a/include/mbgl/style/layers/circle_layer.hpp +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -25,68 +25,68 @@ public: // Paint properties static PropertyValue getDefaultCircleRadius(); - PropertyValue getCircleRadius() const; - void setCircleRadius(PropertyValue); + const PropertyValue& getCircleRadius() const; + void setCircleRadius(const PropertyValue&); void setCircleRadiusTransition(const TransitionOptions&); TransitionOptions getCircleRadiusTransition() const; static PropertyValue getDefaultCircleColor(); - PropertyValue getCircleColor() const; - void setCircleColor(PropertyValue); + const PropertyValue& getCircleColor() const; + void setCircleColor(const PropertyValue&); void setCircleColorTransition(const TransitionOptions&); TransitionOptions getCircleColorTransition() const; static PropertyValue getDefaultCircleBlur(); - PropertyValue getCircleBlur() const; - void setCircleBlur(PropertyValue); + const PropertyValue& getCircleBlur() const; + void setCircleBlur(const PropertyValue&); void setCircleBlurTransition(const TransitionOptions&); TransitionOptions getCircleBlurTransition() const; static PropertyValue getDefaultCircleOpacity(); - PropertyValue getCircleOpacity() const; - void setCircleOpacity(PropertyValue); + const PropertyValue& getCircleOpacity() const; + void setCircleOpacity(const PropertyValue&); void setCircleOpacityTransition(const TransitionOptions&); TransitionOptions getCircleOpacityTransition() const; static PropertyValue> getDefaultCircleTranslate(); - PropertyValue> getCircleTranslate() const; - void setCircleTranslate(PropertyValue>); + const PropertyValue>& getCircleTranslate() const; + void setCircleTranslate(const PropertyValue>&); void setCircleTranslateTransition(const TransitionOptions&); TransitionOptions getCircleTranslateTransition() const; static PropertyValue getDefaultCircleTranslateAnchor(); - PropertyValue getCircleTranslateAnchor() const; - void setCircleTranslateAnchor(PropertyValue); + const PropertyValue& getCircleTranslateAnchor() const; + void setCircleTranslateAnchor(const PropertyValue&); void setCircleTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getCircleTranslateAnchorTransition() const; static PropertyValue getDefaultCirclePitchScale(); - PropertyValue getCirclePitchScale() const; - void setCirclePitchScale(PropertyValue); + const PropertyValue& getCirclePitchScale() const; + void setCirclePitchScale(const PropertyValue&); void setCirclePitchScaleTransition(const TransitionOptions&); TransitionOptions getCirclePitchScaleTransition() const; static PropertyValue getDefaultCirclePitchAlignment(); - PropertyValue getCirclePitchAlignment() const; - void setCirclePitchAlignment(PropertyValue); + const PropertyValue& getCirclePitchAlignment() const; + void setCirclePitchAlignment(const PropertyValue&); void setCirclePitchAlignmentTransition(const TransitionOptions&); TransitionOptions getCirclePitchAlignmentTransition() const; static PropertyValue getDefaultCircleStrokeWidth(); - PropertyValue getCircleStrokeWidth() const; - void setCircleStrokeWidth(PropertyValue); + const PropertyValue& getCircleStrokeWidth() const; + void setCircleStrokeWidth(const PropertyValue&); void setCircleStrokeWidthTransition(const TransitionOptions&); TransitionOptions getCircleStrokeWidthTransition() const; static PropertyValue getDefaultCircleStrokeColor(); - PropertyValue getCircleStrokeColor() const; - void setCircleStrokeColor(PropertyValue); + const PropertyValue& getCircleStrokeColor() const; + void setCircleStrokeColor(const PropertyValue&); void setCircleStrokeColorTransition(const TransitionOptions&); TransitionOptions getCircleStrokeColorTransition() const; static PropertyValue getDefaultCircleStrokeOpacity(); - PropertyValue getCircleStrokeOpacity() const; - void setCircleStrokeOpacity(PropertyValue); + const PropertyValue& getCircleStrokeOpacity() const; + void setCircleStrokeOpacity(const PropertyValue&); void setCircleStrokeOpacityTransition(const TransitionOptions&); TransitionOptions getCircleStrokeOpacityTransition() const; diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp index c4b7ecfcdb..80152de80a 100644 --- a/include/mbgl/style/layers/fill_extrusion_layer.hpp +++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp @@ -25,50 +25,50 @@ public: // Paint properties static PropertyValue getDefaultFillExtrusionOpacity(); - PropertyValue getFillExtrusionOpacity() const; - void setFillExtrusionOpacity(PropertyValue); + const PropertyValue& getFillExtrusionOpacity() const; + void setFillExtrusionOpacity(const PropertyValue&); void setFillExtrusionOpacityTransition(const TransitionOptions&); TransitionOptions getFillExtrusionOpacityTransition() const; static PropertyValue getDefaultFillExtrusionColor(); - PropertyValue getFillExtrusionColor() const; - void setFillExtrusionColor(PropertyValue); + const PropertyValue& getFillExtrusionColor() const; + void setFillExtrusionColor(const PropertyValue&); void setFillExtrusionColorTransition(const TransitionOptions&); TransitionOptions getFillExtrusionColorTransition() const; static PropertyValue> getDefaultFillExtrusionTranslate(); - PropertyValue> getFillExtrusionTranslate() const; - void setFillExtrusionTranslate(PropertyValue>); + const PropertyValue>& getFillExtrusionTranslate() const; + void setFillExtrusionTranslate(const PropertyValue>&); void setFillExtrusionTranslateTransition(const TransitionOptions&); TransitionOptions getFillExtrusionTranslateTransition() const; static PropertyValue getDefaultFillExtrusionTranslateAnchor(); - PropertyValue getFillExtrusionTranslateAnchor() const; - void setFillExtrusionTranslateAnchor(PropertyValue); + const PropertyValue& getFillExtrusionTranslateAnchor() const; + void setFillExtrusionTranslateAnchor(const PropertyValue&); void setFillExtrusionTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getFillExtrusionTranslateAnchorTransition() const; static PropertyValue getDefaultFillExtrusionPattern(); - PropertyValue getFillExtrusionPattern() const; - void setFillExtrusionPattern(PropertyValue); + const PropertyValue& getFillExtrusionPattern() const; + void setFillExtrusionPattern(const PropertyValue&); void setFillExtrusionPatternTransition(const TransitionOptions&); TransitionOptions getFillExtrusionPatternTransition() const; static PropertyValue getDefaultFillExtrusionHeight(); - PropertyValue getFillExtrusionHeight() const; - void setFillExtrusionHeight(PropertyValue); + const PropertyValue& getFillExtrusionHeight() const; + void setFillExtrusionHeight(const PropertyValue&); void setFillExtrusionHeightTransition(const TransitionOptions&); TransitionOptions getFillExtrusionHeightTransition() const; static PropertyValue getDefaultFillExtrusionBase(); - PropertyValue getFillExtrusionBase() const; - void setFillExtrusionBase(PropertyValue); + const PropertyValue& getFillExtrusionBase() const; + void setFillExtrusionBase(const PropertyValue&); void setFillExtrusionBaseTransition(const TransitionOptions&); TransitionOptions getFillExtrusionBaseTransition() const; static PropertyValue getDefaultFillExtrusionVerticalGradient(); - PropertyValue getFillExtrusionVerticalGradient() const; - void setFillExtrusionVerticalGradient(PropertyValue); + const PropertyValue& getFillExtrusionVerticalGradient() const; + void setFillExtrusionVerticalGradient(const PropertyValue&); void setFillExtrusionVerticalGradientTransition(const TransitionOptions&); TransitionOptions getFillExtrusionVerticalGradientTransition() const; diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp index 6a402f28f7..e4872a5fd8 100644 --- a/include/mbgl/style/layers/fill_layer.hpp +++ b/include/mbgl/style/layers/fill_layer.hpp @@ -25,44 +25,44 @@ public: // Paint properties static PropertyValue getDefaultFillAntialias(); - PropertyValue getFillAntialias() const; - void setFillAntialias(PropertyValue); + const PropertyValue& getFillAntialias() const; + void setFillAntialias(const PropertyValue&); void setFillAntialiasTransition(const TransitionOptions&); TransitionOptions getFillAntialiasTransition() const; static PropertyValue getDefaultFillOpacity(); - PropertyValue getFillOpacity() const; - void setFillOpacity(PropertyValue); + const PropertyValue& getFillOpacity() const; + void setFillOpacity(const PropertyValue&); void setFillOpacityTransition(const TransitionOptions&); TransitionOptions getFillOpacityTransition() const; static PropertyValue getDefaultFillColor(); - PropertyValue getFillColor() const; - void setFillColor(PropertyValue); + const PropertyValue& getFillColor() const; + void setFillColor(const PropertyValue&); void setFillColorTransition(const TransitionOptions&); TransitionOptions getFillColorTransition() const; static PropertyValue getDefaultFillOutlineColor(); - PropertyValue getFillOutlineColor() const; - void setFillOutlineColor(PropertyValue); + const PropertyValue& getFillOutlineColor() const; + void setFillOutlineColor(const PropertyValue&); void setFillOutlineColorTransition(const TransitionOptions&); TransitionOptions getFillOutlineColorTransition() const; static PropertyValue> getDefaultFillTranslate(); - PropertyValue> getFillTranslate() const; - void setFillTranslate(PropertyValue>); + const PropertyValue>& getFillTranslate() const; + void setFillTranslate(const PropertyValue>&); void setFillTranslateTransition(const TransitionOptions&); TransitionOptions getFillTranslateTransition() const; static PropertyValue getDefaultFillTranslateAnchor(); - PropertyValue getFillTranslateAnchor() const; - void setFillTranslateAnchor(PropertyValue); + const PropertyValue& getFillTranslateAnchor() const; + void setFillTranslateAnchor(const PropertyValue&); void setFillTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getFillTranslateAnchorTransition() const; static PropertyValue getDefaultFillPattern(); - PropertyValue getFillPattern() const; - void setFillPattern(PropertyValue); + const PropertyValue& getFillPattern() const; + void setFillPattern(const PropertyValue&); void setFillPatternTransition(const TransitionOptions&); TransitionOptions getFillPatternTransition() const; diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp index 4c3ae0daf8..bbd9d6eb7b 100644 --- a/include/mbgl/style/layers/heatmap_layer.hpp +++ b/include/mbgl/style/layers/heatmap_layer.hpp @@ -26,32 +26,32 @@ public: // Paint properties static PropertyValue getDefaultHeatmapRadius(); - PropertyValue getHeatmapRadius() const; - void setHeatmapRadius(PropertyValue); + const PropertyValue& getHeatmapRadius() const; + void setHeatmapRadius(const PropertyValue&); void setHeatmapRadiusTransition(const TransitionOptions&); TransitionOptions getHeatmapRadiusTransition() const; static PropertyValue getDefaultHeatmapWeight(); - PropertyValue getHeatmapWeight() const; - void setHeatmapWeight(PropertyValue); + const PropertyValue& getHeatmapWeight() const; + void setHeatmapWeight(const PropertyValue&); void setHeatmapWeightTransition(const TransitionOptions&); TransitionOptions getHeatmapWeightTransition() const; static PropertyValue getDefaultHeatmapIntensity(); - PropertyValue getHeatmapIntensity() const; - void setHeatmapIntensity(PropertyValue); + const PropertyValue& getHeatmapIntensity() const; + void setHeatmapIntensity(const PropertyValue&); void setHeatmapIntensityTransition(const TransitionOptions&); TransitionOptions getHeatmapIntensityTransition() const; static ColorRampPropertyValue getDefaultHeatmapColor(); - ColorRampPropertyValue getHeatmapColor() const; - void setHeatmapColor(ColorRampPropertyValue); + const ColorRampPropertyValue& getHeatmapColor() const; + void setHeatmapColor(const ColorRampPropertyValue&); void setHeatmapColorTransition(const TransitionOptions&); TransitionOptions getHeatmapColorTransition() const; static PropertyValue getDefaultHeatmapOpacity(); - PropertyValue getHeatmapOpacity() const; - void setHeatmapOpacity(PropertyValue); + const PropertyValue& getHeatmapOpacity() const; + void setHeatmapOpacity(const PropertyValue&); void setHeatmapOpacityTransition(const TransitionOptions&); TransitionOptions getHeatmapOpacityTransition() const; diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp index 760e70aa75..d2eebadf9d 100644 --- a/include/mbgl/style/layers/hillshade_layer.hpp +++ b/include/mbgl/style/layers/hillshade_layer.hpp @@ -25,38 +25,38 @@ public: // Paint properties static PropertyValue getDefaultHillshadeIlluminationDirection(); - PropertyValue getHillshadeIlluminationDirection() const; - void setHillshadeIlluminationDirection(PropertyValue); + const PropertyValue& getHillshadeIlluminationDirection() const; + void setHillshadeIlluminationDirection(const PropertyValue&); void setHillshadeIlluminationDirectionTransition(const TransitionOptions&); TransitionOptions getHillshadeIlluminationDirectionTransition() const; static PropertyValue getDefaultHillshadeIlluminationAnchor(); - PropertyValue getHillshadeIlluminationAnchor() const; - void setHillshadeIlluminationAnchor(PropertyValue); + const PropertyValue& getHillshadeIlluminationAnchor() const; + void setHillshadeIlluminationAnchor(const PropertyValue&); void setHillshadeIlluminationAnchorTransition(const TransitionOptions&); TransitionOptions getHillshadeIlluminationAnchorTransition() const; static PropertyValue getDefaultHillshadeExaggeration(); - PropertyValue getHillshadeExaggeration() const; - void setHillshadeExaggeration(PropertyValue); + const PropertyValue& getHillshadeExaggeration() const; + void setHillshadeExaggeration(const PropertyValue&); void setHillshadeExaggerationTransition(const TransitionOptions&); TransitionOptions getHillshadeExaggerationTransition() const; static PropertyValue getDefaultHillshadeShadowColor(); - PropertyValue getHillshadeShadowColor() const; - void setHillshadeShadowColor(PropertyValue); + const PropertyValue& getHillshadeShadowColor() const; + void setHillshadeShadowColor(const PropertyValue&); void setHillshadeShadowColorTransition(const TransitionOptions&); TransitionOptions getHillshadeShadowColorTransition() const; static PropertyValue getDefaultHillshadeHighlightColor(); - PropertyValue getHillshadeHighlightColor() const; - void setHillshadeHighlightColor(PropertyValue); + const PropertyValue& getHillshadeHighlightColor() const; + void setHillshadeHighlightColor(const PropertyValue&); void setHillshadeHighlightColorTransition(const TransitionOptions&); TransitionOptions getHillshadeHighlightColorTransition() const; static PropertyValue getDefaultHillshadeAccentColor(); - PropertyValue getHillshadeAccentColor() const; - void setHillshadeAccentColor(PropertyValue); + const PropertyValue& getHillshadeAccentColor() const; + void setHillshadeAccentColor(const PropertyValue&); void setHillshadeAccentColorTransition(const TransitionOptions&); TransitionOptions getHillshadeAccentColorTransition() const; diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs index a7a8ff35c5..8371f11910 100644 --- a/include/mbgl/style/layers/layer.hpp.ejs +++ b/include/mbgl/style/layers/layer.hpp.ejs @@ -43,8 +43,8 @@ public: <% for (const property of layoutProperties) { -%> static <%- propertyValueType(property) %> getDefault<%- camelize(property.name) %>(); - <%- propertyValueType(property) %> get<%- camelize(property.name) %>() const; - void set<%- camelize(property.name) %>(<%- propertyValueType(property) %>); + const <%- propertyValueType(property) %>& get<%- camelize(property.name) %>() const; + void set<%- camelize(property.name) %>(const <%- propertyValueType(property) %>&); <% } -%> <% } -%> @@ -52,8 +52,8 @@ public: <% for (const property of paintProperties) { -%> static <%- propertyValueType(property) %> getDefault<%- camelize(property.name) %>(); - <%- propertyValueType(property) %> get<%- camelize(property.name) %>() const; - void set<%- camelize(property.name) %>(<%- propertyValueType(property) %>); + const <%- propertyValueType(property) %>& get<%- camelize(property.name) %>() const; + void set<%- camelize(property.name) %>(const <%- propertyValueType(property) %>&); void set<%- camelize(property.name) %>Transition(const TransitionOptions&); TransitionOptions get<%- camelize(property.name) %>Transition() const; diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp index 5993ac8730..21fdb3653e 100644 --- a/include/mbgl/style/layers/line_layer.hpp +++ b/include/mbgl/style/layers/line_layer.hpp @@ -28,86 +28,86 @@ public: // Layout properties static PropertyValue getDefaultLineCap(); - PropertyValue getLineCap() const; - void setLineCap(PropertyValue); + const PropertyValue& getLineCap() const; + void setLineCap(const PropertyValue&); static PropertyValue getDefaultLineJoin(); - PropertyValue getLineJoin() const; - void setLineJoin(PropertyValue); + const PropertyValue& getLineJoin() const; + void setLineJoin(const PropertyValue&); static PropertyValue getDefaultLineMiterLimit(); - PropertyValue getLineMiterLimit() const; - void setLineMiterLimit(PropertyValue); + const PropertyValue& getLineMiterLimit() const; + void setLineMiterLimit(const PropertyValue&); static PropertyValue getDefaultLineRoundLimit(); - PropertyValue getLineRoundLimit() const; - void setLineRoundLimit(PropertyValue); + const PropertyValue& getLineRoundLimit() const; + void setLineRoundLimit(const PropertyValue&); // Paint properties static PropertyValue getDefaultLineOpacity(); - PropertyValue getLineOpacity() const; - void setLineOpacity(PropertyValue); + const PropertyValue& getLineOpacity() const; + void setLineOpacity(const PropertyValue&); void setLineOpacityTransition(const TransitionOptions&); TransitionOptions getLineOpacityTransition() const; static PropertyValue getDefaultLineColor(); - PropertyValue getLineColor() const; - void setLineColor(PropertyValue); + const PropertyValue& getLineColor() const; + void setLineColor(const PropertyValue&); void setLineColorTransition(const TransitionOptions&); TransitionOptions getLineColorTransition() const; static PropertyValue> getDefaultLineTranslate(); - PropertyValue> getLineTranslate() const; - void setLineTranslate(PropertyValue>); + const PropertyValue>& getLineTranslate() const; + void setLineTranslate(const PropertyValue>&); void setLineTranslateTransition(const TransitionOptions&); TransitionOptions getLineTranslateTransition() const; static PropertyValue getDefaultLineTranslateAnchor(); - PropertyValue getLineTranslateAnchor() const; - void setLineTranslateAnchor(PropertyValue); + const PropertyValue& getLineTranslateAnchor() const; + void setLineTranslateAnchor(const PropertyValue&); void setLineTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getLineTranslateAnchorTransition() const; static PropertyValue getDefaultLineWidth(); - PropertyValue getLineWidth() const; - void setLineWidth(PropertyValue); + const PropertyValue& getLineWidth() const; + void setLineWidth(const PropertyValue&); void setLineWidthTransition(const TransitionOptions&); TransitionOptions getLineWidthTransition() const; static PropertyValue getDefaultLineGapWidth(); - PropertyValue getLineGapWidth() const; - void setLineGapWidth(PropertyValue); + const PropertyValue& getLineGapWidth() const; + void setLineGapWidth(const PropertyValue&); void setLineGapWidthTransition(const TransitionOptions&); TransitionOptions getLineGapWidthTransition() const; static PropertyValue getDefaultLineOffset(); - PropertyValue getLineOffset() const; - void setLineOffset(PropertyValue); + const PropertyValue& getLineOffset() const; + void setLineOffset(const PropertyValue&); void setLineOffsetTransition(const TransitionOptions&); TransitionOptions getLineOffsetTransition() const; static PropertyValue getDefaultLineBlur(); - PropertyValue getLineBlur() const; - void setLineBlur(PropertyValue); + const PropertyValue& getLineBlur() const; + void setLineBlur(const PropertyValue&); void setLineBlurTransition(const TransitionOptions&); TransitionOptions getLineBlurTransition() const; static PropertyValue> getDefaultLineDasharray(); - PropertyValue> getLineDasharray() const; - void setLineDasharray(PropertyValue>); + const PropertyValue>& getLineDasharray() const; + void setLineDasharray(const PropertyValue>&); void setLineDasharrayTransition(const TransitionOptions&); TransitionOptions getLineDasharrayTransition() const; static PropertyValue getDefaultLinePattern(); - PropertyValue getLinePattern() const; - void setLinePattern(PropertyValue); + const PropertyValue& getLinePattern() const; + void setLinePattern(const PropertyValue&); void setLinePatternTransition(const TransitionOptions&); TransitionOptions getLinePatternTransition() const; static ColorRampPropertyValue getDefaultLineGradient(); - ColorRampPropertyValue getLineGradient() const; - void setLineGradient(ColorRampPropertyValue); + const ColorRampPropertyValue& getLineGradient() const; + void setLineGradient(const ColorRampPropertyValue&); void setLineGradientTransition(const TransitionOptions&); TransitionOptions getLineGradientTransition() const; diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp index f4736c9dcd..bdd9857c39 100644 --- a/include/mbgl/style/layers/raster_layer.hpp +++ b/include/mbgl/style/layers/raster_layer.hpp @@ -25,50 +25,50 @@ public: // Paint properties static PropertyValue getDefaultRasterOpacity(); - PropertyValue getRasterOpacity() const; - void setRasterOpacity(PropertyValue); + const PropertyValue& getRasterOpacity() const; + void setRasterOpacity(const PropertyValue&); void setRasterOpacityTransition(const TransitionOptions&); TransitionOptions getRasterOpacityTransition() const; static PropertyValue getDefaultRasterHueRotate(); - PropertyValue getRasterHueRotate() const; - void setRasterHueRotate(PropertyValue); + const PropertyValue& getRasterHueRotate() const; + void setRasterHueRotate(const PropertyValue&); void setRasterHueRotateTransition(const TransitionOptions&); TransitionOptions getRasterHueRotateTransition() const; static PropertyValue getDefaultRasterBrightnessMin(); - PropertyValue getRasterBrightnessMin() const; - void setRasterBrightnessMin(PropertyValue); + const PropertyValue& getRasterBrightnessMin() const; + void setRasterBrightnessMin(const PropertyValue&); void setRasterBrightnessMinTransition(const TransitionOptions&); TransitionOptions getRasterBrightnessMinTransition() const; static PropertyValue getDefaultRasterBrightnessMax(); - PropertyValue getRasterBrightnessMax() const; - void setRasterBrightnessMax(PropertyValue); + const PropertyValue& getRasterBrightnessMax() const; + void setRasterBrightnessMax(const PropertyValue&); void setRasterBrightnessMaxTransition(const TransitionOptions&); TransitionOptions getRasterBrightnessMaxTransition() const; static PropertyValue getDefaultRasterSaturation(); - PropertyValue getRasterSaturation() const; - void setRasterSaturation(PropertyValue); + const PropertyValue& getRasterSaturation() const; + void setRasterSaturation(const PropertyValue&); void setRasterSaturationTransition(const TransitionOptions&); TransitionOptions getRasterSaturationTransition() const; static PropertyValue getDefaultRasterContrast(); - PropertyValue getRasterContrast() const; - void setRasterContrast(PropertyValue); + const PropertyValue& getRasterContrast() const; + void setRasterContrast(const PropertyValue&); void setRasterContrastTransition(const TransitionOptions&); TransitionOptions getRasterContrastTransition() const; static PropertyValue getDefaultRasterResampling(); - PropertyValue getRasterResampling() const; - void setRasterResampling(PropertyValue); + const PropertyValue& getRasterResampling() const; + void setRasterResampling(const PropertyValue&); void setRasterResamplingTransition(const TransitionOptions&); TransitionOptions getRasterResamplingTransition() const; static PropertyValue getDefaultRasterFadeDuration(); - PropertyValue getRasterFadeDuration() const; - void setRasterFadeDuration(PropertyValue); + const PropertyValue& getRasterFadeDuration() const; + void setRasterFadeDuration(const PropertyValue&); void setRasterFadeDurationTransition(const TransitionOptions&); TransitionOptions getRasterFadeDurationTransition() const; diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index 35fe72e6bf..c7082f232d 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -27,244 +27,244 @@ public: // Layout properties static PropertyValue getDefaultSymbolPlacement(); - PropertyValue getSymbolPlacement() const; - void setSymbolPlacement(PropertyValue); + const PropertyValue& getSymbolPlacement() const; + void setSymbolPlacement(const PropertyValue&); static PropertyValue getDefaultSymbolSpacing(); - PropertyValue getSymbolSpacing() const; - void setSymbolSpacing(PropertyValue); + const PropertyValue& getSymbolSpacing() const; + void setSymbolSpacing(const PropertyValue&); static PropertyValue getDefaultSymbolAvoidEdges(); - PropertyValue getSymbolAvoidEdges() const; - void setSymbolAvoidEdges(PropertyValue); + const PropertyValue& getSymbolAvoidEdges() const; + void setSymbolAvoidEdges(const PropertyValue&); static PropertyValue getDefaultSymbolZOrder(); - PropertyValue getSymbolZOrder() const; - void setSymbolZOrder(PropertyValue); + const PropertyValue& getSymbolZOrder() const; + void setSymbolZOrder(const PropertyValue&); static PropertyValue getDefaultIconAllowOverlap(); - PropertyValue getIconAllowOverlap() const; - void setIconAllowOverlap(PropertyValue); + const PropertyValue& getIconAllowOverlap() const; + void setIconAllowOverlap(const PropertyValue&); static PropertyValue getDefaultIconIgnorePlacement(); - PropertyValue getIconIgnorePlacement() const; - void setIconIgnorePlacement(PropertyValue); + const PropertyValue& getIconIgnorePlacement() const; + void setIconIgnorePlacement(const PropertyValue&); static PropertyValue getDefaultIconOptional(); - PropertyValue getIconOptional() const; - void setIconOptional(PropertyValue); + const PropertyValue& getIconOptional() const; + void setIconOptional(const PropertyValue&); static PropertyValue getDefaultIconRotationAlignment(); - PropertyValue getIconRotationAlignment() const; - void setIconRotationAlignment(PropertyValue); + const PropertyValue& getIconRotationAlignment() const; + void setIconRotationAlignment(const PropertyValue&); static PropertyValue getDefaultIconSize(); - PropertyValue getIconSize() const; - void setIconSize(PropertyValue); + const PropertyValue& getIconSize() const; + void setIconSize(const PropertyValue&); static PropertyValue getDefaultIconTextFit(); - PropertyValue getIconTextFit() const; - void setIconTextFit(PropertyValue); + const PropertyValue& getIconTextFit() const; + void setIconTextFit(const PropertyValue&); static PropertyValue> getDefaultIconTextFitPadding(); - PropertyValue> getIconTextFitPadding() const; - void setIconTextFitPadding(PropertyValue>); + const PropertyValue>& getIconTextFitPadding() const; + void setIconTextFitPadding(const PropertyValue>&); static PropertyValue getDefaultIconImage(); - PropertyValue getIconImage() const; - void setIconImage(PropertyValue); + const PropertyValue& getIconImage() const; + void setIconImage(const PropertyValue&); static PropertyValue getDefaultIconRotate(); - PropertyValue getIconRotate() const; - void setIconRotate(PropertyValue); + const PropertyValue& getIconRotate() const; + void setIconRotate(const PropertyValue&); static PropertyValue getDefaultIconPadding(); - PropertyValue getIconPadding() const; - void setIconPadding(PropertyValue); + const PropertyValue& getIconPadding() const; + void setIconPadding(const PropertyValue&); static PropertyValue getDefaultIconKeepUpright(); - PropertyValue getIconKeepUpright() const; - void setIconKeepUpright(PropertyValue); + const PropertyValue& getIconKeepUpright() const; + void setIconKeepUpright(const PropertyValue&); static PropertyValue> getDefaultIconOffset(); - PropertyValue> getIconOffset() const; - void setIconOffset(PropertyValue>); + const PropertyValue>& getIconOffset() const; + void setIconOffset(const PropertyValue>&); static PropertyValue getDefaultIconAnchor(); - PropertyValue getIconAnchor() const; - void setIconAnchor(PropertyValue); + const PropertyValue& getIconAnchor() const; + void setIconAnchor(const PropertyValue&); static PropertyValue getDefaultIconPitchAlignment(); - PropertyValue getIconPitchAlignment() const; - void setIconPitchAlignment(PropertyValue); + const PropertyValue& getIconPitchAlignment() const; + void setIconPitchAlignment(const PropertyValue&); static PropertyValue getDefaultTextPitchAlignment(); - PropertyValue getTextPitchAlignment() const; - void setTextPitchAlignment(PropertyValue); + const PropertyValue& getTextPitchAlignment() const; + void setTextPitchAlignment(const PropertyValue&); static PropertyValue getDefaultTextRotationAlignment(); - PropertyValue getTextRotationAlignment() const; - void setTextRotationAlignment(PropertyValue); + const PropertyValue& getTextRotationAlignment() const; + void setTextRotationAlignment(const PropertyValue&); static PropertyValue getDefaultTextField(); - PropertyValue getTextField() const; - void setTextField(PropertyValue); + const PropertyValue& getTextField() const; + void setTextField(const PropertyValue&); static PropertyValue> getDefaultTextFont(); - PropertyValue> getTextFont() const; - void setTextFont(PropertyValue>); + const PropertyValue>& getTextFont() const; + void setTextFont(const PropertyValue>&); static PropertyValue getDefaultTextSize(); - PropertyValue getTextSize() const; - void setTextSize(PropertyValue); + const PropertyValue& getTextSize() const; + void setTextSize(const PropertyValue&); static PropertyValue getDefaultTextMaxWidth(); - PropertyValue getTextMaxWidth() const; - void setTextMaxWidth(PropertyValue); + const PropertyValue& getTextMaxWidth() const; + void setTextMaxWidth(const PropertyValue&); static PropertyValue getDefaultTextLineHeight(); - PropertyValue getTextLineHeight() const; - void setTextLineHeight(PropertyValue); + const PropertyValue& getTextLineHeight() const; + void setTextLineHeight(const PropertyValue&); static PropertyValue getDefaultTextLetterSpacing(); - PropertyValue getTextLetterSpacing() const; - void setTextLetterSpacing(PropertyValue); + const PropertyValue& getTextLetterSpacing() const; + void setTextLetterSpacing(const PropertyValue&); static PropertyValue getDefaultTextJustify(); - PropertyValue getTextJustify() const; - void setTextJustify(PropertyValue); + const PropertyValue& getTextJustify() const; + void setTextJustify(const PropertyValue&); static PropertyValue getDefaultTextRadialOffset(); - PropertyValue getTextRadialOffset() const; - void setTextRadialOffset(PropertyValue); + const PropertyValue& getTextRadialOffset() const; + void setTextRadialOffset(const PropertyValue&); static PropertyValue> getDefaultTextVariableAnchor(); - PropertyValue> getTextVariableAnchor() const; - void setTextVariableAnchor(PropertyValue>); + const PropertyValue>& getTextVariableAnchor() const; + void setTextVariableAnchor(const PropertyValue>&); static PropertyValue getDefaultTextAnchor(); - PropertyValue getTextAnchor() const; - void setTextAnchor(PropertyValue); + const PropertyValue& getTextAnchor() const; + void setTextAnchor(const PropertyValue&); static PropertyValue getDefaultTextMaxAngle(); - PropertyValue getTextMaxAngle() const; - void setTextMaxAngle(PropertyValue); + const PropertyValue& getTextMaxAngle() const; + void setTextMaxAngle(const PropertyValue&); static PropertyValue getDefaultTextRotate(); - PropertyValue getTextRotate() const; - void setTextRotate(PropertyValue); + const PropertyValue& getTextRotate() const; + void setTextRotate(const PropertyValue&); static PropertyValue getDefaultTextPadding(); - PropertyValue getTextPadding() const; - void setTextPadding(PropertyValue); + const PropertyValue& getTextPadding() const; + void setTextPadding(const PropertyValue&); static PropertyValue getDefaultTextKeepUpright(); - PropertyValue getTextKeepUpright() const; - void setTextKeepUpright(PropertyValue); + const PropertyValue& getTextKeepUpright() const; + void setTextKeepUpright(const PropertyValue&); static PropertyValue getDefaultTextTransform(); - PropertyValue getTextTransform() const; - void setTextTransform(PropertyValue); + const PropertyValue& getTextTransform() const; + void setTextTransform(const PropertyValue&); static PropertyValue> getDefaultTextOffset(); - PropertyValue> getTextOffset() const; - void setTextOffset(PropertyValue>); + const PropertyValue>& getTextOffset() const; + void setTextOffset(const PropertyValue>&); static PropertyValue getDefaultTextAllowOverlap(); - PropertyValue getTextAllowOverlap() const; - void setTextAllowOverlap(PropertyValue); + const PropertyValue& getTextAllowOverlap() const; + void setTextAllowOverlap(const PropertyValue&); static PropertyValue getDefaultTextIgnorePlacement(); - PropertyValue getTextIgnorePlacement() const; - void setTextIgnorePlacement(PropertyValue); + const PropertyValue& getTextIgnorePlacement() const; + void setTextIgnorePlacement(const PropertyValue&); static PropertyValue getDefaultTextOptional(); - PropertyValue getTextOptional() const; - void setTextOptional(PropertyValue); + const PropertyValue& getTextOptional() const; + void setTextOptional(const PropertyValue&); // Paint properties static PropertyValue getDefaultIconOpacity(); - PropertyValue getIconOpacity() const; - void setIconOpacity(PropertyValue); + const PropertyValue& getIconOpacity() const; + void setIconOpacity(const PropertyValue&); void setIconOpacityTransition(const TransitionOptions&); TransitionOptions getIconOpacityTransition() const; static PropertyValue getDefaultIconColor(); - PropertyValue getIconColor() const; - void setIconColor(PropertyValue); + const PropertyValue& getIconColor() const; + void setIconColor(const PropertyValue&); void setIconColorTransition(const TransitionOptions&); TransitionOptions getIconColorTransition() const; static PropertyValue getDefaultIconHaloColor(); - PropertyValue getIconHaloColor() const; - void setIconHaloColor(PropertyValue); + const PropertyValue& getIconHaloColor() const; + void setIconHaloColor(const PropertyValue&); void setIconHaloColorTransition(const TransitionOptions&); TransitionOptions getIconHaloColorTransition() const; static PropertyValue getDefaultIconHaloWidth(); - PropertyValue getIconHaloWidth() const; - void setIconHaloWidth(PropertyValue); + const PropertyValue& getIconHaloWidth() const; + void setIconHaloWidth(const PropertyValue&); void setIconHaloWidthTransition(const TransitionOptions&); TransitionOptions getIconHaloWidthTransition() const; static PropertyValue getDefaultIconHaloBlur(); - PropertyValue getIconHaloBlur() const; - void setIconHaloBlur(PropertyValue); + const PropertyValue& getIconHaloBlur() const; + void setIconHaloBlur(const PropertyValue&); void setIconHaloBlurTransition(const TransitionOptions&); TransitionOptions getIconHaloBlurTransition() const; static PropertyValue> getDefaultIconTranslate(); - PropertyValue> getIconTranslate() const; - void setIconTranslate(PropertyValue>); + const PropertyValue>& getIconTranslate() const; + void setIconTranslate(const PropertyValue>&); void setIconTranslateTransition(const TransitionOptions&); TransitionOptions getIconTranslateTransition() const; static PropertyValue getDefaultIconTranslateAnchor(); - PropertyValue getIconTranslateAnchor() const; - void setIconTranslateAnchor(PropertyValue); + const PropertyValue& getIconTranslateAnchor() const; + void setIconTranslateAnchor(const PropertyValue&); void setIconTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getIconTranslateAnchorTransition() const; static PropertyValue getDefaultTextOpacity(); - PropertyValue getTextOpacity() const; - void setTextOpacity(PropertyValue); + const PropertyValue& getTextOpacity() const; + void setTextOpacity(const PropertyValue&); void setTextOpacityTransition(const TransitionOptions&); TransitionOptions getTextOpacityTransition() const; static PropertyValue getDefaultTextColor(); - PropertyValue getTextColor() const; - void setTextColor(PropertyValue); + const PropertyValue& getTextColor() const; + void setTextColor(const PropertyValue&); void setTextColorTransition(const TransitionOptions&); TransitionOptions getTextColorTransition() const; static PropertyValue getDefaultTextHaloColor(); - PropertyValue getTextHaloColor() const; - void setTextHaloColor(PropertyValue); + const PropertyValue& getTextHaloColor() const; + void setTextHaloColor(const PropertyValue&); void setTextHaloColorTransition(const TransitionOptions&); TransitionOptions getTextHaloColorTransition() const; static PropertyValue getDefaultTextHaloWidth(); - PropertyValue getTextHaloWidth() const; - void setTextHaloWidth(PropertyValue); + const PropertyValue& getTextHaloWidth() const; + void setTextHaloWidth(const PropertyValue&); void setTextHaloWidthTransition(const TransitionOptions&); TransitionOptions getTextHaloWidthTransition() const; static PropertyValue getDefaultTextHaloBlur(); - PropertyValue getTextHaloBlur() const; - void setTextHaloBlur(PropertyValue); + const PropertyValue& getTextHaloBlur() const; + void setTextHaloBlur(const PropertyValue&); void setTextHaloBlurTransition(const TransitionOptions&); TransitionOptions getTextHaloBlurTransition() const; static PropertyValue> getDefaultTextTranslate(); - PropertyValue> getTextTranslate() const; - void setTextTranslate(PropertyValue>); + const PropertyValue>& getTextTranslate() const; + void setTextTranslate(const PropertyValue>&); void setTextTranslateTransition(const TransitionOptions&); TransitionOptions getTextTranslateTransition() const; static PropertyValue getDefaultTextTranslateAnchor(); - PropertyValue getTextTranslateAnchor() const; - void setTextTranslateAnchor(PropertyValue); + const PropertyValue& getTextTranslateAnchor() const; + void setTextTranslateAnchor(const PropertyValue&); void setTextTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getTextTranslateAnchorTransition() const; diff --git a/platform/default/src/mbgl/storage/default_file_source.cpp b/platform/default/src/mbgl/storage/default_file_source.cpp index 4d812044cf..1ccf999109 100644 --- a/platform/default/src/mbgl/storage/default_file_source.cpp +++ b/platform/default/src/mbgl/storage/default_file_source.cpp @@ -14,13 +14,14 @@ #include #include +#include namespace mbgl { class DefaultFileSource::Impl { public: Impl(std::shared_ptr assetFileSource_, std::string cachePath, uint64_t maximumCacheSize) - : assetFileSource(assetFileSource_) + : assetFileSource(std::move(assetFileSource_)) , localFileSource(std::make_unique()) , offlineDatabase(std::make_unique(cachePath, maximumCacheSize)) { } diff --git a/platform/default/src/mbgl/storage/offline.cpp b/platform/default/src/mbgl/storage/offline.cpp index fd945c724f..dd809ad129 100644 --- a/platform/default/src/mbgl/storage/offline.cpp +++ b/platform/default/src/mbgl/storage/offline.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace mbgl { @@ -33,7 +34,7 @@ OfflineTilePyramidRegionDefinition::OfflineTilePyramidRegionDefinition( // OfflineGeometryRegionDefinition OfflineGeometryRegionDefinition::OfflineGeometryRegionDefinition(std::string styleURL_, Geometry geometry_, double minZoom_, double maxZoom_, float pixelRatio_, bool includeIdeographs_) - : styleURL(styleURL_) + : styleURL(std::move(styleURL_)) , geometry(std::move(geometry_)) , minZoom(minZoom_) , maxZoom(maxZoom_) diff --git a/platform/default/src/mbgl/text/bidi.cpp b/platform/default/src/mbgl/text/bidi.cpp index 32a3dc23ef..6bb2d36446 100644 --- a/platform/default/src/mbgl/text/bidi.cpp +++ b/platform/default/src/mbgl/text/bidi.cpp @@ -180,7 +180,7 @@ std::vector BiDi::processStyledText(const StyledText& input, std::se std::u16string BiDi::writeReverse(const std::u16string& input, std::size_t logicalStart, std::size_t logicalEnd) { UErrorCode errorCode = U_ZERO_ERROR; - int32_t logicalLength = static_cast(logicalEnd - logicalStart); + auto logicalLength = static_cast(logicalEnd - logicalStart); std::u16string outputText(logicalLength + 1, 0); // UBIDI_DO_MIRRORING: Apply unicode mirroring of characters like parentheses diff --git a/platform/node/src/node_expression.cpp b/platform/node/src/node_expression.cpp index 4f1e392505..e980c464d8 100644 --- a/platform/node/src/node_expression.cpp +++ b/platform/node/src/node_expression.cpp @@ -173,7 +173,7 @@ struct ToValue { } else { serializedSection.emplace("fontStack", mbgl::NullValue()); } - sections.push_back(serializedSection); + sections.emplace_back(serializedSection); } serialized.emplace("sections", sections); @@ -205,7 +205,7 @@ v8::Local toJS(const Value& value) { } void NodeExpression::Evaluate(const Nan::FunctionCallbackInfo& info) { - NodeExpression* nodeExpr = ObjectWrap::Unwrap(info.Holder()); + auto* nodeExpr = ObjectWrap::Unwrap(info.Holder()); const std::unique_ptr& expression = nodeExpr->expression; if (info.Length() < 2 || !info[0]->IsObject()) { @@ -246,7 +246,7 @@ void NodeExpression::Evaluate(const Nan::FunctionCallbackInfo& info) } void NodeExpression::GetType(const Nan::FunctionCallbackInfo& info) { - NodeExpression* nodeExpr = ObjectWrap::Unwrap(info.Holder()); + auto* nodeExpr = ObjectWrap::Unwrap(info.Holder()); const std::unique_ptr& expression = nodeExpr->expression; const type::Type type = expression->getType(); @@ -255,19 +255,19 @@ void NodeExpression::GetType(const Nan::FunctionCallbackInfo& info) { } void NodeExpression::IsFeatureConstant(const Nan::FunctionCallbackInfo& info) { - NodeExpression* nodeExpr = ObjectWrap::Unwrap(info.Holder()); + auto* nodeExpr = ObjectWrap::Unwrap(info.Holder()); const std::unique_ptr& expression = nodeExpr->expression; info.GetReturnValue().Set(Nan::New(isFeatureConstant(*expression))); } void NodeExpression::IsZoomConstant(const Nan::FunctionCallbackInfo& info) { - NodeExpression* nodeExpr = ObjectWrap::Unwrap(info.Holder()); + auto* nodeExpr = ObjectWrap::Unwrap(info.Holder()); const std::unique_ptr& expression = nodeExpr->expression; info.GetReturnValue().Set(Nan::New(isZoomConstant(*expression))); } void NodeExpression::Serialize(const Nan::FunctionCallbackInfo& info) { - NodeExpression* nodeExpr = ObjectWrap::Unwrap(info.Holder()); + auto* nodeExpr = ObjectWrap::Unwrap(info.Holder()); const std::unique_ptr& expression = nodeExpr->expression; const mbgl::Value serialized = expression->serialize(); diff --git a/platform/node/src/node_feature.cpp b/platform/node/src/node_feature.cpp index ee1cdab031..2dfab686a7 100644 --- a/platform/node/src/node_feature.cpp +++ b/platform/node/src/node_feature.cpp @@ -47,9 +47,9 @@ public: } private: - v8::Local type(const char* type) { + v8::Local type(const char* type_) { Nan::EscapableHandleScope scope; - return scope.Escape(Nan::New(type).ToLocalChecked()); + return scope.Escape(Nan::New(type_).ToLocalChecked()); } }; diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 291dea6bb7..7156a1f1bf 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -1254,10 +1254,10 @@ std::unique_ptr NodeFileSource::request(const mbgl::Resource Nan::Set(instance, Nan::New("url").ToLocalChecked(), Nan::New(resource.url).ToLocalChecked()); Nan::Set(instance, Nan::New("kind").ToLocalChecked(), Nan::New(resource.kind)); - auto request = Nan::ObjectWrap::Unwrap(instance); - request->Execute(); + auto req = Nan::ObjectWrap::Unwrap(instance); + req->Execute(); - return std::make_unique(request); + return std::make_unique(req); } } // namespace node_mbgl diff --git a/scripts/clang-tidy-diff.py b/scripts/clang-tidy-diff.py new file mode 100755 index 0000000000..e5e0ff3911 --- /dev/null +++ b/scripts/clang-tidy-diff.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python +# +#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===# +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# + +r""" +ClangTidy Diff Checker +====================== + +This script reads input from a unified diff, runs clang-tidy on all changed +files and outputs clang-tidy warnings in changed lines only. This is useful to +detect clang-tidy regressions in the lines touched by a specific patch. +Example usage for git/svn users: + + git diff -U0 HEAD^ | clang-tidy-diff.py -p1 + svn diff --diff-cmd=diff -x-U0 | \ + clang-tidy-diff.py -fix -checks=-*,modernize-use-override + +""" + +import argparse +import json +import re +import subprocess +import sys +import multiprocessing +import os +import threading + +is_py2 = sys.version[0] == '2' + +if is_py2: + import Queue as queue +else: + import queue as queue + +def run_tidy(command, lines_by_file, queue, failed_files): + """Takes filenames out of queue and runs clang-tidy on them.""" + while True: + name = queue.get() + + line_filter_json = json.dumps([{"name" : name, "lines" : lines_by_file[name]}], separators = (',', ':')) + if sys.platform == 'win32': + line_filter_json = re.sub(r'"', r'"""', line_filter_json) + else: + line_filter_json = "'" + line_filter_json + "'"; + + invocation = list(command) + invocation.append('-line-filter=' + line_filter_json) + invocation.append(name) + + sys.stdout.write('Checking differences in {}...\n'.format(name)) + return_code = subprocess.call(' '.join(invocation), shell=True) + if return_code != 0: + failed_files.append(name) + queue.task_done() + +def main(): + parser = argparse.ArgumentParser(description= + 'Run clang-tidy against changed files, and ' + 'output diagnostics only for modified ' + 'lines.') + parser.add_argument('-clang-tidy-binary', metavar='PATH', + default='clang-tidy', + help='path to clang-tidy binary') + parser.add_argument('-p', metavar='NUM', default=0, + help='strip the smallest prefix containing P slashes') + parser.add_argument('-regex', metavar='PATTERN', default=None, + help='custom pattern selecting file paths to check ' + '(case sensitive, overrides -iregex)') + parser.add_argument('-iregex', metavar='PATTERN', default= + r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc)', + help='custom pattern selecting file paths to check ' + '(case insensitive, overridden by -regex)') + + parser.add_argument('-fix', action='store_true', default=False, + help='apply suggested fixes') + parser.add_argument('-checks', + help='checks filter, when not specified, use clang-tidy ' + 'default', + default='') + parser.add_argument('-path', dest='build_path', + help='Path used to read a compile command database.') + parser.add_argument('-extra-arg', dest='extra_arg', + action='append', default=[], + help='Additional argument to append to the compiler ' + 'command line.') + parser.add_argument('-extra-arg-before', dest='extra_arg_before', + action='append', default=[], + help='Additional argument to prepend to the compiler ' + 'command line.') + parser.add_argument('-j', type=int, default=0, + help='number of tidy instances to be run in parallel.') + parser.add_argument('-quiet', action='store_true', default=False, + help='Run clang-tidy in quiet mode') + clang_tidy_args = [] + argv = sys.argv[1:] + if '--' in argv: + clang_tidy_args.extend(argv[argv.index('--'):]) + argv = argv[:argv.index('--')] + + args = parser.parse_args(argv) + + # Extract changed lines for each file. + filename = None + lines_by_file = {} + for line in sys.stdin: + match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line) + if match: + filename = match.group(2) + if filename == None: + continue + + if args.regex is not None: + if not re.match('^%s$' % args.regex, filename): + continue + else: + if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE): + continue + + match = re.search('^@@.*\+(\d+)(,(\d+))?', line) + if match: + start_line = int(match.group(1)) + line_count = 1 + if match.group(3): + line_count = int(match.group(3)) + if line_count == 0: + continue + end_line = start_line + line_count - 1; + lines_by_file.setdefault(filename, []).append([start_line, end_line]) + + if len(lines_by_file) == 0: + print("No relevant changes found.") + sys.exit(0) + + # Run clang-tidy on files containing changes. + command = [args.clang_tidy_binary] + if args.fix: + command.append('-fix') + if args.checks != '': + command.append('-checks=' + quote + args.checks + quote) + if args.quiet: + command.append('-quiet') + if args.build_path is not None: + command.append('-p=%s' % args.build_path) + for arg in args.extra_arg: + command.append('-extra-arg=%s' % arg) + for arg in args.extra_arg_before: + command.append('-extra-arg-before=%s' % arg) + command.extend(clang_tidy_args) + + try: + invocation = list(command) + invocation.append('-') + subprocess.check_call(invocation) + except: + print("Unable to run clang-tidy: {}".format(' '.join(command))) + sys.exit(1) + + max_task = args.j + if max_task == 0: + max_task = multiprocessing.cpu_count() + + return_code = 0 + try: + # Spin up a bunch of tidy-launching threads. + task_queue = queue.Queue(max_task) + # List of files with a non-zero return code. + failed_files = [] + for _ in range(max_task): + t = threading.Thread(target=run_tidy, + args=(command, lines_by_file, task_queue, failed_files)) + t.daemon = True + t.start() + + # Fill the queue with files. + for name in lines_by_file: + task_queue.put(name) + + # Wait for all threads to be done. + task_queue.join() + if len(failed_files): + return_code = 1 + + except KeyboardInterrupt: + # This is a sad hack. Unfortunately subprocess goes + # bonkers with ctrl-c and we start forking merrily. + print('\nCtrl-C detected, goodbye.') + os.kill(0, 9) + return_code = 1 + + sys.exit(return_code) + +if __name__ == '__main__': + main() diff --git a/scripts/clang-tools.sh b/scripts/clang-tools.sh index 1e73951176..54a3958488 100755 --- a/scripts/clang-tools.sh +++ b/scripts/clang-tools.sh @@ -1,64 +1,31 @@ #!/usr/bin/env bash -set -e -set -o pipefail +set -euo pipefail -CLANG_TIDY_PREFIX=${CLANG_TIDY_PREFIX:-$(scripts/mason.sh PREFIX clang-tidy VERSION 4.0.1)} -CLANG_TIDY=${CLANG_TIDY:-${CLANG_TIDY_PREFIX}/bin/clang-tidy} -CLANG_APPLY=${CLANG_APPLY:-${CLANG_TIDY_PREFIX}/bin/clang-apply-replacements} +CLANG_TIDY_PREFIX=${CLANG_TIDY_PREFIX:-$(scripts/mason.sh PREFIX clang-tidy VERSION 7.0.0)} +CLANG_TIDY=${CLANG_TIDY_PREFIX}/bin/clang-tidy +CLANG_APPLY=${CLANG_TIDY_PREFIX}/bin/clang-apply-replacements -CLANG_FORMAT=${CLANG_FORMAT:-$(scripts/mason.sh PREFIX clang-format VERSION 4.0.1)/bin/clang-format} - -for CLANG_FILE in "${CLANG_TIDY} ${CLANG_APPLY} ${CLANG_FORMAT}"; do - command -v ${CLANG_TIDY} > /dev/null 2>&1 || { +for CLANG_FILE in "${CLANG_TIDY}" "${CLANG_APPLY}"; do + command -v "${CLANG_FILE}" > /dev/null 2>&1 || { echo "Can't find ${CLANG_FILE} in PATH." - if [ -z ${CLANG_FILE} ]; then + if [ -z "${CLANG_FILE}" ]; then echo "Alternatively, you can manually set ${!CLANG_FILE@}." fi exit 1 } done -cd $1 - -export CDUP=$(git rev-parse --show-cdup) -export CLANG_TIDY CLANG_APPLY CLANG_FORMAT - -function run_clang_tidy() { - FILES=$(git ls-files "src/mbgl/*.cpp" "platform/*.cpp" "test/*.cpp") - ${CLANG_TIDY_PREFIX}/share/run-clang-tidy.py -j ${JOBS} \ - -clang-tidy-binary ${CLANG_TIDY} \ - -clang-apply-replacements-binary ${CLANG_APPLY} \ - -fix ${FILES} 2>/dev/null || exit 1 -} - -function run_clang_tidy_diff() { - OUTPUT=$(git diff origin/$2 --src-prefix=${CDUP} --dst-prefix=${CDUP} | \ - ${CLANG_TIDY_PREFIX}/share/clang-tidy-diff.py \ - -clang-tidy-binary ${CLANG_TIDY} \ - 2>/dev/null) - if [[ -n $OUTPUT ]] && [[ $OUTPUT != "No relevant changes found." ]]; then - echo -e "${OUTPUT}" - exit 1 - fi -} - -function run_clang_format() { - echo "Running clang-format on $0..." - DIFF_FILES=$(git diff origin/$2 --name-only *cpp) - echo "${DIFF_FILES}" | xargs -I{} -P ${JOBS} bash -c 'run_clang_format' {} - ${CLANG_FORMAT} -i ${CDUP}/$0 || exit 1 -} - -export -f run_clang_tidy run_clang_tidy_diff run_clang_format - echo "Running Clang checks... (this might take a while)" -if [[ -n $3 ]] && [[ $3 == "--diff" ]]; then - run_clang_tidy_diff $@ - # XXX disabled until we run clang-format over the entire codebase. - #run_clang_format $@ - echo "All checks pass!" +if [[ -n ${3:-} ]] && [[ ${3:-} == "--diff" ]]; then + git diff "origin/$2" | "scripts/clang-tidy-diff.py" \ + -clang-tidy-binary "${CLANG_TIDY}" \ + -p 1 -quiet -path "$1" else - run_clang_tidy $@ + git ls-files "src/*.cpp" "test/*.cpp" "platform/*.cpp" "bin/*.cpp" | \ + xargs "${CLANG_TIDY_PREFIX}/share/run-clang-tidy.py" \ + -clang-tidy-binary "${CLANG_TIDY}" \ + -clang-apply-replacements-binary "${CLANG_APPLY}" \ + -quiet -p "$1" -fix fi diff --git a/src/mbgl/actor/mailbox.cpp b/src/mbgl/actor/mailbox.cpp index 8ee8dca114..dfe0520790 100644 --- a/src/mbgl/actor/mailbox.cpp +++ b/src/mbgl/actor/mailbox.cpp @@ -6,8 +6,7 @@ namespace mbgl { -Mailbox::Mailbox() { -} +Mailbox::Mailbox() = default; Mailbox::Mailbox(Scheduler& scheduler_) : scheduler(&scheduler_) { diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp index 7ece03c78a..6c3c9eb617 100644 --- a/src/mbgl/annotation/annotation_tile.cpp +++ b/src/mbgl/annotation/annotation_tile.cpp @@ -64,7 +64,7 @@ GeometryCollection AnnotationTileFeature::getGeometries() const { class AnnotationTileLayerData { public: - AnnotationTileLayerData(const std::string& name_) : name(name_) { + AnnotationTileLayerData(std::string name_) : name(std::move(name_)) { } const std::string name; diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp index 315a36954b..533a137a3d 100644 --- a/src/mbgl/annotation/line_annotation_impl.cpp +++ b/src/mbgl/annotation/line_annotation_impl.cpp @@ -22,7 +22,7 @@ void LineAnnotationImpl::updateStyle(Style::Impl& style) const { layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID); } - LineLayer* lineLayer = static_cast(layer); + auto* lineLayer = static_cast(layer); lineLayer->setLineOpacity(annotation.opacity); lineLayer->setLineWidth(annotation.width); lineLayer->setLineColor(annotation.color); diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index 0197df1066..809aa2f451 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace mbgl { @@ -34,7 +35,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor_, const IndexedSubfeature& indexedFeature, const std::size_t layoutFeatureIndex_, const std::size_t dataFeatureIndex_, - const std::u16string& key_, + std::u16string key_, const float overscaling, const float rotate, float radialTextOffset_) : @@ -52,7 +53,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor_, dataFeatureIndex(dataFeatureIndex_), textOffset(textOffset_), iconOffset(iconOffset_), - key(key_), + key(std::move(key_)), textBoxScale(textBoxScale_), radialTextOffset(radialTextOffset_), singleLine(shapedTextOrientations.singleLine) { diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp index 5169b16adb..95159deeb1 100644 --- a/src/mbgl/layout/symbol_instance.hpp +++ b/src/mbgl/layout/symbol_instance.hpp @@ -40,7 +40,7 @@ public: const IndexedSubfeature&, const std::size_t layoutFeatureIndex, const std::size_t dataFeatureIndex, - const std::u16string& key, + std::u16string key, const float overscaling, const float rotate, float radialTextOffset); diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index d1c50d7773..badc352f76 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -117,8 +117,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, FontStack baseFontStack = layout.evaluate(zoom, ft); ft.formattedText = TaggedString(); - for (std::size_t j = 0; j < formatted.sections.size(); j++) { - const auto& section = formatted.sections[j]; + for (const auto & section : formatted.sections) { std::string u8string = section.text; if (textTransform == TextTransformType::Uppercase) { u8string = platform::uppercase(u8string); diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index b22a9ee2f2..c31bb8ca34 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -252,7 +252,7 @@ CameraOptions Map::cameraForGeometry(const Geometry& geometry, const Edg std::vector latLngs; forEachPoint(geometry, [&](const Point& pt) { - latLngs.push_back({ pt.y, pt.x }); + latLngs.emplace_back(pt.y, pt.x); }); return cameraForLatLngs(latLngs, padding, bearing, pitch); } diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 68f683c8d6..a0ebab20be 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -203,8 +203,8 @@ void SymbolBucket::sortFeatures(const float angle) { std::sort(symbolInstanceIndexes.begin(), symbolInstanceIndexes.end(), [sin, cos, this](size_t &aIndex, size_t &bIndex) { const SymbolInstance& a = symbolInstances[aIndex]; const SymbolInstance& b = symbolInstances[bIndex]; - const int32_t aRotated = static_cast(::lround(sin * a.anchor.point.x + cos * a.anchor.point.y)); - const int32_t bRotated = static_cast(::lround(sin * b.anchor.point.x + cos * b.anchor.point.y)); + const auto aRotated = static_cast(::lround(sin * a.anchor.point.x + cos * a.anchor.point.y)); + const auto bRotated = static_cast(::lround(sin * b.anchor.point.x + cos * b.anchor.point.y)); return aRotated != bRotated ? aRotated < bRotated : a.dataFeatureIndex > b.dataFeatureIndex; diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp index 0b99460e76..9284ed8238 100644 --- a/src/mbgl/renderer/layers/render_custom_layer.cpp +++ b/src/mbgl/renderer/layers/render_custom_layer.cpp @@ -59,7 +59,7 @@ void RenderCustomLayer::render(PaintParameters& paintParameters, RenderSource*) } // TODO: remove cast - gl::Context& glContext = static_cast(paintParameters.context); + auto& glContext = static_cast(paintParameters.context); const TransformState& state = paintParameters.state; // Reset GL state to a known state so the CustomLayer always has a clean slate. diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 6f69916734..4041e420df 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -138,7 +138,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* continue; } const auto fillPatternValue = evaluated.get().constantOr(mbgl::Faded >{"", ""}); - GeometryTile& geometryTile = static_cast(tile.tile); + auto& geometryTile = static_cast(tile.tile); optional patternPosA = geometryTile.getPattern(fillPatternValue.from); optional patternPosB = geometryTile.getPattern(fillPatternValue.to); FillExtrusionBucket& bucket = *bucket_; diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index aba1481044..e6447c83a4 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -150,7 +150,7 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { } const auto fillPatternValue = evaluated.get().constantOr(Faded>{"", ""}); for (const RenderTile& tile : renderTiles) { - GeometryTile& geometryTile = static_cast(tile.tile); + auto& geometryTile = static_cast(tile.tile); optional patternPosA = geometryTile.getPattern(fillPatternValue.from); optional patternPosB = geometryTile.getPattern(fillPatternValue.to); diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index 5736280892..08efa898f6 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -61,7 +61,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src if (parameters.pass != RenderPass::Translucent && parameters.pass != RenderPass::Pass3D) return; - RenderRasterDEMSource* demsrc = static_cast(src); + auto* demsrc = static_cast(src); const uint8_t TERRAIN_RGB_MAXZOOM = 15; const uint8_t maxzoom = demsrc != nullptr ? demsrc->getMaxZoom() : TERRAIN_RGB_MAXZOOM; diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index ba6d045b49..2ea910f911 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -126,7 +126,7 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) { } else if (!unevaluated.get().isUndefined()) { const auto linePatternValue = evaluated.get().constantOr(Faded>{ "", ""}); - GeometryTile& geometryTile = static_cast(tile.tile); + auto& geometryTile = static_cast(tile.tile); const Size texsize = geometryTile.iconAtlasTexture->size; optional posA = geometryTile.getPattern(linePatternValue.from); diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index 4964afe6a7..55caeaf5b0 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -127,7 +127,7 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source const gfx::TextureFilterType filter = evaluated.get() == RasterResamplingType::Nearest ? gfx::TextureFilterType::Nearest : gfx::TextureFilterType::Linear; - if (RenderImageSource* imageSource = source->as()) { + if (auto* imageSource = source->as()) { if (imageSource->isEnabled() && imageSource->isLoaded() && !imageSource->bucket->needsUpload()) { RasterBucket& bucket = *imageSource->bucket; assert(bucket.texture); diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 84ce0a73e0..17bb08c0ea 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -148,7 +148,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { }; assert(tile.tile.kind == Tile::Kind::Geometry); - GeometryTile& geometryTile = static_cast(tile.tile); + auto& geometryTile = static_cast(tile.tile); if (bucket.hasIconData()) { auto values = iconPropertyValues(evaluated_, layout); diff --git a/src/mbgl/renderer/render_source.cpp b/src/mbgl/renderer/render_source.cpp index dfe1f25ed6..81638605f0 100644 --- a/src/mbgl/renderer/render_source.cpp +++ b/src/mbgl/renderer/render_source.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace mbgl { @@ -50,7 +51,7 @@ std::unique_ptr RenderSource::create(Immutable impl) static RenderSourceObserver nullObserver; RenderSource::RenderSource(Immutable impl) - : baseImpl(impl), + : baseImpl(std::move(impl)), observer(&nullObserver) { } diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index 87178d775e..f1fb31f693 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -576,7 +576,7 @@ void Renderer::Impl::queryRenderedSymbols(std::unordered_mapgetCollisionIndex().queryRenderedSymbols(geometry); std::vector> bucketQueryData; for (auto entry : renderedSymbols) { - bucketQueryData.push_back(placement->getQueryData(entry.first)); + bucketQueryData.emplace_back(placement->getQueryData(entry.first)); } // Although symbol query is global, symbol results are only sortable within a bucket // For a predictable global sort renderItems, we sort the buckets based on their corresponding tile position diff --git a/src/mbgl/renderer/sources/render_geojson_source.cpp b/src/mbgl/renderer/sources/render_geojson_source.cpp index 5eb6a931d3..3cfcfc7392 100644 --- a/src/mbgl/renderer/sources/render_geojson_source.cpp +++ b/src/mbgl/renderer/sources/render_geojson_source.cpp @@ -66,7 +66,7 @@ MAPBOX_ETERNAL_CONSTEXPR const auto extensionGetters = mapbox::eternal::hash_map {"expansion-zoom", &getClusterExpansionZoom} }); -} +} // namespace RenderGeoJSONSource::RenderGeoJSONSource(Immutable impl_) : RenderSource(impl_) { diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp index 102125be19..7190f25bc7 100644 --- a/src/mbgl/renderer/sources/render_image_source.cpp +++ b/src/mbgl/renderer/sources/render_image_source.cpp @@ -38,10 +38,10 @@ void RenderImageSource::startRender(PaintParameters& parameters) { matrices.clear(); - for (size_t i = 0; i < tileIds.size(); i++) { + for (auto& tileId : tileIds) { mat4 matrix; matrix::identity(matrix); - parameters.state.matrixFor(matrix, tileIds[i]); + parameters.state.matrixFor(matrix, tileId); matrix::multiply(matrix, parameters.alignedProjMatrix, matrix); matrices.push_back(matrix); } @@ -167,7 +167,7 @@ void RenderImageSource::update(Immutable baseImpl_, auto idealTiles = util::tileCover(transformState, transformState.getZoom()); for (auto tile : idealTiles) { if (tile.wrap != 0 && tileCover[0].canonical.isChildOf(tile.canonical)) { - tileIds.push_back({ tile.wrap, tileCover[0].canonical }); + tileIds.emplace_back(tile.wrap, tileCover[0].canonical); hasVisibleTile = true; } else if (!hasVisibleTile) { diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.cpp b/src/mbgl/renderer/sources/render_raster_dem_source.cpp index 2bc3a91c7c..63ab3ca370 100644 --- a/src/mbgl/renderer/sources/render_raster_dem_source.cpp +++ b/src/mbgl/renderer/sources/render_raster_dem_source.cpp @@ -60,7 +60,7 @@ void RenderRasterDEMSource::update(Immutable baseImpl_, } void RenderRasterDEMSource::onTileChanged(Tile& tile){ - RasterDEMTile& demtile = static_cast(tile); + auto& demtile = static_cast(tile); std::map opposites = { { DEMTileNeighbors::Left, DEMTileNeighbors::Right }, @@ -104,13 +104,13 @@ void RenderRasterDEMSource::onTileChanged(Tile& tile){ }; for (uint8_t i = 0; i < 8; i++) { - DEMTileNeighbors mask = DEMTileNeighbors(std::pow(2,i)); + auto mask = DEMTileNeighbors(std::pow(2,i)); // only backfill if this neighbor has not been previously backfilled if ((demtile.neighboringTiles & mask) != mask) { OverscaledTileID neighborid = getNeighbor(mask); Tile* renderableNeighbor = tilePyramid.getTile(neighborid); if (renderableNeighbor != nullptr && renderableNeighbor->isRenderable()) { - RasterDEMTile& borderTile = static_cast(*renderableNeighbor); + auto& borderTile = static_cast(*renderableNeighbor); demtile.backfillBorder(borderTile, mask); // if the border tile has not been backfilled by a previous instance of the main diff --git a/src/mbgl/storage/file_source.cpp b/src/mbgl/storage/file_source.cpp index 5854682771..5f60a05278 100644 --- a/src/mbgl/storage/file_source.cpp +++ b/src/mbgl/storage/file_source.cpp @@ -18,7 +18,7 @@ std::shared_ptr FileSource::getSharedFileSource(const ResourceOption it = it->second.expired() ? fileSources.erase(it) : ++it; } - const uint64_t context = reinterpret_cast(options.platformContext()); + const auto context = reinterpret_cast(options.platformContext()); const std::string key = options.baseURL() + '|' + options.accessToken() + '|' + options.cachePath() + '|' + util::toString(context); std::shared_ptr fileSource; diff --git a/src/mbgl/style/conversion/filter.cpp b/src/mbgl/style/conversion/filter.cpp index 18a29ed808..4e8d9c48e5 100644 --- a/src/mbgl/style/conversion/filter.cpp +++ b/src/mbgl/style/conversion/filter.cpp @@ -233,7 +233,7 @@ optional serializeLegacyFilter(const Convertible& values) { if (arrayValue) { result.push_back(*arrayValue); } else { - result.push_back(NullValue()); + result.emplace_back(NullValue()); } } return (mbgl::Value)result; diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp index df4decc73e..579924c78c 100644 --- a/src/mbgl/style/conversion/function.cpp +++ b/src/mbgl/style/conversion/function.cpp @@ -251,7 +251,7 @@ static optional> convertLiteral(type::Type type, con error.message = "value must be an array of numbers"; return nullopt; } - result.push_back(double(*number)); + result.emplace_back(double(*number)); } return literal(result); }, @@ -264,7 +264,7 @@ static optional> convertLiteral(type::Type type, con error.message = "value must be an array of strings"; return nullopt; } - result.push_back(*string); + result.emplace_back(*string); } return literal(result); }, diff --git a/src/mbgl/style/custom_tile_loader.cpp b/src/mbgl/style/custom_tile_loader.cpp index 1c587302b8..48fd5ae9e2 100644 --- a/src/mbgl/style/custom_tile_loader.cpp +++ b/src/mbgl/style/custom_tile_loader.cpp @@ -20,9 +20,9 @@ void CustomTileLoader::fetchTile(const OverscaledTileID& tileID, ActorRef(1, tuple) }); } else { - for (auto iter = tileCallbacks->second.begin(); iter != tileCallbacks->second.end(); iter++) { - if (std::get<0>(*iter) == tileID.overscaledZ && std::get<1>(*iter) == tileID.wrap ) { - std::get<2>(*iter) = tileRef; + for (auto& iter : tileCallbacks->second) { + if (std::get<0>(iter) == tileID.overscaledZ && std::get<1>(iter) == tileID.wrap ) { + std::get<2>(iter) = tileRef; return; } } @@ -70,8 +70,8 @@ void CustomTileLoader::setTileData(const CanonicalTileID& tileID, const GeoJSON& void CustomTileLoader::invalidateTile(const CanonicalTileID& tileID) { auto tileCallbacks = tileCallbackMap.find(tileID); if (tileCallbacks == tileCallbackMap.end()) { return; } - for (auto iter = tileCallbacks->second.begin(); iter != tileCallbacks->second.end(); iter++) { - auto actor = std::get<2>(*iter); + for (auto& iter : tileCallbacks->second) { + auto actor = std::get<2>(iter); actor.invoke(&CustomGeometryTile::invalidateTileData); invokeTileCancel(tileID); } @@ -82,20 +82,20 @@ void CustomTileLoader::invalidateTile(const CanonicalTileID& tileID) { void CustomTileLoader::invalidateRegion(const LatLngBounds& bounds, Range ) { std::map tileRanges; - for (auto idtuple= tileCallbackMap.begin(); idtuple != tileCallbackMap.end(); idtuple++) { - auto zoom = idtuple->first.z; + for (auto& idtuple : tileCallbackMap) { + auto zoom = idtuple.first.z; auto tileRange = tileRanges.find(zoom); if(tileRange == tileRanges.end()) { tileRange = tileRanges.emplace(std::make_pair(zoom, util::TileRange::fromLatLngBounds(bounds, zoom))).first; } - if (tileRange->second.contains(idtuple->first)) { - for (auto iter = idtuple->second.begin(); iter != idtuple->second.end(); iter++) { + if (tileRange->second.contains(idtuple.first)) { + for (auto iter = idtuple.second.begin(); iter != idtuple.second.end(); iter++) { auto actor = std::get<2>(*iter); actor.invoke(&CustomGeometryTile::invalidateTileData); - invokeTileCancel(idtuple->first); - dataCache.erase(idtuple->first); + invokeTileCancel(idtuple.first); + dataCache.erase(idtuple.first); } - idtuple->second.clear(); + idtuple.second.clear(); } } } diff --git a/src/mbgl/style/expression/boolean_operator.cpp b/src/mbgl/style/expression/boolean_operator.cpp index fa472270ce..a02c08131f 100644 --- a/src/mbgl/style/expression/boolean_operator.cpp +++ b/src/mbgl/style/expression/boolean_operator.cpp @@ -6,8 +6,8 @@ namespace style { namespace expression { EvaluationResult Any::evaluate(const EvaluationContext& params) const { - for (auto it = inputs.begin(); it != inputs.end(); it++) { - const EvaluationResult result = (*it)->evaluate(params); + for (const auto& input : inputs) { + const EvaluationResult result = input->evaluate(params); if (!result) return result; if (result->get()) return EvaluationResult(true); } @@ -34,8 +34,8 @@ std::vector> Any::possibleOutputs() const { EvaluationResult All::evaluate(const EvaluationContext& params) const { - for (auto it = inputs.begin(); it != inputs.end(); it++) { - const EvaluationResult result = (*it)->evaluate(params); + for (const auto& input : inputs) { + const EvaluationResult result = input->evaluate(params); if (!result) return result; if (!result->get()) return EvaluationResult(false); } diff --git a/src/mbgl/style/expression/case.cpp b/src/mbgl/style/expression/case.cpp index 0c2ff0d7cd..314551592f 100644 --- a/src/mbgl/style/expression/case.cpp +++ b/src/mbgl/style/expression/case.cpp @@ -86,7 +86,7 @@ ParseResult Case::parse(const Convertible& value, ParsingContext& ctx) { outputType = (*output)->getType(); } - branches.push_back(std::make_pair(std::move(*test), std::move(*output))); + branches.emplace_back(std::move(*test), std::move(*output)); } assert(outputType); diff --git a/src/mbgl/style/expression/coercion.cpp b/src/mbgl/style/expression/coercion.cpp index 75a6056081..e0c29be1a2 100644 --- a/src/mbgl/style/expression/coercion.cpp +++ b/src/mbgl/style/expression/coercion.cpp @@ -113,7 +113,7 @@ mbgl::Value Coercion::serialize() const { // by string expressions that get implicitly coerced to "formatted". std::vector serialized{{ std::string("format") }}; serialized.push_back(inputs[0]->serialize()); - serialized.push_back(std::unordered_map()); + serialized.emplace_back(std::unordered_map()); return serialized; } else { return Expression::serialize(); diff --git a/src/mbgl/style/expression/comparison.cpp b/src/mbgl/style/expression/comparison.cpp index cdcdb5d59c..aa5808a975 100644 --- a/src/mbgl/style/expression/comparison.cpp +++ b/src/mbgl/style/expression/comparison.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -149,7 +150,7 @@ CollatorComparison::CollatorComparison( std::unique_ptr rhs_, std::unique_ptr collator_) : Expression(Kind::Comparison, type::Boolean), - op(op_), + op(std::move(op_)), compare(getCollatorComparisonFunction(op)), lhs(std::move(lhs_)), rhs(std::move(rhs_)), diff --git a/src/mbgl/style/expression/dsl.cpp b/src/mbgl/style/expression/dsl.cpp index e7d90ba07b..b4fd8fa551 100644 --- a/src/mbgl/style/expression/dsl.cpp +++ b/src/mbgl/style/expression/dsl.cpp @@ -41,7 +41,7 @@ std::unique_ptr literal(Value value) { std::unique_ptr literal(std::initializer_list value) { std::vector values; for (auto i : value) { - values.push_back(i); + values.emplace_back(i); } return literal(values); } @@ -49,7 +49,7 @@ std::unique_ptr literal(std::initializer_list value) { std::unique_ptr literal(std::initializer_list value) { std::vector values; for (auto i : value) { - values.push_back(std::string(i)); + values.emplace_back(std::string(i)); } return literal(values); } diff --git a/src/mbgl/style/expression/format_expression.cpp b/src/mbgl/style/expression/format_expression.cpp index b5e4ba62c4..743942c769 100644 --- a/src/mbgl/style/expression/format_expression.cpp +++ b/src/mbgl/style/expression/format_expression.cpp @@ -152,7 +152,7 @@ mbgl::Value FormatExpression::serialize() const { if (section.textColor) { options.emplace(kFormattedSectionTextColor, (*section.textColor)->serialize()); } - serialized.push_back(options); + serialized.emplace_back(options); } return serialized; } diff --git a/src/mbgl/style/expression/formatted.cpp b/src/mbgl/style/expression/formatted.cpp index 3fa39b2cdc..5d45806ecb 100644 --- a/src/mbgl/style/expression/formatted.cpp +++ b/src/mbgl/style/expression/formatted.cpp @@ -104,7 +104,7 @@ optional Converter::operator()(const Convertible& value, E } } - sections.push_back(FormattedSection(*sectionText, fontScale, textFont, textColor)); + sections.emplace_back(*sectionText, fontScale, textFont, textColor); } return Formatted(sections); } else if (optional result = toString(value)) { diff --git a/src/mbgl/style/expression/let.cpp b/src/mbgl/style/expression/let.cpp index 592ceed58a..5acd52f578 100644 --- a/src/mbgl/style/expression/let.cpp +++ b/src/mbgl/style/expression/let.cpp @@ -12,8 +12,8 @@ EvaluationResult Let::evaluate(const EvaluationContext& params) const { } void Let::eachChild(const std::function& visit) const { - for (auto it = bindings.begin(); it != bindings.end(); it++) { - visit(*it->second); + for (const auto& binding : bindings) { + visit(*binding.second); } visit(*result); } diff --git a/src/mbgl/style/expression/match.cpp b/src/mbgl/style/expression/match.cpp index 93627e9df1..70d3ac8d6d 100644 --- a/src/mbgl/style/expression/match.cpp +++ b/src/mbgl/style/expression/match.cpp @@ -287,7 +287,7 @@ ParseResult parseMatch(const Convertible& value, ParsingContext& ctx) { outputType = (*output)->getType(); } - branches.push_back(std::make_pair(std::move(labels), std::move(*output))); + branches.emplace_back(std::move(labels), std::move(*output)); } auto input = ctx.parse(arrayMember(value, 1), 1, {type::Value}); diff --git a/src/mbgl/style/expression/step.cpp b/src/mbgl/style/expression/step.cpp index 39b04c04a0..170e84bfc6 100644 --- a/src/mbgl/style/expression/step.cpp +++ b/src/mbgl/style/expression/step.cpp @@ -46,13 +46,13 @@ EvaluationResult Step::evaluate(const EvaluationContext& params) const { void Step::eachChild(const std::function& visit) const { visit(*input); - for (auto it = stops.begin(); it != stops.end(); it++) { - visit(*it->second); + for (const auto& stop : stops) { + visit(*stop.second); } } void Step::eachStop(const std::function& visit) const { - for (const auto &stop : stops) { + for (const auto& stop : stops) { visit(stop.first, *stop.second); } } diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp index e826a8a3cc..7e11efaa09 100644 --- a/src/mbgl/style/expression/value.cpp +++ b/src/mbgl/style/expression/value.cpp @@ -171,7 +171,7 @@ mbgl::Value ValueConverter::fromExpressionValue(const Value& value) options.emplace("text-color", fromExpressionValue(*section.textColor)); } - serialized.push_back(options); + serialized.emplace_back(options); } return serialized; }, diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index 89b367b632..8d2b1b144b 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -66,11 +66,11 @@ PropertyValue BackgroundLayer::getDefaultBackgroundColor() { return { Color::black() }; } -PropertyValue BackgroundLayer::getBackgroundColor() const { +const PropertyValue& BackgroundLayer::getBackgroundColor() const { return impl().paint.template get().value; } -void BackgroundLayer::setBackgroundColor(PropertyValue value) { +void BackgroundLayer::setBackgroundColor(const PropertyValue& value) { if (value == getBackgroundColor()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue BackgroundLayer::getDefaultBackgroundPattern() { return { "" }; } -PropertyValue BackgroundLayer::getBackgroundPattern() const { +const PropertyValue& BackgroundLayer::getBackgroundPattern() const { return impl().paint.template get().value; } -void BackgroundLayer::setBackgroundPattern(PropertyValue value) { +void BackgroundLayer::setBackgroundPattern(const PropertyValue& value) { if (value == getBackgroundPattern()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue BackgroundLayer::getDefaultBackgroundOpacity() { return { 1 }; } -PropertyValue BackgroundLayer::getBackgroundOpacity() const { +const PropertyValue& BackgroundLayer::getBackgroundOpacity() const { return impl().paint.template get().value; } -void BackgroundLayer::setBackgroundOpacity(PropertyValue value) { +void BackgroundLayer::setBackgroundOpacity(const PropertyValue& value) { if (value == getBackgroundOpacity()) return; auto impl_ = mutableImpl(); @@ -169,7 +169,7 @@ optional BackgroundLayer::setPaintProperty(const std::string& name, const return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::BackgroundColor) { diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index 18f9a62f74..f2e3649c5a 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -66,11 +66,11 @@ PropertyValue CircleLayer::getDefaultCircleRadius() { return { 5 }; } -PropertyValue CircleLayer::getCircleRadius() const { +const PropertyValue& CircleLayer::getCircleRadius() const { return impl().paint.template get().value; } -void CircleLayer::setCircleRadius(PropertyValue value) { +void CircleLayer::setCircleRadius(const PropertyValue& value) { if (value == getCircleRadius()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue CircleLayer::getDefaultCircleColor() { return { Color::black() }; } -PropertyValue CircleLayer::getCircleColor() const { +const PropertyValue& CircleLayer::getCircleColor() const { return impl().paint.template get().value; } -void CircleLayer::setCircleColor(PropertyValue value) { +void CircleLayer::setCircleColor(const PropertyValue& value) { if (value == getCircleColor()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue CircleLayer::getDefaultCircleBlur() { return { 0 }; } -PropertyValue CircleLayer::getCircleBlur() const { +const PropertyValue& CircleLayer::getCircleBlur() const { return impl().paint.template get().value; } -void CircleLayer::setCircleBlur(PropertyValue value) { +void CircleLayer::setCircleBlur(const PropertyValue& value) { if (value == getCircleBlur()) return; auto impl_ = mutableImpl(); @@ -147,11 +147,11 @@ PropertyValue CircleLayer::getDefaultCircleOpacity() { return { 1 }; } -PropertyValue CircleLayer::getCircleOpacity() const { +const PropertyValue& CircleLayer::getCircleOpacity() const { return impl().paint.template get().value; } -void CircleLayer::setCircleOpacity(PropertyValue value) { +void CircleLayer::setCircleOpacity(const PropertyValue& value) { if (value == getCircleOpacity()) return; auto impl_ = mutableImpl(); @@ -174,11 +174,11 @@ PropertyValue> CircleLayer::getDefaultCircleTranslate() { return { {{ 0, 0 }} }; } -PropertyValue> CircleLayer::getCircleTranslate() const { +const PropertyValue>& CircleLayer::getCircleTranslate() const { return impl().paint.template get().value; } -void CircleLayer::setCircleTranslate(PropertyValue> value) { +void CircleLayer::setCircleTranslate(const PropertyValue>& value) { if (value == getCircleTranslate()) return; auto impl_ = mutableImpl(); @@ -201,11 +201,11 @@ PropertyValue CircleLayer::getDefaultCircleTranslateAnchor( return { TranslateAnchorType::Map }; } -PropertyValue CircleLayer::getCircleTranslateAnchor() const { +const PropertyValue& CircleLayer::getCircleTranslateAnchor() const { return impl().paint.template get().value; } -void CircleLayer::setCircleTranslateAnchor(PropertyValue value) { +void CircleLayer::setCircleTranslateAnchor(const PropertyValue& value) { if (value == getCircleTranslateAnchor()) return; auto impl_ = mutableImpl(); @@ -228,11 +228,11 @@ PropertyValue CircleLayer::getDefaultCirclePitchScale() { return { CirclePitchScaleType::Map }; } -PropertyValue CircleLayer::getCirclePitchScale() const { +const PropertyValue& CircleLayer::getCirclePitchScale() const { return impl().paint.template get().value; } -void CircleLayer::setCirclePitchScale(PropertyValue value) { +void CircleLayer::setCirclePitchScale(const PropertyValue& value) { if (value == getCirclePitchScale()) return; auto impl_ = mutableImpl(); @@ -255,11 +255,11 @@ PropertyValue CircleLayer::getDefaultCirclePitchAlignment() { return { AlignmentType::Viewport }; } -PropertyValue CircleLayer::getCirclePitchAlignment() const { +const PropertyValue& CircleLayer::getCirclePitchAlignment() const { return impl().paint.template get().value; } -void CircleLayer::setCirclePitchAlignment(PropertyValue value) { +void CircleLayer::setCirclePitchAlignment(const PropertyValue& value) { if (value == getCirclePitchAlignment()) return; auto impl_ = mutableImpl(); @@ -282,11 +282,11 @@ PropertyValue CircleLayer::getDefaultCircleStrokeWidth() { return { 0 }; } -PropertyValue CircleLayer::getCircleStrokeWidth() const { +const PropertyValue& CircleLayer::getCircleStrokeWidth() const { return impl().paint.template get().value; } -void CircleLayer::setCircleStrokeWidth(PropertyValue value) { +void CircleLayer::setCircleStrokeWidth(const PropertyValue& value) { if (value == getCircleStrokeWidth()) return; auto impl_ = mutableImpl(); @@ -309,11 +309,11 @@ PropertyValue CircleLayer::getDefaultCircleStrokeColor() { return { Color::black() }; } -PropertyValue CircleLayer::getCircleStrokeColor() const { +const PropertyValue& CircleLayer::getCircleStrokeColor() const { return impl().paint.template get().value; } -void CircleLayer::setCircleStrokeColor(PropertyValue value) { +void CircleLayer::setCircleStrokeColor(const PropertyValue& value) { if (value == getCircleStrokeColor()) return; auto impl_ = mutableImpl(); @@ -336,11 +336,11 @@ PropertyValue CircleLayer::getDefaultCircleStrokeOpacity() { return { 1 }; } -PropertyValue CircleLayer::getCircleStrokeOpacity() const { +const PropertyValue& CircleLayer::getCircleStrokeOpacity() const { return impl().paint.template get().value; } -void CircleLayer::setCircleStrokeOpacity(PropertyValue value) { +void CircleLayer::setCircleStrokeOpacity(const PropertyValue& value) { if (value == getCircleStrokeOpacity()) return; auto impl_ = mutableImpl(); @@ -417,7 +417,7 @@ optional CircleLayer::setPaintProperty(const std::string& name, const Con return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::CircleRadius || property == Property::CircleBlur || property == Property::CircleOpacity || property == Property::CircleStrokeWidth || property == Property::CircleStrokeOpacity) { diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 3bbaebfe6d..913f8e3127 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -66,11 +66,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionOpacity() { return { 1 }; } -PropertyValue FillExtrusionLayer::getFillExtrusionOpacity() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionOpacity() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionOpacity(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionOpacity(const PropertyValue& value) { if (value == getFillExtrusionOpacity()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionColor() { return { Color::black() }; } -PropertyValue FillExtrusionLayer::getFillExtrusionColor() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionColor() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionColor(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionColor(const PropertyValue& value) { if (value == getFillExtrusionColor()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue> FillExtrusionLayer::getDefaultFillExtrusionT return { {{ 0, 0 }} }; } -PropertyValue> FillExtrusionLayer::getFillExtrusionTranslate() const { +const PropertyValue>& FillExtrusionLayer::getFillExtrusionTranslate() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionTranslate(PropertyValue> value) { +void FillExtrusionLayer::setFillExtrusionTranslate(const PropertyValue>& value) { if (value == getFillExtrusionTranslate()) return; auto impl_ = mutableImpl(); @@ -147,11 +147,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionTr return { TranslateAnchorType::Map }; } -PropertyValue FillExtrusionLayer::getFillExtrusionTranslateAnchor() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionTranslateAnchor() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionTranslateAnchor(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionTranslateAnchor(const PropertyValue& value) { if (value == getFillExtrusionTranslateAnchor()) return; auto impl_ = mutableImpl(); @@ -174,11 +174,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionPattern() return { "" }; } -PropertyValue FillExtrusionLayer::getFillExtrusionPattern() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionPattern() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionPattern(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionPattern(const PropertyValue& value) { if (value == getFillExtrusionPattern()) return; auto impl_ = mutableImpl(); @@ -201,11 +201,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionHeight() { return { 0 }; } -PropertyValue FillExtrusionLayer::getFillExtrusionHeight() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionHeight() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionHeight(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionHeight(const PropertyValue& value) { if (value == getFillExtrusionHeight()) return; auto impl_ = mutableImpl(); @@ -228,11 +228,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionBase() { return { 0 }; } -PropertyValue FillExtrusionLayer::getFillExtrusionBase() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionBase() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionBase(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionBase(const PropertyValue& value) { if (value == getFillExtrusionBase()) return; auto impl_ = mutableImpl(); @@ -255,11 +255,11 @@ PropertyValue FillExtrusionLayer::getDefaultFillExtrusionVerticalGradient( return { true }; } -PropertyValue FillExtrusionLayer::getFillExtrusionVerticalGradient() const { +const PropertyValue& FillExtrusionLayer::getFillExtrusionVerticalGradient() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionVerticalGradient(PropertyValue value) { +void FillExtrusionLayer::setFillExtrusionVerticalGradient(const PropertyValue& value) { if (value == getFillExtrusionVerticalGradient()) return; auto impl_ = mutableImpl(); @@ -324,7 +324,7 @@ optional FillExtrusionLayer::setPaintProperty(const std::string& name, co return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::FillExtrusionOpacity) { diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index 6f3c163825..afcb2cae37 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -66,11 +66,11 @@ PropertyValue FillLayer::getDefaultFillAntialias() { return { true }; } -PropertyValue FillLayer::getFillAntialias() const { +const PropertyValue& FillLayer::getFillAntialias() const { return impl().paint.template get().value; } -void FillLayer::setFillAntialias(PropertyValue value) { +void FillLayer::setFillAntialias(const PropertyValue& value) { if (value == getFillAntialias()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue FillLayer::getDefaultFillOpacity() { return { 1 }; } -PropertyValue FillLayer::getFillOpacity() const { +const PropertyValue& FillLayer::getFillOpacity() const { return impl().paint.template get().value; } -void FillLayer::setFillOpacity(PropertyValue value) { +void FillLayer::setFillOpacity(const PropertyValue& value) { if (value == getFillOpacity()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue FillLayer::getDefaultFillColor() { return { Color::black() }; } -PropertyValue FillLayer::getFillColor() const { +const PropertyValue& FillLayer::getFillColor() const { return impl().paint.template get().value; } -void FillLayer::setFillColor(PropertyValue value) { +void FillLayer::setFillColor(const PropertyValue& value) { if (value == getFillColor()) return; auto impl_ = mutableImpl(); @@ -147,11 +147,11 @@ PropertyValue FillLayer::getDefaultFillOutlineColor() { return { {} }; } -PropertyValue FillLayer::getFillOutlineColor() const { +const PropertyValue& FillLayer::getFillOutlineColor() const { return impl().paint.template get().value; } -void FillLayer::setFillOutlineColor(PropertyValue value) { +void FillLayer::setFillOutlineColor(const PropertyValue& value) { if (value == getFillOutlineColor()) return; auto impl_ = mutableImpl(); @@ -174,11 +174,11 @@ PropertyValue> FillLayer::getDefaultFillTranslate() { return { {{ 0, 0 }} }; } -PropertyValue> FillLayer::getFillTranslate() const { +const PropertyValue>& FillLayer::getFillTranslate() const { return impl().paint.template get().value; } -void FillLayer::setFillTranslate(PropertyValue> value) { +void FillLayer::setFillTranslate(const PropertyValue>& value) { if (value == getFillTranslate()) return; auto impl_ = mutableImpl(); @@ -201,11 +201,11 @@ PropertyValue FillLayer::getDefaultFillTranslateAnchor() { return { TranslateAnchorType::Map }; } -PropertyValue FillLayer::getFillTranslateAnchor() const { +const PropertyValue& FillLayer::getFillTranslateAnchor() const { return impl().paint.template get().value; } -void FillLayer::setFillTranslateAnchor(PropertyValue value) { +void FillLayer::setFillTranslateAnchor(const PropertyValue& value) { if (value == getFillTranslateAnchor()) return; auto impl_ = mutableImpl(); @@ -228,11 +228,11 @@ PropertyValue FillLayer::getDefaultFillPattern() { return { "" }; } -PropertyValue FillLayer::getFillPattern() const { +const PropertyValue& FillLayer::getFillPattern() const { return impl().paint.template get().value; } -void FillLayer::setFillPattern(PropertyValue value) { +void FillLayer::setFillPattern(const PropertyValue& value) { if (value == getFillPattern()) return; auto impl_ = mutableImpl(); @@ -293,7 +293,7 @@ optional FillLayer::setPaintProperty(const std::string& name, const Conve return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::FillAntialias) { diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index d548ee9b74..9e0fe93557 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -66,11 +66,11 @@ PropertyValue HeatmapLayer::getDefaultHeatmapRadius() { return { 30 }; } -PropertyValue HeatmapLayer::getHeatmapRadius() const { +const PropertyValue& HeatmapLayer::getHeatmapRadius() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapRadius(PropertyValue value) { +void HeatmapLayer::setHeatmapRadius(const PropertyValue& value) { if (value == getHeatmapRadius()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue HeatmapLayer::getDefaultHeatmapWeight() { return { 1 }; } -PropertyValue HeatmapLayer::getHeatmapWeight() const { +const PropertyValue& HeatmapLayer::getHeatmapWeight() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapWeight(PropertyValue value) { +void HeatmapLayer::setHeatmapWeight(const PropertyValue& value) { if (value == getHeatmapWeight()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue HeatmapLayer::getDefaultHeatmapIntensity() { return { 1 }; } -PropertyValue HeatmapLayer::getHeatmapIntensity() const { +const PropertyValue& HeatmapLayer::getHeatmapIntensity() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapIntensity(PropertyValue value) { +void HeatmapLayer::setHeatmapIntensity(const PropertyValue& value) { if (value == getHeatmapIntensity()) return; auto impl_ = mutableImpl(); @@ -149,11 +149,11 @@ ColorRampPropertyValue HeatmapLayer::getDefaultHeatmapColor() { return *conversion::convertJSON(rawValue, error); } -ColorRampPropertyValue HeatmapLayer::getHeatmapColor() const { +const ColorRampPropertyValue& HeatmapLayer::getHeatmapColor() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapColor(ColorRampPropertyValue value) { +void HeatmapLayer::setHeatmapColor(const ColorRampPropertyValue& value) { if (value == getHeatmapColor()) return; auto impl_ = mutableImpl(); @@ -176,11 +176,11 @@ PropertyValue HeatmapLayer::getDefaultHeatmapOpacity() { return { 1 }; } -PropertyValue HeatmapLayer::getHeatmapOpacity() const { +const PropertyValue& HeatmapLayer::getHeatmapOpacity() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapOpacity(PropertyValue value) { +void HeatmapLayer::setHeatmapOpacity(const PropertyValue& value) { if (value == getHeatmapOpacity()) return; auto impl_ = mutableImpl(); @@ -233,7 +233,7 @@ optional HeatmapLayer::setPaintProperty(const std::string& name, const Co return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::HeatmapRadius || property == Property::HeatmapWeight) { diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp index 49d3217a3b..ac26e331fc 100644 --- a/src/mbgl/style/layers/hillshade_layer.cpp +++ b/src/mbgl/style/layers/hillshade_layer.cpp @@ -66,11 +66,11 @@ PropertyValue HillshadeLayer::getDefaultHillshadeIlluminationDirection() return { 335 }; } -PropertyValue HillshadeLayer::getHillshadeIlluminationDirection() const { +const PropertyValue& HillshadeLayer::getHillshadeIlluminationDirection() const { return impl().paint.template get().value; } -void HillshadeLayer::setHillshadeIlluminationDirection(PropertyValue value) { +void HillshadeLayer::setHillshadeIlluminationDirection(const PropertyValue& value) { if (value == getHillshadeIlluminationDirection()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue HillshadeLayer::getDefaultHillsha return { HillshadeIlluminationAnchorType::Viewport }; } -PropertyValue HillshadeLayer::getHillshadeIlluminationAnchor() const { +const PropertyValue& HillshadeLayer::getHillshadeIlluminationAnchor() const { return impl().paint.template get().value; } -void HillshadeLayer::setHillshadeIlluminationAnchor(PropertyValue value) { +void HillshadeLayer::setHillshadeIlluminationAnchor(const PropertyValue& value) { if (value == getHillshadeIlluminationAnchor()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue HillshadeLayer::getDefaultHillshadeExaggeration() { return { 0.5 }; } -PropertyValue HillshadeLayer::getHillshadeExaggeration() const { +const PropertyValue& HillshadeLayer::getHillshadeExaggeration() const { return impl().paint.template get().value; } -void HillshadeLayer::setHillshadeExaggeration(PropertyValue value) { +void HillshadeLayer::setHillshadeExaggeration(const PropertyValue& value) { if (value == getHillshadeExaggeration()) return; auto impl_ = mutableImpl(); @@ -147,11 +147,11 @@ PropertyValue HillshadeLayer::getDefaultHillshadeShadowColor() { return { Color::black() }; } -PropertyValue HillshadeLayer::getHillshadeShadowColor() const { +const PropertyValue& HillshadeLayer::getHillshadeShadowColor() const { return impl().paint.template get().value; } -void HillshadeLayer::setHillshadeShadowColor(PropertyValue value) { +void HillshadeLayer::setHillshadeShadowColor(const PropertyValue& value) { if (value == getHillshadeShadowColor()) return; auto impl_ = mutableImpl(); @@ -174,11 +174,11 @@ PropertyValue HillshadeLayer::getDefaultHillshadeHighlightColor() { return { Color::white() }; } -PropertyValue HillshadeLayer::getHillshadeHighlightColor() const { +const PropertyValue& HillshadeLayer::getHillshadeHighlightColor() const { return impl().paint.template get().value; } -void HillshadeLayer::setHillshadeHighlightColor(PropertyValue value) { +void HillshadeLayer::setHillshadeHighlightColor(const PropertyValue& value) { if (value == getHillshadeHighlightColor()) return; auto impl_ = mutableImpl(); @@ -201,11 +201,11 @@ PropertyValue HillshadeLayer::getDefaultHillshadeAccentColor() { return { Color::black() }; } -PropertyValue HillshadeLayer::getHillshadeAccentColor() const { +const PropertyValue& HillshadeLayer::getHillshadeAccentColor() const { return impl().paint.template get().value; } -void HillshadeLayer::setHillshadeAccentColor(PropertyValue value) { +void HillshadeLayer::setHillshadeAccentColor(const PropertyValue& value) { if (value == getHillshadeAccentColor()) return; auto impl_ = mutableImpl(); @@ -262,7 +262,7 @@ optional HillshadeLayer::setPaintProperty(const std::string& name, const return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::HillshadeIlluminationDirection || property == Property::HillshadeExaggeration) { diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index 201189c849..107c3cb527 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -118,11 +118,11 @@ void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer::defaultValue(); } -<%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { +const <%- propertyValueType(property) %>& <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { return impl().layout.get<<%- camelize(property.name) %>>(); } -void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value) { +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(const <%- propertyValueType(property) %>& value) { if (value == get<%- camelize(property.name) %>()) return; auto impl_ = mutableImpl(); @@ -144,11 +144,11 @@ void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyV <% } -%> } -<%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { +const <%- propertyValueType(property) %>& <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { return impl().paint.template get<<%- camelize(property.name) %>>().value; } -void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value) { +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(const <%- propertyValueType(property) %>& value) { if (value == get<%- camelize(property.name) %>()) return; auto impl_ = mutableImpl(); @@ -193,7 +193,7 @@ optional <%- camelize(type) %>Layer::setPaintProperty(const std::string& return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); <% const paintConversions = {}; @@ -260,7 +260,7 @@ optional <%- camelize(type) %>Layer::setLayoutProperty(const std::string& return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); <% const layoutConversions = {}; diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 0a20762697..d52a552605 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -64,11 +64,11 @@ PropertyValue LineLayer::getDefaultLineCap() { return LineCap::defaultValue(); } -PropertyValue LineLayer::getLineCap() const { +const PropertyValue& LineLayer::getLineCap() const { return impl().layout.get(); } -void LineLayer::setLineCap(PropertyValue value) { +void LineLayer::setLineCap(const PropertyValue& value) { if (value == getLineCap()) return; auto impl_ = mutableImpl(); @@ -80,11 +80,11 @@ PropertyValue LineLayer::getDefaultLineJoin() { return LineJoin::defaultValue(); } -PropertyValue LineLayer::getLineJoin() const { +const PropertyValue& LineLayer::getLineJoin() const { return impl().layout.get(); } -void LineLayer::setLineJoin(PropertyValue value) { +void LineLayer::setLineJoin(const PropertyValue& value) { if (value == getLineJoin()) return; auto impl_ = mutableImpl(); @@ -96,11 +96,11 @@ PropertyValue LineLayer::getDefaultLineMiterLimit() { return LineMiterLimit::defaultValue(); } -PropertyValue LineLayer::getLineMiterLimit() const { +const PropertyValue& LineLayer::getLineMiterLimit() const { return impl().layout.get(); } -void LineLayer::setLineMiterLimit(PropertyValue value) { +void LineLayer::setLineMiterLimit(const PropertyValue& value) { if (value == getLineMiterLimit()) return; auto impl_ = mutableImpl(); @@ -112,11 +112,11 @@ PropertyValue LineLayer::getDefaultLineRoundLimit() { return LineRoundLimit::defaultValue(); } -PropertyValue LineLayer::getLineRoundLimit() const { +const PropertyValue& LineLayer::getLineRoundLimit() const { return impl().layout.get(); } -void LineLayer::setLineRoundLimit(PropertyValue value) { +void LineLayer::setLineRoundLimit(const PropertyValue& value) { if (value == getLineRoundLimit()) return; auto impl_ = mutableImpl(); @@ -131,11 +131,11 @@ PropertyValue LineLayer::getDefaultLineOpacity() { return { 1 }; } -PropertyValue LineLayer::getLineOpacity() const { +const PropertyValue& LineLayer::getLineOpacity() const { return impl().paint.template get().value; } -void LineLayer::setLineOpacity(PropertyValue value) { +void LineLayer::setLineOpacity(const PropertyValue& value) { if (value == getLineOpacity()) return; auto impl_ = mutableImpl(); @@ -158,11 +158,11 @@ PropertyValue LineLayer::getDefaultLineColor() { return { Color::black() }; } -PropertyValue LineLayer::getLineColor() const { +const PropertyValue& LineLayer::getLineColor() const { return impl().paint.template get().value; } -void LineLayer::setLineColor(PropertyValue value) { +void LineLayer::setLineColor(const PropertyValue& value) { if (value == getLineColor()) return; auto impl_ = mutableImpl(); @@ -185,11 +185,11 @@ PropertyValue> LineLayer::getDefaultLineTranslate() { return { {{ 0, 0 }} }; } -PropertyValue> LineLayer::getLineTranslate() const { +const PropertyValue>& LineLayer::getLineTranslate() const { return impl().paint.template get().value; } -void LineLayer::setLineTranslate(PropertyValue> value) { +void LineLayer::setLineTranslate(const PropertyValue>& value) { if (value == getLineTranslate()) return; auto impl_ = mutableImpl(); @@ -212,11 +212,11 @@ PropertyValue LineLayer::getDefaultLineTranslateAnchor() { return { TranslateAnchorType::Map }; } -PropertyValue LineLayer::getLineTranslateAnchor() const { +const PropertyValue& LineLayer::getLineTranslateAnchor() const { return impl().paint.template get().value; } -void LineLayer::setLineTranslateAnchor(PropertyValue value) { +void LineLayer::setLineTranslateAnchor(const PropertyValue& value) { if (value == getLineTranslateAnchor()) return; auto impl_ = mutableImpl(); @@ -239,11 +239,11 @@ PropertyValue LineLayer::getDefaultLineWidth() { return { 1 }; } -PropertyValue LineLayer::getLineWidth() const { +const PropertyValue& LineLayer::getLineWidth() const { return impl().paint.template get().value; } -void LineLayer::setLineWidth(PropertyValue value) { +void LineLayer::setLineWidth(const PropertyValue& value) { if (value == getLineWidth()) return; auto impl_ = mutableImpl(); @@ -267,11 +267,11 @@ PropertyValue LineLayer::getDefaultLineGapWidth() { return { 0 }; } -PropertyValue LineLayer::getLineGapWidth() const { +const PropertyValue& LineLayer::getLineGapWidth() const { return impl().paint.template get().value; } -void LineLayer::setLineGapWidth(PropertyValue value) { +void LineLayer::setLineGapWidth(const PropertyValue& value) { if (value == getLineGapWidth()) return; auto impl_ = mutableImpl(); @@ -294,11 +294,11 @@ PropertyValue LineLayer::getDefaultLineOffset() { return { 0 }; } -PropertyValue LineLayer::getLineOffset() const { +const PropertyValue& LineLayer::getLineOffset() const { return impl().paint.template get().value; } -void LineLayer::setLineOffset(PropertyValue value) { +void LineLayer::setLineOffset(const PropertyValue& value) { if (value == getLineOffset()) return; auto impl_ = mutableImpl(); @@ -321,11 +321,11 @@ PropertyValue LineLayer::getDefaultLineBlur() { return { 0 }; } -PropertyValue LineLayer::getLineBlur() const { +const PropertyValue& LineLayer::getLineBlur() const { return impl().paint.template get().value; } -void LineLayer::setLineBlur(PropertyValue value) { +void LineLayer::setLineBlur(const PropertyValue& value) { if (value == getLineBlur()) return; auto impl_ = mutableImpl(); @@ -348,11 +348,11 @@ PropertyValue> LineLayer::getDefaultLineDasharray() { return { { } }; } -PropertyValue> LineLayer::getLineDasharray() const { +const PropertyValue>& LineLayer::getLineDasharray() const { return impl().paint.template get().value; } -void LineLayer::setLineDasharray(PropertyValue> value) { +void LineLayer::setLineDasharray(const PropertyValue>& value) { if (value == getLineDasharray()) return; auto impl_ = mutableImpl(); @@ -375,11 +375,11 @@ PropertyValue LineLayer::getDefaultLinePattern() { return { "" }; } -PropertyValue LineLayer::getLinePattern() const { +const PropertyValue& LineLayer::getLinePattern() const { return impl().paint.template get().value; } -void LineLayer::setLinePattern(PropertyValue value) { +void LineLayer::setLinePattern(const PropertyValue& value) { if (value == getLinePattern()) return; auto impl_ = mutableImpl(); @@ -402,11 +402,11 @@ ColorRampPropertyValue LineLayer::getDefaultLineGradient() { return { {} }; } -ColorRampPropertyValue LineLayer::getLineGradient() const { +const ColorRampPropertyValue& LineLayer::getLineGradient() const { return impl().paint.template get().value; } -void LineLayer::setLineGradient(ColorRampPropertyValue value) { +void LineLayer::setLineGradient(const ColorRampPropertyValue& value) { if (value == getLineGradient()) return; auto impl_ = mutableImpl(); @@ -483,7 +483,7 @@ optional LineLayer::setPaintProperty(const std::string& name, const Conve return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::LineOpacity || property == Property::LineWidth || property == Property::LineGapWidth || property == Property::LineOffset || property == Property::LineBlur) { @@ -680,7 +680,7 @@ optional LineLayer::setLayoutProperty(const std::string& name, const Conv return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::LineCap) { diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index b0820456e1..dc7dd4a74f 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -66,11 +66,11 @@ PropertyValue RasterLayer::getDefaultRasterOpacity() { return { 1 }; } -PropertyValue RasterLayer::getRasterOpacity() const { +const PropertyValue& RasterLayer::getRasterOpacity() const { return impl().paint.template get().value; } -void RasterLayer::setRasterOpacity(PropertyValue value) { +void RasterLayer::setRasterOpacity(const PropertyValue& value) { if (value == getRasterOpacity()) return; auto impl_ = mutableImpl(); @@ -93,11 +93,11 @@ PropertyValue RasterLayer::getDefaultRasterHueRotate() { return { 0 }; } -PropertyValue RasterLayer::getRasterHueRotate() const { +const PropertyValue& RasterLayer::getRasterHueRotate() const { return impl().paint.template get().value; } -void RasterLayer::setRasterHueRotate(PropertyValue value) { +void RasterLayer::setRasterHueRotate(const PropertyValue& value) { if (value == getRasterHueRotate()) return; auto impl_ = mutableImpl(); @@ -120,11 +120,11 @@ PropertyValue RasterLayer::getDefaultRasterBrightnessMin() { return { 0 }; } -PropertyValue RasterLayer::getRasterBrightnessMin() const { +const PropertyValue& RasterLayer::getRasterBrightnessMin() const { return impl().paint.template get().value; } -void RasterLayer::setRasterBrightnessMin(PropertyValue value) { +void RasterLayer::setRasterBrightnessMin(const PropertyValue& value) { if (value == getRasterBrightnessMin()) return; auto impl_ = mutableImpl(); @@ -147,11 +147,11 @@ PropertyValue RasterLayer::getDefaultRasterBrightnessMax() { return { 1 }; } -PropertyValue RasterLayer::getRasterBrightnessMax() const { +const PropertyValue& RasterLayer::getRasterBrightnessMax() const { return impl().paint.template get().value; } -void RasterLayer::setRasterBrightnessMax(PropertyValue value) { +void RasterLayer::setRasterBrightnessMax(const PropertyValue& value) { if (value == getRasterBrightnessMax()) return; auto impl_ = mutableImpl(); @@ -174,11 +174,11 @@ PropertyValue RasterLayer::getDefaultRasterSaturation() { return { 0 }; } -PropertyValue RasterLayer::getRasterSaturation() const { +const PropertyValue& RasterLayer::getRasterSaturation() const { return impl().paint.template get().value; } -void RasterLayer::setRasterSaturation(PropertyValue value) { +void RasterLayer::setRasterSaturation(const PropertyValue& value) { if (value == getRasterSaturation()) return; auto impl_ = mutableImpl(); @@ -201,11 +201,11 @@ PropertyValue RasterLayer::getDefaultRasterContrast() { return { 0 }; } -PropertyValue RasterLayer::getRasterContrast() const { +const PropertyValue& RasterLayer::getRasterContrast() const { return impl().paint.template get().value; } -void RasterLayer::setRasterContrast(PropertyValue value) { +void RasterLayer::setRasterContrast(const PropertyValue& value) { if (value == getRasterContrast()) return; auto impl_ = mutableImpl(); @@ -228,11 +228,11 @@ PropertyValue RasterLayer::getDefaultRasterResampling() { return { RasterResamplingType::Linear }; } -PropertyValue RasterLayer::getRasterResampling() const { +const PropertyValue& RasterLayer::getRasterResampling() const { return impl().paint.template get().value; } -void RasterLayer::setRasterResampling(PropertyValue value) { +void RasterLayer::setRasterResampling(const PropertyValue& value) { if (value == getRasterResampling()) return; auto impl_ = mutableImpl(); @@ -255,11 +255,11 @@ PropertyValue RasterLayer::getDefaultRasterFadeDuration() { return { 300 }; } -PropertyValue RasterLayer::getRasterFadeDuration() const { +const PropertyValue& RasterLayer::getRasterFadeDuration() const { return impl().paint.template get().value; } -void RasterLayer::setRasterFadeDuration(PropertyValue value) { +void RasterLayer::setRasterFadeDuration(const PropertyValue& value) { if (value == getRasterFadeDuration()) return; auto impl_ = mutableImpl(); @@ -324,7 +324,7 @@ optional RasterLayer::setPaintProperty(const std::string& name, const Con return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::RasterOpacity || property == Property::RasterHueRotate || property == Property::RasterBrightnessMin || property == Property::RasterBrightnessMax || property == Property::RasterSaturation || property == Property::RasterContrast || property == Property::RasterFadeDuration) { diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 1c56888f73..c8d7816180 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -64,11 +64,11 @@ PropertyValue SymbolLayer::getDefaultSymbolPlacement() { return SymbolPlacement::defaultValue(); } -PropertyValue SymbolLayer::getSymbolPlacement() const { +const PropertyValue& SymbolLayer::getSymbolPlacement() const { return impl().layout.get(); } -void SymbolLayer::setSymbolPlacement(PropertyValue value) { +void SymbolLayer::setSymbolPlacement(const PropertyValue& value) { if (value == getSymbolPlacement()) return; auto impl_ = mutableImpl(); @@ -80,11 +80,11 @@ PropertyValue SymbolLayer::getDefaultSymbolSpacing() { return SymbolSpacing::defaultValue(); } -PropertyValue SymbolLayer::getSymbolSpacing() const { +const PropertyValue& SymbolLayer::getSymbolSpacing() const { return impl().layout.get(); } -void SymbolLayer::setSymbolSpacing(PropertyValue value) { +void SymbolLayer::setSymbolSpacing(const PropertyValue& value) { if (value == getSymbolSpacing()) return; auto impl_ = mutableImpl(); @@ -96,11 +96,11 @@ PropertyValue SymbolLayer::getDefaultSymbolAvoidEdges() { return SymbolAvoidEdges::defaultValue(); } -PropertyValue SymbolLayer::getSymbolAvoidEdges() const { +const PropertyValue& SymbolLayer::getSymbolAvoidEdges() const { return impl().layout.get(); } -void SymbolLayer::setSymbolAvoidEdges(PropertyValue value) { +void SymbolLayer::setSymbolAvoidEdges(const PropertyValue& value) { if (value == getSymbolAvoidEdges()) return; auto impl_ = mutableImpl(); @@ -112,11 +112,11 @@ PropertyValue SymbolLayer::getDefaultSymbolZOrder() { return SymbolZOrder::defaultValue(); } -PropertyValue SymbolLayer::getSymbolZOrder() const { +const PropertyValue& SymbolLayer::getSymbolZOrder() const { return impl().layout.get(); } -void SymbolLayer::setSymbolZOrder(PropertyValue value) { +void SymbolLayer::setSymbolZOrder(const PropertyValue& value) { if (value == getSymbolZOrder()) return; auto impl_ = mutableImpl(); @@ -128,11 +128,11 @@ PropertyValue SymbolLayer::getDefaultIconAllowOverlap() { return IconAllowOverlap::defaultValue(); } -PropertyValue SymbolLayer::getIconAllowOverlap() const { +const PropertyValue& SymbolLayer::getIconAllowOverlap() const { return impl().layout.get(); } -void SymbolLayer::setIconAllowOverlap(PropertyValue value) { +void SymbolLayer::setIconAllowOverlap(const PropertyValue& value) { if (value == getIconAllowOverlap()) return; auto impl_ = mutableImpl(); @@ -144,11 +144,11 @@ PropertyValue SymbolLayer::getDefaultIconIgnorePlacement() { return IconIgnorePlacement::defaultValue(); } -PropertyValue SymbolLayer::getIconIgnorePlacement() const { +const PropertyValue& SymbolLayer::getIconIgnorePlacement() const { return impl().layout.get(); } -void SymbolLayer::setIconIgnorePlacement(PropertyValue value) { +void SymbolLayer::setIconIgnorePlacement(const PropertyValue& value) { if (value == getIconIgnorePlacement()) return; auto impl_ = mutableImpl(); @@ -160,11 +160,11 @@ PropertyValue SymbolLayer::getDefaultIconOptional() { return IconOptional::defaultValue(); } -PropertyValue SymbolLayer::getIconOptional() const { +const PropertyValue& SymbolLayer::getIconOptional() const { return impl().layout.get(); } -void SymbolLayer::setIconOptional(PropertyValue value) { +void SymbolLayer::setIconOptional(const PropertyValue& value) { if (value == getIconOptional()) return; auto impl_ = mutableImpl(); @@ -176,11 +176,11 @@ PropertyValue SymbolLayer::getDefaultIconRotationAlignment() { return IconRotationAlignment::defaultValue(); } -PropertyValue SymbolLayer::getIconRotationAlignment() const { +const PropertyValue& SymbolLayer::getIconRotationAlignment() const { return impl().layout.get(); } -void SymbolLayer::setIconRotationAlignment(PropertyValue value) { +void SymbolLayer::setIconRotationAlignment(const PropertyValue& value) { if (value == getIconRotationAlignment()) return; auto impl_ = mutableImpl(); @@ -192,11 +192,11 @@ PropertyValue SymbolLayer::getDefaultIconSize() { return IconSize::defaultValue(); } -PropertyValue SymbolLayer::getIconSize() const { +const PropertyValue& SymbolLayer::getIconSize() const { return impl().layout.get(); } -void SymbolLayer::setIconSize(PropertyValue value) { +void SymbolLayer::setIconSize(const PropertyValue& value) { if (value == getIconSize()) return; auto impl_ = mutableImpl(); @@ -208,11 +208,11 @@ PropertyValue SymbolLayer::getDefaultIconTextFit() { return IconTextFit::defaultValue(); } -PropertyValue SymbolLayer::getIconTextFit() const { +const PropertyValue& SymbolLayer::getIconTextFit() const { return impl().layout.get(); } -void SymbolLayer::setIconTextFit(PropertyValue value) { +void SymbolLayer::setIconTextFit(const PropertyValue& value) { if (value == getIconTextFit()) return; auto impl_ = mutableImpl(); @@ -224,11 +224,11 @@ PropertyValue> SymbolLayer::getDefaultIconTextFitPadding() return IconTextFitPadding::defaultValue(); } -PropertyValue> SymbolLayer::getIconTextFitPadding() const { +const PropertyValue>& SymbolLayer::getIconTextFitPadding() const { return impl().layout.get(); } -void SymbolLayer::setIconTextFitPadding(PropertyValue> value) { +void SymbolLayer::setIconTextFitPadding(const PropertyValue>& value) { if (value == getIconTextFitPadding()) return; auto impl_ = mutableImpl(); @@ -240,11 +240,11 @@ PropertyValue SymbolLayer::getDefaultIconImage() { return IconImage::defaultValue(); } -PropertyValue SymbolLayer::getIconImage() const { +const PropertyValue& SymbolLayer::getIconImage() const { return impl().layout.get(); } -void SymbolLayer::setIconImage(PropertyValue value) { +void SymbolLayer::setIconImage(const PropertyValue& value) { if (value == getIconImage()) return; auto impl_ = mutableImpl(); @@ -256,11 +256,11 @@ PropertyValue SymbolLayer::getDefaultIconRotate() { return IconRotate::defaultValue(); } -PropertyValue SymbolLayer::getIconRotate() const { +const PropertyValue& SymbolLayer::getIconRotate() const { return impl().layout.get(); } -void SymbolLayer::setIconRotate(PropertyValue value) { +void SymbolLayer::setIconRotate(const PropertyValue& value) { if (value == getIconRotate()) return; auto impl_ = mutableImpl(); @@ -272,11 +272,11 @@ PropertyValue SymbolLayer::getDefaultIconPadding() { return IconPadding::defaultValue(); } -PropertyValue SymbolLayer::getIconPadding() const { +const PropertyValue& SymbolLayer::getIconPadding() const { return impl().layout.get(); } -void SymbolLayer::setIconPadding(PropertyValue value) { +void SymbolLayer::setIconPadding(const PropertyValue& value) { if (value == getIconPadding()) return; auto impl_ = mutableImpl(); @@ -288,11 +288,11 @@ PropertyValue SymbolLayer::getDefaultIconKeepUpright() { return IconKeepUpright::defaultValue(); } -PropertyValue SymbolLayer::getIconKeepUpright() const { +const PropertyValue& SymbolLayer::getIconKeepUpright() const { return impl().layout.get(); } -void SymbolLayer::setIconKeepUpright(PropertyValue value) { +void SymbolLayer::setIconKeepUpright(const PropertyValue& value) { if (value == getIconKeepUpright()) return; auto impl_ = mutableImpl(); @@ -304,11 +304,11 @@ PropertyValue> SymbolLayer::getDefaultIconOffset() { return IconOffset::defaultValue(); } -PropertyValue> SymbolLayer::getIconOffset() const { +const PropertyValue>& SymbolLayer::getIconOffset() const { return impl().layout.get(); } -void SymbolLayer::setIconOffset(PropertyValue> value) { +void SymbolLayer::setIconOffset(const PropertyValue>& value) { if (value == getIconOffset()) return; auto impl_ = mutableImpl(); @@ -320,11 +320,11 @@ PropertyValue SymbolLayer::getDefaultIconAnchor() { return IconAnchor::defaultValue(); } -PropertyValue SymbolLayer::getIconAnchor() const { +const PropertyValue& SymbolLayer::getIconAnchor() const { return impl().layout.get(); } -void SymbolLayer::setIconAnchor(PropertyValue value) { +void SymbolLayer::setIconAnchor(const PropertyValue& value) { if (value == getIconAnchor()) return; auto impl_ = mutableImpl(); @@ -336,11 +336,11 @@ PropertyValue SymbolLayer::getDefaultIconPitchAlignment() { return IconPitchAlignment::defaultValue(); } -PropertyValue SymbolLayer::getIconPitchAlignment() const { +const PropertyValue& SymbolLayer::getIconPitchAlignment() const { return impl().layout.get(); } -void SymbolLayer::setIconPitchAlignment(PropertyValue value) { +void SymbolLayer::setIconPitchAlignment(const PropertyValue& value) { if (value == getIconPitchAlignment()) return; auto impl_ = mutableImpl(); @@ -352,11 +352,11 @@ PropertyValue SymbolLayer::getDefaultTextPitchAlignment() { return TextPitchAlignment::defaultValue(); } -PropertyValue SymbolLayer::getTextPitchAlignment() const { +const PropertyValue& SymbolLayer::getTextPitchAlignment() const { return impl().layout.get(); } -void SymbolLayer::setTextPitchAlignment(PropertyValue value) { +void SymbolLayer::setTextPitchAlignment(const PropertyValue& value) { if (value == getTextPitchAlignment()) return; auto impl_ = mutableImpl(); @@ -368,11 +368,11 @@ PropertyValue SymbolLayer::getDefaultTextRotationAlignment() { return TextRotationAlignment::defaultValue(); } -PropertyValue SymbolLayer::getTextRotationAlignment() const { +const PropertyValue& SymbolLayer::getTextRotationAlignment() const { return impl().layout.get(); } -void SymbolLayer::setTextRotationAlignment(PropertyValue value) { +void SymbolLayer::setTextRotationAlignment(const PropertyValue& value) { if (value == getTextRotationAlignment()) return; auto impl_ = mutableImpl(); @@ -384,11 +384,11 @@ PropertyValue SymbolLayer::getDefaultTextField() { return TextField::defaultValue(); } -PropertyValue SymbolLayer::getTextField() const { +const PropertyValue& SymbolLayer::getTextField() const { return impl().layout.get(); } -void SymbolLayer::setTextField(PropertyValue value) { +void SymbolLayer::setTextField(const PropertyValue& value) { if (value == getTextField()) return; auto impl_ = mutableImpl(); @@ -400,11 +400,11 @@ PropertyValue> SymbolLayer::getDefaultTextFont() { return TextFont::defaultValue(); } -PropertyValue> SymbolLayer::getTextFont() const { +const PropertyValue>& SymbolLayer::getTextFont() const { return impl().layout.get(); } -void SymbolLayer::setTextFont(PropertyValue> value) { +void SymbolLayer::setTextFont(const PropertyValue>& value) { if (value == getTextFont()) return; auto impl_ = mutableImpl(); @@ -416,11 +416,11 @@ PropertyValue SymbolLayer::getDefaultTextSize() { return TextSize::defaultValue(); } -PropertyValue SymbolLayer::getTextSize() const { +const PropertyValue& SymbolLayer::getTextSize() const { return impl().layout.get(); } -void SymbolLayer::setTextSize(PropertyValue value) { +void SymbolLayer::setTextSize(const PropertyValue& value) { if (value == getTextSize()) return; auto impl_ = mutableImpl(); @@ -432,11 +432,11 @@ PropertyValue SymbolLayer::getDefaultTextMaxWidth() { return TextMaxWidth::defaultValue(); } -PropertyValue SymbolLayer::getTextMaxWidth() const { +const PropertyValue& SymbolLayer::getTextMaxWidth() const { return impl().layout.get(); } -void SymbolLayer::setTextMaxWidth(PropertyValue value) { +void SymbolLayer::setTextMaxWidth(const PropertyValue& value) { if (value == getTextMaxWidth()) return; auto impl_ = mutableImpl(); @@ -448,11 +448,11 @@ PropertyValue SymbolLayer::getDefaultTextLineHeight() { return TextLineHeight::defaultValue(); } -PropertyValue SymbolLayer::getTextLineHeight() const { +const PropertyValue& SymbolLayer::getTextLineHeight() const { return impl().layout.get(); } -void SymbolLayer::setTextLineHeight(PropertyValue value) { +void SymbolLayer::setTextLineHeight(const PropertyValue& value) { if (value == getTextLineHeight()) return; auto impl_ = mutableImpl(); @@ -464,11 +464,11 @@ PropertyValue SymbolLayer::getDefaultTextLetterSpacing() { return TextLetterSpacing::defaultValue(); } -PropertyValue SymbolLayer::getTextLetterSpacing() const { +const PropertyValue& SymbolLayer::getTextLetterSpacing() const { return impl().layout.get(); } -void SymbolLayer::setTextLetterSpacing(PropertyValue value) { +void SymbolLayer::setTextLetterSpacing(const PropertyValue& value) { if (value == getTextLetterSpacing()) return; auto impl_ = mutableImpl(); @@ -480,11 +480,11 @@ PropertyValue SymbolLayer::getDefaultTextJustify() { return TextJustify::defaultValue(); } -PropertyValue SymbolLayer::getTextJustify() const { +const PropertyValue& SymbolLayer::getTextJustify() const { return impl().layout.get(); } -void SymbolLayer::setTextJustify(PropertyValue value) { +void SymbolLayer::setTextJustify(const PropertyValue& value) { if (value == getTextJustify()) return; auto impl_ = mutableImpl(); @@ -496,11 +496,11 @@ PropertyValue SymbolLayer::getDefaultTextRadialOffset() { return TextRadialOffset::defaultValue(); } -PropertyValue SymbolLayer::getTextRadialOffset() const { +const PropertyValue& SymbolLayer::getTextRadialOffset() const { return impl().layout.get(); } -void SymbolLayer::setTextRadialOffset(PropertyValue value) { +void SymbolLayer::setTextRadialOffset(const PropertyValue& value) { if (value == getTextRadialOffset()) return; auto impl_ = mutableImpl(); @@ -512,11 +512,11 @@ PropertyValue> SymbolLayer::getDefaultTextVa return TextVariableAnchor::defaultValue(); } -PropertyValue> SymbolLayer::getTextVariableAnchor() const { +const PropertyValue>& SymbolLayer::getTextVariableAnchor() const { return impl().layout.get(); } -void SymbolLayer::setTextVariableAnchor(PropertyValue> value) { +void SymbolLayer::setTextVariableAnchor(const PropertyValue>& value) { if (value == getTextVariableAnchor()) return; auto impl_ = mutableImpl(); @@ -528,11 +528,11 @@ PropertyValue SymbolLayer::getDefaultTextAnchor() { return TextAnchor::defaultValue(); } -PropertyValue SymbolLayer::getTextAnchor() const { +const PropertyValue& SymbolLayer::getTextAnchor() const { return impl().layout.get(); } -void SymbolLayer::setTextAnchor(PropertyValue value) { +void SymbolLayer::setTextAnchor(const PropertyValue& value) { if (value == getTextAnchor()) return; auto impl_ = mutableImpl(); @@ -544,11 +544,11 @@ PropertyValue SymbolLayer::getDefaultTextMaxAngle() { return TextMaxAngle::defaultValue(); } -PropertyValue SymbolLayer::getTextMaxAngle() const { +const PropertyValue& SymbolLayer::getTextMaxAngle() const { return impl().layout.get(); } -void SymbolLayer::setTextMaxAngle(PropertyValue value) { +void SymbolLayer::setTextMaxAngle(const PropertyValue& value) { if (value == getTextMaxAngle()) return; auto impl_ = mutableImpl(); @@ -560,11 +560,11 @@ PropertyValue SymbolLayer::getDefaultTextRotate() { return TextRotate::defaultValue(); } -PropertyValue SymbolLayer::getTextRotate() const { +const PropertyValue& SymbolLayer::getTextRotate() const { return impl().layout.get(); } -void SymbolLayer::setTextRotate(PropertyValue value) { +void SymbolLayer::setTextRotate(const PropertyValue& value) { if (value == getTextRotate()) return; auto impl_ = mutableImpl(); @@ -576,11 +576,11 @@ PropertyValue SymbolLayer::getDefaultTextPadding() { return TextPadding::defaultValue(); } -PropertyValue SymbolLayer::getTextPadding() const { +const PropertyValue& SymbolLayer::getTextPadding() const { return impl().layout.get(); } -void SymbolLayer::setTextPadding(PropertyValue value) { +void SymbolLayer::setTextPadding(const PropertyValue& value) { if (value == getTextPadding()) return; auto impl_ = mutableImpl(); @@ -592,11 +592,11 @@ PropertyValue SymbolLayer::getDefaultTextKeepUpright() { return TextKeepUpright::defaultValue(); } -PropertyValue SymbolLayer::getTextKeepUpright() const { +const PropertyValue& SymbolLayer::getTextKeepUpright() const { return impl().layout.get(); } -void SymbolLayer::setTextKeepUpright(PropertyValue value) { +void SymbolLayer::setTextKeepUpright(const PropertyValue& value) { if (value == getTextKeepUpright()) return; auto impl_ = mutableImpl(); @@ -608,11 +608,11 @@ PropertyValue SymbolLayer::getDefaultTextTransform() { return TextTransform::defaultValue(); } -PropertyValue SymbolLayer::getTextTransform() const { +const PropertyValue& SymbolLayer::getTextTransform() const { return impl().layout.get(); } -void SymbolLayer::setTextTransform(PropertyValue value) { +void SymbolLayer::setTextTransform(const PropertyValue& value) { if (value == getTextTransform()) return; auto impl_ = mutableImpl(); @@ -624,11 +624,11 @@ PropertyValue> SymbolLayer::getDefaultTextOffset() { return TextOffset::defaultValue(); } -PropertyValue> SymbolLayer::getTextOffset() const { +const PropertyValue>& SymbolLayer::getTextOffset() const { return impl().layout.get(); } -void SymbolLayer::setTextOffset(PropertyValue> value) { +void SymbolLayer::setTextOffset(const PropertyValue>& value) { if (value == getTextOffset()) return; auto impl_ = mutableImpl(); @@ -640,11 +640,11 @@ PropertyValue SymbolLayer::getDefaultTextAllowOverlap() { return TextAllowOverlap::defaultValue(); } -PropertyValue SymbolLayer::getTextAllowOverlap() const { +const PropertyValue& SymbolLayer::getTextAllowOverlap() const { return impl().layout.get(); } -void SymbolLayer::setTextAllowOverlap(PropertyValue value) { +void SymbolLayer::setTextAllowOverlap(const PropertyValue& value) { if (value == getTextAllowOverlap()) return; auto impl_ = mutableImpl(); @@ -656,11 +656,11 @@ PropertyValue SymbolLayer::getDefaultTextIgnorePlacement() { return TextIgnorePlacement::defaultValue(); } -PropertyValue SymbolLayer::getTextIgnorePlacement() const { +const PropertyValue& SymbolLayer::getTextIgnorePlacement() const { return impl().layout.get(); } -void SymbolLayer::setTextIgnorePlacement(PropertyValue value) { +void SymbolLayer::setTextIgnorePlacement(const PropertyValue& value) { if (value == getTextIgnorePlacement()) return; auto impl_ = mutableImpl(); @@ -672,11 +672,11 @@ PropertyValue SymbolLayer::getDefaultTextOptional() { return TextOptional::defaultValue(); } -PropertyValue SymbolLayer::getTextOptional() const { +const PropertyValue& SymbolLayer::getTextOptional() const { return impl().layout.get(); } -void SymbolLayer::setTextOptional(PropertyValue value) { +void SymbolLayer::setTextOptional(const PropertyValue& value) { if (value == getTextOptional()) return; auto impl_ = mutableImpl(); @@ -691,11 +691,11 @@ PropertyValue SymbolLayer::getDefaultIconOpacity() { return { 1 }; } -PropertyValue SymbolLayer::getIconOpacity() const { +const PropertyValue& SymbolLayer::getIconOpacity() const { return impl().paint.template get().value; } -void SymbolLayer::setIconOpacity(PropertyValue value) { +void SymbolLayer::setIconOpacity(const PropertyValue& value) { if (value == getIconOpacity()) return; auto impl_ = mutableImpl(); @@ -718,11 +718,11 @@ PropertyValue SymbolLayer::getDefaultIconColor() { return { Color::black() }; } -PropertyValue SymbolLayer::getIconColor() const { +const PropertyValue& SymbolLayer::getIconColor() const { return impl().paint.template get().value; } -void SymbolLayer::setIconColor(PropertyValue value) { +void SymbolLayer::setIconColor(const PropertyValue& value) { if (value == getIconColor()) return; auto impl_ = mutableImpl(); @@ -745,11 +745,11 @@ PropertyValue SymbolLayer::getDefaultIconHaloColor() { return { {} }; } -PropertyValue SymbolLayer::getIconHaloColor() const { +const PropertyValue& SymbolLayer::getIconHaloColor() const { return impl().paint.template get().value; } -void SymbolLayer::setIconHaloColor(PropertyValue value) { +void SymbolLayer::setIconHaloColor(const PropertyValue& value) { if (value == getIconHaloColor()) return; auto impl_ = mutableImpl(); @@ -772,11 +772,11 @@ PropertyValue SymbolLayer::getDefaultIconHaloWidth() { return { 0 }; } -PropertyValue SymbolLayer::getIconHaloWidth() const { +const PropertyValue& SymbolLayer::getIconHaloWidth() const { return impl().paint.template get().value; } -void SymbolLayer::setIconHaloWidth(PropertyValue value) { +void SymbolLayer::setIconHaloWidth(const PropertyValue& value) { if (value == getIconHaloWidth()) return; auto impl_ = mutableImpl(); @@ -799,11 +799,11 @@ PropertyValue SymbolLayer::getDefaultIconHaloBlur() { return { 0 }; } -PropertyValue SymbolLayer::getIconHaloBlur() const { +const PropertyValue& SymbolLayer::getIconHaloBlur() const { return impl().paint.template get().value; } -void SymbolLayer::setIconHaloBlur(PropertyValue value) { +void SymbolLayer::setIconHaloBlur(const PropertyValue& value) { if (value == getIconHaloBlur()) return; auto impl_ = mutableImpl(); @@ -826,11 +826,11 @@ PropertyValue> SymbolLayer::getDefaultIconTranslate() { return { {{ 0, 0 }} }; } -PropertyValue> SymbolLayer::getIconTranslate() const { +const PropertyValue>& SymbolLayer::getIconTranslate() const { return impl().paint.template get().value; } -void SymbolLayer::setIconTranslate(PropertyValue> value) { +void SymbolLayer::setIconTranslate(const PropertyValue>& value) { if (value == getIconTranslate()) return; auto impl_ = mutableImpl(); @@ -853,11 +853,11 @@ PropertyValue SymbolLayer::getDefaultIconTranslateAnchor() return { TranslateAnchorType::Map }; } -PropertyValue SymbolLayer::getIconTranslateAnchor() const { +const PropertyValue& SymbolLayer::getIconTranslateAnchor() const { return impl().paint.template get().value; } -void SymbolLayer::setIconTranslateAnchor(PropertyValue value) { +void SymbolLayer::setIconTranslateAnchor(const PropertyValue& value) { if (value == getIconTranslateAnchor()) return; auto impl_ = mutableImpl(); @@ -880,11 +880,11 @@ PropertyValue SymbolLayer::getDefaultTextOpacity() { return { 1 }; } -PropertyValue SymbolLayer::getTextOpacity() const { +const PropertyValue& SymbolLayer::getTextOpacity() const { return impl().paint.template get().value; } -void SymbolLayer::setTextOpacity(PropertyValue value) { +void SymbolLayer::setTextOpacity(const PropertyValue& value) { if (value == getTextOpacity()) return; auto impl_ = mutableImpl(); @@ -907,11 +907,11 @@ PropertyValue SymbolLayer::getDefaultTextColor() { return { Color::black() }; } -PropertyValue SymbolLayer::getTextColor() const { +const PropertyValue& SymbolLayer::getTextColor() const { return impl().paint.template get().value; } -void SymbolLayer::setTextColor(PropertyValue value) { +void SymbolLayer::setTextColor(const PropertyValue& value) { if (value == getTextColor()) return; auto impl_ = mutableImpl(); @@ -934,11 +934,11 @@ PropertyValue SymbolLayer::getDefaultTextHaloColor() { return { {} }; } -PropertyValue SymbolLayer::getTextHaloColor() const { +const PropertyValue& SymbolLayer::getTextHaloColor() const { return impl().paint.template get().value; } -void SymbolLayer::setTextHaloColor(PropertyValue value) { +void SymbolLayer::setTextHaloColor(const PropertyValue& value) { if (value == getTextHaloColor()) return; auto impl_ = mutableImpl(); @@ -961,11 +961,11 @@ PropertyValue SymbolLayer::getDefaultTextHaloWidth() { return { 0 }; } -PropertyValue SymbolLayer::getTextHaloWidth() const { +const PropertyValue& SymbolLayer::getTextHaloWidth() const { return impl().paint.template get().value; } -void SymbolLayer::setTextHaloWidth(PropertyValue value) { +void SymbolLayer::setTextHaloWidth(const PropertyValue& value) { if (value == getTextHaloWidth()) return; auto impl_ = mutableImpl(); @@ -988,11 +988,11 @@ PropertyValue SymbolLayer::getDefaultTextHaloBlur() { return { 0 }; } -PropertyValue SymbolLayer::getTextHaloBlur() const { +const PropertyValue& SymbolLayer::getTextHaloBlur() const { return impl().paint.template get().value; } -void SymbolLayer::setTextHaloBlur(PropertyValue value) { +void SymbolLayer::setTextHaloBlur(const PropertyValue& value) { if (value == getTextHaloBlur()) return; auto impl_ = mutableImpl(); @@ -1015,11 +1015,11 @@ PropertyValue> SymbolLayer::getDefaultTextTranslate() { return { {{ 0, 0 }} }; } -PropertyValue> SymbolLayer::getTextTranslate() const { +const PropertyValue>& SymbolLayer::getTextTranslate() const { return impl().paint.template get().value; } -void SymbolLayer::setTextTranslate(PropertyValue> value) { +void SymbolLayer::setTextTranslate(const PropertyValue>& value) { if (value == getTextTranslate()) return; auto impl_ = mutableImpl(); @@ -1042,11 +1042,11 @@ PropertyValue SymbolLayer::getDefaultTextTranslateAnchor() return { TranslateAnchorType::Map }; } -PropertyValue SymbolLayer::getTextTranslateAnchor() const { +const PropertyValue& SymbolLayer::getTextTranslateAnchor() const { return impl().paint.template get().value; } -void SymbolLayer::setTextTranslateAnchor(PropertyValue value) { +void SymbolLayer::setTextTranslateAnchor(const PropertyValue& value) { if (value == getTextTranslateAnchor()) return; auto impl_ = mutableImpl(); @@ -1135,7 +1135,7 @@ optional SymbolLayer::setPaintProperty(const std::string& name, const Con return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::IconOpacity || property == Property::IconHaloWidth || property == Property::IconHaloBlur || property == Property::TextOpacity || property == Property::TextHaloWidth || property == Property::TextHaloBlur) { @@ -1417,7 +1417,7 @@ optional SymbolLayer::setLayoutProperty(const std::string& name, const Co return Error { "layer doesn't support this property" }; } - Property property = static_cast(it->second); + auto property = static_cast(it->second); if (property == Property::SymbolPlacement) { diff --git a/src/mbgl/style/sources/raster_source.cpp b/src/mbgl/style/sources/raster_source.cpp index c2f96dbd55..2d08e4be80 100644 --- a/src/mbgl/style/sources/raster_source.cpp +++ b/src/mbgl/style/sources/raster_source.cpp @@ -48,7 +48,7 @@ void RasterSource::loadDescription(FileSource& fileSource) { return; } - const std::string& url = urlOrTileset.get(); + const auto& url = urlOrTileset.get(); req = fileSource.request(Resource::source(url), [this, url](Response res) { if (res.error) { observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message))); diff --git a/src/mbgl/style/sources/vector_source.cpp b/src/mbgl/style/sources/vector_source.cpp index 6cede8fae9..d141d291e1 100644 --- a/src/mbgl/style/sources/vector_source.cpp +++ b/src/mbgl/style/sources/vector_source.cpp @@ -45,7 +45,7 @@ void VectorSource::loadDescription(FileSource& fileSource) { return; } - const std::string& url = urlOrTileset.get(); + const auto& url = urlOrTileset.get(); req = fileSource.request(Resource::source(url), [this, url](Response res) { if (res.error) { observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message))); diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp index 0992433ccb..5170bfad75 100644 --- a/src/mbgl/text/cross_tile_symbol_index.cpp +++ b/src/mbgl/text/cross_tile_symbol_index.cpp @@ -59,8 +59,7 @@ void TileLayerIndex::findMatches(std::vector& symbolInstances, c } } -CrossTileSymbolLayerIndex::CrossTileSymbolLayerIndex() { -} +CrossTileSymbolLayerIndex::CrossTileSymbolLayerIndex() = default; /* * Sometimes when a user pans across the antimeridian the longitude value gets wrapped. @@ -163,7 +162,7 @@ bool CrossTileSymbolLayerIndex::removeStaleBuckets(const std::unordered_set }; LanguageTag LanguageTag::fromBCP47(const std::string& bcp47Tag) { - typedef std::string::const_iterator iterator_type; - typedef bcp47_parser bcp47_parser; + using iterator_type = std::string::const_iterator; + using bcp47_parser = bcp47_parser; bcp47_parser parser; std::string::const_iterator iter = bcp47Tag.begin(); diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index f6c4ac1eb6..16295256c5 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace mbgl { @@ -62,7 +63,7 @@ Placement::Placement(const TransformState& state_, MapMode mapMode_, style::Tran : collisionIndex(state_) , state(state_) , mapMode(mapMode_) - , transitionOptions(transitionOptions_) + , transitionOptions(std::move(transitionOptions_)) , collisionGroups(crossSourceCollisions) , prevPlacement(std::move(prevPlacement_)) { @@ -80,7 +81,7 @@ void Placement::placeLayer(const RenderLayerSymbolInterface& symbolInterface, co continue; } assert(renderTile.tile.kind == Tile::Kind::Geometry); - GeometryTile& geometryTile = static_cast(renderTile.tile); + auto& geometryTile = static_cast(renderTile.tile); auto bucket = symbolInterface.getSymbolBucket(renderTile); if (!bucket) { diff --git a/src/mbgl/tile/custom_geometry_tile.cpp b/src/mbgl/tile/custom_geometry_tile.cpp index 7e99a4568c..7b1fc2e2d9 100644 --- a/src/mbgl/tile/custom_geometry_tile.cpp +++ b/src/mbgl/tile/custom_geometry_tile.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace mbgl { @@ -19,7 +20,7 @@ CustomGeometryTile::CustomGeometryTile(const OverscaledTileID& overscaledTileID, : GeometryTile(overscaledTileID, sourceID_, parameters), necessity(TileNecessity::Optional), options(options_), - loader(loader_), + loader(std::move(loader_)), mailbox(std::make_shared(*Scheduler::GetCurrent())), actorRef(*this, mailbox) { } diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index 0b703cd68b..0c8b7a4ca1 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -21,6 +21,7 @@ #include #include +#include namespace mbgl { @@ -29,7 +30,7 @@ using namespace style; GeometryTileWorker::GeometryTileWorker(ActorRef self_, ActorRef parent_, OverscaledTileID id_, - const std::string& sourceID_, + std::string sourceID_, const std::atomic& obsolete_, const MapMode mode_, const float pixelRatio_, @@ -37,7 +38,7 @@ GeometryTileWorker::GeometryTileWorker(ActorRef self_, : self(std::move(self_)), parent(std::move(parent_)), id(std::move(id_)), - sourceID(sourceID_), + sourceID(std::move(sourceID_)), obsolete(obsolete_), mode(mode_), pixelRatio(pixelRatio_), diff --git a/src/mbgl/tile/geometry_tile_worker.hpp b/src/mbgl/tile/geometry_tile_worker.hpp index 706bac0154..4402875603 100644 --- a/src/mbgl/tile/geometry_tile_worker.hpp +++ b/src/mbgl/tile/geometry_tile_worker.hpp @@ -32,7 +32,7 @@ public: GeometryTileWorker(ActorRef self, ActorRef parent, OverscaledTileID, - const std::string&, + std::string, const std::atomic&, const MapMode, const float pixelRatio, diff --git a/src/mbgl/util/string.cpp b/src/mbgl/util/string.cpp index 2f737e7436..5d3e44bff6 100644 --- a/src/mbgl/util/string.cpp +++ b/src/mbgl/util/string.cpp @@ -78,7 +78,7 @@ std::string toPaddedHex(T x) { return result; } -} +} // namespace std::string toHex(size_t value) { return toPaddedHex(value); diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp index 7979c550a9..5189b79f26 100644 --- a/src/mbgl/util/tile_cover.cpp +++ b/src/mbgl/util/tile_cover.cpp @@ -237,9 +237,7 @@ TileCover::TileCover(const Geometry& geom, int32_t z, bool project/* = t : impl( std::make_unique(z, geom, project)) { } -TileCover::~TileCover() { - -} +TileCover::~TileCover() = default; optional TileCover::next() { return impl->next(); diff --git a/src/mbgl/util/tile_cover_impl.cpp b/src/mbgl/util/tile_cover_impl.cpp index f783dfc4bd..e7181eeb5f 100644 --- a/src/mbgl/util/tile_cover_impl.cpp +++ b/src/mbgl/util/tile_cover_impl.cpp @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include namespace mbgl { diff --git a/test/actor/actor.test.cpp b/test/actor/actor.test.cpp index 7493abe263..02308b7ce0 100644 --- a/test/actor/actor.test.cpp +++ b/test/actor/actor.test.cpp @@ -101,7 +101,7 @@ TEST(Actor, DestructionBlocksOnSend) { waited(false) { } - ~TestScheduler() { + ~TestScheduler() override { EXPECT_TRUE(waited.load()); } diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index c836ab81ac..4a0a34bafc 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -39,7 +39,7 @@ void main() { class TestLayer : public mbgl::style::CustomLayerHost { public: - void initialize() { + void initialize() override { program = MBGL_CHECK_ERROR(glCreateProgram()); vertexShader = MBGL_CHECK_ERROR(glCreateShader(GL_VERTEX_SHADER)); fragmentShader = MBGL_CHECK_ERROR(glCreateShader(GL_FRAGMENT_SHADER)); @@ -59,7 +59,7 @@ public: MBGL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(GLfloat), triangle, GL_STATIC_DRAW)); } - void render(const mbgl::style::CustomLayerRenderParameters&) { + void render(const mbgl::style::CustomLayerRenderParameters&) override { MBGL_CHECK_ERROR(glUseProgram(program)); MBGL_CHECK_ERROR(glBindBuffer(GL_ARRAY_BUFFER, buffer)); MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); @@ -67,9 +67,9 @@ public: MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 3)); } - void contextLost() {} + void contextLost() override {} - void deinitialize() { + void deinitialize() override { if (program) { MBGL_CHECK_ERROR(glDeleteBuffers(1, &buffer)); MBGL_CHECK_ERROR(glDetachShader(program, vertexShader)); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index a2d36b2ca2..3af2acdb8b 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -48,7 +48,7 @@ public: template MapTest(const std::string& cachePath, const std::string& assetPath, float pixelRatio = 1, MapMode mode = MapMode::Static, - typename std::enable_if::value>::type* = 0) + typename std::enable_if::value>::type* = nullptr) : fileSource(std::make_shared(cachePath, assetPath)) , frontend(pixelRatio, threadPool) , map(frontend, observer, fileSource, threadPool, diff --git a/test/src/mbgl/test/sqlite3_test_fs.cpp b/test/src/mbgl/test/sqlite3_test_fs.cpp index 16d411faff..e4f958c900 100644 --- a/test/src/mbgl/test/sqlite3_test_fs.cpp +++ b/test/src/mbgl/test/sqlite3_test_fs.cpp @@ -29,11 +29,11 @@ static int sqlite3_test_fs_close(sqlite3_file* pFile) { if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; const int rc = file->real->pMethods->xClose(file->real); if (rc == SQLITE_OK) { sqlite3_free((void*)file->base.pMethods); - file->base.pMethods = 0; + file->base.pMethods = nullptr; } return rc; } @@ -52,7 +52,7 @@ static int sqlite3_test_fs_read(sqlite3_file* pFile, void* zBuf, int iAmt, sqlit } sqlite3_test_fs_read_limit -= iAmt; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xRead(file->real, zBuf, iAmt, iOfst); } @@ -70,7 +70,7 @@ static int sqlite3_test_fs_write(sqlite3_file* pFile, const void* zBuf, int iAmt } sqlite3_test_fs_write_limit -= iAmt; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xWrite(file->real, zBuf, iAmt, iOfst); } @@ -81,7 +81,7 @@ static int sqlite3_test_fs_truncate(sqlite3_file* pFile, sqlite3_int64 size) { if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xTruncate(file->real, size); } @@ -92,7 +92,7 @@ static int sqlite3_test_fs_sync(sqlite3_file* pFile, int flags) { if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xSync(file->real, flags); } @@ -103,7 +103,7 @@ static int sqlite3_test_fs_file_size(sqlite3_file* pFile, sqlite3_int64* pSize) if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xFileSize(file->real, pSize); } @@ -111,7 +111,7 @@ static int sqlite3_test_fs_lock(sqlite3_file* pFile, int eLock) { if (sqlite3_test_fs_debug) { fprintf(stderr, "SQLite3: lock(%p, %d)\n", pFile, eLock); } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xLock(file->real, eLock); } @@ -119,7 +119,7 @@ static int sqlite3_test_fs_unlock(sqlite3_file* pFile, int eLock) { if (sqlite3_test_fs_debug) { fprintf(stderr, "SQLite3: unlock(%p, %d)\n", pFile, eLock); } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xUnlock(file->real, eLock); } @@ -127,7 +127,7 @@ static int sqlite3_test_fs_check_reserved_lock(sqlite3_file* pFile, int* pResOut if (sqlite3_test_fs_debug) { fprintf(stderr, "SQLite3: check_reserved_lock(%p)\n", pFile); } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xCheckReservedLock(file->real, pResOut); } @@ -138,7 +138,7 @@ static int sqlite3_test_fs_file_control(sqlite3_file* pFile, int op, void* pArg) if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xFileControl(file->real, op, pArg); } @@ -149,7 +149,7 @@ static int sqlite3_test_fs_sector_size(sqlite3_file* pFile) { if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xSectorSize(file->real); } @@ -160,7 +160,7 @@ static int sqlite3_test_fs_device_characteristics(sqlite3_file* pFile) { if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - File* file = (File*)pFile; + auto* file = (File*)pFile; return file->real->pMethods->xDeviceCharacteristics(file->real); } @@ -169,34 +169,34 @@ static int sqlite3_test_fs_open(sqlite3_vfs* vfs, const char* zName, sqlite3_fil fprintf(stderr, "SQLite3: open(name=%s, flags=%d) -> %p\n", zName, flags, pFile); } if (!sqlite3_test_fs_io) { - pFile->pMethods = NULL; + pFile->pMethods = nullptr; return SQLITE_AUTH; } if (!sqlite3_test_fs_file_open) { - pFile->pMethods = NULL; + pFile->pMethods = nullptr; return SQLITE_CANTOPEN; } - File* file = (File*)pFile; - sqlite3_vfs* unix_fs = (sqlite3_vfs*)vfs->pAppData; + auto* file = (File*)pFile; + auto* unix_fs = (sqlite3_vfs*)vfs->pAppData; file->real = (sqlite3_file*)&file[1]; if (!sqlite3_test_fs_file_create) { int res; const int result = unix_fs->xAccess(vfs, zName, SQLITE_ACCESS_EXISTS, &res); if (result != SQLITE_OK) { - pFile->pMethods = NULL; + pFile->pMethods = nullptr; return result; } if (res != 1) { - pFile->pMethods = NULL; + pFile->pMethods = nullptr; return SQLITE_CANTOPEN; } } const int status = unix_fs->xOpen(unix_fs, zName, file->real, flags, pOutFlags); if (file->real->pMethods) { - sqlite3_io_methods* methods = (sqlite3_io_methods*)sqlite3_malloc(sizeof(sqlite3_io_methods)); + auto* methods = (sqlite3_io_methods*)sqlite3_malloc(sizeof(sqlite3_io_methods)); memset(methods, 0, sizeof(sqlite3_io_methods)); methods->iVersion = 1; methods->xClose = sqlite3_test_fs_close; @@ -223,7 +223,7 @@ static int sqlite3_test_fs_delete(sqlite3_vfs* vfs, const char *zPath, int dirSy if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - sqlite3_vfs* unix_fs = (sqlite3_vfs*)vfs->pAppData; + auto* unix_fs = (sqlite3_vfs*)vfs->pAppData; return unix_fs->xDelete(unix_fs, zPath, dirSync); } @@ -234,7 +234,7 @@ static int sqlite3_test_fs_access(sqlite3_vfs* vfs, const char *zPath, int flags if (!sqlite3_test_fs_io) { return SQLITE_AUTH; } - sqlite3_vfs* unix_fs = (sqlite3_vfs*)vfs->pAppData; + auto* unix_fs = (sqlite3_vfs*)vfs->pAppData; return unix_fs->xAccess(unix_fs, zPath, flags, pResOut); } @@ -243,12 +243,12 @@ namespace test { SQLite3TestFS::SQLite3TestFS() { sqlite3_vfs* unix_fs = sqlite3_vfs_find("unix"); - if (unix_fs == 0) { + if (unix_fs == nullptr) { abort(); } - sqlite3_vfs* test_fs = (sqlite3_vfs*)sqlite3_malloc(sizeof(sqlite3_vfs)); - if (test_fs == 0) { + auto* test_fs = (sqlite3_vfs*)sqlite3_malloc(sizeof(sqlite3_vfs)); + if (test_fs == nullptr) { abort(); } memset(test_fs, 0, sizeof(sqlite3_vfs)); diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp index 744803a4b2..90cdc13d7c 100644 --- a/test/storage/offline_database.test.cpp +++ b/test/storage/offline_database.test.cpp @@ -91,7 +91,7 @@ const Response response = [] { return res; }(); -} // namespace +} // namespace fixture TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Create)) { FixtureLog log; diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp index ef38a1a789..40219108bb 100644 --- a/test/style/filter.test.cpp +++ b/test/style/filter.test.cpp @@ -117,10 +117,10 @@ TEST(Filter, EqualsType) { ASSERT_TRUE(filter(f, {{}}, {}, FeatureType::LineString, {})); ASSERT_FALSE(filter(f, {{}}, {}, FeatureType::Point, {})); - invalidFilter("[\"==\", \"$type\"]"); - invalidFilter("[\"==\", \"$type\", null]"); - invalidFilter("[\"==\", \"$type\", \"foo\", 1]"); - invalidFilter("[\"==\", \"$type\", \"foo\", \"Point\"]"); + invalidFilter(R"(["==", "$type"])"); + invalidFilter(R"(["==", "$type", null])"); + invalidFilter(R"(["==", "$type", "foo", 1])"); + invalidFilter(R"(["==", "$type", "foo", "Point"])"); } TEST(Filter, InType) { diff --git a/test/text/glyph_manager.test.cpp b/test/text/glyph_manager.test.cpp index 3d7a220dc5..3dcf1e204c 100644 --- a/test/text/glyph_manager.test.cpp +++ b/test/text/glyph_manager.test.cpp @@ -19,11 +19,11 @@ static constexpr const size_t stubBitmapLength = 900; class StubLocalGlyphRasterizer : public LocalGlyphRasterizer { public: - bool canRasterizeGlyph(const FontStack&, GlyphID glyphID) { + bool canRasterizeGlyph(const FontStack&, GlyphID glyphID) override { return util::i18n::allowsIdeographicBreaking(glyphID); } - Glyph rasterizeGlyph(const FontStack&, GlyphID glyphID) { + Glyph rasterizeGlyph(const FontStack&, GlyphID glyphID) override { Glyph stub; stub.id = glyphID; diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp index 1d4b0d230e..1c8c7aae8f 100644 --- a/test/util/merge_lines.test.cpp +++ b/test/util/merge_lines.test.cpp @@ -15,7 +15,7 @@ namespace { PropertyMap properties; LineString emptyLine; -} +} // namespace class SymbolFeatureStub : public SymbolFeature { public: diff --git a/test/util/peer.test.cpp b/test/util/peer.test.cpp index aa5a4cc538..a808dd27d1 100644 --- a/test/util/peer.test.cpp +++ b/test/util/peer.test.cpp @@ -6,7 +6,7 @@ using namespace mbgl::util; class TestType { public: - TestType() : i1(0), i2(1) { + TestType() { str[0] = 'a'; } @@ -18,14 +18,14 @@ public: TestType(const TestType&) = delete; TestType& operator=(const TestType&) = delete; - int i1; - int i2; + int i1 = 0; + int i2 = 1; char str[256]; }; bool IsStackAllocated (const peer& a, const void* obj1) { - uintptr_t a_ptr = (uintptr_t)(&a); - uintptr_t obj = (uintptr_t)(obj1); + auto a_ptr = (uintptr_t)(&a); + auto obj = (uintptr_t)(obj1); return (obj >= a_ptr && obj < a_ptr + sizeof(peer)); }; @@ -163,7 +163,7 @@ TEST(Peer, UniquePtr) { EXPECT_FALSE(u1.has_value()); peer u2; - TestType * t3 = new TestType(); + auto* t3 = new TestType(); u2 = std::unique_ptr(t3); EXPECT_TRUE(u2.has_value()); } diff --git a/test/util/tile_cover.test.cpp b/test/util/tile_cover.test.cpp index 7045305625..3fc7681520 100644 --- a/test/util/tile_cover.test.cpp +++ b/test/util/tile_cover.test.cpp @@ -3,8 +3,8 @@ #include #include -#include /* srand, rand */ -#include /* time */ +#include /* srand, rand */ +#include /* time */ #include using namespace mbgl; @@ -314,9 +314,9 @@ TEST(TileCount, BoundsCrossingAntimeridian) { } TEST(TileCover, DISABLED_FuzzPoly) { - while(1) + while(true) { - std::srand (time(NULL)); + std::srand (time(nullptr)); std::size_t len = std::rand() % 10000 + 3; Polygon polygon; @@ -342,9 +342,9 @@ TEST(TileCover, DISABLED_FuzzPoly) { } TEST(TileCover, DISABLED_FuzzLine) { - while(1) + while(true) { - std::srand (time(NULL)); + std::srand (time(nullptr)); std::size_t len = std::rand() % 10000 + 3; MultiLineString mls; -- cgit v1.2.1