diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-12 18:41:34 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-01-13 10:36:26 (GMT) |
commit | f3bc816af1b0d61452de973963e453bf3b3f95a2 (patch) | |
tree | e895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/spirit/home/support/nonterminal | |
parent | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff) | |
download | swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2 |
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/support/nonterminal')
3 files changed, 265 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp new file mode 100644 index 0000000..f037acc --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_SPIRIT_EXPAND_ARG_FEB_19_2007_1107AM) +#define BOOST_SPIRIT_EXPAND_ARG_FEB_19_2007_1107AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/utility/result_of.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/spirit/home/support/string_traits.hpp> + +namespace boost { namespace spirit { namespace detail +{ + /////////////////////////////////////////////////////////////////////////// + template <typename Context> + struct expand_arg + { + template <typename T> + struct result_type + { + // This is a temporary hack. The better way is to detect if T + // can be called given unused context. + typedef typename + mpl::eval_if< + mpl::or_<is_scalar<T>, traits::is_string<T> > + , mpl::identity<T const &> + , boost::result_of<T(unused_type, Context)> + >::type + type; + }; + + template <typename T> + struct result; + + template <typename F, typename A0> + struct result<F(A0)> + : result_type<A0> {}; + + template <typename F, typename A0> + struct result<F(A0&)> + : result_type<A0> {}; + + expand_arg(Context& context) + : context(context) + { + } + + template <typename T> + typename result_type<T>::type + call(T const& f, mpl::false_) const + { + return f(unused, context); + } + + template <typename T> + typename result_type<T>::type + call(T const& val, mpl::true_) const + { + return val; + } + + template <typename T> + typename result_type<T>::type + operator()(T const& x) const + { + return call(x, mpl::or_<is_scalar<T>, traits::is_string<T> >()); + } + + Context& context; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + expand_arg& operator= (expand_arg const&); + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/extract_param.hpp b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/extract_param.hpp new file mode 100644 index 0000000..6149932 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/extract_param.hpp @@ -0,0 +1,123 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2009 Francois Barel + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_SPIRIT_EXTRACT_PARAM_AUGUST_08_2009_0848AM) +#define BOOST_SPIRIT_EXTRACT_PARAM_AUGUST_08_2009_0848AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/support/meta_compiler.hpp> +#include <boost/spirit/home/support/nonterminal/locals.hpp> +#include <boost/spirit/home/support/unused.hpp> +#include <boost/spirit/home/support/common_terminals.hpp> + +#include <boost/function_types/is_function.hpp> +#include <boost/function_types/parameter_types.hpp> +#include <boost/function_types/result_type.hpp> +#include <boost/fusion/include/as_list.hpp> +#include <boost/fusion/include/as_vector.hpp> +#include <boost/mpl/deref.hpp> +#include <boost/mpl/end.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/find_if.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> + +namespace boost { namespace spirit { namespace detail +{ + /////////////////////////////////////////////////////////////////////////// + // Helpers to extract params (locals, attributes, ...) from nonterminal + // template arguments + /////////////////////////////////////////////////////////////////////////// + template <typename Types, typename Pred, typename Default> + struct extract_param + { + typedef typename mpl::find_if<Types, Pred>::type pos; + + typedef typename + mpl::eval_if< + is_same<pos, typename mpl::end<Types>::type> + , mpl::identity<Default> + , mpl::deref<pos> + >::type + type; + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename Types> + struct extract_locals + : fusion::result_of::as_vector< + typename extract_param< + Types + , is_locals<mpl::_> + , locals<> + >::type + > + {}; + + /////////////////////////////////////////////////////////////////////////// + template <typename Domain, typename Types> + struct extract_component + : spirit::result_of::compile< + Domain + , typename extract_param< + Types + , traits::matches<Domain, mpl::_> + , unused_type + >::type + > + {}; + + /////////////////////////////////////////////////////////////////////////// + template <typename Types> + struct extract_sig + : extract_param< + Types + , function_types::is_function<mpl::_> + , void() + > + {}; + + template <typename Sig> + struct attr_from_sig + { + typedef typename function_types::result_type<Sig>::type attr; + + typedef typename + mpl::if_< + is_same<attr, void> + , unused_type + , attr + >::type + type; + }; + + template <typename Sig> + struct params_from_sig + { + typedef typename function_types::parameter_types<Sig>::type params; + + typedef typename fusion::result_of::as_list<params>::type type; + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename Types> + struct extract_encoding + : extract_param< + Types + , is_char_encoding<mpl::_> + , unused_type + > + {}; +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/locals.hpp b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/locals.hpp new file mode 100644 index 0000000..4db0349 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/locals.hpp @@ -0,0 +1,54 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_SPIRIT_LOCALS_APRIL_03_2007_0506PM) +#define BOOST_SPIRIT_LOCALS_APRIL_03_2007_0506PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/bool.hpp> + +#if !defined(BOOST_SPIRIT_MAX_LOCALS_SIZE) +# define BOOST_SPIRIT_MAX_LOCALS_SIZE 10 +#else +# if BOOST_SPIRIT_MAX_LOCALS_SIZE < 3 +# undef BOOST_SPIRIT_MAX_LOCALS_SIZE +# define BOOST_SPIRIT_MAX_LOCALS_SIZE 10 +# endif +#endif + +namespace boost { namespace spirit +{ + /////////////////////////////////////////////////////////////////////////// + template < + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + BOOST_SPIRIT_MAX_LOCALS_SIZE, typename T, mpl::na) + > + struct locals + : mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_MAX_LOCALS_SIZE, T)> {}; + + /////////////////////////////////////////////////////////////////////////// + namespace detail + { + template <typename T> + struct is_locals + : mpl::false_ + {}; + + template <BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_MAX_LOCALS_SIZE, typename T)> + struct is_locals<locals<BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_MAX_LOCALS_SIZE, T)> > + : mpl::true_ + {}; + } +}} + +#endif |