From 48a310406621957db4154e844d28e98f460a0226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 16 Oct 2014 18:58:23 +0200 Subject: Update README.md use master branch for travis icon [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82ad7966e9..ee9d1bacb0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Travis](https://api.travis-ci.org/mapbox/mapbox-gl-native.svg)](https://travis-ci.org/mapbox/mapbox-gl-native/builds) +[![Travis](https://api.travis-ci.org/mapbox/mapbox-gl-native.svg?branch=master)](https://travis-ci.org/mapbox/mapbox-gl-native/builds) An OpenGL renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blog/vector-tiles), implemented in C++11, currently targeting iOS, OS X, and Ubuntu Linux. -- cgit v1.2.1 From 4603ca037cab2d0f732285ce9e006744ad3118d6 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 26 Aug 2014 15:24:16 -0700 Subject: background-image support --- include/mbgl/map/transform_state.hpp | 8 +++- include/mbgl/style/property_key.hpp | 3 +- include/mbgl/style/style_properties.hpp | 1 + include/mbgl/util/mat3.hpp | 2 + src/map/transform_state.cpp | 30 +++++++++++++-- src/renderer/painter.cpp | 67 +++++++++++++++++++++++++++------ src/style/style_layer.cpp | 1 + src/style/style_parser.cpp | 1 + src/util/mat3.cpp | 46 +++++++++++++++++++++- 9 files changed, 142 insertions(+), 17 deletions(-) diff --git a/include/mbgl/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp index 5b3b7d3755..ed49dc3e99 100644 --- a/include/mbgl/map/transform_state.hpp +++ b/include/mbgl/map/transform_state.hpp @@ -29,10 +29,16 @@ public: const std::array getFramebufferDimensions() const; float getPixelRatio() const; + float worldSize() const; + float lngX(float lon) const; + float latY(float lat) const; + std::array locationCoordinate(float lon, float lat) const; + // Zoom float getNormalizedZoom() const; - int32_t getIntegerZoom() const; double getZoom() const; + int32_t getIntegerZoom() const; + double getZoomFraction() const; double getScale() const; // Rotation diff --git a/include/mbgl/style/property_key.hpp b/include/mbgl/style/property_key.hpp index 28aa800607..cbf9ad2ac5 100644 --- a/include/mbgl/style/property_key.hpp +++ b/include/mbgl/style/property_key.hpp @@ -61,7 +61,8 @@ enum class PropertyKey { RasterFade, BackgroundOpacity, - BackgroundColor + BackgroundColor, + BackgroundImage }; } diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp index 20200a0dd7..0a5e993411 100644 --- a/include/mbgl/style/style_properties.hpp +++ b/include/mbgl/style/style_properties.hpp @@ -94,6 +94,7 @@ struct BackgroundProperties { inline BackgroundProperties() {} float opacity = 1.0f; Color color = {{ 0, 0, 0, 1 }}; + std::string image; }; typedef mapbox::util::variant< diff --git a/include/mbgl/util/mat3.hpp b/include/mbgl/util/mat3.hpp index d44b1435d3..fa40751764 100644 --- a/include/mbgl/util/mat3.hpp +++ b/include/mbgl/util/mat3.hpp @@ -32,6 +32,8 @@ typedef std::array mat3; namespace matrix { void identity(mat3& out); +void translate(mat3& out, const mat3& a, float x, float y); +void rotate(mat3& out, const mat3& a, float rad); void scale(mat3& out, const mat3& a, float x, float y); } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index d103897375..4b1bc4161e 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -83,11 +83,31 @@ const std::array TransformState::getFramebufferDimensions() const { return framebuffer; } - float TransformState::getPixelRatio() const { return pixelRatio; } +float TransformState::worldSize() const { + return scale * util::tileSize; +} + +float TransformState::lngX(float lon) const { + return (180 + lon) * worldSize() / 360; +} + +float TransformState::latY(float lat) const { + float y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - y) * worldSize() / 360; +} + +std::array TransformState::locationCoordinate(float lon, float lat) const { + float k = std::pow(2, getIntegerZoom()) / worldSize(); + return {{ + lngX(lon) * k, + latY(lat) * k + }}; +} + #pragma mark - Zoom @@ -95,12 +115,16 @@ float TransformState::getNormalizedZoom() const { return std::log(scale * util::tileSize / 512.0f) / M_LN2; } +double TransformState::getZoom() const { + return std::log(scale) / M_LN2; +} + int32_t TransformState::getIntegerZoom() const { return std::floor(getZoom()); } -double TransformState::getZoom() const { - return std::log(scale) / M_LN2; +double TransformState::getZoomFraction() const { + return getZoom() - getIntegerZoom(); } double TransformState::getScale() const { diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 9643fb1561..474b7b954f 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -7,6 +7,9 @@ #include #include #include +#include +#include + #if defined(DEBUG) #include #endif @@ -188,24 +191,66 @@ void Painter::renderTileLayer(const Tile& tile, util::ptr layer_desc void Painter::renderBackground(util::ptr layer_desc) { const BackgroundProperties& properties = layer_desc->getProperties(); + const std::shared_ptr sprite = map.getSprite(); + + if (properties.image.size() && sprite) { + if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque)) + return; + + SpriteAtlas &spriteAtlas = *map.getSpriteAtlas(); + SpriteAtlasPosition imagePos = spriteAtlas.getPosition(properties.image, *sprite, true); + float zoomFraction = map.getState().getZoomFraction(); + + useProgram(patternShader->program); + patternShader->u_matrix = identityMatrix; + patternShader->u_pattern_tl = imagePos.tl; + patternShader->u_pattern_br = imagePos.br; + patternShader->u_mix = zoomFraction; + patternShader->u_opacity = properties.opacity; + + std::array size = imagePos.size; + double lon, lat; + map.getLonLat(lon, lat); + std::array center = map.getState().locationCoordinate(lon, lat); + float scale = 1 / std::pow(2, zoomFraction); + + mat3 matrix; + matrix::identity(matrix); + matrix::scale(matrix, matrix, + 1.0f / size[0], + 1.0f / size[1]); + matrix::translate(matrix, matrix, + std::fmod(center[0] * 512, size[0]), + std::fmod(center[1] * 512, size[1])); + matrix::rotate(matrix, matrix, -map.getState().getAngle()); + matrix::scale(matrix, matrix, + scale * map.getState().getWidth() / 2, + -scale * map.getState().getHeight() / 2); + patternShader->u_patternmatrix = matrix; + + backgroundBuffer.bind(); + patternShader->bind(0); + spriteAtlas.bind(true); + } else { + Color color = properties.color; + color[0] *= properties.opacity; + color[1] *= properties.opacity; + color[2] *= properties.opacity; + color[3] *= properties.opacity; - Color color = properties.color; - color[0] *= properties.opacity; - color[1] *= properties.opacity; - color[2] *= properties.opacity; - color[3] *= properties.opacity; + if ((color[3] >= 1.0f) != (pass == RenderPass::Opaque)) + return; - if ((color[3] >= 1.0f) == (pass == RenderPass::Opaque)) { useProgram(plainShader->program); plainShader->u_matrix = identityMatrix; plainShader->u_color = color; backgroundArray.bind(*plainShader, backgroundBuffer, BUFFER_OFFSET(0)); - - glDisable(GL_STENCIL_TEST); - depthRange(strata + strata_epsilon, 1.0f); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glEnable(GL_STENCIL_TEST); } + + glDisable(GL_STENCIL_TEST); + depthRange(strata + strata_epsilon, 1.0f); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glEnable(GL_STENCIL_TEST); } mat4 Painter::translatedMatrix(const mat4& matrix, const std::array &translation, const Tile::ID &id, TranslateAnchorType anchor) { diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index 4f758fe723..d78750195b 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -235,6 +235,7 @@ void StyleLayer::applyStyleProperties(const float z, const BackgroundProperties &background = properties.get(); applyTransitionedStyleProperty(PropertyKey::BackgroundOpacity, background.opacity, z, now); applyTransitionedStyleProperty(PropertyKey::BackgroundColor, background.color, z, now); + applyStyleProperty(PropertyKey::BackgroundImage, background.image, z, now); } void StyleLayer::updateProperties(float z, const timestamp now) { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index c2247d51b2..3aa12a6670 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -640,6 +640,7 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) { parseOptionalProperty>("background-opacity", Key::BackgroundOpacity, klass, value); parseOptionalProperty>("background-color", Key::BackgroundColor, klass, value); + parseOptionalProperty("background-image", Key::BackgroundImage, klass, value); } void StyleParser::parseReference(JSVal value, util::ptr &layer) { diff --git a/src/util/mat3.cpp b/src/util/mat3.cpp index 38858d2385..263768ee41 100644 --- a/src/util/mat3.cpp +++ b/src/util/mat3.cpp @@ -38,7 +38,51 @@ void matrix::identity(mat3& out) { out[8] = 1.0f; } -void matrix::scale(mat3& out, const mat3& a, const float x, const float y) { +void matrix::translate(mat3& out, const mat3& a, float x, float y) { + float a00 = a[0], a01 = a[1], a02 = a[2], + a10 = a[3], a11 = a[4], a12 = a[5], + a20 = a[6], a21 = a[7], a22 = a[8]; + + out[0] = a00; + out[1] = a01; + out[2] = a02; + + out[3] = a10; + out[4] = a11; + out[5] = a12; + + out[6] = x * a00 + y * a10 + a20; + out[7] = x * a01 + y * a11 + a21; + out[8] = x * a02 + y * a12 + a22; +} + +void matrix::rotate(mat3& out, const mat3& a, float rad) { + float s = std::sin(rad), + c = std::cos(rad), + a00 = a[0], + a01 = a[1], + a02 = a[2], + a10 = a[3], + a11 = a[4], + a12 = a[5], + a20 = a[6], + a21 = a[7], + a22 = a[8]; + + out[0] = c * a00 + s * a10; + out[1] = c * a01 + s * a11; + out[2] = c * a02 + s * a12; + + out[3] = c * a10 - s * a00; + out[4] = c * a11 - s * a01; + out[5] = c * a12 - s * a02; + + out[6] = a20; + out[7] = a21; + out[8] = a22; +}; + +void matrix::scale(mat3& out, const mat3& a, float x, float y) { out[0] = x * a[0]; out[1] = x * a[1]; out[2] = x * a[2]; -- cgit v1.2.1 From 4e9688e430037b9a454320d8b29a5c99a9616fba Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 17 Oct 2014 11:11:24 -0700 Subject: Fix compiler warnings --- include/mbgl/platform/event.hpp | 6 ++++-- test/fixtures/fixture_request.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp index d2a06618a3..576e9e5b85 100644 --- a/include/mbgl/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -58,8 +58,10 @@ struct EventPermutation { }; constexpr EventSeverity disabledEventSeverities[] = { -#if !DEBUG - EventSeverity::Debug, +#if DEBUG + EventSeverity(-1) // Avoid zero size array +#else + EventSeverity::Debug #endif }; diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 3f72b890db..be944eb071 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -48,7 +48,7 @@ void HTTPRequestBaton::start(const util::ptr &baton) { uv_async_send(baton->async); } -void HTTPRequestBaton::stop(const util::ptr &baton) { +void HTTPRequestBaton::stop(const util::ptr &/*baton*/) { fprintf(stderr, "HTTP request cannot be canceled because it is answered immediately"); abort(); } -- cgit v1.2.1 From d54809b04adf0b64e13b97852cfed860f92682a9 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 17 Oct 2014 12:02:51 -0700 Subject: Fix log message filtering Taking the sizeof a pointer doesn't give you the array length! --- include/mbgl/platform/log.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp index dc000b4d52..406b3eea37 100644 --- a/include/mbgl/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -19,9 +19,9 @@ public: class Log { private: - template - constexpr static bool includes(const T e, T const *l, const size_t i = 0) { - return i >= sizeof l ? false : *(l + i) == e ? true : includes(e, l, i + 1); + template + constexpr static bool includes(const T e, const T (&l)[N], const size_t i = 0) { + return i < N && (l[i] == e || includes(e, l, i + 1)); } public: -- cgit v1.2.1 From 5a87fb337dc034c6d96ff74d20c5c257c0a65b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 20 Oct 2014 17:55:49 +0200 Subject: first attempt at using mason to install packages [skip ci] --- Makefile | 1 + configure | 179 ++++++++++--------------------------- include/mbgl/map/map.hpp | 7 +- include/mbgl/util/uv_detail.hpp | 20 ++++- src/map/map.cpp | 16 +++- src/storage/file_request_baton.cpp | 26 +++++- src/storage/http_request.cpp | 9 ++ src/util/uv.cpp | 6 ++ 8 files changed, 118 insertions(+), 146 deletions(-) diff --git a/Makefile b/Makefile index 584fe2a2e4..a29e30cab6 100644 --- a/Makefile +++ b/Makefile @@ -109,3 +109,4 @@ distclean: clean -find ./mapnik-packaging/osx/out/packages -type d ! -name 'packages' -maxdepth 1 -exec rm -rf {} \; .PHONY: mbgl test linux build/test/Makefile +# DO NOT DELETE diff --git a/configure b/configure index b92f97758b..d8a5e08ed8 100755 --- a/configure +++ b/configure @@ -1,144 +1,55 @@ -#!/usr/bin/env python -import optparse -import os -import pprint -import re -import shlex -import subprocess -import sys +#!/usr/bin/env bash -root_dir = os.path.dirname(__file__) +set -e +set -o pipefail -# parse our options -parser = optparse.OptionParser() +. ~/.nvm/nvm.sh +nvm use 0.10 -parser.add_option("--debug", - action="store_true", - dest="debug", - help="Also build debug build") +LIBCURL_VERSION=system +GLFW_VERSION=a21f2377 +LIBPNG_VERSION=1.6.13 +SQLITE_VERSION=system +LIBUV_VERSION=0.10.28 -parser.add_option("--node", - action="store", - dest="node", - help="Name of the node executable (defaults to node)") +mason install libcurl ${LIBCURL_VERSION} +mason install glfw ${GLFW_VERSION} +mason install libpng ${LIBPNG_VERSION} +mason install sqlite ${SQLITE_VERSION} +mason install libuv ${LIBUV_VERSION} -parser.add_option("--npm", - action="store", - dest="npm", - help="Name of the npm executable (defaults to npm)") +BOOST_ROOT=/usr +if [ -d '/usr/local/boost' ]; then BOOST_ROOT='/usr/local' ; fi -parser.add_option("--pkg-config-root", - action="store", - dest="pkgconfig_root", - help="Path to pkg-config directory") - -parser.add_option("--boost", - action="store", - dest="boost_root", - help="Path to boost (defaults to /usr/local)") - -(options, args) = parser.parse_args() - -def pkg_config(pkg, pkgconfig_root): - env = os.environ.copy() - if pkgconfig_root: - env["PKG_CONFIG_PATH"] = pkgconfig_root - env["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "1" - env["PKG_CONFIG_ALLOW_SYSTEM_LIBS"] = "1" - cmd = subprocess.Popen(['pkg-config', '--static', '--libs', pkg], stdout=subprocess.PIPE, env=env) - libs, ret = cmd.communicate() - if (ret): return None - - cmd = subprocess.Popen(['pkg-config', '--static', '--cflags', pkg], stdout=subprocess.PIPE, env=env) - cflags, ret = cmd.communicate() - if (ret): return None - - return (libs, cflags) - -def configure_mbgl(o): - if options.boost_root: - o['variables']['boost_root'] = options.boost_root - else: - o['variables']['boost_root'] = '/usr/local' - if options.node: - o['variables']['node'] = options.node - else: - o['variables']['node'] = 'node' - if options.npm: - o['variables']['npm'] = options.npm - else: - o['variables']['npm'] = 'npm' - o['target_defaults']['default_configuration'] = 'Debug' if options.debug else 'Release' - - -def fix_frameworks(libs): - # don't split "-framework Foo" - return re.split('(? config.gypi - write('config.gypi', "# Do not edit. Generated by the configure script.\n" + - pprint.pformat(output, indent=2) + "\n") +cat config.gypi diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index a69943aa74..bea82e6b4c 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -143,10 +143,15 @@ public: private: // uv async callbacks +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + static void render(uv_async_t *async, int status); + static void terminate(uv_async_t *async, int status); + static void cleanup(uv_async_t *async, int status); +#else static void render(uv_async_t *async); static void terminate(uv_async_t *async); static void cleanup(uv_async_t *async); - static void delete_async(uv_handle_t *handle); +#endif // Setup void setup(); diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index e0a57ce65d..f80ca1bff5 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -24,17 +24,31 @@ private: class loop { public: inline loop() { +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + l = uv_loop_new(); + if (l == nullptr) { +#else + l = new uv_loop_t; if (uv_loop_init(&l) != 0) { +#endif throw std::runtime_error("failed to initialize loop"); } } - inline ~loop() { uv_loop_close(&l); } + inline ~loop() { +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + uv_loop_delete(l); +#else + uv_loop_close(l); + delete l; +#endif + + } - inline uv_loop_t *operator*() { return &l; } + inline uv_loop_t *operator*() { return l; } private: - uv_loop_t l; + uv_loop_t *l = nullptr; }; class mutex { diff --git a/src/map/map.cpp b/src/map/map.cpp index a1543dbdae..f255c3ff65 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -145,10 +145,6 @@ void Map::stop(stop_callback cb, void *data) { async = false; } -void Map::delete_async(uv_handle_t *handle) { - delete (uv_async_t *)handle; -} - void Map::run() { #ifndef NDEBUG if (!async) { @@ -203,7 +199,11 @@ void Map::cleanup() { } } +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +void Map::cleanup(uv_async_t *async, int) { +#else void Map::cleanup(uv_async_t *async) { +#endif Map *map = static_cast(async->data); map->view.make_active(); @@ -221,7 +221,11 @@ void Map::setReachability(bool reachable) { } } +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +void Map::render(uv_async_t *async, int) { +#else void Map::render(uv_async_t *async) { +#endif Map *map = static_cast(async->data); assert(uv_thread_self() == map->map_thread); @@ -241,7 +245,11 @@ void Map::render(uv_async_t *async) { } } +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +void Map::terminate(uv_async_t *async, int) { +#else void Map::terminate(uv_async_t *async) { +#endif // Closes all open handles on the loop. This means that the loop will automatically terminate. Map *map = static_cast(async->data); assert(uv_thread_self() == map->map_thread); diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index 127c78f3e5..d4c135fd71 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -29,7 +29,11 @@ void FileRequestBaton::notify_error(uv_fs_t *req) { if (ptr->request && req->result < 0 && !ptr->canceled && req->result != UV_ECANCELED) { ptr->request->response = std::unique_ptr(new Response); ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500; +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + ptr->request->response->message = uv_strerror(uv_last_error(req->loop)); +#else ptr->request->response->message = uv_strerror(int(req->result)); +#endif ptr->request->notify(); } } @@ -54,7 +58,8 @@ void FileRequestBaton::file_opened(uv_fs_t *req) { uv_fs_close(req->loop, req, fd, file_closed); } else { ptr->fd = fd; - uv_fs_fstat(req->loop, req, fd, file_stated); + const int r = uv_fs_fstat(req->loop, req, fd, file_stated); + assert(r == 0); } } } @@ -63,7 +68,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { FileRequestBaton *ptr = (FileRequestBaton *)req->data; assert(ptr->thread_id == uv_thread_self()); - if (req->result < 0 || ptr->canceled || !ptr->request) { + if (req->result != 0 || ptr->canceled || !ptr->request) { // Stating failed or was canceled. We already have an open file handle // though, which we'll have to close. notify_error(req); @@ -71,13 +76,22 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_req_cleanup(req); uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { - if (static_cast(req->ptr)->st_size > std::numeric_limits::max()) { +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + const uv_statbuf_t *stat = static_cast(req->ptr); +#else + const uv_stat_t *stat = static_cast(req->ptr); +#endif + if (stat->st_size > std::numeric_limits::max()) { // File is too large for us to open this way because uv_buf's only support unsigned // ints as maximum size. if (ptr->request) { ptr->request->response = std::unique_ptr(new Response); ptr->request->response->code = UV_EFBIG; +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + ptr->request->response->message = uv_strerror(uv_err_t {UV_EFBIG, 0}); +#else ptr->request->response->message = uv_strerror(UV_EFBIG); +#endif ptr->request->notify(); } @@ -85,11 +99,15 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { const unsigned int size = - (unsigned int)(static_cast(req->ptr)->st_size); + (unsigned int)(stat->st_size); ptr->body.resize(size); ptr->buffer = uv_buf_init(const_cast(ptr->body.data()), size); uv_fs_req_cleanup(req); +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + uv_fs_read(req->loop, req, ptr->fd, ptr->buffer.base, ptr->buffer.len, -1, file_read); +#else uv_fs_read(req->loop, req, ptr->fd, &ptr->buffer, 1, 0, file_read); +#endif } } } diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 1b799d4895..ca1412fd9e 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -77,7 +77,11 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr &&res) { http_baton->response = std::move(res); http_baton->async->data = new util::ptr(http_baton); +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + uv_async_init(loop, http_baton->async, [](uv_async_t *async, int) { +#else uv_async_init(loop, http_baton->async, [](uv_async_t *async) { +#endif util::ptr &http_baton = *(util::ptr *)async->data; if (http_baton->request) { @@ -193,7 +197,12 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr &&res, uint64_t tim backoff_timer = new uv_timer_t(); uv_timer_init(loop, backoff_timer); backoff_timer->data = new RetryBaton(this, std::move(res)); + +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + uv_timer_start(backoff_timer, [](uv_timer_t *timer, int) { +#else uv_timer_start(backoff_timer, [](uv_timer_t *timer) { +#endif std::unique_ptr pair { static_cast(timer->data) }; pair->first->startHTTPRequest(std::move(pair->second)); pair->first->backoff_timer = nullptr; diff --git a/src/util/uv.cpp b/src/util/uv.cpp index b97074f054..03a885d308 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -5,6 +5,11 @@ namespace uv { std::string cwd() { +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + char dir[512]; + uv_cwd(dir, 512); + return dir; +#else size_t max = 0; std::string dir; do { @@ -14,6 +19,7 @@ std::string cwd() { } while (max == dir.size()); dir.resize(max - 1); return dir; +#endif } void deleter::operator()(uv_async_t *async) { -- cgit v1.2.1 From 1da471abba1a64b691b8c90ac13bae81daa1c698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 20 Oct 2014 18:21:21 +0200 Subject: curl fixes [skip ci] --- common/http_request_baton_curl.cpp | 23 +++-- linux/mapboxgl-app.gyp | 2 + mapboxgl.gyp | 8 -- setup-libraries-cross.sh | 62 ------------- setup-libraries.sh | 178 ------------------------------------- 5 files changed, 18 insertions(+), 255 deletions(-) delete mode 100755 setup-libraries-cross.sh delete mode 100755 setup-libraries.sh diff --git a/common/http_request_baton_curl.cpp b/common/http_request_baton_curl.cpp index 772aeb86e1..d4753266c0 100644 --- a/common/http_request_baton_curl.cpp +++ b/common/http_request_baton_curl.cpp @@ -52,7 +52,7 @@ // Handles the request thread + messaging to the thread. static uv_once_t once; -static uv_loop_t loop; +static uv_loop_t *loop = nullptr; static uv_messenger_t start_messenger; static uv_messenger_t stop_messenger; static uv_thread_t thread; @@ -228,7 +228,7 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void * context->sockfd = sockfd; assert(!context->poll_handle); context->poll_handle = new uv_poll_t; - uv_poll_init_socket(&loop, context->poll_handle, sockfd); + uv_poll_init_socket(loop, context->poll_handle, sockfd); context->poll_handle->data = context; curl_multi_assign(multi, sockfd, context); } @@ -253,7 +253,11 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void * return 0; } +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +void on_timeout(uv_timer_t *, int = 0) { +#else void on_timeout(uv_timer_t *) { +#endif int running_handles; CURLMcode error = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); if (error != CURLM_OK) { @@ -275,7 +279,7 @@ void thread_init(void *) { #endif thread_id = uv_thread_self(); - uv_timer_init(&loop, &timeout); + uv_timer_init(loop, &timeout); CURLSHcode share_error; share = curl_share_init(); @@ -305,7 +309,7 @@ void thread_init(void *) { } // Main event loop. This will not return until the request loop is terminated. - uv_run(&loop, UV_RUN_DEFAULT); + uv_run(loop, UV_RUN_DEFAULT); curl_multi_cleanup(multi); multi = nullptr; @@ -442,9 +446,14 @@ void stop_request(void *const ptr) { void create_thread() { uv_mutex_init(&share_mutex); - uv_loop_init(&loop); - uv_messenger_init(&loop, &start_messenger, start_request); - uv_messenger_init(&loop, &stop_messenger, stop_request); +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 + loop = uv_loop_new(); +#else + loop = new uv_loop_t; + uv_loop_init(loop); +#endif + uv_messenger_init(loop, &start_messenger, start_request); + uv_messenger_init(loop, &stop_messenger, stop_request); uv_thread_create(&thread, thread_init, nullptr); } diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index dac1934d31..05716dd11c 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -33,6 +33,7 @@ ], 'OTHER_LDFLAGS': [ '<@(glfw3_libraries)', + '<@(curl_libraries)', ], } }, @@ -46,6 +47,7 @@ 'link_settings': { 'libraries': [ '<@(glfw3_libraries)', + '<@(curl_libraries)', '-lboost_regex' ], }, diff --git a/mapboxgl.gyp b/mapboxgl.gyp index 68434bf2ba..05569d82cb 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -139,7 +139,6 @@ 'OTHER_CPLUSPLUSFLAGS': [ '<@(png_cflags)', '<@(uv_cflags)', - '<@(curl_cflags)', '<@(sqlite3_cflags)', '-I<(boost_root)/include', ], @@ -151,7 +150,6 @@ 'cflags': [ '<@(png_cflags)', '<@(uv_cflags)', - '<@(curl_cflags)', '<@(sqlite3_cflags)', '-I<(boost_root)/include', ], @@ -166,26 +164,22 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)', - '<@(curl_cflags)', '-I<(boost_root)/include', ], 'OTHER_LDFLAGS': [ '<@(png_libraries)', '<@(uv_libraries)', - '<@(curl_libraries)', '<@(sqlite3_libraries)', ] } }, { 'cflags': [ '<@(uv_cflags)', - '<@(curl_cflags)', '-I<(boost_root)/include', ], 'libraries': [ '<@(png_libraries)', '<@(uv_libraries)', - '<@(curl_libraries)', '<@(sqlite3_libraries)', ] }] @@ -222,7 +216,6 @@ 'OTHER_CPLUSPLUSFLAGS': [ '<@(png_cflags)', '<@(uv_cflags)', - '<@(curl_cflags)', '<@(sqlite3_cflags)', '-I<(boost_root)/include', ], @@ -238,7 +231,6 @@ 'OTHER_LDFLAGS': [ '<@(png_libraries)', '<@(uv_libraries)', - '<@(curl_libraries)', '<@(sqlite3_libraries)', ], 'OTHER_CPLUSPLUSFLAGS': [ diff --git a/setup-libraries-cross.sh b/setup-libraries-cross.sh deleted file mode 100755 index 4f3a5bfbea..0000000000 --- a/setup-libraries-cross.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -set -e -u - -UNAME=$(uname -s); - -MISSING_DEPS="" - -function ensure_dep { - if [[ ! `which $1` ]]; then - MISSING_DEPS="$MISSING_DEPS $1" - fi -} - -ensure_dep aclocal -ensure_dep cmake -ensure_dep automake -ensure_dep autoconf -ensure_dep pkg-config -ensure_dep node -ensure_dep libtool -ensure_dep gccmakedep - -if [[ $MISSING_DEPS != "" ]]; then - if [ ${UNAME} = 'Darwin' ]; then - echo "Missing build deps: ${MISSING_DEPS}" - echo 'Please run "brew install autoconf automake libtool makedepend cmake pkg-config node"' - echo 'and then re-run ./setup-libraries.sh' - elif [ ${UNAME} = 'Linux' ]; then - echo "Missing build deps: ${MISSING_DEPS}" - echo 'Please run "sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config nodejs-legacy libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev"' - echo 'and then re-run ./setup-libraries.sh' - fi - exit 1 -fi - -export SYSROOT=`pwd`/../rootfs -export SDK_PATH=`pwd`/../arm-linux-gnueabi-linaro_4.8.3-2014.04 -export V=1 - -if [ ! -d 'mapnik-packaging/.git' ]; then - git clone --depth=1 https://github.com/mapnik/mapnik-packaging.git -fi - -cd mapnik-packaging/osx/ -# git pull - -export CXX11=true - -source Linaro-softfp.sh - if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi - -cd ../../ -./configure \ ---pkg-config-root=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/pkgconfig \ ---boost=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp \ ---node=`which node` - diff --git a/setup-libraries.sh b/setup-libraries.sh deleted file mode 100755 index c049e88a1e..0000000000 --- a/setup-libraries.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash -set -e -u - -UNAME=$(uname -s); - -MISSING_DEPS="" - -function ensure_dep { - if [[ ! `which $1` ]]; then - MISSING_DEPS="$MISSING_DEPS $1" - fi -} - -ensure_dep aclocal -ensure_dep cmake -ensure_dep automake -ensure_dep autoconf -ensure_dep pkg-config -if [ ${UNAME} = 'Darwin' ]; then - ensure_dep makedepend - if [[ ! `which libtool` ]] && [[ ! `which glibtool` ]]; then - MISSING_DEPS="$MISSING_DEPS libtool" - fi -elif [ ${UNAME} = 'Linux' ]; then - ensure_dep libtool - ensure_dep gccmakedep -fi - -if [[ $MISSING_DEPS != "" ]]; then - if [ ${UNAME} = 'Darwin' ]; then - echo "Missing build deps: ${MISSING_DEPS}" - echo 'Please run "brew install autoconf automake libtool makedepend cmake pkg-config"' - echo 'and then re-run ./setup-libraries.sh' - elif [ ${UNAME} = 'Linux' ]; then - echo "Missing build deps: ${MISSING_DEPS}" - echo 'Please run "sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev"' - echo 'and then re-run ./setup-libraries.sh' - fi - exit 1 -fi - -# bootstrap node install -if [[ ! -d ~/.nvm ]]; then - git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm -fi -set +u -source ~/.nvm/nvm.sh -nvm install 0.10 -set -u - -NODE=$(which node) -NPM=$(which npm) - -MP_HASH="f543fecbeb0982983593aa0847715d26c323b990" -DIR_HASH=$(echo `pwd` | git hash-object --stdin) - -if [ ! -d 'mapnik-packaging/' ]; then - git clone https://github.com/mapnik/mapnik-packaging.git -fi - -cd mapnik-packaging -git fetch -git checkout ${MP_HASH} -cd ./osx/ - -export CXX11=true - -if [ ${UNAME} = 'Darwin' ]; then - -if [[ -n ${TRAVIS:-} ]]; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then - rm -rf out/build-cpp11-libcpp-x86_64-macosx - rm -rf out/build-cpp11-libcpp-universal - tar -xzf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz - tar -xzf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz - fi - fi -fi - -if test -z "${TRAVIS:-}" || ! test -d out/build-cpp11-libcpp-universal; then - -source iPhoneOS.sh - if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - echo ' ...done' - -source iPhoneOSs.sh - if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - echo ' ...done' - -source iPhoneOS64.sh - if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - echo ' ...done' - -source iPhoneSimulator.sh - if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - echo ' ...done' - -source iPhoneSimulator64.sh - if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - echo ' ...done' - -source MacOSX.sh - if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi - if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -d out/build-cpp11-libcpp-x86_64-macosx/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../include/ `pwd`/../../linux/ `pwd`/../../common/ ; fi - echo ' ...done' - -# setup iOS universal libs -./scripts/make_universal.sh -patch -p0 --forward < patches/curl-ios.diff || true -echo "NOTE: One patch FAILURE is expected. The other should have been applied or ignored." - -if [[ ${TRAVIS:-} && ${AWS_ACCESS_KEY_ID:-} && ${AWS_SECRET_ACCESS_KEY:-} ]] ; then - tar -zcf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-universal - aws s3 cp --acl public-read out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/ - tar -zcf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-x86_64-macosx - aws s3 cp --acl public-read out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/ -fi - -fi - -cd ../../ - -# default to OS X build product symlinking -./mapnik-packaging/osx/darwin_configure.sh osx - -elif [ ${UNAME} = 'Linux' ]; then - -if [[ ${TRAVIS:-} ]]; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ./out/ ; then - rm -rf out/build-cpp11-libstdcpp-gcc-x86_64-linux - tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz - fi -fi - -source Linux.sh - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi - if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi - -if [[ ${TRAVIS:-} && ${AWS_ACCESS_KEY_ID:-} && ${AWS_SECRET_ACCESS_KEY:-} ]] ; then - if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then - tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux - aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://mapbox-gl-testing/dependencies/ - fi -fi - -cd ../../ -./configure \ ---pkg-config-root=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/pkgconfig \ ---boost=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-x86_64-linux \ ---npm=$NPM \ ---node=$NODE -fi -- cgit v1.2.1 From 9103d84acebdc8bc3065d09f786881cd3f1ead15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 11:41:30 +0200 Subject: ios build system fixes [skip ci] --- Makefile | 7 ++--- configure | 75 ++++++++++++++++++++++++++++++++++++------------- src/util/uv-messenger.c | 5 ++++ 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index a29e30cab6..a9c24ffdb3 100644 --- a/Makefile +++ b/Makefile @@ -6,14 +6,11 @@ all: setup setup: config.gypi -config.gypi: - ./setup-libraries.sh - xlibs: @./mapnik-packaging/osx/darwin_configure.sh osx ilibs: - @./mapnik-packaging/osx/darwin_configure.sh ios + MASON_PLATFORM=ios ./configure # Builds the regular library mbgl: config.gypi mapboxgl.gyp node @@ -84,7 +81,7 @@ xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode -iproj-cli: config.gypi ilibs ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node +iproj-cli: ilibs config.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode iproj: iproj-cli diff --git a/configure b/configure index d8a5e08ed8..d02972d0a4 100755 --- a/configure +++ b/configure @@ -12,11 +12,21 @@ LIBPNG_VERSION=1.6.13 SQLITE_VERSION=system LIBUV_VERSION=0.10.28 -mason install libcurl ${LIBCURL_VERSION} -mason install glfw ${GLFW_VERSION} -mason install libpng ${LIBPNG_VERSION} -mason install sqlite ${SQLITE_VERSION} -mason install libuv ${LIBUV_VERSION} +case $MASON_PLATFORM in + 'ios') + SQLITE_VERSION=system + LIBPNG_VERSION=1.6.13 + LIBUV_VERSION=0.10.28 + ;; + *) + GLFW_VERSION=a21f2377 + SQLITE_VERSION=system + LIBPNG_VERSION=system + LIBCURL_VERSION=system + LIBUV_VERSION=0.10.28 + ;; +esac + BOOST_ROOT=/usr if [ -d '/usr/local/boost' ]; then BOOST_ROOT='/usr/local' ; fi @@ -25,7 +35,9 @@ function quote_flags { python -c "import sys, re; print re.split('(? config.gypi + 'boost_root': '${BOOST_ROOT}', +" + +if [ ! -z ${LIBCURL_VERSION} ]; then + mason install libcurl ${LIBCURL_VERSION} + CONFIG+=$" 'curl_cflags': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),"$LN + CONFIG+=$" 'curl_libraries': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),"$LN +fi + +if [ ! -z ${GLFW_VERSION} ]; then + mason install glfw ${GLFW_VERSION} + CONFIG+=$" 'glfw3_cflags': $(quote_flags $(mason cflags glfw ${GLFW_VERSION})),"$LN + CONFIG+=$" 'glfw3_libraries': $(quote_flags $(mason ldflags glfw ${GLFW_VERSION})),"$LN +fi + +if [ ! -z ${LIBPNG_VERSION} ]; then + mason install libpng ${LIBPNG_VERSION} + CONFIG+=$" 'png_cflags': $(quote_flags $(mason cflags libpng ${LIBPNG_VERSION})),"$LN + CONFIG+=$" 'png_libraries': $(quote_flags $(mason ldflags libpng ${LIBPNG_VERSION})),"$LN +fi + +if [ ! -z ${SQLITE_VERSION} ]; then + mason install sqlite ${SQLITE_VERSION} + CONFIG+=$" 'sqlite3_cflags': $(quote_flags $(mason cflags sqlite ${SQLITE_VERSION})),"$LN + CONFIG+=$" 'sqlite3_libraries': $(quote_flags $(mason ldflags sqlite ${SQLITE_VERSION})),"$LN +fi + +if [ ! -z ${LIBUV_VERSION} ]; then + mason install libuv ${LIBUV_VERSION} + CONFIG+=$" 'uv_cflags': $(quote_flags $(mason cflags libuv ${LIBUV_VERSION})),"$LN + CONFIG+=$" 'uv_libraries': $(quote_flags $(mason ldflags libuv ${LIBUV_VERSION})),"$LN +fi + +CONFIG+=" } +} +" + +echo "${CONFIG}" > config.gypi cat config.gypi diff --git a/src/util/uv-messenger.c b/src/util/uv-messenger.c index a25c84dc59..9457cc378b 100644 --- a/src/util/uv-messenger.c +++ b/src/util/uv-messenger.c @@ -8,7 +8,12 @@ typedef struct { void *queue[2]; } uv__messenger_item_t; + +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +void uv__messenger_callback(uv_async_t *async, int) { +#else void uv__messenger_callback(uv_async_t *async) { +#endif uv_messenger_t *msgr = (uv_messenger_t *)async->data; uv__messenger_item_t *item; -- cgit v1.2.1 From a1c5e0cdc1ab89bd78953fe4c9d87b08ad8c652d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 03:06:11 -0700 Subject: don't omit parameter name [skip ci] --- src/util/uv-messenger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/uv-messenger.c b/src/util/uv-messenger.c index 9457cc378b..cb3c3ca99b 100644 --- a/src/util/uv-messenger.c +++ b/src/util/uv-messenger.c @@ -10,7 +10,7 @@ typedef struct { #if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void uv__messenger_callback(uv_async_t *async, int) { +void uv__messenger_callback(uv_async_t *async, int status) { #else void uv__messenger_callback(uv_async_t *async) { #endif -- cgit v1.2.1 From ef1792fe470a6b280aa2864ae988561c4784ddb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 12:08:04 +0200 Subject: properly detect boost root [skip ci] --- configure | 31 +++++++++++++++++++++++-------- mapboxgl.gyp | 6 ++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/configure b/configure index d02972d0a4..dc32be1356 100755 --- a/configure +++ b/configure @@ -6,17 +6,12 @@ set -o pipefail . ~/.nvm/nvm.sh nvm use 0.10 -LIBCURL_VERSION=system -GLFW_VERSION=a21f2377 -LIBPNG_VERSION=1.6.13 -SQLITE_VERSION=system -LIBUV_VERSION=0.10.28 - case $MASON_PLATFORM in 'ios') SQLITE_VERSION=system LIBPNG_VERSION=1.6.13 LIBUV_VERSION=0.10.28 + ZLIB_VERSION=system ;; *) GLFW_VERSION=a21f2377 @@ -24,12 +19,26 @@ case $MASON_PLATFORM in LIBPNG_VERSION=system LIBCURL_VERSION=system LIBUV_VERSION=0.10.28 + ZLIB_VERSION=system ;; esac +if [ -z "${BOOST_ROOT}" ]; then + if [ -d '/usr/local/include/boost' ]; then + BOOST_ROOT='/usr/local' + elif [ -d '/usr/include/boost' ]; then + BOOST_ROOT='/usr' + else + >&2 echo -e "\033[1m\033[31mCannot find Boost\033[0m"; + fi +fi + +if [ ! -d "${BOOST_ROOT}/include/boost" ]; then + >&2 echo -e "\033[1m\033[31mCannot find Boost at ${BOOST_ROOT}\033[0m"; +else + >&2 echo -e "\033[1m\033[32m* Using Boost installation at ${BOOST_ROOT}\033[0m"; +fi -BOOST_ROOT=/usr -if [ -d '/usr/local/boost' ]; then BOOST_ROOT='/usr/local' ; fi function quote_flags { python -c "import sys, re; print re.split('(? Date: Tue, 21 Oct 2014 12:49:19 +0200 Subject: cleanup makefile [skip ci] --- .travis.yml | 7 ++----- Makefile | 22 +++++++++------------- configure | 4 ++++ scripts/travis_install.sh | 8 -------- scripts/travis_install_test_suite.sh | 8 ++++++++ 5 files changed, 23 insertions(+), 26 deletions(-) delete mode 100755 scripts/travis_install.sh create mode 100755 scripts/travis_install_test_suite.sh diff --git a/.travis.yml b/.travis.yml index 42cca837c6..3e34bace7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,11 +28,8 @@ before_install: - ./scripts/travis_before_install.sh install: -- make setup -- ./scripts/travis_install.sh - -before_script: -- rm -rf mapnik-packaging/out/packages +- make config.gypi +- ./scripts/travis_install_test_suite.sh script: - ./scripts/travis_script.sh diff --git a/Makefile b/Makefile index a9c24ffdb3..2e740f38ee 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,13 @@ BUILDTYPE ?= Release PYTHON ?= python V ?= 1 -all: setup +all: mbgl -setup: config.gypi +config.gypi: + ./configure -xlibs: - @./mapnik-packaging/osx/darwin_configure.sh osx - -ilibs: - MASON_PLATFORM=ios ./configure +config-ios.gypi: + MASON_PLATFORM=ios ./configure config-ios.gypi # Builds the regular library mbgl: config.gypi mapboxgl.gyp node @@ -74,14 +72,14 @@ clear_xcode_cache: fi # build Mac OS X project for Xcode -xproj-cli: config.gypi xlibs macosx/mapboxgl-app.gyp clear_xcode_cache node +xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache node deps/run_gyp macosx/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode -iproj-cli: ilibs config.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node +iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode iproj: iproj-cli @@ -98,12 +96,10 @@ lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node clean: clear_xcode_cache -find ./deps/gyp -name "*.pyc" -exec rm {} \; -rm -rf ./build/ - -rm -rf ./config.gypi + -rm -rf ./config.gypi ./config-ios.gypi distclean: clean - -rm -rf ./mapnik-packaging/osx/out/build-* - -rm -rf ./mapnik-packaging/osx/out/universal - -find ./mapnik-packaging/osx/out/packages -type d ! -name 'packages' -maxdepth 1 -exec rm -rf {} \; + -rm -rf ./mason_packages .PHONY: mbgl test linux build/test/Makefile # DO NOT DELETE diff --git a/configure b/configure index dc32be1356..e943690513 100755 --- a/configure +++ b/configure @@ -3,6 +3,8 @@ set -e set -o pipefail +CONFIG_FILE=${1:-config.gypi} + . ~/.nvm/nvm.sh nvm use 0.10 @@ -30,11 +32,13 @@ if [ -z "${BOOST_ROOT}" ]; then BOOST_ROOT='/usr' else >&2 echo -e "\033[1m\033[31mCannot find Boost\033[0m"; + exit 1 fi fi if [ ! -d "${BOOST_ROOT}/include/boost" ]; then >&2 echo -e "\033[1m\033[31mCannot find Boost at ${BOOST_ROOT}\033[0m"; + exit 1 else >&2 echo -e "\033[1m\033[32m* Using Boost installation at ${BOOST_ROOT}\033[0m"; fi diff --git a/scripts/travis_install.sh b/scripts/travis_install.sh deleted file mode 100755 index eca24e719c..0000000000 --- a/scripts/travis_install.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then - # - # we'll need the test suite on Linux - # - npm install git+https://github.com/mapbox/mapbox-gl-test-suite.git -fi diff --git a/scripts/travis_install_test_suite.sh b/scripts/travis_install_test_suite.sh new file mode 100755 index 0000000000..eca24e719c --- /dev/null +++ b/scripts/travis_install_test_suite.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + # + # we'll need the test suite on Linux + # + npm install git+https://github.com/mapbox/mapbox-gl-test-suite.git +fi -- cgit v1.2.1 From e98b3e5d86f4108075e8814155ed9b684f99439c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 13:04:22 +0200 Subject: install nvm and node [skip ci] --- configure | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure b/configure index e943690513..3e26c7e428 100755 --- a/configure +++ b/configure @@ -5,8 +5,18 @@ set -o pipefail CONFIG_FILE=${1:-config.gypi} +# Install node +if [[ ! -d ~/.nvm ]]; then + git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm +fi +set +u . ~/.nvm/nvm.sh -nvm use 0.10 +if [ ! `nvm use 0.10 > /dev/null; echo $?` = 0 ]; then + >&2 echo -e "\033[1m\033[32m* $(nvm install 0.10)\033[0m"; +else + >&2 echo -e "\033[1m\033[32m* $(nvm use 0.10)\033[0m"; +fi + case $MASON_PLATFORM in 'ios') -- cgit v1.2.1 From dddd1c275ce01244efef3d591e0efde449d648b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 15:45:27 +0200 Subject: add libraries and make configure script more robust [skip ci] --- .travis.yml | 1 + configure | 80 ++++++++++++++++++++++------------------ scripts/travis_before_install.sh | 7 +++- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e34bace7b..058d4e8c74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ env: before_install: - source ./scripts/flags.sh +- (git clone https://github.com/mapbox/mason.git ~/.mason ; sudo ln -s ~/.mason/mason /usr/local/bin/mason) - ./scripts/travis_before_install.sh install: diff --git a/configure b/configure index 3e26c7e428..2dc78dfc37 100755 --- a/configure +++ b/configure @@ -5,6 +5,11 @@ set -o pipefail CONFIG_FILE=${1:-config.gypi} +function finish { + >&2 echo -en "\033[0m"; +} +trap finish EXIT + # Install node if [[ ! -d ~/.nvm ]]; then git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm @@ -12,9 +17,13 @@ fi set +u . ~/.nvm/nvm.sh if [ ! `nvm use 0.10 > /dev/null; echo $?` = 0 ]; then - >&2 echo -e "\033[1m\033[32m* $(nvm install 0.10)\033[0m"; + >&2 echo -en "\033[1m\033[32m* " + nvm install 0.10 + >&2 echo -en "\033[0m"; else - >&2 echo -e "\033[1m\033[32m* $(nvm use 0.10)\033[0m"; + >&2 echo -en "\033[1m\033[32m* " + nvm use 0.10 + >&2 echo -en "\033[0m"; fi @@ -24,6 +33,7 @@ case $MASON_PLATFORM in LIBPNG_VERSION=1.6.13 LIBUV_VERSION=0.10.28 ZLIB_VERSION=system + BOOST_VERSION=system ;; *) GLFW_VERSION=a21f2377 @@ -32,30 +42,26 @@ case $MASON_PLATFORM in LIBCURL_VERSION=system LIBUV_VERSION=0.10.28 ZLIB_VERSION=system + BOOST_VERSION=system ;; esac -if [ -z "${BOOST_ROOT}" ]; then - if [ -d '/usr/local/include/boost' ]; then - BOOST_ROOT='/usr/local' - elif [ -d '/usr/include/boost' ]; then - BOOST_ROOT='/usr' - else - >&2 echo -e "\033[1m\033[31mCannot find Boost\033[0m"; - exit 1 - fi -fi +function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } -if [ ! -d "${BOOST_ROOT}/include/boost" ]; then - >&2 echo -e "\033[1m\033[31mCannot find Boost at ${BOOST_ROOT}\033[0m"; - exit 1 -else - >&2 echo -e "\033[1m\033[32m* Using Boost installation at ${BOOST_ROOT}\033[0m"; -fi +NODE=`which node || abort 'Cannot find node'` +NPM=`which npm || abort 'Cannot find npm'` +PYTHON=`which python || abort 'Cannot find python'` +>&2 echo -en "\033[1m\033[32m* Using npm " +>&2 ${NPM} --version +>&2 echo -en "\033[0m"; + +>&2 echo -en "\033[1m\033[32m* Using " +>&2 ${PYTHON} --version +>&2 echo -en "\033[0m"; function quote_flags { - python -c "import sys, re; print re.split('(? Date: Tue, 21 Oct 2014 06:57:44 -0700 Subject: use ppa for more recent boost --- scripts/flags.sh | 3 ++- scripts/travis_before_install.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/flags.sh b/scripts/flags.sh index 58aee18a04..c3c36a6404 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -6,7 +6,8 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # use g++ that supports c++11 if [[ ${CXX} == "g++" ]]; then - export CXX="g++-4.8" ; + export CXX="g++-4.8" + export CXX="gcc-4.8" fi # If building in debug then turn on sanitizers. diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index a77aa703e3..31315dce38 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -10,11 +10,12 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then if [[ `lsb_release -r` =~ "12.04" ]]; then sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test fi + sudo add-apt-repository --yes ppa:boost-latest/ppa sudo apt-get update -y sudo apt-get -y install gcc-4.8 g++-4.8 sudo apt-get -y install git build-essential zlib1g-dev automake \ libtool xutils-dev make cmake pkg-config python-pip \ - libboost-dev libboost-regex-dev libcurl4-openssl-dev \ + libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \ libpng-dev libsqlite3-dev sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev \ x11proto-xext-dev libxrandr-dev \ -- cgit v1.2.1 From b6a42afe7e0eb77c7f8a4a79a9fdf81b0603f2f1 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 21 Oct 2014 11:44:23 -0700 Subject: correctly set CC --- scripts/flags.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flags.sh b/scripts/flags.sh index c3c36a6404..b1de8f3c71 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -7,7 +7,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # use g++ that supports c++11 if [[ ${CXX} == "g++" ]]; then export CXX="g++-4.8" - export CXX="gcc-4.8" + export CC="gcc-4.8" fi # If building in debug then turn on sanitizers. -- cgit v1.2.1 From 3a39d69504c3a8d87015908424e4ee199ef0c215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 17:02:07 +0200 Subject: link boost when the boost variable is set --- configure | 2 +- include/mbgl/text/collision.hpp | 1 + include/mbgl/util/uv-worker.h | 3 +-- src/storage/file_request_baton.cpp | 6 ++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 2dc78dfc37..4416299213 100755 --- a/configure +++ b/configure @@ -81,7 +81,7 @@ CONFIG="# Do not edit. Generated by the configure script. 'python': '${PYTHON}', " -if [ ! -z ${LIBCURL_VERSION} ]; then +if [ ! -z ${BOOST_VERSION} ]; then mason install boost ${BOOST_VERSION} CONFIG+=" 'boost_root': '$(mason prefix boost ${BOOST_VERSION})',"$LN fi diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp index 8eec30f216..b7ee6b4520 100644 --- a/include/mbgl/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -5,6 +5,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wunused-variable" #ifdef __clang__ #pragma GCC diagnostic ignored "-Wdeprecated-register" #else diff --git a/include/mbgl/util/uv-worker.h b/include/mbgl/util/uv-worker.h index 451b6fb04d..cb2075d1c3 100644 --- a/include/mbgl/util/uv-worker.h +++ b/include/mbgl/util/uv-worker.h @@ -5,8 +5,7 @@ extern "C" { #endif -typedef struct uv_messenger_s uv_messenger_t; - +#include #include #include diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index d4c135fd71..64c6c13b12 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -58,8 +58,7 @@ void FileRequestBaton::file_opened(uv_fs_t *req) { uv_fs_close(req->loop, req, fd, file_closed); } else { ptr->fd = fd; - const int r = uv_fs_fstat(req->loop, req, fd, file_stated); - assert(r == 0); + uv_fs_fstat(req->loop, req, fd, file_stated); } } } @@ -135,8 +134,7 @@ void FileRequestBaton::file_read(uv_fs_t *req) { } void FileRequestBaton::file_closed(uv_fs_t *req) { - FileRequestBaton *ptr = (FileRequestBaton *)req->data; - assert(ptr->thread_id == uv_thread_self()); + assert(((FileRequestBaton *)req->data)->thread_id == uv_thread_self()); if (req->result < 0) { // Closing the file failed. But there isn't anything we can do. -- cgit v1.2.1 From b9d422ebc3d48ff91e8f2eda071a0596ada36233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 21 Oct 2014 17:02:22 +0200 Subject: use glfw3 libs instead of manually linking OpenGL frameworks on OS X [skip ci] --- test/test.gyp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.gyp b/test/test.gyp index fd7725bb03..bd13ad7fd2 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -12,12 +12,12 @@ ['OS == "mac"', { 'link_settings': { 'libraries': [ - '-framework OpenGL', + '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW ], }, 'xcode_settings': { 'OTHER_LDFLAGS': [ - '-framework OpenGL', + '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW ], }, }, { -- cgit v1.2.1 From 2f3952b30541d5bbb3579c39a36052c02b47b37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 10:45:42 +0200 Subject: fix compile warnings --- include/mbgl/platform/event.hpp | 6 ++++-- include/mbgl/platform/log.hpp | 2 +- macosx/main.mm | 2 +- src/util/compression.cpp | 4 ++-- src/util/parsedate.c | 2 +- test/fixtures/fixture_request.cpp | 14 ++++++++++---- test/headless.cpp | 16 ++++++++-------- test/test.gyp | 32 -------------------------------- 8 files changed, 27 insertions(+), 51 deletions(-) diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp index d2a06618a3..0405cddfad 100644 --- a/include/mbgl/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -57,11 +57,13 @@ struct EventPermutation { } }; -constexpr EventSeverity disabledEventSeverities[] = { #if !DEBUG +constexpr EventSeverity disabledEventSeverities[] = { EventSeverity::Debug, -#endif }; +#else +constexpr EventSeverity *disabledEventSeverities = nullptr; +#endif constexpr Event disabledEvents[] = { diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp index dc000b4d52..bcb6d79224 100644 --- a/include/mbgl/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -21,7 +21,7 @@ class Log { private: template constexpr static bool includes(const T e, T const *l, const size_t i = 0) { - return i >= sizeof l ? false : *(l + i) == e ? true : includes(e, l, i + 1); + return l == nullptr ? false : i >= sizeof l ? false : *(l + i) == e ? true : includes(e, l, i + 1); } public: diff --git a/macosx/main.mm b/macosx/main.mm index aeb49225cb..8cf3cc81c3 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -85,7 +85,7 @@ int main() { // Notify map object when network reachability status changes. Reachability* reachability = [Reachability reachabilityForInternetConnection]; - reachability.reachableBlock = ^(Reachability *reachability) { + reachability.reachableBlock = ^(Reachability *) { map_ptr->setReachability(true); }; [reachability startNotifier]; diff --git a/src/util/compression.cpp b/src/util/compression.cpp index de4e09764c..d6d6370546 100644 --- a/src/util/compression.cpp +++ b/src/util/compression.cpp @@ -18,7 +18,7 @@ std::string compress(const std::string &raw) { } deflate_stream.next_in = (Bytef *)raw.data(); - deflate_stream.avail_in = raw.size(); + deflate_stream.avail_in = uInt(raw.size()); std::string result; char out[16384]; @@ -53,7 +53,7 @@ std::string decompress(const std::string &raw) { } inflate_stream.next_in = (Bytef *)raw.data(); - inflate_stream.avail_in = raw.size(); + inflate_stream.avail_in = uInt(raw.size()); std::string result; char out[15384]; diff --git a/src/util/parsedate.c b/src/util/parsedate.c index 123c5c4e5f..f888def853 100644 --- a/src/util/parsedate.c +++ b/src/util/parsedate.c @@ -208,7 +208,7 @@ int raw_equal(const char *first, const char *second) int clamp_to_int(long slnum) { - return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : slnum; + return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : (int)slnum; } diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 3f72b890db..9d2971c73e 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -35,11 +35,17 @@ void HTTPRequestBaton::start(const util::ptr &baton) { const size_t size = ftell(file); fseek(file, 0, SEEK_SET); baton->response->data.resize(size); - fread(&baton->response->data[0], size, 1, file); + const size_t read = fread(&baton->response->data[0], 1, size, file); fclose(file); - baton->response->code = 200; - baton->type = HTTPResponseType::Successful; + if (read == size) { + baton->response->code = 200; + baton->type = HTTPResponseType::Successful; + } else { + baton->response->code = 500; + baton->type = HTTPResponseType::PermanentError; + baton->response->message = "Read bytes differed from file size"; + } } else { baton->type = HTTPResponseType::PermanentError; baton->response->code = 404; @@ -48,7 +54,7 @@ void HTTPRequestBaton::start(const util::ptr &baton) { uv_async_send(baton->async); } -void HTTPRequestBaton::stop(const util::ptr &baton) { +void HTTPRequestBaton::stop(const util::ptr &) { fprintf(stderr, "HTTP request cannot be canceled because it is answered immediately"); abort(); } diff --git a/test/headless.cpp b/test/headless.cpp index 3cc2607e47..3255cff062 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -35,8 +35,8 @@ TEST_P(HeadlessTest, render) { // Parse style. rapidjson::Document styleDoc; styleDoc.Parse<0>((const char *const)style.c_str()); - ASSERT_EQ(false, styleDoc.HasParseError()); - ASSERT_EQ(true, styleDoc.IsObject()); + ASSERT_FALSE(styleDoc.HasParseError()); + ASSERT_TRUE(styleDoc.IsObject()); rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); @@ -46,16 +46,16 @@ TEST_P(HeadlessTest, render) { // Parse settings. rapidjson::Document infoDoc; infoDoc.Parse<0>((const char *const)info.c_str()); - ASSERT_EQ(false, infoDoc.HasParseError()); - ASSERT_EQ(true, infoDoc.IsObject()); + ASSERT_FALSE(infoDoc.HasParseError()); + ASSERT_TRUE(infoDoc.IsObject()); Log::Set(); for (auto it = infoDoc.MemberBegin(), end = infoDoc.MemberEnd(); it != end; it++) { const std::string name { it->name.GetString(), it->name.GetStringLength() }; const rapidjson::Value &value = it->value; - ASSERT_EQ(true, value.IsObject()); - if (value.HasMember("center")) ASSERT_EQ(true, value["center"].IsArray()); + ASSERT_TRUE(value.IsObject()); + if (value.HasMember("center")) ASSERT_TRUE(value["center"].IsArray()); const std::string actual_image = base_directory + "tests/" + base + "/" + name + "/actual.png"; @@ -70,10 +70,10 @@ TEST_P(HeadlessTest, render) { std::vector classes; if (value.HasMember("classes")) { const rapidjson::Value &js_classes = value["classes"]; - ASSERT_EQ(true, js_classes.IsArray()); + ASSERT_TRUE(js_classes.IsArray()); for (rapidjson::SizeType i = 0; i < js_classes.Size(); i++) { const rapidjson::Value &js_class = js_classes[i]; - ASSERT_EQ(true, js_class.IsString()); + ASSERT_TRUE(js_class.IsString()); classes.push_back({ js_class.GetString(), js_class.GetStringLength() }); } } diff --git a/test/test.gyp b/test/test.gyp index bd13ad7fd2..1f63756e71 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -10,11 +10,6 @@ 'direct_dependent_settings': { 'conditions': [ ['OS == "mac"', { - 'link_settings': { - 'libraries': [ - '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW - ], - }, 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW @@ -62,9 +57,6 @@ "target_name": "rotation_range", "product_name": "test_rotation_range", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./rotation_range.cpp", @@ -78,9 +70,6 @@ "target_name": "clip_ids", "product_name": "test_clip_ids", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./clip_ids.cpp", @@ -94,9 +83,6 @@ "target_name": "enums", "product_name": "test_enums", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./enums.cpp", @@ -110,9 +96,6 @@ "target_name": "style_parser", "product_name": "test_style_parser", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./style_parser.cpp", @@ -129,9 +112,6 @@ "target_name": "variant", "product_name": "test_variant", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./variant.cpp", @@ -145,9 +125,6 @@ "target_name": "comparisons", "product_name": "test_comparisons", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./comparisons.cpp", @@ -161,9 +138,6 @@ "target_name": "tile", "product_name": "test_tile", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./tile.cpp", @@ -177,9 +151,6 @@ "target_name": "functions", "product_name": "test_functions", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./functions.cpp", @@ -193,9 +164,6 @@ "target_name": "headless", "product_name": "test_headless", "type": "executable", - "libraries": [ - "-lpthread", - ], "sources": [ "./main.cpp", "./headless.cpp", -- cgit v1.2.1 From 326af8a332d45cc7f68c1c493b6c530c039d079b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 10:46:15 +0200 Subject: install boost on osx --- scripts/travis_before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index 31315dce38..59bd15d3ba 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -26,6 +26,6 @@ elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # # install OS X dependencies # - brew install autoconf automake libtool makedepend cmake pkg-config node git + brew install autoconf automake libtool makedepend cmake pkg-config node git boost sudo pip install awscli fi -- cgit v1.2.1 From 159130a058a3051dacecf0e956bc1113874dfabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 10:59:38 +0200 Subject: silence warning; GCC needs this parameter, but Clang says its unused --- src/util/uv-messenger.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/uv-messenger.c b/src/util/uv-messenger.c index cb3c3ca99b..82df1cae75 100644 --- a/src/util/uv-messenger.c +++ b/src/util/uv-messenger.c @@ -10,7 +10,10 @@ typedef struct { #if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" void uv__messenger_callback(uv_async_t *async, int status) { +#pragma clang diagnostic pop #else void uv__messenger_callback(uv_async_t *async) { #endif -- cgit v1.2.1 From baa684eb9861d83c350a4acbc58d00568817b0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 11:18:48 +0200 Subject: make gyp generate newer project files patch from https://groups.google.com/forum/#!msg/gyp-developer/0JiSNtsKc30/xYxQFqRfrTcJ --- deps/gyp/pylib/gyp/generator/xcode.py | 6 +++++- deps/gyp/pylib/gyp/xcodeproj_file.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deps/gyp/pylib/gyp/generator/xcode.py b/deps/gyp/pylib/gyp/generator/xcode.py index 7972459363..a6faa4c063 100644 --- a/deps/gyp/pylib/gyp/generator/xcode.py +++ b/deps/gyp/pylib/gyp/generator/xcode.py @@ -604,7 +604,11 @@ def GenerateOutput(target_list, target_dicts, data, params): if parallel_builds: pbxp.SetProperty('attributes', - {'BuildIndependentTargetsInParallel': 'YES'}) + { + 'BuildIndependentTargetsInParallel': 'YES', + 'LastUpgradeCheck': '0500' + } + ) if project_version: xcp.project_file.SetXcodeVersion(project_version) diff --git a/deps/gyp/pylib/gyp/xcodeproj_file.py b/deps/gyp/pylib/gyp/xcodeproj_file.py index 79c3abcf02..fc40fcb2db 100644 --- a/deps/gyp/pylib/gyp/xcodeproj_file.py +++ b/deps/gyp/pylib/gyp/xcodeproj_file.py @@ -2158,6 +2158,7 @@ class XCTarget(XCRemoteObject): if configs.HasBuildSetting('PRODUCT_NAME') == 0: configs.SetBuildSetting('PRODUCT_NAME', self._properties['productName']) + configs.SetBuildSetting('COMBINE_HIDPI_IMAGES', 'YES') def AddDependency(self, other): pbxproject = self.PBXProjectAncestor() @@ -2811,7 +2812,7 @@ class XCProjectFile(XCObject): _schema.update({ 'archiveVersion': [0, int, 0, 1, 1], 'classes': [0, dict, 0, 1, {}], - 'objectVersion': [0, int, 0, 1, 45], + 'objectVersion': [0, int, 0, 1, 46], 'rootObject': [0, PBXProject, 1, 1], }) -- cgit v1.2.1 From 13c698fa26eaa91cc9310aac52ee5c45cf3f60f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 11:55:34 +0200 Subject: fix more xcode upgrade warnings --- deps/gyp/pylib/gyp/generator/xcode.py | 6 ++++++ mapboxgl.gyp | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deps/gyp/pylib/gyp/generator/xcode.py b/deps/gyp/pylib/gyp/generator/xcode.py index a6faa4c063..783dafa0b0 100644 --- a/deps/gyp/pylib/gyp/generator/xcode.py +++ b/deps/gyp/pylib/gyp/generator/xcode.py @@ -31,6 +31,10 @@ _intermediate_var = 'INTERMEDIATE_DIR' # targets that share the same BUILT_PRODUCTS_DIR. _shared_intermediate_var = 'SHARED_INTERMEDIATE_DIR' +# ONLY_ACTIVE_ARCH means that only the active architecture should be build for +# Debugging purposes to shorten the build time +_only_active_arch = 'ONLY_ACTIVE_ARCH' + _library_search_paths_var = 'LIBRARY_SEARCH_PATHS' generator_default_variables = { @@ -168,6 +172,8 @@ class XcodeProject(object): xccl.SetBuildSetting(_shared_intermediate_var, '$(SYMROOT)/DerivedSources/$(CONFIGURATION)') + xccl.ConfigurationNamed('Debug').SetBuildSetting(_only_active_arch, 'YES') + # Set user-specified project-wide build settings and config files. This # is intended to be used very sparingly. Really, almost everything should # go into target-specific build settings sections. The project-wide diff --git a/mapboxgl.gyp b/mapboxgl.gyp index d0356194d5..339e819fa0 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -210,8 +210,7 @@ ], 'xcode_settings': { 'SDKROOT': 'iphoneos', - 'SUPPORTED_PLATFORMS': ['iphonesimulator','iphoneos'], - 'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ], + 'SUPPORTED_PLATFORMS': 'iphonesimulator iphoneos', 'TARGETED_DEVICE_FAMILY': '1,2', 'CODE_SIGN_IDENTITY': 'iPhone Developer', 'IPHONEOS_DEPLOYMENT_TARGET': '7.0', -- cgit v1.2.1 From 2dbe9edb06abfa7a0127344c6f5bb616b6654160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 12:01:04 +0200 Subject: write to correct file and add to gitignore --- .gitignore | 3 ++- configure | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 23dbb0f8f7..04eb4ad884 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,11 @@ *.actual.png *.diff.png /node_modules -/mapnik-packaging +/mason_packages /macosx/build /ios/build /config.gypi +/config-ios.gypi /config/constants_local.cpp /build /bin/node_modules diff --git a/configure b/configure index 4416299213..2fffd59206 100755 --- a/configure +++ b/configure @@ -126,6 +126,6 @@ CONFIG+=" } } " -echo "${CONFIG}" > config.gypi +echo "${CONFIG}" > ${CONFIG_FILE} -cat config.gypi +cat ${CONFIG_FILE} -- cgit v1.2.1 From 8df906e2bcc6eed8968b37068317f7bfb1ab33f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 12:40:30 +0200 Subject: use correct configuration file --- Makefile | 16 ++++++++-------- mapboxgl.gyp | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 2e740f38ee..c74a328068 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ config-ios.gypi: # Builds the regular library mbgl: config.gypi mapboxgl.gyp node - deps/run_gyp mapboxgl.gyp --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl node: @@ -21,7 +21,7 @@ node: ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp - deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make + deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/test -f make test: build/test/Makefile $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test @@ -32,7 +32,7 @@ test_%: build/test/Makefile # build Mac OS X project for Xcode xtest: config.gypi clear_xcode_cache node - deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build -f xcode + deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode open ./build/test/test.xcodeproj ##### Makefile builds ########################################################## @@ -40,7 +40,7 @@ xtest: config.gypi clear_xcode_cache node # Builds the linux app with make. linux: config.gypi linux/mapboxgl-app.gyp node - deps/run_gyp linux/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp # Executes the Linux binary @@ -51,7 +51,7 @@ run-linux: linux # Builds the OS X app with make. osx: config.gypi macosx/mapboxgl-app.gyp node - deps/run_gyp macosx/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp # Executes the OS X binary @@ -73,21 +73,21 @@ clear_xcode_cache: # build Mac OS X project for Xcode xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache node - deps/run_gyp macosx/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node - deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi --depth=. --generator-output=./build -f xcode iproj: iproj-cli open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node - deps/run_gyp linux/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode open ./build/linux/mapboxgl-app.xcodeproj diff --git a/mapboxgl.gyp b/mapboxgl.gyp index 339e819fa0..a0ad3212d4 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -1,7 +1,6 @@ { 'includes': [ './common.gypi', - './config.gypi', ], 'targets': [ { -- cgit v1.2.1 From 5d6748f8fee0fe9d7aa0da0d9ff26de1c8044815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 12:41:10 +0200 Subject: fix compile warnings in libtess2 --- src/libtess2/bucketalloc.c | 2 +- src/libtess2/priorityq.c | 8 ++++---- src/libtess2/sweep.c | 3 +++ src/libtess2/tess.c | 14 +++----------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/libtess2/bucketalloc.c b/src/libtess2/bucketalloc.c index ce64e579e7..df1a83c76c 100755 --- a/src/libtess2/bucketalloc.c +++ b/src/libtess2/bucketalloc.c @@ -59,7 +59,7 @@ struct BucketAlloc static int CreateBucket( struct BucketAlloc* ba ) { - size_t size; + unsigned int size; Bucket* bucket; void* freelist; unsigned char* head; diff --git a/src/libtess2/priorityq.c b/src/libtess2/priorityq.c index 2af5f347b9..49e1c012f5 100755 --- a/src/libtess2/priorityq.c +++ b/src/libtess2/priorityq.c @@ -209,13 +209,13 @@ PQhandle pqHeapInsert( TESSalloc* alloc, PriorityQHeap *pq, PQkey keyNew ) // If the heap overflows, double its size. pq->max <<= 1; pq->nodes = (PQnode *)alloc->memrealloc( alloc->userData, pq->nodes, - (size_t)((pq->max + 1) * sizeof( pq->nodes[0] ))); + (unsigned int)((pq->max + 1) * sizeof( pq->nodes[0] ))); if (pq->nodes == NULL) { pq->nodes = saveNodes; // restore ptr to free upon return return INV_HANDLE; } pq->handles = (PQhandleElem *)alloc->memrealloc( alloc->userData, pq->handles, - (size_t) ((pq->max + 1) * sizeof( pq->handles[0] ))); + (unsigned int) ((pq->max + 1) * sizeof( pq->handles[0] ))); if (pq->handles == NULL) { pq->handles = saveHandles; // restore ptr to free upon return return INV_HANDLE; @@ -351,7 +351,7 @@ int pqInit( TESSalloc* alloc, PriorityQ *pq ) (pq->size * sizeof(pq->order[0])) ); */ pq->order = (PQkey **)alloc->memalloc( alloc->userData, - (size_t)((pq->size+1) * sizeof(pq->order[0])) ); + (unsigned int)((pq->size+1) * sizeof(pq->order[0])) ); /* the previous line is a patch to compensate for the fact that IBM */ /* machines return a null on a malloc of zero bytes (unlike SGI), */ /* so we have to put in this defense to guard against a memory */ @@ -438,7 +438,7 @@ PQhandle pqInsert( TESSalloc* alloc, PriorityQ *pq, PQkey keyNew ) // If the heap overflows, double its size. pq->max <<= 1; pq->keys = (PQkey *)alloc->memrealloc( alloc->userData, pq->keys, - (size_t)(pq->max * sizeof( pq->keys[0] ))); + (unsigned int)(pq->max * sizeof( pq->keys[0] ))); if (pq->keys == NULL) { pq->keys = saveKey; // restore ptr to free upon return return INV_HANDLE; diff --git a/src/libtess2/sweep.c b/src/libtess2/sweep.c index 0204d3e8a3..49559fa124 100755 --- a/src/libtess2/sweep.c +++ b/src/libtess2/sweep.c @@ -428,9 +428,12 @@ static void VertexWeights( TESSvertex *isect, TESSvertex *org, TESSvertex *dst, } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" static void GetIntersectData( TESStesselator *tess, TESSvertex *isect, TESSvertex *orgUp, TESSvertex *dstUp, TESSvertex *orgLo, TESSvertex *dstLo ) +#pragma GCC diagnostic pop /* * We've computed a new intersection point, now we need a "data" pointer * from the user so that we can refer to this new vertex in the diff --git a/src/libtess2/tess.c b/src/libtess2/tess.c index ad71478375..80c5b70f41 100755 --- a/src/libtess2/tess.c +++ b/src/libtess2/tess.c @@ -46,17 +46,6 @@ #define Dot(u,v) (u[0]*v[0] + u[1]*v[1] + u[2]*v[2]) -static void Normalize( TESSreal v[3] ) -{ - TESSreal len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - - assert( len > 0 ); - len = sqrtf( len ); - v[0] /= len; - v[1] /= len; - v[2] /= len; -} - #define ABS(x) ((x) < 0 ? -(x) : (x)) static int LongAxis( TESSreal v[3] ) @@ -436,6 +425,8 @@ int tessMeshSetWindingNumber( TESSmesh *mesh, int value, return 1; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" void* heapAlloc( void* userData, unsigned int size ) { return malloc( size ); @@ -450,6 +441,7 @@ void heapFree( void* userData, void* ptr ) { free( ptr ); } +#pragma GCC diagnostic pop static TESSalloc defaulAlloc = { -- cgit v1.2.1 From fd5b07d353bbf4b108eb986a3066304a12411ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 12:45:42 +0200 Subject: don't pass on boost path; it's unneeded --- mapboxgl.gyp | 2 -- 1 file changed, 2 deletions(-) diff --git a/mapboxgl.gyp b/mapboxgl.gyp index a0ad3212d4..bdecb94d06 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -165,7 +165,6 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '<@(uv_cflags)', - '-I<(boost_root)/include', ], 'OTHER_LDFLAGS': [ '<@(png_libraries)', @@ -177,7 +176,6 @@ }, { 'cflags': [ '<@(uv_cflags)', - '-I<(boost_root)/include', ], 'libraries': [ '<@(png_libraries)', -- cgit v1.2.1 From 352bd095d46d09e7d47bcb52874f23c4bd8faa51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 04:17:43 -0700 Subject: GCC doesn't like #pragmas between the function declaration and definition --- src/libtess2/sweep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtess2/sweep.c b/src/libtess2/sweep.c index 49559fa124..be3ee561ce 100755 --- a/src/libtess2/sweep.c +++ b/src/libtess2/sweep.c @@ -433,7 +433,6 @@ static void VertexWeights( TESSvertex *isect, TESSvertex *org, TESSvertex *dst, static void GetIntersectData( TESStesselator *tess, TESSvertex *isect, TESSvertex *orgUp, TESSvertex *dstUp, TESSvertex *orgLo, TESSvertex *dstLo ) -#pragma GCC diagnostic pop /* * We've computed a new intersection point, now we need a "data" pointer * from the user so that we can refer to this new vertex in the @@ -447,6 +446,7 @@ static void GetIntersectData( TESStesselator *tess, TESSvertex *isect, VertexWeights( isect, orgUp, dstUp, &weights[0] ); VertexWeights( isect, orgLo, dstLo, &weights[2] ); } +#pragma GCC diagnostic pop static int CheckForRightSplice( TESStesselator *tess, ActiveRegion *regUp ) /* -- cgit v1.2.1 From f701fb340fb01e0561ca77559473bc4aa09dc6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 04:18:05 -0700 Subject: GCC doesn't like {} initialization --- src/style/function_properties.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/style/function_properties.cpp b/src/style/function_properties.cpp index 346efe65b6..69466c1f64 100644 --- a/src/style/function_properties.cpp +++ b/src/style/function_properties.cpp @@ -18,10 +18,10 @@ template T StopsFunction::evaluate(float z) const { bool smaller = false; float smaller_z = 0.0f; - T smaller_val {}; + T smaller_val = T(); bool larger = false; float larger_z = 0.0f; - T larger_val {}; + T larger_val = T(); for (uint32_t i = 0; i < values.size(); i++) { float stop_z = values[i].first; -- cgit v1.2.1 From c6e4cf2f80216c7139b6587dcd6d919080aef20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 04:20:35 -0700 Subject: use ASSERT_FALSE for boolean comparisons --- test/enums.cpp | 4 ++-- test/style_parser.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/enums.cpp b/test/enums.cpp index dce20ca592..67ff0aa7e8 100644 --- a/test/enums.cpp +++ b/test/enums.cpp @@ -31,7 +31,7 @@ TEST(Enums, StyleLayerType) { ASSERT_EQ(StyleLayerTypeClass(StyleLayerType::Raster), StyleLayerTypeClass(StyleLayerType::Raster)); ASSERT_EQ(StyleLayerTypeClass(StyleLayerType::Background), StyleLayerTypeClass(StyleLayerType::Background)); - ASSERT_EQ(false, StyleLayerTypeClass("").valid()); - ASSERT_EQ(false, StyleLayerTypeClass("Backgrund").valid()); + ASSERT_FALSE(StyleLayerTypeClass("").valid()); + ASSERT_FALSE(StyleLayerTypeClass("Backgrund").valid()); } diff --git a/test/style_parser.cpp b/test/style_parser.cpp index d530fe1f8b..fe237b7888 100644 --- a/test/style_parser.cpp +++ b/test/style_parser.cpp @@ -34,8 +34,8 @@ TEST_P(StyleParserTest, ParseStyle) { // Parse settings. rapidjson::Document doc; doc.Parse<0>((const char *const)info.c_str()); - ASSERT_EQ(false, doc.HasParseError()); - ASSERT_EQ(true, doc.IsObject()); + ASSERT_FALSE(doc.HasParseError()); + ASSERT_TRUE(doc.IsObject()); std::ifstream stylefile(style_path); ASSERT_TRUE(stylefile.good()); -- cgit v1.2.1 From 251fafe2bf6dff34868a4e32953adcb73cb20db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 15:05:33 +0200 Subject: don't check for node in the current bash. we are using our own anyway --- Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c74a328068..06b38ec34b 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,10 @@ config-ios.gypi: MASON_PLATFORM=ios ./configure config-ios.gypi # Builds the regular library -mbgl: config.gypi mapboxgl.gyp node +mbgl: config.gypi mapboxgl.gyp deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl -node: - @if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi; - ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp @@ -31,7 +28,7 @@ test_%: build/test/Makefile (cd build/$(BUILDTYPE) && exec ./test_$*) # build Mac OS X project for Xcode -xtest: config.gypi clear_xcode_cache node +xtest: config.gypi clear_xcode_cache deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode open ./build/test/test.xcodeproj @@ -39,7 +36,7 @@ xtest: config.gypi clear_xcode_cache node # Builds the linux app with make. -linux: config.gypi linux/mapboxgl-app.gyp node +linux: config.gypi linux/mapboxgl-app.gyp deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp @@ -50,7 +47,7 @@ run-linux: linux # Builds the OS X app with make. -osx: config.gypi macosx/mapboxgl-app.gyp node +osx: config.gypi macosx/mapboxgl-app.gyp deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp @@ -72,21 +69,21 @@ clear_xcode_cache: fi # build Mac OS X project for Xcode -xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache node +xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode -iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node +iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi --depth=. --generator-output=./build -f xcode iproj: iproj-cli open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) -lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node +lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode open ./build/linux/mapboxgl-app.xcodeproj -- cgit v1.2.1 From 02e88e445d9960c3b248ea95d03d4a191ef91289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 15:29:28 +0200 Subject: fixes for libuv 0.11 --- common/curl_request.cpp | 383 ------------------------------------- src/storage/file_request_baton.cpp | 1 - src/util/uv.cpp | 2 +- 3 files changed, 1 insertion(+), 385 deletions(-) delete mode 100644 common/curl_request.cpp diff --git a/common/curl_request.cpp b/common/curl_request.cpp deleted file mode 100644 index 3370c0a859..0000000000 --- a/common/curl_request.cpp +++ /dev/null @@ -1,383 +0,0 @@ - -#include -#include -#include -#include - -#include -#include - -#include - -// This file contains code from http://curl.haxx.se/libcurl/c/multi-uv.html: - -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* Example application code using the multi socket interface to download - multiple files at once, but instead of using curl_multi_perform and - curl_multi_wait, which uses select(), we use libuv. - It supports epoll, kqueue, etc. on unixes and fast IO completion ports on - Windows, which means, it should be very fast on all platforms.. - - Written by Clemens Gruber, based on an outdated example from uvbook and - some tests from libuv. - - Requires libuv and (of course) libcurl. - - See http://nikhilm.github.com/uvbook/ for more information on libuv. -*/ - -namespace mbgl { -namespace platform { -namespace request { - -struct curl_context { - uv_poll_t poll_handle; - curl_socket_t sockfd; -}; - -// Handles the request thread + messaging to the thread. -static uv_thread_t thread; -static uv::once init_thread_once; -static uv_loop_t *loop = nullptr; -static uv_async_t async_add; -static uv_async_t async_cancel; - -// Stores pointers (!) to shared_ptrs. We use shared_ptrs so that request objects don't get -// auto-destructed while they're in progress. The TileData object retains a weak_ptr to this -// request, so we have to use a shared_ptr here to ensure that this object stays alive. -static boost::lockfree::queue *> add_queue(8); -static boost::lockfree::queue *> cancel_queue(8); - -// Used as the CURL timer function to periodically check for socket updates. -static uv_timer_t timeout; - -// CURL multi handle that we use to request multiple URLs at the same time, without having to block -// and spawn threads. -static CURLM *curl_multi = nullptr; - -// CURL share handles are used for sharing session state (e.g.) -static uv::mutex curl_share_mutex; -static CURLSH *curl_share = nullptr; - -// A queue that we use for storing resuable CURL easy handles to avoid creating and destroying them -// all the time. -static std::queue curl_handle_cache; - - -class CURLRequest : public mbgl::platform::Request { -public: - CURLRequest(const std::string &url, - std::function callback, - std::shared_ptr loop) - : Request(url, callback, loop) {} - - CURL *curl = nullptr; -}; - - -// Implementation starts here. - -// Locks the CURL share handle -void curl_share_lock(CURL *, curl_lock_data, curl_lock_access, void *) { curl_share_mutex.lock(); } - -// Unlocks the CURL share handle -void curl_share_unlock(CURL *, curl_lock_data, void *) { curl_share_mutex.unlock(); } - -curl_context *create_curl_context(curl_socket_t sockfd) { - curl_context *context = new curl_context; - context->sockfd = sockfd; - - uv_poll_init_socket(loop, &context->poll_handle, sockfd); - context->poll_handle.data = context; - - return context; -} - -void curl_close_cb(uv_handle_t *handle) { - curl_context *context = (curl_context *)handle->data; - free(context); -} - -void destroy_curl_context(curl_context *context) { - uv_close((uv_handle_t *)&context->poll_handle, curl_close_cb); -} - -void remove_curl_handle(CURL *handle) { - CURLMcode error = curl_multi_remove_handle(curl_multi, handle); - if (error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(error)); - } - - curl_easy_reset(handle); - curl_handle_cache.push(handle); -} - -void curl_perform(uv_poll_t *req, int /*status*/, int events) { - int running_handles; - int flags = 0; - curl_context *context; - CURLMsg *message; - int pending; - - uv_timer_stop(&timeout); - - if (events & UV_READABLE) - flags |= CURL_CSELECT_IN; - if (events & UV_WRITABLE) - flags |= CURL_CSELECT_OUT; - - context = (curl_context *)req; - - curl_multi_socket_action(curl_multi, context->sockfd, flags, &running_handles); - - while ((message = curl_multi_info_read(curl_multi, &pending))) { - switch (message->msg) { - case CURLMSG_DONE: { - std::shared_ptr *req = nullptr; - curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, (char *)&req); - - // Add human-readable error code - if (message->data.result != CURLE_OK) { - (*req)->res->error_message = curl_easy_strerror(message->data.result); - (*req)->res->code = -1; - } else { - curl_easy_getinfo(message->easy_handle, CURLINFO_RESPONSE_CODE, &(*req)->res->code); - } - - // We're currently in the CURL request thread. We're going to schedule a uv_work request - // that executes the background function in a threadpool, and tell it to call the - // after callback back in the main uv loop. - (*req)->complete(); - - CURL *handle = message->easy_handle; - remove_curl_handle(handle); - - // We're setting this to NULL because there might still be shared_ptrs around that could - // be cancelled. - ((CURLRequest *)req->get())->curl = nullptr; - - // Delete the shared_ptr pointer we created earlier. - delete req; - break; - } - - default: - // This should never happen, because there are no other message types. - throw std::runtime_error("CURLMSG returned unknown message type"); - } - } -} - -int handle_socket(CURL * /*easy*/, curl_socket_t s, int action, void * /*userp*/, void *socketp) { - curl_context *context = nullptr; - - if (socketp) { - context = (curl_context *)socketp; - } else if (action != CURL_POLL_REMOVE) { - context = create_curl_context(s); - } - - if (context) { - curl_multi_assign(curl_multi, s, (void *)context); - if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) { - uv_poll_start(&context->poll_handle, UV_READABLE, curl_perform); - } - if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) { - uv_poll_start(&context->poll_handle, UV_WRITABLE, curl_perform); - } - if (action == CURL_POLL_REMOVE && socketp) { - uv_poll_stop(&context->poll_handle); - destroy_curl_context(context); - curl_multi_assign(curl_multi, s, NULL); - } - } - - return 0; -} - -void on_timeout(uv_timer_t *, int status /*req*/) { - int running_handles; - CURLMcode error = - curl_multi_socket_action(curl_multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); - if (error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(error)); - } -} - -void start_timeout(CURLM * /*multi*/, long timeout_ms, void * /*userp*/) { - if (timeout_ms <= 0) { - on_timeout(&timeout, -1); - } else { - uv_timer_start(&timeout, &on_timeout, timeout_ms, 0); - } -} - -// This function is the first function called in the request thread. It sets up the CURL share/multi -// handles and runs the thread loop. -void thread_init(void * /*ptr*/) { - uv_timer_init(loop, &timeout); - - CURLSHcode share_error; - curl_share = curl_share_init(); - - share_error = curl_share_setopt(curl_share, CURLSHOPT_LOCKFUNC, curl_share_lock); - if (share_error != CURLSHE_OK) { - throw std::runtime_error(std::string("CURL share error: ") + curl_share_strerror(share_error)); - } - - share_error = curl_share_setopt(curl_share, CURLSHOPT_UNLOCKFUNC, curl_share_unlock); - if (share_error != CURLSHE_OK) { - throw std::runtime_error(std::string("CURL share error: ") + curl_share_strerror(share_error)); - } - - CURLMcode multi_error; - curl_multi = curl_multi_init(); - - multi_error = curl_multi_setopt(curl_multi, CURLMOPT_SOCKETFUNCTION, handle_socket); - if (multi_error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(multi_error)); - } - multi_error = curl_multi_setopt(curl_multi, CURLMOPT_TIMERFUNCTION, start_timeout); - if (multi_error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(multi_error)); - - } - - // Main event loop. This will not return until the request loop is terminated. - uv_run(loop, UV_RUN_DEFAULT); - - curl_multi_cleanup(curl_multi); - curl_multi = nullptr; - curl_share_cleanup(curl_share); - curl_share = nullptr; - - // Clean up all the CURL easy handles that we kept around for potential future reuse. - while (!curl_handle_cache.empty()) { - curl_easy_cleanup(curl_handle_cache.front()); - curl_handle_cache.pop(); - } -} - -// This function is called when we have new data for a request. We just append it to the string -// containing the previous data. -size_t curl_write_cb(void *contents, size_t size, size_t nmemb, void *userp) { - ((std::string *)userp)->append((char *)contents, size * nmemb); - return size * nmemb; -} - -// This callback is called in the request event loop (on the request thread). -// It initializes newly queued up download requests and adds them to the CURL -// multi handle. -void async_add_cb(uv_async_t *, int status /*async*/) { - std::shared_ptr *req = nullptr; - while (add_queue.pop(req)) { - // Make sure that we're not starting requests that have been cancelled - // already by async_cancel_cb. - if ((*req)->cancelled) { - delete req; - continue; - } - - // Obtain a curl handle (and try to reuse existing handles before creating new ones). - CURL *handle = nullptr; - if (!curl_handle_cache.empty()) { - handle = curl_handle_cache.front(); - curl_handle_cache.pop(); - } else { - handle = curl_easy_init(); - } - - ((CURLRequest *)req->get())->curl = handle; - - curl_easy_setopt(handle, CURLOPT_PRIVATE, req); - curl_easy_setopt(handle, CURLOPT_CAINFO, "ca-bundle.crt"); - curl_easy_setopt(handle, CURLOPT_URL, (*req)->url.c_str()); - curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curl_write_cb); - curl_easy_setopt(handle, CURLOPT_WRITEDATA, &(*req)->res->body); - curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "gzip, deflate"); - curl_easy_setopt(handle, CURLOPT_SHARE, curl_share); - curl_multi_add_handle(curl_multi, handle); - } -} - -void async_cancel_cb(uv_async_t *, int status /*async*/) { - std::shared_ptr *req = nullptr; - while (cancel_queue.pop(req)) { - // It is possible that the request has not yet been started, but that it already has been - // added to the queue for scheduling new requests. In this case, the CURL handle is invalid - // and we manually mark the Request as cancelled. - CURL *handle = ((CURLRequest *)req->get())->curl; - if (handle && !(*req)->cancelled) { - remove_curl_handle(handle); - ((CURLRequest *)req->get())->curl = nullptr; - } - (*req)->cancelled = true; - - delete req; - req = nullptr; - } -} - -void thread_init_cb() { - curl_global_init(CURL_GLOBAL_ALL); - - loop = uv_loop_new(); - uv_async_init(loop, &async_add, &async_add_cb); - uv_async_init(loop, &async_cancel, &async_cancel_cb); - uv_thread_create(&thread, thread_init, nullptr); -} -} // end namespace request -} // end namespace platform - - -std::shared_ptr -platform::request_http(const std::string &url, - std::function callback, - std::shared_ptr loop) { - using namespace request; - init_thread_once(thread_init_cb); - std::shared_ptr req = std::make_shared(url, callback, loop); - - // Note that we are creating a new shared_ptr pointer(!) because the lockless queue can't store - // objects with nontrivial destructors. We have to make absolutely sure that we manually delete - // the shared_ptr when we pop it from the queue. - add_queue.push(new std::shared_ptr(req)); - uv_async_send(&async_add); - - return req; -} - -// Cancels an HTTP request. -void platform::cancel_request_http(const std::shared_ptr &req) { - if (req) { - using namespace request; - - // Note that we are creating a new shared_ptr pointer(!) because the lockless queue can't - // store objects with nontrivial destructors. We have to make absolutely shure that we - // manually delete the shared_ptr when we pop it from the queue. - cancel_queue.push(new std::shared_ptr(req)); - uv_async_send(&async_cancel); - } -} -} // end namespace mbgl diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index e54b743c43..aafed82d55 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -83,7 +83,6 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { if (stat->st_size > std::numeric_limits::max()) { // File is too large for us to open this way because uv_buf's only support unsigned // ints as maximum size. - const uv_err_t error = {UV_EFBIG, 0}; if (ptr->request) { ptr->request->response = std::unique_ptr(new Response); ptr->request->response->code = UV_EFBIG; diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 1e51d3dbb6..03a885d308 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -15,7 +15,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), max); + uv_cwd(const_cast(dir.data()), &max); } while (max == dir.size()); dir.resize(max - 1); return dir; -- cgit v1.2.1 From 2422e938ac87f5790c4977d93e667c95e695f76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 15:50:54 +0200 Subject: fix typo --- scripts/travis_before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index d445ae8174..1ecfc4f26b 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -24,7 +24,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \ libpng-dev libsqlite3-dev - apbox_time "install_opengl" \ + mapbox_time "install_opengl" \ sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev \ x11proto-xext-dev libxrandr-dev \ x11proto-xf86vidmode-dev libxxf86vm-dev \ -- cgit v1.2.1 From 7d6feffd56cde7d6e5d9dd53b358f5afa8e4eb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:29:10 +0200 Subject: replace boost optional with mapbox optional --- include/mbgl/text/types.hpp | 7 ++--- include/mbgl/util/optional.hpp | 69 ++++++++++++++++++++++++++++++++++++++++++ include/mbgl/util/variant.hpp | 20 +++--------- test/fixtures/fixture_log.hpp | 17 +++++------ test/variant.cpp | 7 ----- 5 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 include/mbgl/util/optional.hpp diff --git a/include/mbgl/text/types.hpp b/include/mbgl/text/types.hpp index dbb483ea8f..1d21ded2a5 100644 --- a/include/mbgl/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -3,11 +3,10 @@ #include #include +#include #include #include -#include - namespace mbgl { typedef vec2 CollisionPoint; @@ -53,7 +52,7 @@ struct GlyphBox { float minScale = 0.0f; float maxScale = std::numeric_limits::infinity(); float padding = 0.0f; - boost::optional hBox; + mapbox::util::optional hBox; }; typedef std::vector GlyphBoxes; @@ -88,7 +87,7 @@ typedef std::vector PlacedGlyphs; struct PlacementBox { CollisionAnchor anchor; CollisionRect box; - boost::optional hBox; + mapbox::util::optional hBox; PlacementRange placementRange = {{0.0f, 0.0f}}; float placementScale = 0.0f; float maxScale = std::numeric_limits::infinity(); diff --git a/include/mbgl/util/optional.hpp b/include/mbgl/util/optional.hpp new file mode 100644 index 0000000000..133e2c8f97 --- /dev/null +++ b/include/mbgl/util/optional.hpp @@ -0,0 +1,69 @@ +#ifndef MAPBOX_UTIL_OPTIONAL_HPP +#define MAPBOX_UTIL_OPTIONAL_HPP + +#include + +#include "variant.hpp" + +namespace mapbox +{ +namespace util +{ + +template class optional +{ + static_assert(!std::is_reference::value, "optional doesn't support references"); + + struct none_type + { + }; + + variant variant_; + + public: + optional() = default; + + optional(optional const &rhs) + { + if (this != &rhs) + { // protect against invalid self-assignment + variant_ = rhs.variant_; + } + } + + optional(T const &v) { variant_ = v; } + + explicit operator bool() const noexcept { return variant_.template is(); } + + T const &get() const { return variant_.template get(); } + T &get() { return variant_.template get(); } + + T const &operator*() const { return this->get(); } + T operator*() { return this->get(); } + + optional &operator=(T const &v) + { + variant_ = v; + return *this; + } + + optional &operator=(optional const &rhs) + { + if (this != &rhs) + { + variant_ = rhs.variant_; + } + return *this; + } + + template void emplace(Args &&... args) + { + variant_ = T{std::forward(args)...}; + } + + void reset() { variant_ = none_type{}; } +}; +} +} + +#endif diff --git a/include/mbgl/util/variant.hpp b/include/mbgl/util/variant.hpp index 1eca5160c7..3b5659425a 100644 --- a/include/mbgl/util/variant.hpp +++ b/include/mbgl/util/variant.hpp @@ -4,7 +4,6 @@ #include #include #include -#include // std::move/swap #include // runtime_error #include // operator new #include // size_t @@ -515,22 +514,13 @@ public: VARIANT_INLINE variant(no_init) : type_index(detail::invalid_value) {} + // http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers template ::value>::type> - VARIANT_INLINE explicit variant(T const& val) noexcept - : type_index(detail::value_traits::index) - { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; - using target_type = typename detail::select_type::type; - new (&data) target_type(val); - } - - template ::value>::type> + detail::is_valid_type::type, Types...>::value>::type> VARIANT_INLINE variant(T && val) noexcept - : type_index(detail::value_traits::index) + : type_index(detail::value_traits::type, Types...>::index) { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; + constexpr std::size_t index = sizeof...(Types) - detail::value_traits::type, Types...>::index - 1; using target_type = typename detail::select_type::type; new (&data) target_type(std::forward(val)); // nothrow } @@ -565,7 +555,7 @@ public: template VARIANT_INLINE variant& operator=(T && rhs) noexcept { - variant temp(std::move(rhs)); + variant temp(std::forward(rhs)); swap(*this, temp); return *this; } diff --git a/test/fixtures/fixture_log.hpp b/test/fixtures/fixture_log.hpp index 263871575b..dc92f93198 100644 --- a/test/fixtures/fixture_log.hpp +++ b/test/fixtures/fixture_log.hpp @@ -3,8 +3,7 @@ #include #include - -#include +#include #include #include @@ -17,11 +16,11 @@ public: inline LogMessage(EventSeverity severity, Event event, int64_t code, const std::string &msg) : severity(severity), event(event), code(code), msg(msg) {} inline LogMessage(EventSeverity severity, Event event, int64_t code) - : severity(severity), event(event), code(code) {} + : severity(severity), event(event), code(code), msg() {} inline LogMessage(EventSeverity severity, Event event, const std::string &msg) - : severity(severity), event(event), msg(msg) {} + : severity(severity), event(event), code(), msg(msg) {} inline LogMessage(EventSeverity severity, Event event) - : severity(severity), event(event) {} + : severity(severity), event(event), code(), msg() {} inline bool operator==(const LogMessage &rhs) const { return (!severity || !rhs.severity || severity.get() == rhs.severity.get()) && @@ -30,10 +29,10 @@ public: (!msg || !rhs.msg || msg.get() == rhs.msg.get()); } - const boost::optional severity; - const boost::optional event; - const boost::optional code; - const boost::optional msg; + const mapbox::util::optional severity; + const mapbox::util::optional event; + const mapbox::util::optional code; + const mapbox::util::optional msg; mutable bool checked = false; }; diff --git a/test/variant.cpp b/test/variant.cpp index dd4578b49d..4557465cfa 100644 --- a/test/variant.cpp +++ b/test/variant.cpp @@ -4,13 +4,6 @@ #include #include -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#endif -#include -#pragma GCC diagnostic pop - using namespace mbgl; TEST(Variant, toString) { -- cgit v1.2.1 From 20ea7ef104eab469cb88edab0d580b5b56e94560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:30:06 +0200 Subject: remove erroneous output during test run --- test/enums.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/enums.cpp b/test/enums.cpp index 67ff0aa7e8..b45fc0ed0d 100644 --- a/test/enums.cpp +++ b/test/enums.cpp @@ -8,8 +8,6 @@ using namespace mbgl; TEST(Enums, StyleLayerType) { - std::cerr << StyleLayerType::Raster; - ASSERT_EQ(StyleLayerType::Unknown, StyleLayerTypeClass("unknown")); ASSERT_EQ(StyleLayerType::Fill, StyleLayerTypeClass("fill")); ASSERT_EQ(StyleLayerType::Line, StyleLayerTypeClass("line")); -- cgit v1.2.1 From 74387c54e35e0f8f6bf1dcc7b7b171a3ec6db212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:37:59 +0200 Subject: add missing include header --- src/storage/file_request_baton.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index aafed82d55..1b41a53706 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -2,6 +2,8 @@ #include #include +#include + namespace mbgl { FileRequestBaton::FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop) -- cgit v1.2.1 From 214f99673f6f7480f9cc3bf9d6fa32ef8dd2ede5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 18:06:11 +0200 Subject: fix variable shadowing --- Makefile | 2 +- common/glfw_view.cpp | 2 +- include/csscolorparser/csscolorparser.hpp | 4 +-- include/mbgl/geometry/anchor.hpp | 8 ++--- include/mbgl/geometry/elements_buffer.hpp | 6 ++-- include/mbgl/geometry/geometry.hpp | 4 +-- include/mbgl/geometry/glyph_atlas.hpp | 4 +-- include/mbgl/map/tile.hpp | 4 +-- include/mbgl/map/view.hpp | 4 +-- include/mbgl/renderer/frame_history.hpp | 2 +- include/mbgl/renderer/painter.hpp | 8 ++--- include/mbgl/style/class_properties.hpp | 4 +-- include/mbgl/style/filter_comparison.hpp | 6 ++-- include/mbgl/style/filter_expression.hpp | 2 +- include/mbgl/style/function_properties.hpp | 6 ++-- include/mbgl/style/style_source.hpp | 4 +-- include/mbgl/text/collision.hpp | 1 + include/mbgl/text/glyph.hpp | 10 +++--- include/mbgl/text/types.hpp | 56 +++++++++++++++--------------- include/mbgl/util/enum.hpp | 8 ++--- include/mbgl/util/error.hpp | 2 +- include/mbgl/util/pbf.hpp | 6 ++-- include/mbgl/util/rect.hpp | 2 +- include/mbgl/util/transition.hpp | 20 +++++------ include/mbgl/util/uv_detail.hpp | 16 ++++----- include/mbgl/util/vec.hpp | 6 ++-- src/clipper/clipper.cpp | 2 +- src/geometry/debug_font.cpp | 8 ++--- src/geometry/glyph_atlas.cpp | 10 +++--- src/geometry/sprite_atlas.cpp | 12 +++---- src/map/map.cpp | 9 ++--- src/map/source.cpp | 10 +++--- src/map/sprite.cpp | 28 +++++++-------- src/map/tile.cpp | 4 +-- src/map/tile_data.cpp | 10 +++--- src/map/tile_parser.cpp | 4 +-- src/map/transform.cpp | 2 +- src/map/transform_state.cpp | 4 +-- src/map/vector_tile.cpp | 12 +++---- src/renderer/debug_bucket.cpp | 4 +-- src/renderer/fill_bucket.cpp | 28 +++++++-------- src/renderer/line_bucket.cpp | 24 ++++++------- src/renderer/painter.cpp | 4 +-- src/renderer/prerendered_texture.cpp | 4 +-- src/renderer/raster_bucket.cpp | 10 +++--- src/renderer/symbol_bucket.cpp | 14 ++++---- src/shader/shader.cpp | 4 +-- src/storage/http_request.cpp | 14 ++++---- src/storage/sqlite_store.cpp | 4 +-- src/style/applied_class_properties.cpp | 8 ++--- src/style/style_layer.cpp | 18 +++++----- src/style/style_parser.cpp | 14 ++++---- src/text/collision.cpp | 6 ++-- src/text/glyph_store.cpp | 2 +- src/text/placement.cpp | 8 ++--- src/util/image.cpp | 8 ++--- src/util/raster.cpp | 30 ++++++++-------- src/util/timer.cpp | 20 +++++------ test/comparisons.cpp | 2 +- test/fixtures/fixture_log.hpp | 16 ++++----- 60 files changed, 276 insertions(+), 278 deletions(-) diff --git a/Makefile b/Makefile index 06b38ec34b..95a7d90f34 100644 --- a/Makefile +++ b/Makefile @@ -98,5 +98,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl test linux build/test/Makefile +.PHONY: mbgl test linux build/test/Makefile clean distclean # DO NOT DELETE diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 120faf4df1..53cd068d09 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -2,7 +2,7 @@ #include -GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) { +GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) { #ifdef NVIDIA glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC)glfwGetProcAddress("glDiscardFramebufferEXT"); #endif diff --git a/include/csscolorparser/csscolorparser.hpp b/include/csscolorparser/csscolorparser.hpp index 1d074627f6..6caf796943 100644 --- a/include/csscolorparser/csscolorparser.hpp +++ b/include/csscolorparser/csscolorparser.hpp @@ -31,8 +31,8 @@ namespace CSSColorParser { struct Color { inline Color() {} - inline Color(unsigned char r, unsigned char g, unsigned char b, float a) - : r(r), g(g), b(b), a(a) {} + inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_) + : r(r_), g(g_), b(b_), a(a_) {} unsigned char r = 0, g = 0, b = 0; float a = 1.0f; }; diff --git a/include/mbgl/geometry/anchor.hpp b/include/mbgl/geometry/anchor.hpp index ab006530ff..d30394f0b9 100644 --- a/include/mbgl/geometry/anchor.hpp +++ b/include/mbgl/geometry/anchor.hpp @@ -12,10 +12,10 @@ struct Anchor { float scale = 0.0f; int segment = -1; - explicit Anchor(float x, float y, float angle, float scale) - : x(x), y(y), angle(angle), scale(scale) {} - explicit Anchor(float x, float y, float angle, float scale, int segment) - : x(x), y(y), angle(angle), scale(scale), segment(segment) {} + explicit Anchor(float x_, float y_, float angle_, float scale_) + : x(x_), y(y_), angle(angle_), scale(scale_) {} + explicit Anchor(float x_, float y_, float angle_, float scale_, int segment_) + : x(x_), y(y_), angle(angle_), scale(scale_), segment(segment_) {} }; typedef std::vector Anchors; diff --git a/include/mbgl/geometry/elements_buffer.hpp b/include/mbgl/geometry/elements_buffer.hpp index 56080e29fe..045560f9aa 100644 --- a/include/mbgl/geometry/elements_buffer.hpp +++ b/include/mbgl/geometry/elements_buffer.hpp @@ -16,9 +16,9 @@ struct ElementGroup : public util::noncopyable { uint32_t elements_length; ElementGroup() : vertex_length(0), elements_length(0) {} - ElementGroup(uint32_t vertex_length, uint32_t elements_length) - : vertex_length(vertex_length), - elements_length(elements_length) { + ElementGroup(uint32_t vertex_length_, uint32_t elements_length_) + : vertex_length(vertex_length_), + elements_length(elements_length_) { } ElementGroup(ElementGroup &&rhs) noexcept diff --git a/include/mbgl/geometry/geometry.hpp b/include/mbgl/geometry/geometry.hpp index 961569204d..484d17b36d 100644 --- a/include/mbgl/geometry/geometry.hpp +++ b/include/mbgl/geometry/geometry.hpp @@ -30,8 +30,8 @@ private: int32_t ox, oy; }; -Geometry::Geometry(pbf& data) - : data(data), +Geometry::Geometry(pbf& data_) + : data(data_), cmd(1), length(0), x(0), y(0), diff --git a/include/mbgl/geometry/glyph_atlas.hpp b/include/mbgl/geometry/glyph_atlas.hpp index 336c4af284..5b09cbcd6d 100644 --- a/include/mbgl/geometry/glyph_atlas.hpp +++ b/include/mbgl/geometry/glyph_atlas.hpp @@ -18,8 +18,8 @@ public: private: struct GlyphValue { - GlyphValue(const Rect& rect, uint64_t id) - : rect(rect), ids({ id }) {} + GlyphValue(const Rect& rect_, uint64_t id) + : rect(rect_), ids({ id }) {} Rect rect; std::set ids; }; diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index b9f0556add..1ae13dd79d 100644 --- a/include/mbgl/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -37,8 +37,8 @@ public: const int8_t z = 0; const int32_t x = 0, y = 0; - inline explicit ID(int8_t z, int32_t x, int32_t y) - : w((x < 0 ? x - (1 << z) + 1 : x) / (1 << z)), z(z), x(x), y(y) {} + inline explicit ID(int8_t z_, int32_t x_, int32_t y_) + : w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_) {} inline uint64_t to_uint64() const { return ((std::pow(2, z) * y + x) * 32) + z; diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index b567cd424f..513c73b483 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -22,8 +22,8 @@ enum MapChange : uint8_t { class View { public: - virtual void initialize(Map *map) { - this->map = map; + virtual void initialize(Map *map_) { + map = map_; } // Called from the render (=GL) thread. Signals that the context should diff --git a/include/mbgl/renderer/frame_history.hpp b/include/mbgl/renderer/frame_history.hpp index b1f0bcb597..61bb59da33 100644 --- a/include/mbgl/renderer/frame_history.hpp +++ b/include/mbgl/renderer/frame_history.hpp @@ -11,7 +11,7 @@ namespace mbgl { struct FrameSnapshot { - explicit inline FrameSnapshot(timestamp t, float z) : t(t), z(z) {} + explicit inline FrameSnapshot(timestamp t_, float z_) : t(t_), z(z_) {} float t; float z; }; diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 0f9bd79173..a8229a0978 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -154,10 +154,10 @@ public: // used to composite images and flips the geometry upside down const mat4 flipMatrix = []{ - mat4 flipMatrix; - matrix::ortho(flipMatrix, 0, 4096, -4096, 0, 0, 1); - matrix::translate(flipMatrix, flipMatrix, 0, -4096, 0); - return flipMatrix; + mat4 flip; + matrix::ortho(flip, 0, 4096, -4096, 0, 0, 1); + matrix::translate(flip, flip, 0, -4096, 0); + return flip; }(); const mat4 identityMatrix = []{ diff --git a/include/mbgl/style/class_properties.hpp b/include/mbgl/style/class_properties.hpp index 84b6f483bd..888a90c5d7 100644 --- a/include/mbgl/style/class_properties.hpp +++ b/include/mbgl/style/class_properties.hpp @@ -12,8 +12,8 @@ namespace mbgl { class ClassProperties { public: inline ClassProperties() {} - inline ClassProperties(ClassProperties &&properties) - : properties(std::move(properties.properties)) {} + inline ClassProperties(ClassProperties &&properties_) + : properties(std::move(properties_.properties)) {} inline void set(PropertyKey key, const PropertyValue &value) { properties.emplace(key, value); diff --git a/include/mbgl/style/filter_comparison.hpp b/include/mbgl/style/filter_comparison.hpp index bf48744f1e..1b0a9b5486 100644 --- a/include/mbgl/style/filter_comparison.hpp +++ b/include/mbgl/style/filter_comparison.hpp @@ -24,8 +24,8 @@ public: class Instance { public: - Instance(Operator op, std::vector &&values) - : op(op), values(values) {} + Instance(Operator op_, std::vector &&values_) + : op(op_), values(values_) {} bool compare(const std::vector &property_values) const; @@ -37,7 +37,7 @@ public: }; public: - FilterComparison(const std::string &field) : field(field) {}; + FilterComparison(const std::string &field_) : field(field_) {}; const std::string &getField() const; template inline bool compare(const Extractor &extractor) const; diff --git a/include/mbgl/style/filter_expression.hpp b/include/mbgl/style/filter_expression.hpp index 2a96578792..915d3931d1 100644 --- a/include/mbgl/style/filter_expression.hpp +++ b/include/mbgl/style/filter_expression.hpp @@ -28,7 +28,7 @@ public: public: FilterExpression() = default; - FilterExpression(Operator op) : op(op) {}; + FilterExpression(Operator op_) : op(op_) {}; bool empty() const; diff --git a/include/mbgl/style/function_properties.hpp b/include/mbgl/style/function_properties.hpp index 56092f9a63..924f192330 100644 --- a/include/mbgl/style/function_properties.hpp +++ b/include/mbgl/style/function_properties.hpp @@ -9,7 +9,7 @@ namespace mbgl { template struct ConstantFunction { - inline ConstantFunction(const T &value) : value(value) {} + inline ConstantFunction(const T &value_) : value(value_) {} inline T evaluate(float) const { return value; } private: @@ -18,7 +18,7 @@ private: template struct StopsFunction { - inline StopsFunction(const std::vector> &values, float base) : values(values), base(base) {} + inline StopsFunction(const std::vector> &values_, float base_) : values(values_), base(base_) {} T evaluate(float z) const; private: @@ -36,7 +36,7 @@ using Function = mapbox::util::variant< template struct FunctionEvaluator { typedef T result_type; - inline FunctionEvaluator(float z) : z(z) {} + inline FunctionEvaluator(float z_) : z(z_) {} inline result_type operator()(const std::false_type &) { return result_type(); diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp index 00c48431a1..86473079cf 100644 --- a/include/mbgl/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -36,8 +36,8 @@ public: bool enabled = false; util::ptr source; - StyleSource(const util::ptr &info) - : info(info) + StyleSource(const util::ptr &info_) + : info(info_) {} }; diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp index b7ee6b4520..dfefab689e 100644 --- a/include/mbgl/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -6,6 +6,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wshadow" #ifdef __clang__ #pragma GCC diagnostic ignored "-Wdeprecated-register" #else diff --git a/include/mbgl/text/glyph.hpp b/include/mbgl/text/glyph.hpp index de7f55bdc6..4fbb75fc1e 100644 --- a/include/mbgl/text/glyph.hpp +++ b/include/mbgl/text/glyph.hpp @@ -30,9 +30,9 @@ struct GlyphMetrics { struct Glyph { inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {} - inline explicit Glyph(const Rect &rect, - const GlyphMetrics &metrics) - : rect(rect), metrics(metrics) {} + inline explicit Glyph(const Rect &rect_, + const GlyphMetrics &metrics_) + : rect(rect_), metrics(metrics_) {} operator bool() const { return metrics || rect; @@ -46,8 +46,8 @@ typedef std::map GlyphPositions; class PositionedGlyph { public: - inline explicit PositionedGlyph(uint32_t glyph, float x, float y) - : glyph(glyph), x(x), y(y) {} + inline explicit PositionedGlyph(uint32_t glyph_, float x_, float y_) + : glyph(glyph_), x(x_), y(y_) {} uint32_t glyph = 0; float x = 0; diff --git a/include/mbgl/text/types.hpp b/include/mbgl/text/types.hpp index 1d21ded2a5..23f49aa748 100644 --- a/include/mbgl/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -28,24 +28,24 @@ struct CollisionRect { CollisionPoint::Type bx, CollisionPoint::Type by) : tl(ax, ay), br(bx, by) {} - inline explicit CollisionRect(const CollisionPoint &tl, - const CollisionPoint &br) - : tl(tl), br(br) {} + inline explicit CollisionRect(const CollisionPoint &tl_, + const CollisionPoint &br_) + : tl(tl_), br(br_) {} }; // These are the glyph boxes that we want to have placed. struct GlyphBox { explicit GlyphBox() {} - explicit GlyphBox(const CollisionRect &box, - const CollisionAnchor &anchor, - float minScale, - float maxScale, - float padding) - : box(box), anchor(anchor), minScale(minScale), maxScale(maxScale), padding(padding) {} - explicit GlyphBox(const CollisionRect &box, - float minScale, - float padding) - : box(box), minScale(minScale), padding(padding) {} + explicit GlyphBox(const CollisionRect &box_, + const CollisionAnchor &anchor_, + float minScale_, + float maxScale_, + float padding_) + : box(box_), anchor(anchor_), minScale(minScale_), maxScale(maxScale_), padding(padding_) {} + explicit GlyphBox(const CollisionRect &box_, + float minScale_, + float padding_) + : box(box_), minScale(minScale_), padding(padding_) {} CollisionRect box; CollisionAnchor anchor; @@ -60,19 +60,19 @@ typedef std::vector GlyphBoxes; // TODO: Transform the vec2s to vec2 to save bytes struct PlacedGlyph { - explicit PlacedGlyph(const vec2 &tl, const vec2 &tr, - const vec2 &bl, const vec2 &br, - const Rect &tex, float angle, const vec2 &anchor, - float minScale, float maxScale) - : tl(tl), - tr(tr), - bl(bl), - br(br), - tex(tex), - angle(angle), - anchor(anchor), - minScale(minScale), - maxScale(maxScale) {} + explicit PlacedGlyph(const vec2 &tl_, const vec2 &tr_, + const vec2 &bl_, const vec2 &br_, + const Rect &tex_, float angle_, const vec2 &anchor_, + float minScale_, float maxScale_) + : tl(tl_), + tr(tr_), + bl(bl_), + br(br_), + tex(tex_), + angle(angle_), + anchor(anchor_), + minScale(minScale_), + maxScale(maxScale_) {} vec2 tl, tr, bl, br; Rect tex; @@ -96,8 +96,8 @@ struct PlacementBox { struct PlacementProperty { explicit PlacementProperty() {} - explicit PlacementProperty(float zoom, const PlacementRange &rotationRange) - : zoom(zoom), rotationRange(rotationRange) {} + explicit PlacementProperty(float zoom_, const PlacementRange &rotationRange_) + : zoom(zoom_), rotationRange(rotationRange_) {} inline operator bool() const { return !std::isnan(zoom) && zoom != std::numeric_limits::infinity() && diff --git a/include/mbgl/util/enum.hpp b/include/mbgl/util/enum.hpp index 195aaab5a5..3c3e4a5c4e 100644 --- a/include/mbgl/util/enum.hpp +++ b/include/mbgl/util/enum.hpp @@ -21,11 +21,11 @@ private: static constexpr inline bool compare(const char *a, const char *b) { return *a == *b && (*a == '\0' || compare(a + 1, b + 1)); } - static constexpr inline const char *lookup_type(Type e, EnumValue const * const l, size_t r) { - return r == 0 ? "" : l->value == e ? l->name : lookup_type(e, l + 1, r - 1); + static constexpr inline const char *lookup_type(Type e, EnumValue const * const list, size_t r) { + return r == 0 ? "" : list->value == e ? list->name : lookup_type(e, list + 1, r - 1); } - static constexpr inline Type lookup_name(const char *n, EnumValue const * const l, size_t r) { - return r == 0 ? Type(-1) : compare(l->name, n) ? l->value : lookup_name(n, l + 1, r - 1); + static constexpr inline Type lookup_name(const char *n, EnumValue const * const list, size_t r) { + return r == 0 ? Type(-1) : compare(list->name, n) ? list->value : lookup_name(n, list + 1, r - 1); } public: inline constexpr Enum(const char *n) : value(lookup_name(n, names, length)) {} diff --git a/include/mbgl/util/error.hpp b/include/mbgl/util/error.hpp index 99e27f770c..09fa8d3e21 100644 --- a/include/mbgl/util/error.hpp +++ b/include/mbgl/util/error.hpp @@ -8,7 +8,7 @@ namespace mbgl { namespace error { struct style_parse : std::exception { - inline style_parse(size_t offset, const char *msg) : offset(offset), msg(msg) {} + inline style_parse(size_t offset_, const char *msg_) : offset(offset_), msg(msg_) {} inline const char* what() const noexcept { return msg.c_str(); } const size_t offset; const std::string msg; diff --git a/include/mbgl/util/pbf.hpp b/include/mbgl/util/pbf.hpp index 1f78a0072f..ab4d60cd37 100644 --- a/include/mbgl/util/pbf.hpp +++ b/include/mbgl/util/pbf.hpp @@ -49,9 +49,9 @@ struct pbf { uint32_t tag = 0; }; -pbf::pbf(const unsigned char *data, size_t length) - : data(data), - end(data + length), +pbf::pbf(const unsigned char *data_, size_t length) + : data(data_), + end(data_ + length), value(0), tag(0) { } diff --git a/include/mbgl/util/rect.hpp b/include/mbgl/util/rect.hpp index dedd4afc94..f5c77f93d1 100644 --- a/include/mbgl/util/rect.hpp +++ b/include/mbgl/util/rect.hpp @@ -6,7 +6,7 @@ namespace mbgl { template struct Rect { inline Rect() {} - inline Rect(T x, T y, T w, T h) : x(x), y(y), w(w), h(h) {} + inline Rect(T x_, T y_, T w_, T h_) : x(x_), y(y_), w(w_), h(h_) {} T x = 0, y = 0; T w = 0, h = 0; diff --git a/include/mbgl/util/transition.hpp b/include/mbgl/util/transition.hpp index 8a6836c885..16adc41ceb 100644 --- a/include/mbgl/util/transition.hpp +++ b/include/mbgl/util/transition.hpp @@ -15,9 +15,9 @@ public: complete }; - inline transition(timestamp start, timestamp duration) - : start(start), - duration(duration) {} + inline transition(timestamp start_, timestamp duration_) + : start(start_), + duration(duration_) {} inline float progress(timestamp now) const { if (duration == 0) return 1; @@ -36,11 +36,11 @@ protected: template class ease_transition : public transition { public: - ease_transition(T from, T to, T& value, timestamp start, timestamp duration) + ease_transition(T from_, T to_, T& value_, timestamp start, timestamp duration) : transition(start, duration), - from(from), - to(to), - value(value) {} + from(from_), + to(to_), + value(value_) {} state update(timestamp now) const; @@ -53,10 +53,10 @@ private: template class timeout : public transition { public: - timeout(T final_value, T& value, timestamp start, timestamp duration) + timeout(T final_value_, T& value_, timestamp start, timestamp duration) : transition(start, duration), - final_value(final_value), - value(value) {} + final_value(final_value_), + value(value_) {} state update(timestamp now) const { if (progress(now) >= 1) { diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index f80ca1bff5..b4b41f31af 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -68,7 +68,7 @@ private: class lock { public: - lock(mutex &mtx) : mtx(mtx) { mtx.lock(); } + lock(mutex &mtx_) : mtx(mtx_) { mtx.lock(); } ~lock() { mtx.unlock(); } private: @@ -94,8 +94,8 @@ private: class readlock { public: - inline readlock(rwlock &mtx) : mtx(mtx) { mtx.rdlock(); } - inline readlock(const std::unique_ptr &mtx) : mtx(*mtx) { mtx->rdlock(); } + inline readlock(rwlock &mtx_) : mtx(mtx_) { mtx.rdlock(); } + inline readlock(const std::unique_ptr &mtx_) : mtx(*mtx_) { mtx.rdlock(); } inline ~readlock() { mtx.rdunlock(); } private: @@ -104,8 +104,8 @@ private: class writelock { public: - inline writelock(rwlock &mtx) : mtx(mtx) { mtx.wrlock(); } - inline writelock(const std::unique_ptr &mtx) : mtx(*mtx) { mtx->wrlock(); } + inline writelock(rwlock &mtx_) : mtx(mtx_) { mtx.wrlock(); } + inline writelock(const std::unique_ptr &mtx_) : mtx(*mtx_) { mtx.wrlock(); } inline ~writelock() { mtx.wrunlock(); } private: @@ -148,10 +148,10 @@ public: typedef void (*after_work_callback)(T &object); template - work(worker &worker, work_callback work_cb, after_work_callback after_work_cb, Args&&... args) + work(worker &worker, work_callback work_cb_, after_work_callback after_work_cb_, Args&&... args) : data(std::forward(args)...), - work_cb(work_cb), - after_work_cb(after_work_cb) { + work_cb(work_cb_), + after_work_cb(after_work_cb_) { worker.add(this, do_work, after_work); } diff --git a/include/mbgl/util/vec.hpp b/include/mbgl/util/vec.hpp index a5fbee477b..0179254fda 100644 --- a/include/mbgl/util/vec.hpp +++ b/include/mbgl/util/vec.hpp @@ -29,7 +29,7 @@ struct vec2 { template inline vec2(const U& u) : x(u.x), y(u.y) {} - inline vec2(T x, T y) : x(x), y(y) {} + inline vec2(T x_, T y_) : x(x_), y(y_) {} inline bool operator==(const vec2& rhs) const { return x == rhs.x && y == rhs.y; @@ -86,7 +86,7 @@ struct vec3 { inline vec3() {} inline vec3(const vec3& o) : x(o.x), y(o.y), z(o.z) {} - inline vec3(T x, T y, T z) : x(x), y(y), z(z) {} + inline vec3(T x_, T y_, T z_) : x(x_), y(y_), z(z_) {} inline bool operator==(const vec3& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } @@ -98,7 +98,7 @@ struct vec4 { inline vec4() {} inline vec4(const vec4& o) : x(o.x), y(o.y), z(o.z), w(o.w) {} - inline vec4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {} + inline vec4(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) {} inline bool operator==(const vec4& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; } diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 56ad58416d..7571ae1439 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -3242,7 +3242,7 @@ void Clipper::BuildResult(Paths &polys) int cnt = PointCount(p); if (cnt < 2) continue; pg.reserve(cnt); - for (int i = 0; i < cnt; ++i) + for (int j = 0; j < cnt; ++j) { pg.push_back(p->Pt); p = p->Prev; diff --git a/src/geometry/debug_font.cpp b/src/geometry/debug_font.cpp index 2da0c67841..8ee9f6811f 100644 --- a/src/geometry/debug_font.cpp +++ b/src/geometry/debug_font.cpp @@ -98,10 +98,10 @@ const int8_t simplex_94[] = { 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16 struct glyph { glyph() : width(0), length(0), data(nullptr) { } - glyph(uint8_t width, uint8_t length, const int8_t *data) - : width(width), - length(length), - data(data) {} + glyph(uint8_t width_, uint8_t length_, const int8_t *data_) + : width(width_), + length(length_), + data(data_) {} uint8_t width; uint8_t length; const int8_t *data; diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index 76df941d90..6bee475da3 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -9,11 +9,11 @@ using namespace mbgl; -GlyphAtlas::GlyphAtlas(uint16_t width, uint16_t height) - : width(width), - height(height), - bin(width, height), - data(new char[width *height]), +GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) + : width(width_), + height(height_), + bin(width_, height_), + data(new char[width_ *height_]), dirty(true) { } diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 7ea9d4ce7d..10922790c0 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -14,10 +14,10 @@ using namespace mbgl; -SpriteAtlas::SpriteAtlas(dimension width, dimension height) - : width(width), - height(height), - bin(width, height), +SpriteAtlas::SpriteAtlas(dimension width_, dimension height_) + : width(width_), + height(height_), + bin(width_, height_), dirty(true) { } @@ -88,10 +88,10 @@ void copy_bitmap(const uint32_t *src, const int src_stride, const int src_x, con } } -Rect SpriteAtlas::allocateImage(size_t width, size_t height) { +Rect SpriteAtlas::allocateImage(size_t pixel_width, size_t pixel_height) { // We have to allocate a new area in the bin, and store an empty image in it. // Add a 1px border around every image. - Rect rect = bin.allocate(width + 2 * buffer, height + 2 * buffer); + Rect rect = bin.allocate(pixel_width + 2 * buffer, pixel_height + 2 * buffer); if (rect.w == 0) { return rect; } diff --git a/src/map/map.cpp b/src/map/map.cpp index 451385d3d5..a7520b2517 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -30,17 +30,17 @@ using namespace mbgl; -Map::Map(View& view) +Map::Map(View& view_) : loop(std::make_shared()), thread(std::make_unique()), async_terminate(new uv_async_t()), async_render(new uv_async_t()), async_cleanup(new uv_async_t()), - view(view), + view(view_), #ifndef NDEBUG main_thread(uv_thread_self()), #endif - transform(view), + transform(view_), glyphAtlas(std::make_shared(1024, 1024)), spriteAtlas(std::make_shared(512, 512)), texturepool(std::make_shared()), @@ -653,9 +653,6 @@ void Map::prepare() { void Map::render() { view.make_active(); -#if defined(DEBUG) - std::vector debug; -#endif painter.clear(); painter.resize(); diff --git a/src/map/source.cpp b/src/map/source.cpp index 36f1a71c84..ca1f3d5323 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -20,8 +20,8 @@ namespace mbgl { -Source::Source(const util::ptr& info) - : info(info) +Source::Source(const util::ptr& info_) + : info(info_) { } @@ -219,15 +219,15 @@ std::forward_list Source::coveringTiles(const TransformState& state) c box points = state.cornersToBox(z); const vec2& center = points.center; - std::forward_list tiles = Tile::cover(z, points); + std::forward_list covering_tiles = Tile::cover(z, points); - tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { + covering_tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { // Sorts by distance from the box center return std::fabs(a.x - center.x) + std::fabs(a.y - center.y) < std::fabs(b.x - center.x) + std::fabs(b.y - center.y); }); - return tiles; + return covering_tiles; } /** diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index c069ece45a..876586e4b0 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -13,13 +13,13 @@ using namespace mbgl; -SpritePosition::SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio, bool sdf) - : x(x), - y(y), - width(width), - height(height), - pixelRatio(pixelRatio), - sdf(sdf) { +SpritePosition::SpritePosition(uint16_t x_, uint16_t y_, uint16_t width_, uint16_t height_, float pixelRatio_, bool sdf_) + : x(x_), + y(y_), + width(width_), + height(height_), + pixelRatio(pixelRatio_), + sdf(sdf_) { } util::ptr Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr &fileSource) { @@ -28,11 +28,11 @@ util::ptr Sprite::Create(const std::string& base_url, float pixelRatio, return sprite; } -Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio) +Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio_) : valid(base_url.length() > 0), - pixelRatio(pixelRatio), - spriteURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".png"), - jsonURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".json"), + pixelRatio(pixelRatio_), + spriteURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".png"), + jsonURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".json"), raster(), loadedImage(false), loadedJSON(false), @@ -123,16 +123,16 @@ void Sprite::parseJSON() { uint16_t y = 0; uint16_t width = 0; uint16_t height = 0; - float pixelRatio = 1.0f; + float spritePixelRatio = 1.0f; bool sdf = false; if (value.HasMember("x")) x = value["x"].GetInt(); if (value.HasMember("y")) y = value["y"].GetInt(); if (value.HasMember("width")) width = value["width"].GetInt(); if (value.HasMember("height")) height = value["height"].GetInt(); - if (value.HasMember("pixelRatio")) pixelRatio = value["pixelRatio"].GetInt(); + if (value.HasMember("pixelRatio")) spritePixelRatio = value["pixelRatio"].GetInt(); if (value.HasMember("sdf")) sdf = value["sdf"].GetBool(); - pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio, sdf }); + pos.emplace(name, SpritePosition { x, y, width, height, spritePixelRatio, sdf }); } } } else { diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 863fbfbece..1fe0faefde 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -7,8 +7,8 @@ using namespace mbgl; #include -Tile::Tile(const ID& id) - : id(id) { +Tile::Tile(const ID& id_) + : id(id_) { } Tile::ID Tile::ID::parent(int8_t parent_z) const { diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 44e3826bf5..7e4d1a1de1 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -9,14 +9,14 @@ using namespace mbgl; -TileData::TileData(Tile::ID id, Map &map, const util::ptr &source) - : id(id), +TileData::TileData(Tile::ID id_, Map &map_, const util::ptr &source_) + : id(id_), state(State::initial), - map(map), - source(source), + map(map_), + source(source_), debugBucket(debugFontBuffer) { // Initialize tile debug coordinates - const std::string str = util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y); + const std::string str = util::sprintf<32>("%d/%d/%d", id_.z, id_.x, id_.y); debugFontBuffer.addText(str.c_str(), 50, 200, 5); } diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 3dc5cb9cef..235151cd47 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -37,14 +37,14 @@ namespace mbgl { // its header file. TileParser::~TileParser() = default; -TileParser::TileParser(const std::string &data, VectorTileData &tile, +TileParser::TileParser(const std::string &data, VectorTileData &tile_, const util::ptr &style_, const util::ptr &glyphAtlas_, const util::ptr &glyphStore_, const util::ptr &spriteAtlas_, const util::ptr &sprite_) : vector_data(pbf((const uint8_t *)data.data(), data.size())), - tile(tile), + tile(tile_), style(style_), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), diff --git a/src/map/transform.cpp b/src/map/transform.cpp index baa615b94a..b42f24a83d 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -17,7 +17,7 @@ const double R2D = 180.0 / M_PI; const double M2PI = 2 * M_PI; const double MIN_ROTATE_SCALE = 8; -Transform::Transform(View &view) : view(view), mtx(std::make_unique()) { +Transform::Transform(View &view_) : view(view_), mtx(std::make_unique()) { setScale(current.scale); setAngle(current.angle); } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index 4b1bc4161e..fa521400c3 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -96,8 +96,8 @@ float TransformState::lngX(float lon) const { } float TransformState::latY(float lat) const { - float y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); - return (180 - y) * worldSize() / 360; + float latY = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - latY) * worldSize() / 360; } std::array TransformState::locationCoordinate(float lon, float lat) const { diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index 4ec25d6cf6..8f097c8292 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -103,9 +103,9 @@ VectorTileLayer::VectorTileLayer(pbf layer) : data(layer) { } } -FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer, const FilterExpression &filterExpression) - : layer(layer), - filterExpression(filterExpression) { +FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer_, const FilterExpression &filterExpression_) + : layer(layer_), + filterExpression(filterExpression_) { } FilteredVectorTileLayer::iterator FilteredVectorTileLayer::begin() const { @@ -116,10 +116,10 @@ FilteredVectorTileLayer::iterator FilteredVectorTileLayer::end() const { return iterator(*this, pbf(layer.data.end, 0)); } -FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent, const pbf& data) - : parent(parent), +FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent_, const pbf& data_) + : parent(parent_), feature(pbf()), - data(data) { + data(data_) { operator++(); } diff --git a/src/renderer/debug_bucket.cpp b/src/renderer/debug_bucket.cpp index 699c1c1db9..58fbf8a35b 100644 --- a/src/renderer/debug_bucket.cpp +++ b/src/renderer/debug_bucket.cpp @@ -10,8 +10,8 @@ struct geometry_too_long_exception : std::exception {}; using namespace mbgl; -DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer) - : fontBuffer(fontBuffer) { +DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer_) + : fontBuffer(fontBuffer_) { } void DebugBucket::render(Painter& painter, util::ptr /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) { diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index 5358cae0b2..0a7d77935d 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -30,11 +30,11 @@ void FillBucket::free(void *, void *ptr) { ::free(ptr); } -FillBucket::FillBucket(FillVertexBuffer &vertexBuffer, - TriangleElementsBuffer &triangleElementsBuffer, - LineElementsBuffer &lineElementsBuffer, - const StyleBucketFill &properties) - : properties(properties), +FillBucket::FillBucket(FillVertexBuffer &vertexBuffer_, + TriangleElementsBuffer &triangleElementsBuffer_, + LineElementsBuffer &lineElementsBuffer_, + const StyleBucketFill &properties_) + : properties(properties_), allocator(new TESSalloc{&alloc, &realloc, &free, nullptr, // userData 64, // meshEdgeBucketSize 64, // meshVertexBucketSize @@ -44,11 +44,11 @@ FillBucket::FillBucket(FillVertexBuffer &vertexBuffer, 128, // extraVertices allocated for the priority queue. }), tesselator(tessNewTess(allocator)), - vertexBuffer(vertexBuffer), - triangleElementsBuffer(triangleElementsBuffer), - lineElementsBuffer(lineElementsBuffer), - vertex_start(vertexBuffer.index()), - triangle_elements_start(triangleElementsBuffer.index()), + vertexBuffer(vertexBuffer_), + triangleElementsBuffer(triangleElementsBuffer_), + lineElementsBuffer(lineElementsBuffer_), + vertex_start(vertexBuffer_.index()), + triangle_elements_start(triangleElementsBuffer_.index()), line_elements_start(lineElementsBuffer.index()) { assert(tesselator); } @@ -123,10 +123,10 @@ void FillBucket::tessellate() { const size_t group_count = polygon.size(); assert(group_count >= 3); - std::vector line; + std::vector clipped_line; for (const ClipperLib::IntPoint& pt : polygon) { - line.push_back(pt.X); - line.push_back(pt.Y); + clipped_line.push_back(pt.X); + clipped_line.push_back(pt.Y); vertexBuffer.add(pt.X, pt.Y); } @@ -137,7 +137,7 @@ void FillBucket::tessellate() { lineIndex += group_count; - tessAddContour(tesselator, vertexSize, line.data(), stride, (int)line.size() / vertexSize); + tessAddContour(tesselator, vertexSize, clipped_line.data(), stride, (int)clipped_line.size() / vertexSize); } lineGroup.elements_length += total_vertex_count; diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index 3ef7411be6..8267cbaba2 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -17,17 +17,17 @@ struct geometry_too_long_exception : std::exception {}; using namespace mbgl; -LineBucket::LineBucket(LineVertexBuffer& vertexBuffer, - TriangleElementsBuffer& triangleElementsBuffer, - PointElementsBuffer& pointElementsBuffer, - const StyleBucketLine& properties) - : properties(properties), - vertexBuffer(vertexBuffer), - triangleElementsBuffer(triangleElementsBuffer), - pointElementsBuffer(pointElementsBuffer), - vertex_start(vertexBuffer.index()), - triangle_elements_start(triangleElementsBuffer.index()), - point_elements_start(pointElementsBuffer.index()) +LineBucket::LineBucket(LineVertexBuffer& vertexBuffer_, + TriangleElementsBuffer& triangleElementsBuffer_, + PointElementsBuffer& pointElementsBuffer_, + const StyleBucketLine& properties_) + : properties(properties_), + vertexBuffer(vertexBuffer_), + triangleElementsBuffer(triangleElementsBuffer_), + pointElementsBuffer(pointElementsBuffer_), + vertex_start(vertexBuffer_.index()), + triangle_elements_start(triangleElementsBuffer_.index()), + point_elements_start(pointElementsBuffer_.index()) { } @@ -53,7 +53,7 @@ void LineBucket::addGeometry(pbf& geom) { } struct TriangleElement { - TriangleElement(uint16_t a, uint16_t b, uint16_t c) : a(a), b(b), c(c) {} + TriangleElement(uint16_t a_, uint16_t b_, uint16_t c_) : a(a_), b(b_), c(c_) {} uint16_t a, b, c; }; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index e82b1b5f63..aa522734c5 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -21,8 +21,8 @@ using namespace mbgl; #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) -Painter::Painter(Map &map) - : map(map) { +Painter::Painter(Map &map_) + : map(map_) { } Painter::~Painter() { diff --git a/src/renderer/prerendered_texture.cpp b/src/renderer/prerendered_texture.cpp index 0a47816323..adb7a59105 100644 --- a/src/renderer/prerendered_texture.cpp +++ b/src/renderer/prerendered_texture.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties) - : properties(properties) { +PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties_) + : properties(properties_) { } PrerenderedTexture::~PrerenderedTexture() { diff --git a/src/renderer/raster_bucket.cpp b/src/renderer/raster_bucket.cpp index fc5e3dd3c8..7adb3f845e 100644 --- a/src/renderer/raster_bucket.cpp +++ b/src/renderer/raster_bucket.cpp @@ -3,9 +3,9 @@ using namespace mbgl; -RasterBucket::RasterBucket(const util::ptr &texturepool, const StyleBucketRaster& properties) -: properties(properties), - texture(properties), +RasterBucket::RasterBucket(const util::ptr &texturepool, const StyleBucketRaster& properties_) +: properties(properties_), + texture(properties_), raster(texturepool) { } @@ -24,8 +24,8 @@ void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index()); } -void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture) { - raster.bind(texture); +void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture_) { + raster.bind(texture_); shader.u_image = 0; array.bind(shader, vertices, BUFFER_OFFSET(0)); glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index()); diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 3a4b017ef3..47cc4db44c 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -19,8 +19,8 @@ namespace mbgl { -SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties, Collision &collision) - : properties(properties), collision(collision) {} +SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties_, Collision &collision_) + : properties(properties_), collision(collision_) {} void SymbolBucket::render(Painter &painter, util::ptr layer_desc, const Tile::ID &id, const mat4 &matrix) { @@ -52,12 +52,12 @@ std::vector SymbolBucket::processFeatures(const VectorTileLayer & const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite) { - const bool text = properties.text.field.size(); - const bool icon = properties.icon.image.size(); + const bool has_text = properties.text.field.size(); + const bool has_icon = properties.icon.image.size(); std::vector features; - if (!text && !icon) { + if (!has_text && !has_icon) { return features; } @@ -72,7 +72,7 @@ std::vector SymbolBucket::processFeatures(const VectorTileLayer & SymbolFeature ft; - if (text) { + if (has_text) { std::string u8string = util::replaceTokens(properties.text.field, feature.properties); if (properties.text.transform == TextTransformType::Uppercase) { @@ -91,7 +91,7 @@ std::vector SymbolBucket::processFeatures(const VectorTileLayer & } } - if (icon) { + if (has_icon) { ft.sprite = util::replaceTokens(properties.icon.image, feature.properties); } diff --git a/src/shader/shader.cpp b/src/shader/shader.cpp index 91c9b58c89..d9f63cae12 100644 --- a/src/shader/shader.cpp +++ b/src/shader/shader.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -Shader::Shader(const char *name, const GLchar *vertSource, const GLchar *fragSource) - : name(name), +Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSource) + : name(name_), valid(false), program(0) { util::timer timer("shader compilation", Event::Shader); diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index ca1412fd9e..3da4fc7c31 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -82,19 +82,19 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr &&res) { #else uv_async_init(loop, http_baton->async, [](uv_async_t *async) { #endif - util::ptr &http_baton = *(util::ptr *)async->data; + util::ptr &baton = *(util::ptr *)async->data; - if (http_baton->request) { - HTTPRequest *request = http_baton->request; + if (baton->request) { + HTTPRequest *request = baton->request; request->http_baton.reset(); - http_baton->request = nullptr; - request->handleHTTPResponse(http_baton->type, std::move(http_baton->response)); + baton->request = nullptr; + request->handleHTTPResponse(baton->type, std::move(baton->response)); } delete (util::ptr *)async->data; uv_close((uv_handle_t *)async, [](uv_handle_t *handle) { - uv_async_t *async = (uv_async_t *)handle; - delete async; + uv_async_t *async_handle = (uv_async_t *)handle; + delete async_handle; }); }); attempts++; diff --git a/src/storage/sqlite_store.cpp b/src/storage/sqlite_store.cpp index 763100f411..e0757ecc36 100644 --- a/src/storage/sqlite_store.cpp +++ b/src/storage/sqlite_store.cpp @@ -68,8 +68,8 @@ SQLiteStore::~SQLiteStore() { // Nothing to do. This function needs to be here because we're forward-declaring // Database, so we need the actual definition here to be able to properly destruct it. if (worker) { - uv_worker_close(worker, [](uv_worker_t *worker) { - delete worker; + uv_worker_close(worker, [](uv_worker_t *worker_handle) { + delete worker_handle; }); } } diff --git a/src/style/applied_class_properties.cpp b/src/style/applied_class_properties.cpp index ca9c09436c..9037c6ad5d 100644 --- a/src/style/applied_class_properties.cpp +++ b/src/style/applied_class_properties.cpp @@ -2,11 +2,11 @@ namespace mbgl { -AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value) +AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin_, timestamp end_, const PropertyValue &value_) : name(class_id), - begin(begin), - end(end), - value(value) {} + begin(begin_), + end(end_), + value(value_) {} // Returns thie ID of the most recent ClassID AppliedClassProperties::mostRecent() const { diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index 8f79bc9047..4d64386be8 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -7,8 +7,8 @@ namespace mbgl { -StyleLayer::StyleLayer(const std::string &id, std::map &&styles) - : id(id), styles(std::move(styles)) {} +StyleLayer::StyleLayer(const std::string &id_, std::map &&styles_) + : id(id_), styles(std::move(styles_)) {} bool StyleLayer::isBackground() const { return type == StyleLayerType::Background; @@ -70,8 +70,8 @@ void StyleLayer::applyClassProperties(const ClassID class_id, // Loop through all the properties in this style, and add transitions to them, if they're // not already the most recent transition. - const ClassProperties &properties = style_it->second; - for (const std::pair &property_pair : properties) { + const ClassProperties &class_properties = style_it->second; + for (const std::pair &property_pair : class_properties) { PropertyKey key = property_pair.first; if (already_applied.find(key) != already_applied.end()) { // This property has already been set by a previous class. @@ -87,7 +87,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id, AppliedClassProperties &appliedProperties = appliedStyle[key]; if (appliedProperties.mostRecent() != class_id) { const PropertyTransition &transition = - properties.getTransition(key, defaultTransition); + class_properties.getTransition(key, defaultTransition); const timestamp begin = now + transition.delay * 1_millisecond; const timestamp end = begin + transition.duration * 1_millisecond; const PropertyValue &value = property_pair.second; @@ -99,7 +99,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id, template struct PropertyEvaluator { typedef T result_type; - PropertyEvaluator(float z) : z(z) {} + PropertyEvaluator(float z_) : z(z_) {} template ::value, int>::type = 0> T operator()(const P &value) const { @@ -269,11 +269,11 @@ void StyleLayer::cleanupAppliedStyleProperties(timestamp now) { auto it = appliedStyle.begin(); const auto end = appliedStyle.end(); while (it != end) { - AppliedClassProperties &properties = it->second; - properties.cleanup(now); + AppliedClassProperties &applied_properties = it->second; + applied_properties.cleanup(now); // If the current properties object is empty, remove it from the map entirely. - if (properties.empty()) { + if (applied_properties.empty()) { appliedStyle.erase(it++); } else { ++it; diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index a00fe61359..b2714f5da5 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -108,13 +108,13 @@ template<> bool StyleParser::parseRenderProperty(JSVal value, uint16_t &target, if (value.HasMember(name)) { JSVal property = replaceConstant(value[name]); if (property.IsUint()) { - unsigned int value = property.GetUint(); - if (value > std::numeric_limits::max()) { + unsigned int int_value = property.GetUint(); + if (int_value > std::numeric_limits::max()) { Log::Warning(Event::ParseStyle, "values for %s that are larger than %d are not supported", name, std::numeric_limits::max()); return false; } - target = value; + target = int_value; return true; } else { Log::Warning(Event::ParseStyle, "%s must be an unsigned integer", name); @@ -763,11 +763,11 @@ FilterExpression StyleParser::parseFilter(JSVal value, FilterExpression::Operato FilterComparison comparison(name); JSVal filterValue = replaceConstant(itr->value); if (filterValue.IsObject()) { - rapidjson::Value::ConstMemberIterator itr = filterValue.MemberBegin(); - for (; itr != filterValue.MemberEnd(); ++itr) { + rapidjson::Value::ConstMemberIterator filter_itr = filterValue.MemberBegin(); + for (; filter_itr != filterValue.MemberEnd(); ++filter_itr) { comparison.add( - parseFilterComparisonOperator({ itr->name.GetString(), itr->name.GetStringLength() }), - parseValues(replaceConstant(itr->value)) + parseFilterComparisonOperator({ filter_itr->name.GetString(), filter_itr->name.GetStringLength() }), + parseValues(replaceConstant(filter_itr->value)) ); } } else if (filterValue.IsArray()) { diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 6326bea825..2e0ec6dce2 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -19,11 +19,11 @@ Box getBox(const CollisionAnchor &anchor, const CollisionRect &bbox, float minSc }; }; -Collision::Collision(float zoom, float tileExtent, float tileSize, float placementDepth) +Collision::Collision(float zoom_, float tileExtent, float tileSize, float placementDepth) // tile pixels per screen pixels at the tile's zoom level : tilePixelRatio(tileExtent / tileSize), - zoom(zoom), + zoom(zoom_), // Calculate the maximum scale we can go down in our fake-3d rtree so that // placement still makes sense. This is calculated so that the minimum @@ -33,7 +33,7 @@ Collision::Collision(float zoom, float tileExtent, float tileSize, float placeme // We don't want to place labels all the way to 25.5. This lets too many // glyphs be placed, slowing down collision checking. Only place labels if // they will show up within the intended zoom range of the tile. - maxPlacementScale(std::exp(std::log(2) * util::min(3.0f, placementDepth, 25.5f - zoom))) { + maxPlacementScale(std::exp(std::log(2) * util::min(3.0f, placementDepth, 25.5f - zoom_))) { const float m = 4096; const float edge = m * tilePixelRatio * 2; diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 1723bd3d94..5619c4f93f 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -228,7 +228,7 @@ void GlyphPBF::parse(FontStack &stack) { data.clear(); } -GlyphStore::GlyphStore(const util::ptr &fileSource) : fileSource(fileSource) {} +GlyphStore::GlyphStore(const util::ptr &fileSource_) : fileSource(fileSource_) {} void GlyphStore::setURL(const std::string &url) { glyphURL = url; diff --git a/src/text/placement.cpp b/src/text/placement.cpp index 0c95e3a80d..84d4e20b2f 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -12,10 +12,10 @@ namespace mbgl { const float Placement::globalMinScale = 0.5; // underscale by 1 zoom level struct GlyphInstance { - explicit GlyphInstance(const vec2 &anchor) : anchor(anchor) {} - explicit GlyphInstance(const vec2 &anchor, float offset, float minScale, float maxScale, - float angle) - : anchor(anchor), offset(offset), minScale(minScale), maxScale(maxScale), angle(angle) {} + explicit GlyphInstance(const vec2 &anchor_) : anchor(anchor_) {} + explicit GlyphInstance(const vec2 &anchor_, float offset_, float minScale_, float maxScale_, + float angle_) + : anchor(anchor_), offset(offset_), minScale(minScale_), maxScale(maxScale_), angle(angle_) {} const vec2 anchor; const float offset = 0.0f; diff --git a/src/util/image.cpp b/src/util/image.cpp index 28906c4e91..ec218e0bed 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -30,8 +30,8 @@ std::string mbgl::util::compress_png(int width, int height, void *rgba, bool fli } std::string result; - png_set_write_fn(png_ptr, &result, [](png_structp png_ptr, png_bytep data, png_size_t length) { - std::string *out = static_cast(png_get_io_ptr(png_ptr)); + png_set_write_fn(png_ptr, &result, [](png_structp png_ptr_, png_bytep data, png_size_t length) { + std::string *out = static_cast(png_get_io_ptr(png_ptr_)); out->append(reinterpret_cast(data), length); }, NULL); @@ -57,8 +57,8 @@ using namespace mbgl::util; struct Buffer { - Buffer(const std::string& data) - : data(data.data()), length(data.size()) {} + Buffer(const std::string& data_) + : data(data_.data()), length(data_.size()) {} const char *const data = 0; const size_t length = 0; size_t pos = 0; diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 7b52c51037..c4d7a15400 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -13,8 +13,8 @@ using namespace mbgl; -Raster::Raster(const util::ptr &texturepool) - : texturepool(texturepool) +Raster::Raster(const util::ptr &texturepool_) + : texturepool(texturepool_) {} Raster::~Raster() { @@ -59,32 +59,32 @@ void Raster::bind(bool linear) { glBindTexture(GL_TEXTURE_2D, texture); } - GLuint filter = linear ? GL_LINEAR : GL_NEAREST; - if (filter != this->filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - this->filter = filter; + GLuint new_filter = linear ? GL_LINEAR : GL_NEAREST; + if (new_filter != this->filter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter); + filter = new_filter; } } // overload ::bind for prerendered raster textures -void Raster::bind(const GLuint texture) { +void Raster::bind(const GLuint custom_texture) { if (img && !textured) { - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, custom_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->getData()); img.reset(); textured = true; } else if (textured) { - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, custom_texture); } - GLuint filter = GL_LINEAR; - if (filter != this->filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - this->filter = filter; + GLuint new_filter = GL_LINEAR; + if (new_filter != this->filter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter); + filter = new_filter; } } diff --git a/src/util/timer.cpp b/src/util/timer.cpp index d56860d193..5c4af51da4 100644 --- a/src/util/timer.cpp +++ b/src/util/timer.cpp @@ -8,22 +8,22 @@ using namespace mbgl::util; -timer::timer(Event event) - : event(event), start(now()) {} +timer::timer(Event event_) + : event(event_), start(now()) {} -timer::timer(EventSeverity severity, Event event) - : severity(severity), event(event), start(now()) {} +timer::timer(EventSeverity severity_, Event event_) + : severity(severity_), event(event_), start(now()) {} -timer::timer(const std::string &name, Event event) - : name(name), event(event), start(now()) {} +timer::timer(const std::string &name_, Event event_) + : name(name_), event(event_), start(now()) {} -timer::timer(const std::string &name, EventSeverity severity, Event event) - : name(name), severity(severity), event(event), start(now()) {} +timer::timer(const std::string &name_, EventSeverity severity_, Event event_) + : name(name_), severity(severity_), event(event_), start(now()) {} -void timer::report(const std::string &name) { +void timer::report(const std::string &name_) { timestamp duration = now() - start; - Log::Record(severity, event, name + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); + Log::Record(severity, event, name_ + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); start += duration; } diff --git a/test/comparisons.cpp b/test/comparisons.cpp index e1e991d41c..4ffcf2e2ec 100644 --- a/test/comparisons.cpp +++ b/test/comparisons.cpp @@ -10,7 +10,7 @@ class MockExtractor { public: - inline MockExtractor(const std::multimap &values) : values(values) {} + inline MockExtractor(const std::multimap &values_) : values(values_) {} inline MockExtractor() {} inline std::vector getValues(const std::string &key) const { diff --git a/test/fixtures/fixture_log.hpp b/test/fixtures/fixture_log.hpp index dc92f93198..99097a2c47 100644 --- a/test/fixtures/fixture_log.hpp +++ b/test/fixtures/fixture_log.hpp @@ -13,14 +13,14 @@ namespace mbgl { class FixtureLogBackend : public LogBackend, private util::noncopyable { public: struct LogMessage { - inline LogMessage(EventSeverity severity, Event event, int64_t code, const std::string &msg) - : severity(severity), event(event), code(code), msg(msg) {} - inline LogMessage(EventSeverity severity, Event event, int64_t code) - : severity(severity), event(event), code(code), msg() {} - inline LogMessage(EventSeverity severity, Event event, const std::string &msg) - : severity(severity), event(event), code(), msg(msg) {} - inline LogMessage(EventSeverity severity, Event event) - : severity(severity), event(event), code(), msg() {} + inline LogMessage(EventSeverity severity_, Event event_, int64_t code_, const std::string &msg_) + : severity(severity_), event(event_), code(code_), msg(msg_) {} + inline LogMessage(EventSeverity severity_, Event event_, int64_t code_) + : severity(severity_), event(event_), code(code_), msg() {} + inline LogMessage(EventSeverity severity_, Event event_, const std::string &msg_) + : severity(severity_), event(event_), code(), msg(msg_) {} + inline LogMessage(EventSeverity severity_, Event event_) + : severity(severity_), event(event_), code(), msg() {} inline bool operator==(const LogMessage &rhs) const { return (!severity || !rhs.severity || severity.get() == rhs.severity.get()) && -- cgit v1.2.1 From e2aaae665b96e3a39ee52702d43262595475ad07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 18:20:35 +0200 Subject: force exceptions and rtti in case they're disabled by another gyp file --- common.gypi | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/common.gypi b/common.gypi index 5d02a71c13..596db5449d 100644 --- a/common.gypi +++ b/common.gypi @@ -1,17 +1,21 @@ { 'target_defaults': { 'default_configuration': 'Release', - 'xcode_settings': { - 'CLANG_CXX_LIBRARY': 'libc++', - 'CLANG_CXX_LANGUAGE_STANDARD':'c++11', - 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', - 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', - 'GCC_ENABLE_CPP_RTTI':'YES', - 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-Wno-variadic-macros' ], - 'GCC_WARN_PEDANTIC': 'YES', - 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE' - }, - 'cflags_cc': ['-std=c++11', '-Wall', '-Wextra'], + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'CLANG_CXX_LIBRARY': 'libc++', + 'CLANG_CXX_LANGUAGE_STANDARD':'c++11', + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', + 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', + 'GCC_ENABLE_CPP_RTTI':'YES', + 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-Wshadow', '-Wno-variadic-macros', '-frtti', '-fexceptions' ], + 'GCC_WARN_PEDANTIC': 'YES', + 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE', + }, + }], + ], + 'cflags_cc!': [ '-std=c++11', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], 'configurations': { 'Debug': { 'cflags_cc': [ '-g', '-O0', '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], @@ -31,7 +35,7 @@ 'GCC_OPTIMIZATION_LEVEL': '3', 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO', 'DEAD_CODE_STRIPPING': 'YES', - 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' + 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'NO' } }, } -- cgit v1.2.1 From 40a933ddce390b7926c25bb00a95f34fd76453ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 18:22:43 +0200 Subject: add missing header --- src/map/source.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/map/source.cpp b/src/map/source.cpp index ca1f3d5323..9c0f7caf28 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -18,6 +18,8 @@ #include #include +#include + namespace mbgl { Source::Source(const util::ptr& info_) -- cgit v1.2.1