From 9e79e1edf13b2bd4fb6fa4b1a59328e4dfd7c414 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 17 Apr 2018 15:24:55 +0200 Subject: [PATCH 1/7] update const-ness in x3::context definitions to support boost 1_67 [skip-ci] --- .../mapnik/expression_grammar_x3_config.hpp | 2 +- .../json/extract_bounding_boxes_x3_config.hpp | 25 ++++++++----------- include/mapnik/json/json_grammar_config.hpp | 10 ++++---- include/mapnik/svg/svg_grammar_config_x3.hpp | 4 +-- src/css_color_grammar_x3.cpp | 5 +++- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/mapnik/expression_grammar_x3_config.hpp b/include/mapnik/expression_grammar_x3_config.hpp index ffd9f9a1d..8aba3d75b 100644 --- a/include/mapnik/expression_grammar_x3_config.hpp +++ b/include/mapnik/expression_grammar_x3_config.hpp @@ -35,7 +35,7 @@ using phrase_context_type = x3::phrase_parse_context::typ // define combined context using context_type = x3::context const, + std::reference_wrapper, phrase_context_type>; }} diff --git a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp index 082e7b19a..54a2b17a4 100644 --- a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp +++ b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp @@ -84,30 +84,27 @@ using space_type = x3::standard::space_type; using phrase_parse_context_type = x3::phrase_parse_context::type; -using context_type = x3::context const, - phrase_parse_context_type>; - using extract_bounding_boxes_context_type = - x3::context const, - x3::context const, - context_type>>; + x3::context, + x3::context, + context_type>>; using extract_bounding_boxes_reverse_context_type = - x3::context const, - x3::context const, - x3::context const, + x3::context, + x3::context, + x3::context, phrase_parse_context_type>>>; using extract_bounding_boxes_context_type_f = - x3::context const, - x3::context const, + x3::context, + x3::context, context_type>>; using extract_bounding_boxes_reverse_context_type_f = - x3::context const, - x3::context const, - x3::context const, + x3::context, + x3::context, + x3::context, phrase_parse_context_type>>>; }}} diff --git a/include/mapnik/json/json_grammar_config.hpp b/include/mapnik/json/json_grammar_config.hpp index 854a50b21..e17b4773d 100644 --- a/include/mapnik/json/json_grammar_config.hpp +++ b/include/mapnik/json/json_grammar_config.hpp @@ -92,20 +92,20 @@ using iterator_type = char const*; using phrase_parse_context_type = x3::phrase_parse_context::type; using context_type = x3::context const, + std::reference_wrapper, phrase_parse_context_type>; using feature_context_type = x3::context const, + std::reference_wrapper, x3::context const, + std::reference_wrapper, phrase_parse_context_type>>; // our spirit x3 grammars needs this one with changed order of feature_impl and transcoder (??) using feature_context_const_type = x3::context const, + std::reference_wrapper, x3::context const, + std::reference_wrapper, phrase_parse_context_type>>; // helper macro diff --git a/include/mapnik/svg/svg_grammar_config_x3.hpp b/include/mapnik/svg/svg_grammar_config_x3.hpp index db1c7eb8d..63cbf79e1 100644 --- a/include/mapnik/svg/svg_grammar_config_x3.hpp +++ b/include/mapnik/svg/svg_grammar_config_x3.hpp @@ -40,8 +40,8 @@ using space_type = x3::standard::space_type; using iterator_type = char const*; using phrase_parse_context_type = x3::phrase_parse_context::type; -using svg_parse_context_type = x3::context const, - x3::context const, +using svg_parse_context_type = x3::context, + x3::context, phrase_parse_context_type>>; inline double deg2rad(double deg) {return (M_PI * deg) / 180.0;} diff --git a/src/css_color_grammar_x3.cpp b/src/css_color_grammar_x3.cpp index 372f0dff0..5a7a6ed2c 100644 --- a/src/css_color_grammar_x3.cpp +++ b/src/css_color_grammar_x3.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ #include - +#include namespace mapnik { namespace css_color_grammar { namespace x3 = boost::spirit::x3; @@ -30,4 +30,7 @@ using context_type = x3::phrase_parse_context::type; BOOST_SPIRIT_INSTANTIATE(css_color_grammar_type, iterator_type, context_type); +template bool parse_rule +(css_color_grammar_type, iterator_type&, iterator_type const&, context_type const&, mapnik::filter::color_to_alpha&); + }} From c946620fec5e0e8e6d3cfeea6f77f0ad69f47a3b Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 18 Apr 2018 10:31:33 +0200 Subject: [PATCH 2/7] remove unused instantiation --- src/json/feature_grammar_x3.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/json/feature_grammar_x3.cpp b/src/json/feature_grammar_x3.cpp index 9aa2961a3..0d03b3728 100644 --- a/src/json/feature_grammar_x3.cpp +++ b/src/json/feature_grammar_x3.cpp @@ -27,8 +27,6 @@ namespace mapnik { namespace json { namespace grammar { BOOST_SPIRIT_INSTANTIATE(feature_grammar_type, iterator_type, feature_context_type); BOOST_SPIRIT_INSTANTIATE(geometry_grammar_type, iterator_type, phrase_parse_context_type); - -BOOST_SPIRIT_INSTANTIATE_UNUSED(feature_grammar_type, iterator_type, feature_context_type); BOOST_SPIRIT_INSTANTIATE_UNUSED(feature_grammar_type, iterator_type, feature_context_const_type); } From 664d3508deefdbdd70ce9c49b501f57f906bb23b Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 18 Apr 2018 12:52:29 +0200 Subject: [PATCH 3/7] remove reference_wrapper usage when injecting attributes into grammar ( >= boost_1_67) [skip-ci] --- .../mapnik/expression_grammar_x3_config.hpp | 2 +- include/mapnik/expression_grammar_x3_def.hpp | 6 ++--- .../json/extract_bounding_boxes_x3_config.hpp | 20 ++++++++-------- include/mapnik/json/json_grammar_config.hpp | 12 +++++----- include/mapnik/svg/svg_grammar_config_x3.hpp | 4 ++-- .../mapnik/svg/svg_path_grammar_x3_def.hpp | 24 +++++++++---------- .../svg/svg_transform_grammar_x3_def.hpp | 12 +++++----- src/expression.cpp | 2 +- src/json/extract_bounding_boxes_x3.cpp | 6 ++--- src/json/parse_feature.cpp | 4 ++-- src/parse_transform.cpp | 2 +- src/svg/svg_path_parser.cpp | 4 ++-- src/svg/svg_points_parser.cpp | 4 ++-- src/svg/svg_transform_parser.cpp | 2 +- .../mapnik-index/process_geojson_file_x3.cpp | 2 +- 15 files changed, 53 insertions(+), 53 deletions(-) diff --git a/include/mapnik/expression_grammar_x3_config.hpp b/include/mapnik/expression_grammar_x3_config.hpp index 8aba3d75b..3de3e27c4 100644 --- a/include/mapnik/expression_grammar_x3_config.hpp +++ b/include/mapnik/expression_grammar_x3_config.hpp @@ -35,7 +35,7 @@ using phrase_context_type = x3::phrase_parse_context::typ // define combined context using context_type = x3::context, + mapnik::transcoder const, phrase_context_type>; }} diff --git a/include/mapnik/expression_grammar_x3_def.hpp b/include/mapnik/expression_grammar_x3_def.hpp index dd7d40eba..5f234c1f6 100644 --- a/include/mapnik/expression_grammar_x3_def.hpp +++ b/include/mapnik/expression_grammar_x3_def.hpp @@ -130,7 +130,7 @@ namespace mapnik { namespace grammar { auto do_unicode = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto const& tr = x3::get(ctx); _val(ctx) = std::move(tr.transcode(_attr(ctx).c_str())); }; @@ -188,13 +188,13 @@ namespace mapnik { namespace grammar { // regex auto do_regex_match = [] (auto const& ctx) { - auto const& tr = x3::get(ctx).get(); + auto const& tr = x3::get(ctx); _val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)) , std::move(_attr(ctx)))); }; auto do_regex_replace = [] (auto const& ctx) { - auto const& tr = x3::get(ctx).get(); + auto const& tr = x3::get(ctx); auto const& pair = _attr(ctx); auto const& pattern = std::get<0>(pair); auto const& format = std::get<1>(pair); diff --git a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp index 54a2b17a4..eb7eb4193 100644 --- a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp +++ b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp @@ -85,26 +85,26 @@ using space_type = x3::standard::space_type; using phrase_parse_context_type = x3::phrase_parse_context::type; using extract_bounding_boxes_context_type = - x3::context, - x3::context, + x3::context>; using extract_bounding_boxes_reverse_context_type = - x3::context, - x3::context, - x3::context, + x3::context>>; using extract_bounding_boxes_context_type_f = - x3::context, - x3::context, + x3::context>; using extract_bounding_boxes_reverse_context_type_f = - x3::context, - x3::context, - x3::context, + x3::context>>; }}} diff --git a/include/mapnik/json/json_grammar_config.hpp b/include/mapnik/json/json_grammar_config.hpp index e17b4773d..92422031e 100644 --- a/include/mapnik/json/json_grammar_config.hpp +++ b/include/mapnik/json/json_grammar_config.hpp @@ -92,20 +92,20 @@ using iterator_type = char const*; using phrase_parse_context_type = x3::phrase_parse_context::type; using context_type = x3::context, + keys_map, phrase_parse_context_type>; using feature_context_type = x3::context, + mapnik::transcoder const, x3::context, - phrase_parse_context_type>>; + mapnik::feature_impl, + phrase_parse_context_type>>; // our spirit x3 grammars needs this one with changed order of feature_impl and transcoder (??) using feature_context_const_type = x3::context, + mapnik::feature_impl, x3::context, + mapnik::transcoder const, phrase_parse_context_type>>; // helper macro diff --git a/include/mapnik/svg/svg_grammar_config_x3.hpp b/include/mapnik/svg/svg_grammar_config_x3.hpp index 63cbf79e1..c60595572 100644 --- a/include/mapnik/svg/svg_grammar_config_x3.hpp +++ b/include/mapnik/svg/svg_grammar_config_x3.hpp @@ -40,8 +40,8 @@ using space_type = x3::standard::space_type; using iterator_type = char const*; using phrase_parse_context_type = x3::phrase_parse_context::type; -using svg_parse_context_type = x3::context, - x3::context, +using svg_parse_context_type = x3::context>; inline double deg2rad(double deg) {return (M_PI * deg) / 180.0;} diff --git a/include/mapnik/svg/svg_path_grammar_x3_def.hpp b/include/mapnik/svg/svg_path_grammar_x3_def.hpp index 125276e54..dab035bdc 100644 --- a/include/mapnik/svg/svg_path_grammar_x3_def.hpp +++ b/include/mapnik/svg/svg_path_grammar_x3_def.hpp @@ -45,22 +45,22 @@ using coord_type = std::tuple; auto const move_to = [] (auto const& ctx) { - x3::get(ctx).get().move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); + x3::get(ctx).move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); }; auto const line_to = [] (auto const & ctx) { - x3::get(ctx).get().line_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); + x3::get(ctx).line_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); }; auto const hline_to = [] (auto const& ctx) { - x3::get(ctx).get().hline_to(_attr(ctx), x3::get(ctx)); + x3::get(ctx).hline_to(_attr(ctx), x3::get(ctx)); }; auto const vline_to = [] (auto const& ctx) { - x3::get(ctx).get().vline_to(_attr(ctx), x3::get(ctx)); + x3::get(ctx).vline_to(_attr(ctx), x3::get(ctx)); }; auto const curve4 = [] (auto const& ctx) @@ -69,7 +69,7 @@ auto const curve4 = [] (auto const& ctx) auto const& p0 = boost::fusion::at_c<0>(attr); auto const& p1 = boost::fusion::at_c<1>(attr); auto const& p2 = boost::fusion::at_c<2>(attr); - x3::get(ctx).get().curve4(std::get<0>(p0),std::get<1>(p0), + x3::get(ctx).curve4(std::get<0>(p0),std::get<1>(p0), std::get<0>(p1),std::get<1>(p1), std::get<0>(p2),std::get<1>(p2), x3::get(ctx)); @@ -80,7 +80,7 @@ auto const curve4_smooth = [] (auto const& ctx) auto const& attr = _attr(ctx); auto const& p0 = boost::fusion::at_c<0>(attr); auto const& p1 = boost::fusion::at_c<1>(attr); - x3::get(ctx).get().curve4(std::get<0>(p0),std::get<1>(p0), + x3::get(ctx).curve4(std::get<0>(p0),std::get<1>(p0), std::get<0>(p1),std::get<1>(p1), x3::get(ctx)); }; @@ -90,7 +90,7 @@ auto const curve3 = [] (auto const& ctx) auto const& attr = _attr(ctx); auto const& p0 = boost::fusion::at_c<0>(attr); auto const& p1 = boost::fusion::at_c<1>(attr); - x3::get(ctx).get().curve3(std::get<0>(p0),std::get<1>(p0), + x3::get(ctx).curve3(std::get<0>(p0),std::get<1>(p0), std::get<0>(p1),std::get<1>(p1), x3::get(ctx)); }; @@ -98,7 +98,7 @@ auto const curve3 = [] (auto const& ctx) auto const curve3_smooth = [] (auto const& ctx) { auto const& attr = _attr(ctx); - x3::get(ctx).get().curve3(std::get<0>(attr),std::get<1>(attr), + x3::get(ctx).curve3(std::get<0>(attr),std::get<1>(attr), x3::get(ctx)); }; @@ -111,7 +111,7 @@ auto const arc_to = [] (auto & ctx) int large_arc_flag = boost::fusion::at_c<2>(attr); int sweep_flag = boost::fusion::at_c<3>(attr); auto const& v = boost::fusion::at_c<4>(attr); - x3::get(ctx).get().arc_to(std::get<0>(p),std::get<1>(p), + x3::get(ctx).arc_to(std::get<0>(p),std::get<1>(p), deg2rad(angle), large_arc_flag, sweep_flag, std::get<0>(v),std::get<1>(v), x3::get(ctx)); @@ -119,17 +119,17 @@ auto const arc_to = [] (auto & ctx) auto const close_path = [] (auto const& ctx) { - x3::get(ctx).get().close_subpath(); + x3::get(ctx).close_subpath(); }; auto const relative = [] (auto const& ctx) { - x3::get(ctx).get() = true; + x3::get(ctx) = true; }; auto const absolute = [] (auto const& ctx) { - x3::get(ctx).get() = false; + x3::get(ctx) = false; }; // exported rules diff --git a/include/mapnik/svg/svg_transform_grammar_x3_def.hpp b/include/mapnik/svg/svg_transform_grammar_x3_def.hpp index dcf2b274e..b3b7ebe47 100644 --- a/include/mapnik/svg/svg_transform_grammar_x3_def.hpp +++ b/include/mapnik/svg/svg_transform_grammar_x3_def.hpp @@ -46,7 +46,7 @@ using x3::no_case; auto const matrix_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto & tr = x3::get(ctx); auto const& attr = _attr(ctx); auto a = boost::fusion::at_c<0>(attr); auto b = boost::fusion::at_c<1>(attr); @@ -59,7 +59,7 @@ auto const matrix_action = [] (auto const& ctx) auto const rotate_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto & tr = x3::get(ctx); auto const& attr = _attr(ctx); auto a = boost::fusion::at_c<0>(attr); auto cx = boost::fusion::at_c<1>(attr) ? *boost::fusion::at_c<1>(attr) : 0.0; @@ -79,7 +79,7 @@ auto const rotate_action = [] (auto const& ctx) auto const translate_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto & tr = x3::get(ctx); auto const& attr = _attr(ctx); auto tx = boost::fusion::at_c<0>(attr); auto ty = boost::fusion::at_c<1>(attr); @@ -89,7 +89,7 @@ auto const translate_action = [] (auto const& ctx) auto const scale_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto & tr = x3::get(ctx); auto const& attr = _attr(ctx); auto sx = boost::fusion::at_c<0>(attr); auto sy = boost::fusion::at_c<1>(attr); @@ -99,14 +99,14 @@ auto const scale_action = [] (auto const& ctx) auto const skewX_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto & tr = x3::get(ctx); auto skew_x = _attr(ctx); tr = agg::trans_affine_skewing(deg2rad(skew_x), 0.0) * tr; }; auto const skewY_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx).get(); + auto & tr = x3::get(ctx); auto skew_y= _attr(ctx); tr = agg::trans_affine_skewing(0.0, deg2rad(skew_y)) * tr; }; diff --git a/src/expression.cpp b/src/expression.cpp index b1633b2aa..ad87eb5ec 100644 --- a/src/expression.cpp +++ b/src/expression.cpp @@ -35,7 +35,7 @@ expression_ptr parse_expression(std::string const& str) auto node = std::make_shared(); using boost::spirit::x3::ascii::space; mapnik::transcoder const tr("utf8"); - auto parser = boost::spirit::x3::with(std::ref(tr)) + auto parser = boost::spirit::x3::with(tr) [ mapnik::expression_grammar() ]; diff --git a/src/json/extract_bounding_boxes_x3.cpp b/src/json/extract_bounding_boxes_x3.cpp index fe10ee21e..af9367ebe 100644 --- a/src/json/extract_bounding_boxes_x3.cpp +++ b/src/json/extract_bounding_boxes_x3.cpp @@ -185,9 +185,9 @@ void extract_bounding_boxes(Iterator& start, Iterator const& end, Boxes & boxes) extract_positions callback(start, boxes); auto keys = mapnik::json::get_keys(); std::size_t bracket_counter = 0; - auto feature_collection_impl = x3::with(std::ref(bracket_counter)) - [x3::with(std::ref(callback)) - [x3::with(std::ref(keys)) + auto feature_collection_impl = x3::with(bracket_counter) + [x3::with(callback) + [x3::with(keys) [mapnik::json::grammar::feature_collection] ]]; diff --git a/src/json/parse_feature.cpp b/src/json/parse_feature.cpp index c5ac0c491..6530377b4 100644 --- a/src/json/parse_feature.cpp +++ b/src/json/parse_feature.cpp @@ -31,8 +31,8 @@ void parse_feature(Iterator start, Iterator end, feature_impl& feature, mapnik:: { namespace x3 = boost::spirit::x3; using space_type = mapnik::json::grammar::space_type; - auto grammar = x3::with(std::ref(tr)) - [x3::with(std::ref(feature)) + auto grammar = x3::with(tr) + [x3::with(feature) [ mapnik::json::feature_grammar() ]]; if (!x3::phrase_parse(start, end, grammar, space_type())) { diff --git a/src/parse_transform.cpp b/src/parse_transform.cpp index b4affae3b..3d2e5e0e4 100644 --- a/src/parse_transform.cpp +++ b/src/parse_transform.cpp @@ -37,7 +37,7 @@ transform_list_ptr parse_transform(std::string const& str, std::string const& en std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); mapnik::transcoder const tr(encoding); - auto const parser = boost::spirit::x3::with(std::ref(tr)) + auto const parser = boost::spirit::x3::with(tr) [ mapnik::transform_expression_grammar() ]; diff --git a/src/svg/svg_path_parser.cpp b/src/svg/svg_path_parser.cpp index e429d6358..390b80da6 100644 --- a/src/svg/svg_path_parser.cpp +++ b/src/svg/svg_path_parser.cpp @@ -40,8 +40,8 @@ bool parse_path(const char* wkt, PathType& p) iterator_type last = wkt + std::strlen(wkt); bool relative = false; using space_type = mapnik::svg::grammar::space_type; - auto const grammar = x3::with(std::ref(p)) - [ x3::with(std::ref(relative)) + auto const grammar = x3::with(p) + [ x3::with(relative) [mapnik::svg::svg_path_grammar()]]; try diff --git a/src/svg/svg_points_parser.cpp b/src/svg/svg_points_parser.cpp index ddbb7aa81..2fd68734c 100644 --- a/src/svg/svg_points_parser.cpp +++ b/src/svg/svg_points_parser.cpp @@ -40,8 +40,8 @@ bool parse_points(const char* wkt, PathType& p) iterator_type last = wkt + std::strlen(wkt); bool relative = false; - auto const grammar = x3::with(std::ref(p)) - [ x3::with(std::ref(relative)) + auto const grammar = x3::with(p) + [ x3::with(relative) [mapnik::svg::svg_points_grammar()]]; try diff --git a/src/svg/svg_transform_parser.cpp b/src/svg/svg_transform_parser.cpp index e2c8e4636..e1ecf5639 100644 --- a/src/svg/svg_transform_parser.cpp +++ b/src/svg/svg_transform_parser.cpp @@ -37,7 +37,7 @@ bool parse_svg_transform(const char* wkt, Transform& tr) iterator_type first = wkt; iterator_type last = wkt + std::strlen(wkt); using space_type = mapnik::svg::grammar::space_type; - auto const grammar = x3::with(std::ref(tr)) + auto const grammar = x3::with(tr) [mapnik::svg::svg_transform_grammar()]; try diff --git a/utils/mapnik-index/process_geojson_file_x3.cpp b/utils/mapnik-index/process_geojson_file_x3.cpp index 1f4487ce3..62f5ccdea 100644 --- a/utils/mapnik-index/process_geojson_file_x3.cpp +++ b/utils/mapnik-index/process_geojson_file_x3.cpp @@ -285,7 +285,7 @@ std::pair process_geojson_file_x3(T & b using namespace boost::spirit; using space_type = mapnik::json::grammar::space_type; auto keys = mapnik::json::get_keys(); - auto feature_grammar = x3::with(std::ref(keys)) + auto feature_grammar = x3::with(keys) [ geojson_value ]; for (auto const& item : boxes) { From b7bdd08837d0b28902ce943f7c9f0058088e6d9a Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 18 Apr 2018 14:18:19 +0200 Subject: [PATCH 4/7] define BOOST_SPIRIT_INSTANTIATE_UNUSED once and re-use [skip-ci] --- include/mapnik/boost_spirit_instantiate.hpp | 39 +++++++++++++++++++++ include/mapnik/json/json_grammar_config.hpp | 9 +---- src/svg/svg_path_grammar_x3.cpp | 8 +---- 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 include/mapnik/boost_spirit_instantiate.hpp diff --git a/include/mapnik/boost_spirit_instantiate.hpp b/include/mapnik/boost_spirit_instantiate.hpp new file mode 100644 index 000000000..5552ca2bb --- /dev/null +++ b/include/mapnik/boost_spirit_instantiate.hpp @@ -0,0 +1,39 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2018 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP +#define MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP + +namespace boost { namespace spirit { namespace x3 +{ +// helper macro +#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \ + template bool parse_rule( \ + rule_type rule_ \ + , Iterator& first, Iterator const& last \ + , Context const& context, boost::spirit::x3::unused_type const& ); \ + /***/ + +}}} + + +#endif // MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP diff --git a/include/mapnik/json/json_grammar_config.hpp b/include/mapnik/json/json_grammar_config.hpp index 92422031e..ebd2977ff 100644 --- a/include/mapnik/json/json_grammar_config.hpp +++ b/include/mapnik/json/json_grammar_config.hpp @@ -33,6 +33,7 @@ #include #include #pragma GCC diagnostic pop +#include namespace mapnik { namespace json { @@ -108,14 +109,6 @@ using feature_context_const_type = x3::context>; -// helper macro -#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \ - template bool parse_rule( \ - rule_type rule_ \ - , Iterator& first, Iterator const& last \ - , Context const& context, boost::spirit::x3::unused_type const& ); \ - /***/ - }}} #endif // MAPNIK_JSON_GRAMMAR_CONFIG_HPP diff --git a/src/svg/svg_path_grammar_x3.cpp b/src/svg/svg_path_grammar_x3.cpp index 9d53a0e56..31a2622d0 100644 --- a/src/svg/svg_path_grammar_x3.cpp +++ b/src/svg/svg_path_grammar_x3.cpp @@ -21,16 +21,10 @@ *****************************************************************************/ #include +#include namespace mapnik { namespace svg { namespace grammar { -#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \ - template bool parse_rule( \ - rule_type rule_ \ - , Iterator& first, Iterator const& last \ - , Context const& context, boost::spirit::x3::unused_type const& ); \ - /***/ - BOOST_SPIRIT_INSTANTIATE_UNUSED(svg_path_grammar_type, iterator_type, svg_parse_context_type); BOOST_SPIRIT_INSTANTIATE_UNUSED(svg_points_grammar_type, iterator_type, svg_parse_context_type); From a98d1b80716034d74c3a5fe77af7fbeecacb93d8 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 18 Jul 2018 10:40:41 +0100 Subject: [PATCH 5/7] use std::uint8_t as an attribute for hex2 parser --- include/mapnik/json/unicode_string_grammar_x3_def.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/json/unicode_string_grammar_x3_def.hpp b/include/mapnik/json/unicode_string_grammar_x3_def.hpp index 2335b657b..7a989f026 100644 --- a/include/mapnik/json/unicode_string_grammar_x3_def.hpp +++ b/include/mapnik/json/unicode_string_grammar_x3_def.hpp @@ -105,7 +105,7 @@ using x3::char_; using x3::eol; using x3::no_skip; -x3::uint_parser const hex2 {}; +x3::uint_parser const hex2 {}; x3::uint_parser const hex4 {}; x3::uint_parser const hex8 {}; From 65080e2a9570d504bf676fd31fd6f0d9879ad6c7 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 23 Jul 2018 10:58:27 +0100 Subject: [PATCH 6/7] add support for BOOST_VERSION < 106700 --- include/mapnik/expression_grammar_x3.hpp | 9 +++- .../mapnik/expression_grammar_x3_config.hpp | 4 +- include/mapnik/expression_grammar_x3_def.hpp | 16 ++++-- .../json/extract_bounding_boxes_x3_config.hpp | 27 +++++++--- include/mapnik/json/json_grammar_config.hpp | 22 +++++--- include/mapnik/svg/svg_grammar_config_x3.hpp | 12 ++++- .../mapnik/svg/svg_path_grammar_x3_def.hpp | 52 ++++++++++++++----- .../svg/svg_transform_grammar_x3_def.hpp | 26 +++++++--- src/expression.cpp | 8 ++- src/json/extract_bounding_boxes_x3.cpp | 9 +++- src/json/parse_feature.cpp | 8 ++- src/parse_transform.cpp | 8 +++ src/svg/svg_path_parser.cpp | 7 ++- src/svg/svg_points_parser.cpp | 7 ++- src/svg/svg_transform_parser.cpp | 9 +++- .../mapnik-index/process_geojson_file_x3.cpp | 5 ++ 16 files changed, 182 insertions(+), 47 deletions(-) diff --git a/include/mapnik/expression_grammar_x3.hpp b/include/mapnik/expression_grammar_x3.hpp index 34de5c1dd..ffc487645 100644 --- a/include/mapnik/expression_grammar_x3.hpp +++ b/include/mapnik/expression_grammar_x3.hpp @@ -24,7 +24,7 @@ #define MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP #include - +#include #pragma GCC diagnostic push #include #include @@ -32,6 +32,13 @@ namespace mapnik { namespace grammar { +#if BOOST_VERSION >= 106700 +using transcoder_type = mapnik::transcoder; +#else +using transcoder_type = std::reference_wrapper; +#endif + + namespace x3 = boost::spirit::x3; struct transcoder_tag; struct expression_class; // top-most ID diff --git a/include/mapnik/expression_grammar_x3_config.hpp b/include/mapnik/expression_grammar_x3_config.hpp index 3de3e27c4..f8738f320 100644 --- a/include/mapnik/expression_grammar_x3_config.hpp +++ b/include/mapnik/expression_grammar_x3_config.hpp @@ -24,7 +24,6 @@ #define MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP #include -#include #include namespace mapnik { namespace grammar { @@ -32,10 +31,9 @@ namespace mapnik { namespace grammar { namespace x3 = boost::spirit::x3; using iterator_type = std::string::const_iterator; using phrase_context_type = x3::phrase_parse_context::type; - // define combined context using context_type = x3::context; }} diff --git a/include/mapnik/expression_grammar_x3_def.hpp b/include/mapnik/expression_grammar_x3_def.hpp index e3944ff2b..70dc2411d 100644 --- a/include/mapnik/expression_grammar_x3_def.hpp +++ b/include/mapnik/expression_grammar_x3_def.hpp @@ -70,6 +70,16 @@ namespace mapnik { namespace grammar { auto const& escaped_unicode = json::grammar::escaped_unicode; } + template + inline mapnik::transcoder const& extract_transcoder(Context const& ctx) + { +#if BOOST_VERSION >= 106700 + return x3::get(ctx); +#else + return x3::get(ctx).get(); +#endif + } + auto append = [](auto const& ctx) { _val(ctx) += _attr(ctx); @@ -130,7 +140,7 @@ namespace mapnik { namespace grammar { auto do_unicode = [] (auto const& ctx) { - auto const& tr = x3::get(ctx); + auto const& tr = extract_transcoder(ctx); _val(ctx) = std::move(tr.transcode(_attr(ctx).c_str())); }; @@ -188,13 +198,13 @@ namespace mapnik { namespace grammar { // regex auto do_regex_match = [] (auto const& ctx) { - auto const& tr = x3::get(ctx); + auto const& tr = extract_transcoder(ctx); _val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)) , std::move(_attr(ctx)))); }; auto do_regex_replace = [] (auto const& ctx) { - auto const& tr = x3::get(ctx); + auto const& tr = extract_transcoder(ctx); auto const& pair = _attr(ctx); auto const& pattern = std::get<0>(pair); auto const& format = std::get<1>(pair); diff --git a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp index eb7eb4193..40455423d 100644 --- a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp +++ b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp @@ -67,13 +67,24 @@ struct extract_positions using box_type = mapnik::box2d; using boxes_type = std::vector>>; -using callback_type = extract_positions; + using box_type_f = mapnik::box2d; using boxes_type_f = std::vector>>; -using callback_type_f = extract_positions; +#if BOOST_VERSION >= 106700 +using size_type = std::size_t; +using keys_map_type = keys_map; +using callback_type = extract_positions; +using callback_type_f = extract_positions; +#else +using size_type = std::reference_wrapper const; +using keys_map_type = std::reference_wrapper const; +using callback_type = std::reference_wrapper> const; +using callback_type_f = std::reference_wrapper> const; +#endif + namespace grammar { struct bracket_tag; @@ -85,26 +96,26 @@ using space_type = x3::standard::space_type; using phrase_parse_context_type = x3::phrase_parse_context::type; using extract_bounding_boxes_context_type = - x3::context>; using extract_bounding_boxes_reverse_context_type = - x3::context>>; using extract_bounding_boxes_context_type_f = - x3::context>; using extract_bounding_boxes_reverse_context_type_f = - x3::context>>; }}} diff --git a/include/mapnik/json/json_grammar_config.hpp b/include/mapnik/json/json_grammar_config.hpp index ebd2977ff..82a21ff20 100644 --- a/include/mapnik/json/json_grammar_config.hpp +++ b/include/mapnik/json/json_grammar_config.hpp @@ -90,23 +90,33 @@ struct feature_tag; namespace x3 = boost::spirit::x3; using space_type = x3::standard::space_type; using iterator_type = char const*; - using phrase_parse_context_type = x3::phrase_parse_context::type; + +#if BOOST_VERSION >= 106700 +using keys_map_type = keys_map; +using transcoder_type = mapnik::transcoder const; +using feature_impl_type = mapnik::feature_impl; +#else +using keys_map_type = std::reference_wrapper const; +using transcoder_type = std::reference_wrapper const; +using feature_impl_type = std::reference_wrapper const; +#endif + using context_type = x3::context; using feature_context_type = x3::context>; // our spirit x3 grammars needs this one with changed order of feature_impl and transcoder (??) using feature_context_const_type = x3::context>; }}} diff --git a/include/mapnik/svg/svg_grammar_config_x3.hpp b/include/mapnik/svg/svg_grammar_config_x3.hpp index c60595572..391b34420 100644 --- a/include/mapnik/svg/svg_grammar_config_x3.hpp +++ b/include/mapnik/svg/svg_grammar_config_x3.hpp @@ -39,9 +39,17 @@ namespace x3 = boost::spirit::x3; using space_type = x3::standard::space_type; using iterator_type = char const*; +#if BOOST_VERSION >= 106700 +using svg_converter_wrapper_type = svg_converter_type; +using relative_type = bool; +#else +using svg_converter_wrapper_type = std::reference_wrapper const; +using relative_type = std::reference_wrapper const; +#endif + using phrase_parse_context_type = x3::phrase_parse_context::type; -using svg_parse_context_type = x3::context>; inline double deg2rad(double deg) {return (M_PI * deg) / 180.0;} diff --git a/include/mapnik/svg/svg_path_grammar_x3_def.hpp b/include/mapnik/svg/svg_path_grammar_x3_def.hpp index dab035bdc..250f7e1b0 100644 --- a/include/mapnik/svg/svg_path_grammar_x3_def.hpp +++ b/include/mapnik/svg/svg_path_grammar_x3_def.hpp @@ -34,6 +34,7 @@ namespace mapnik { namespace svg { namespace grammar { + namespace x3 = boost::spirit::x3; using x3::lit; @@ -43,24 +44,51 @@ using x3::no_case; using coord_type = std::tuple; +#if BOOST_VERSION >= 106700 + +template +svg_converter_type & extract_path(Context const& ctx) +{ + return x3::get(ctx); +} + +template +bool & extract_relative(Context const& ctx) +{ + return x3::get(ctx); +} + +#else +template +svg_converter_type & extract_path(Context const& ctx) +{ + return x3::get(ctx).get(); +} +template +bool & extract_relative(Context const& ctx) +{ + return x3::get(ctx).get(); +} +#endif + auto const move_to = [] (auto const& ctx) { - x3::get(ctx).move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); + extract_path(ctx).move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); }; auto const line_to = [] (auto const & ctx) { - x3::get(ctx).line_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); + extract_path(ctx).line_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); }; auto const hline_to = [] (auto const& ctx) { - x3::get(ctx).hline_to(_attr(ctx), x3::get(ctx)); + extract_path(ctx).hline_to(_attr(ctx), x3::get(ctx)); }; auto const vline_to = [] (auto const& ctx) { - x3::get(ctx).vline_to(_attr(ctx), x3::get(ctx)); + extract_path(ctx).vline_to(_attr(ctx), x3::get(ctx)); }; auto const curve4 = [] (auto const& ctx) @@ -69,7 +97,7 @@ auto const curve4 = [] (auto const& ctx) auto const& p0 = boost::fusion::at_c<0>(attr); auto const& p1 = boost::fusion::at_c<1>(attr); auto const& p2 = boost::fusion::at_c<2>(attr); - x3::get(ctx).curve4(std::get<0>(p0),std::get<1>(p0), + extract_path(ctx).curve4(std::get<0>(p0),std::get<1>(p0), std::get<0>(p1),std::get<1>(p1), std::get<0>(p2),std::get<1>(p2), x3::get(ctx)); @@ -80,7 +108,7 @@ auto const curve4_smooth = [] (auto const& ctx) auto const& attr = _attr(ctx); auto const& p0 = boost::fusion::at_c<0>(attr); auto const& p1 = boost::fusion::at_c<1>(attr); - x3::get(ctx).curve4(std::get<0>(p0),std::get<1>(p0), + extract_path(ctx).curve4(std::get<0>(p0),std::get<1>(p0), std::get<0>(p1),std::get<1>(p1), x3::get(ctx)); }; @@ -90,7 +118,7 @@ auto const curve3 = [] (auto const& ctx) auto const& attr = _attr(ctx); auto const& p0 = boost::fusion::at_c<0>(attr); auto const& p1 = boost::fusion::at_c<1>(attr); - x3::get(ctx).curve3(std::get<0>(p0),std::get<1>(p0), + extract_path(ctx).curve3(std::get<0>(p0),std::get<1>(p0), std::get<0>(p1),std::get<1>(p1), x3::get(ctx)); }; @@ -98,7 +126,7 @@ auto const curve3 = [] (auto const& ctx) auto const curve3_smooth = [] (auto const& ctx) { auto const& attr = _attr(ctx); - x3::get(ctx).curve3(std::get<0>(attr),std::get<1>(attr), + extract_path(ctx).curve3(std::get<0>(attr),std::get<1>(attr), x3::get(ctx)); }; @@ -111,7 +139,7 @@ auto const arc_to = [] (auto & ctx) int large_arc_flag = boost::fusion::at_c<2>(attr); int sweep_flag = boost::fusion::at_c<3>(attr); auto const& v = boost::fusion::at_c<4>(attr); - x3::get(ctx).arc_to(std::get<0>(p),std::get<1>(p), + extract_path(ctx).arc_to(std::get<0>(p),std::get<1>(p), deg2rad(angle), large_arc_flag, sweep_flag, std::get<0>(v),std::get<1>(v), x3::get(ctx)); @@ -119,17 +147,17 @@ auto const arc_to = [] (auto & ctx) auto const close_path = [] (auto const& ctx) { - x3::get(ctx).close_subpath(); + extract_path(ctx).close_subpath(); }; auto const relative = [] (auto const& ctx) { - x3::get(ctx) = true; + extract_relative(ctx) = true; }; auto const absolute = [] (auto const& ctx) { - x3::get(ctx) = false; + extract_relative(ctx) = false; }; // exported rules diff --git a/include/mapnik/svg/svg_transform_grammar_x3_def.hpp b/include/mapnik/svg/svg_transform_grammar_x3_def.hpp index b3b7ebe47..d6ea30be2 100644 --- a/include/mapnik/svg/svg_transform_grammar_x3_def.hpp +++ b/include/mapnik/svg/svg_transform_grammar_x3_def.hpp @@ -44,9 +44,23 @@ using x3::lit; using x3::double_; using x3::no_case; +#if BOOST_VERSION >= 106700 +template +auto & extract_transform(Context const& ctx) +{ + return x3::get(ctx); +} +#else +template +auto & extract_transform(Context const& ctx) +{ + return x3::get(ctx).get(); +} +#endif + auto const matrix_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx); + auto & tr = extract_transform(ctx); auto const& attr = _attr(ctx); auto a = boost::fusion::at_c<0>(attr); auto b = boost::fusion::at_c<1>(attr); @@ -59,7 +73,7 @@ auto const matrix_action = [] (auto const& ctx) auto const rotate_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx); + auto & tr = extract_transform(ctx); auto const& attr = _attr(ctx); auto a = boost::fusion::at_c<0>(attr); auto cx = boost::fusion::at_c<1>(attr) ? *boost::fusion::at_c<1>(attr) : 0.0; @@ -79,7 +93,7 @@ auto const rotate_action = [] (auto const& ctx) auto const translate_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx); + auto & tr = extract_transform(ctx); auto const& attr = _attr(ctx); auto tx = boost::fusion::at_c<0>(attr); auto ty = boost::fusion::at_c<1>(attr); @@ -89,7 +103,7 @@ auto const translate_action = [] (auto const& ctx) auto const scale_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx); + auto & tr = extract_transform(ctx); auto const& attr = _attr(ctx); auto sx = boost::fusion::at_c<0>(attr); auto sy = boost::fusion::at_c<1>(attr); @@ -99,14 +113,14 @@ auto const scale_action = [] (auto const& ctx) auto const skewX_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx); + auto & tr = extract_transform(ctx); auto skew_x = _attr(ctx); tr = agg::trans_affine_skewing(deg2rad(skew_x), 0.0) * tr; }; auto const skewY_action = [] (auto const& ctx) { - auto & tr = x3::get(ctx); + auto & tr = extract_transform(ctx); auto skew_y= _attr(ctx); tr = agg::trans_affine_skewing(0.0, deg2rad(skew_y)) * tr; }; diff --git a/src/expression.cpp b/src/expression.cpp index ad87eb5ec..9c7c6c710 100644 --- a/src/expression.cpp +++ b/src/expression.cpp @@ -35,11 +35,17 @@ expression_ptr parse_expression(std::string const& str) auto node = std::make_shared(); using boost::spirit::x3::ascii::space; mapnik::transcoder const tr("utf8"); +#if BOOST_VERSION >=106700 auto parser = boost::spirit::x3::with(tr) [ mapnik::expression_grammar() ]; - +#else + auto parser = boost::spirit::x3::with(std::ref(tr)) + [ + mapnik::expression_grammar() + ]; +#endif bool r = false; std::string::const_iterator itr = str.begin(); std::string::const_iterator const end = str.end(); diff --git a/src/json/extract_bounding_boxes_x3.cpp b/src/json/extract_bounding_boxes_x3.cpp index af9367ebe..c1c073d27 100644 --- a/src/json/extract_bounding_boxes_x3.cpp +++ b/src/json/extract_bounding_boxes_x3.cpp @@ -185,12 +185,19 @@ void extract_bounding_boxes(Iterator& start, Iterator const& end, Boxes & boxes) extract_positions callback(start, boxes); auto keys = mapnik::json::get_keys(); std::size_t bracket_counter = 0; +#if BOOST_VERSION >= 106700 auto feature_collection_impl = x3::with(bracket_counter) [x3::with(callback) [x3::with(keys) [mapnik::json::grammar::feature_collection] ]]; - +#else + auto feature_collection_impl = x3::with(std::ref(bracket_counter)) + [x3::with(std::ref(callback)) + [x3::with(std::ref(keys)) + [mapnik::json::grammar::feature_collection] + ]]; +#endif if (!x3::phrase_parse(start, end, feature_collection_impl, space_type())) { throw std::runtime_error("Can't extract bounding boxes"); diff --git a/src/json/parse_feature.cpp b/src/json/parse_feature.cpp index 6530377b4..9155ee306 100644 --- a/src/json/parse_feature.cpp +++ b/src/json/parse_feature.cpp @@ -31,9 +31,15 @@ void parse_feature(Iterator start, Iterator end, feature_impl& feature, mapnik:: { namespace x3 = boost::spirit::x3; using space_type = mapnik::json::grammar::space_type; +#if BOOST_VERSION >= 106700 auto grammar = x3::with(tr) [x3::with(feature) - [ mapnik::json::feature_grammar() ]]; + [ mapnik::json::feature_grammar() ]]; +#else + auto grammar = x3::with(std::ref(tr)) + [x3::with(std::ref(feature)) + [ mapnik::json::feature_grammar() ]]; +#endif if (!x3::phrase_parse(start, end, grammar, space_type())) { throw std::runtime_error("Can't parser GeoJSON Feature"); diff --git a/src/parse_transform.cpp b/src/parse_transform.cpp index 3d2e5e0e4..b4daa8458 100644 --- a/src/parse_transform.cpp +++ b/src/parse_transform.cpp @@ -37,10 +37,18 @@ transform_list_ptr parse_transform(std::string const& str, std::string const& en std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); mapnik::transcoder const tr(encoding); +#if BOOST_VERSION >= 106700 auto const parser = boost::spirit::x3::with(tr) [ mapnik::transform_expression_grammar() ]; +#else + auto const parser = boost::spirit::x3::with(std::ref(tr)) + [ + mapnik::transform_expression_grammar() + ]; +#endif + bool status = false; try { diff --git a/src/svg/svg_path_parser.cpp b/src/svg/svg_path_parser.cpp index 390b80da6..29c9b27ae 100644 --- a/src/svg/svg_path_parser.cpp +++ b/src/svg/svg_path_parser.cpp @@ -40,10 +40,15 @@ bool parse_path(const char* wkt, PathType& p) iterator_type last = wkt + std::strlen(wkt); bool relative = false; using space_type = mapnik::svg::grammar::space_type; +#if BOOST_VERSION >= 106700 auto const grammar = x3::with(p) [ x3::with(relative) [mapnik::svg::svg_path_grammar()]]; - +#else + auto const grammar = x3::with(std::ref(p)) + [ x3::with(std::ref(relative)) + [mapnik::svg::svg_path_grammar()]]; +#endif try { if (!x3::phrase_parse(first, last, grammar, space_type()) diff --git a/src/svg/svg_points_parser.cpp b/src/svg/svg_points_parser.cpp index 2fd68734c..5e21ce4c8 100644 --- a/src/svg/svg_points_parser.cpp +++ b/src/svg/svg_points_parser.cpp @@ -40,10 +40,15 @@ bool parse_points(const char* wkt, PathType& p) iterator_type last = wkt + std::strlen(wkt); bool relative = false; +#if BOOST_VERSION >= 106700 auto const grammar = x3::with(p) [ x3::with(relative) [mapnik::svg::svg_points_grammar()]]; - +#else + auto const grammar = x3::with(std::ref(p)) + [ x3::with(std::ref(relative)) + [mapnik::svg::svg_points_grammar()]]; +#endif try { if (!x3::phrase_parse(first, last, grammar, space_type()) diff --git a/src/svg/svg_transform_parser.cpp b/src/svg/svg_transform_parser.cpp index e1ecf5639..e7f8863f3 100644 --- a/src/svg/svg_transform_parser.cpp +++ b/src/svg/svg_transform_parser.cpp @@ -37,8 +37,15 @@ bool parse_svg_transform(const char* wkt, Transform& tr) iterator_type first = wkt; iterator_type last = wkt + std::strlen(wkt); using space_type = mapnik::svg::grammar::space_type; + +#if BOOST_VERSION >= 106700 auto const grammar = x3::with(tr) - [mapnik::svg::svg_transform_grammar()]; + [mapnik::svg::svg_transform_grammar()]; + +#else + auto const grammar = x3::with(std::ref(tr)) + [mapnik::svg::svg_transform_grammar()]; +#endif try { diff --git a/utils/mapnik-index/process_geojson_file_x3.cpp b/utils/mapnik-index/process_geojson_file_x3.cpp index 62f5ccdea..4f12adbdf 100644 --- a/utils/mapnik-index/process_geojson_file_x3.cpp +++ b/utils/mapnik-index/process_geojson_file_x3.cpp @@ -285,8 +285,13 @@ std::pair process_geojson_file_x3(T & b using namespace boost::spirit; using space_type = mapnik::json::grammar::space_type; auto keys = mapnik::json::get_keys(); +#if BOOST_VERSION >= 106700 auto feature_grammar = x3::with(keys) [ geojson_value ]; +#else + auto feature_grammar = x3::with(std::ref(keys)) + [ geojson_value ]; +#endif for (auto const& item : boxes) { if (item.first.valid()) From 5eca7731e99b907b3018d2dfb0fc0f51d8a40de4 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 23 Jul 2018 13:26:22 +0100 Subject: [PATCH 7/7] rely on implicit std::reference_wrapper -> T conversions (thanks @lightmare) --- include/mapnik/expression_grammar_x3_def.hpp | 4 ---- include/mapnik/svg/svg_path_grammar_x3_def.hpp | 16 ---------------- .../mapnik/svg/svg_transform_grammar_x3_def.hpp | 10 +--------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/include/mapnik/expression_grammar_x3_def.hpp b/include/mapnik/expression_grammar_x3_def.hpp index 70dc2411d..2d9437c62 100644 --- a/include/mapnik/expression_grammar_x3_def.hpp +++ b/include/mapnik/expression_grammar_x3_def.hpp @@ -73,11 +73,7 @@ namespace mapnik { namespace grammar { template inline mapnik::transcoder const& extract_transcoder(Context const& ctx) { -#if BOOST_VERSION >= 106700 return x3::get(ctx); -#else - return x3::get(ctx).get(); -#endif } auto append = [](auto const& ctx) diff --git a/include/mapnik/svg/svg_path_grammar_x3_def.hpp b/include/mapnik/svg/svg_path_grammar_x3_def.hpp index 250f7e1b0..50503fcfc 100644 --- a/include/mapnik/svg/svg_path_grammar_x3_def.hpp +++ b/include/mapnik/svg/svg_path_grammar_x3_def.hpp @@ -34,7 +34,6 @@ namespace mapnik { namespace svg { namespace grammar { - namespace x3 = boost::spirit::x3; using x3::lit; @@ -44,8 +43,6 @@ using x3::no_case; using coord_type = std::tuple; -#if BOOST_VERSION >= 106700 - template svg_converter_type & extract_path(Context const& ctx) { @@ -58,19 +55,6 @@ bool & extract_relative(Context const& ctx) return x3::get(ctx); } -#else -template -svg_converter_type & extract_path(Context const& ctx) -{ - return x3::get(ctx).get(); -} -template -bool & extract_relative(Context const& ctx) -{ - return x3::get(ctx).get(); -} -#endif - auto const move_to = [] (auto const& ctx) { extract_path(ctx).move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get(ctx)); diff --git a/include/mapnik/svg/svg_transform_grammar_x3_def.hpp b/include/mapnik/svg/svg_transform_grammar_x3_def.hpp index d6ea30be2..7b8b7b8c7 100644 --- a/include/mapnik/svg/svg_transform_grammar_x3_def.hpp +++ b/include/mapnik/svg/svg_transform_grammar_x3_def.hpp @@ -44,19 +44,11 @@ using x3::lit; using x3::double_; using x3::no_case; -#if BOOST_VERSION >= 106700 template -auto & extract_transform(Context const& ctx) +agg::trans_affine & extract_transform(Context const& ctx) { return x3::get(ctx); } -#else -template -auto & extract_transform(Context const& ctx) -{ - return x3::get(ctx).get(); -} -#endif auto const matrix_action = [] (auto const& ctx) {