update old boost::phoenix syntax

This commit is contained in:
artemp 2016-03-04 10:25:03 +01:00
parent d2df889b47
commit 9b9e0f5b64
5 changed files with 164 additions and 262 deletions

View file

@ -49,12 +49,7 @@ using ascii_space_type = boost::spirit::ascii::space_type;
struct percent_conv_impl
{
template <typename T>
struct result
{
using type = unsigned;
};
using result_type = unsigned;
unsigned operator() (double val) const
{
return safe_cast<uint8_t>(std::lround((255.0 * val)/100.0));
@ -63,12 +58,7 @@ struct percent_conv_impl
struct alpha_conv_impl
{
template <typename T>
struct result
{
using type = unsigned;
};
using result_type = unsigned;
unsigned operator() (double val) const
{
return safe_cast<uint8_t>(std::lround((255.0 * val)));
@ -77,12 +67,7 @@ struct alpha_conv_impl
struct hsl_conv_impl
{
template<typename T>
struct result
{
using type = void;
};
using result_type = void;
template <typename T0,typename T1, typename T2, typename T3>
void operator() (T0 & c, T1 h, T2 s, T3 l) const
{

View file

@ -47,13 +47,7 @@ inline double deg2rad(double deg)
template <typename PathType>
struct move_to
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit move_to(PathType & path)
: path_(path) {}
@ -69,12 +63,7 @@ struct move_to
template <typename PathType>
struct hline_to
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit hline_to(PathType & path)
: path_(path) {}
@ -91,12 +80,7 @@ struct hline_to
template <typename PathType>
struct vline_to
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit vline_to(PathType & path)
: path_(path) {}
@ -112,12 +96,7 @@ struct vline_to
template <typename PathType>
struct line_to
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit line_to(PathType & path)
: path_(path) {}
@ -134,12 +113,7 @@ struct line_to
template <typename PathType>
struct curve4
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit curve4(PathType & path)
: path_(path) {}
@ -159,12 +133,7 @@ struct curve4
template <typename PathType>
struct curve4_smooth
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit curve4_smooth(PathType & path)
: path_(path) {}
@ -181,12 +150,7 @@ struct curve4_smooth
template <typename PathType>
struct curve3
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit curve3(PathType & path)
: path_(path) {}
@ -204,12 +168,7 @@ struct curve3
template <typename PathType>
struct curve3_smooth
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit curve3_smooth(PathType & path)
: path_(path) {}
@ -226,12 +185,7 @@ struct curve3_smooth
template <typename PathType>
struct arc_to
{
template <typename T0>
struct result
{
using type = void;
};
using result_type = void;
explicit arc_to(PathType & path)
: path_(path) {}

View file

@ -132,7 +132,7 @@ namespace mapnik { namespace svg {
function<close<PathType> > close_;
};
}}
}}
#endif // MAPNIK_SVG_PATH_GRAMMAR_HPP

View file

@ -40,226 +40,189 @@
namespace mapnik { namespace svg {
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
inline double deg2rad(double d)
inline double deg2rad(double d)
{
return M_PI * d / 180.0;
}
template <typename TransformType>
struct process_matrix
{
using result_type = void;
explicit process_matrix( TransformType & tr)
:tr_(tr) {}
void operator () (double a, double b, double c, double d, double e, double f) const
{
return M_PI * d / 180.0;
tr_ = agg::trans_affine(a,b,c,d,e,f) * tr_;
}
template <typename TransformType>
struct process_matrix
TransformType & tr_;
};
template <typename TransformType>
struct process_rotate
{
using result_type = void;
explicit process_rotate( TransformType & tr)
:tr_(tr) {}
template <typename T0,typename T1,typename T2>
void operator () (T0 a, T1 cx, T2 cy) const
{
template <typename T0>
struct result
if (cx == 0.0 && cy == 0.0)
{
using type = void;
};
explicit process_matrix( TransformType & tr)
:tr_(tr) {}
void operator () (double a, double b, double c, double d, double e, double f) const
{
tr_ = agg::trans_affine(a,b,c,d,e,f) * tr_;
tr_ = agg::trans_affine_rotation(deg2rad(a)) * tr_;
}
else
{
agg::trans_affine t = agg::trans_affine_translation(-cx,-cy);
t *= agg::trans_affine_rotation(deg2rad(a));
t *= agg::trans_affine_translation(cx, cy);
tr_ = t * tr_;
}
}
TransformType & tr_;
};
TransformType & tr_;
};
template <typename TransformType>
struct process_rotate
template <typename TransformType>
struct process_translate
{
using result_type = void;
explicit process_translate( TransformType & tr)
:tr_(tr) {}
template <typename T0,typename T1>
void operator () (T0 tx, T1 ty) const
{
template <typename T0>
struct result
{
using type = void;
};
if (ty) tr_ = agg::trans_affine_translation(tx,*ty) * tr_;
else tr_ = agg::trans_affine_translation(tx,0.0) * tr_;
}
explicit process_rotate( TransformType & tr)
:tr_(tr) {}
TransformType & tr_;
};
template <typename T0,typename T1,typename T2>
void operator () (T0 a, T1 cx, T2 cy) const
{
if (cx == 0.0 && cy == 0.0)
{
tr_ = agg::trans_affine_rotation(deg2rad(a)) * tr_;
}
else
{
agg::trans_affine t = agg::trans_affine_translation(-cx,-cy);
t *= agg::trans_affine_rotation(deg2rad(a));
t *= agg::trans_affine_translation(cx, cy);
tr_ = t * tr_;
}
}
template <typename TransformType>
struct process_scale
{
using result_type = void;
explicit process_scale( TransformType & tr)
:tr_(tr) {}
TransformType & tr_;
};
template <typename TransformType>
struct process_translate
template <typename T0,typename T1>
void operator () (T0 sx, T1 sy) const
{
template <typename T0>
struct result
{
using type = void;
};
if (sy) tr_ = agg::trans_affine_scaling(sx,*sy) * tr_;
else tr_ = agg::trans_affine_scaling(sx,sx) * tr_;
}
explicit process_translate( TransformType & tr)
:tr_(tr) {}
TransformType & tr_;
};
template <typename T0,typename T1>
void operator () (T0 tx, T1 ty) const
{
if (ty) tr_ = agg::trans_affine_translation(tx,*ty) * tr_;
else tr_ = agg::trans_affine_translation(tx,0.0) * tr_;
}
TransformType & tr_;
};
template <typename TransformType>
struct process_skew
{
using result_type = void;
explicit process_skew( TransformType & tr)
:tr_(tr) {}
template <typename TransformType>
struct process_scale
template <typename T0,typename T1>
void operator () (T0 skew_x, T1 skew_y) const
{
template <typename T0>
struct result
{
using type = void;
};
tr_ = agg::trans_affine_skewing(deg2rad(skew_x),deg2rad(skew_y)) * tr_;
}
explicit process_scale( TransformType & tr)
:tr_(tr) {}
TransformType & tr_;
};
template <typename T0,typename T1>
void operator () (T0 sx, T1 sy) const
{
if (sy) tr_ = agg::trans_affine_scaling(sx,*sy) * tr_;
else tr_ = agg::trans_affine_scaling(sx,sx) * tr_;
}
TransformType & tr_;
};
template <typename TransformType>
struct process_skew
template <typename Iterator, typename SkipType, typename TransformType>
struct svg_transform_grammar : qi::grammar<Iterator,SkipType>
{
explicit svg_transform_grammar(TransformType & tr)
: svg_transform_grammar::base_type(start),
matrix_action(process_matrix<TransformType>(tr)),
rotate_action(process_rotate<TransformType>(tr)),
translate_action(process_translate<TransformType>(tr)),
scale_action(process_scale<TransformType>(tr)),
skew_action(process_skew<TransformType>(tr))
{
template <typename T0>
struct result
{
using type = void;
};
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_5_type _5;
qi::_6_type _6;
qi::_a_type _a;
qi::_b_type _b;
qi::_c_type _c;
qi::lit_type lit;
qi::double_type double_;
qi::no_case_type no_case;
explicit process_skew( TransformType & tr)
:tr_(tr) {}
start = +transform_ ;
template <typename T0,typename T1>
void operator () (T0 skew_x, T1 skew_y) const
{
tr_ = agg::trans_affine_skewing(deg2rad(skew_x),deg2rad(skew_y)) * tr_;
}
transform_ = matrix | rotate | translate | scale | rotate | skewX | skewY ;
TransformType & tr_;
};
matrix = no_case[lit("matrix")]
>> lit('(')
>> (
double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_) [ matrix_action(_1,_2,_3,_4,_5,_6) ]
>> lit(')')
;
// commented as this does not appear used and crashes clang when used with pch
/*
struct print_action
{
template <typename T>
void operator()(T const& c, qi::unused_type, qi::unused_type) const
{
MAPNIK_LOG_DEBUG(svg) << typeid(c).name();
}
};
*/
translate = no_case[lit("translate")]
>> lit('(')
>> (double_ >> -lit(',')
>> -double_) [ translate_action(_1,_2) ]
>> lit(')');
template <typename Iterator, typename SkipType, typename TransformType>
struct svg_transform_grammar : qi::grammar<Iterator,SkipType>
{
explicit svg_transform_grammar(TransformType & tr)
: svg_transform_grammar::base_type(start),
matrix_action(process_matrix<TransformType>(tr)),
rotate_action(process_rotate<TransformType>(tr)),
translate_action(process_translate<TransformType>(tr)),
scale_action(process_scale<TransformType>(tr)),
skew_action(process_skew<TransformType>(tr))
{
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_5_type _5;
qi::_6_type _6;
qi::_a_type _a;
qi::_b_type _b;
qi::_c_type _c;
qi::lit_type lit;
qi::double_type double_;
qi::no_case_type no_case;
scale = no_case[lit("scale")]
>> lit('(')
>> (double_ >> -lit(',')
>> -double_ )[ scale_action(_1,_2)]
>> lit(')');
start = +transform_ ;
rotate = no_case[lit("rotate")]
>> lit('(')
>> double_[_a = _1] >> -lit(',')
>> -(double_ [_b = _1] >> -lit(',') >> double_[_c = _1])
>> lit(')') [ rotate_action(_a,_b,_c)];
transform_ = matrix | rotate | translate | scale | rotate | skewX | skewY ;
skewX = no_case[lit("skewX")] >> lit('(') >> double_ [ skew_action(_1, 0.0)] >> lit(')');
matrix = no_case[lit("matrix")]
>> lit('(')
>> (
double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_ >> -lit(',')
>> double_) [ matrix_action(_1,_2,_3,_4,_5,_6) ]
>> lit(')')
;
skewY = no_case[lit("skewY")] >> lit('(') >> double_ [ skew_action(0.0, _1)] >> lit(')');
translate = no_case[lit("translate")]
>> lit('(')
>> (double_ >> -lit(',')
>> -double_) [ translate_action(_1,_2) ]
>> lit(')');
}
scale = no_case[lit("scale")]
>> lit('(')
>> (double_ >> -lit(',')
>> -double_ )[ scale_action(_1,_2)]
>> lit(')');
// rules
qi::rule<Iterator,SkipType> start;
qi::rule<Iterator,SkipType> transform_;
qi::rule<Iterator,SkipType> matrix;
qi::rule<Iterator,SkipType> translate;
qi::rule<Iterator,SkipType> scale;
qi::rule<Iterator,qi::locals<double,double,double>, SkipType> rotate;
qi::rule<Iterator,SkipType> skewX;
qi::rule<Iterator,SkipType> skewY;
rotate = no_case[lit("rotate")]
>> lit('(')
>> double_[_a = _1] >> -lit(',')
>> -(double_ [_b = _1] >> -lit(',') >> double_[_c = _1])
>> lit(')') [ rotate_action(_a,_b,_c)];
// actions
function<process_matrix<TransformType> > matrix_action;
function<process_rotate<TransformType> > rotate_action;
function<process_translate<TransformType> > translate_action;
function<process_scale<TransformType> > scale_action;
function<process_skew<TransformType> > skew_action;
};
skewX = no_case[lit("skewX")] >> lit('(') >> double_ [ skew_action(_1, 0.0)] >> lit(')');
skewY = no_case[lit("skewY")] >> lit('(') >> double_ [ skew_action(0.0, _1)] >> lit(')');
}
// rules
qi::rule<Iterator,SkipType> start;
qi::rule<Iterator,SkipType> transform_;
qi::rule<Iterator,SkipType> matrix;
qi::rule<Iterator,SkipType> translate;
qi::rule<Iterator,SkipType> scale;
qi::rule<Iterator,qi::locals<double,double,double>, SkipType> rotate;
qi::rule<Iterator,SkipType> skewX;
qi::rule<Iterator,SkipType> skewY;
// actions
function<process_matrix<TransformType> > matrix_action;
function<process_rotate<TransformType> > rotate_action;
function<process_translate<TransformType> > translate_action;
function<process_scale<TransformType> > scale_action;
function<process_skew<TransformType> > skew_action;
};
}}
}}
#endif // MAPNIK_SVG_TRANSFORM_GRAMMAR_HPP

@ -1 +1 @@
Subproject commit 93e70a5ae91b2bd4b8fc3912a7e6e4b017021b2b
Subproject commit cc17060aaeb459fd5ed3f8c50ef66bfd461585ab