From f996c0df37876dfce7ba4ee46a3b9edc24cf3a8b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 13 Sep 2011 09:40:10 -0600 Subject: [PATCH] One more file no longer using boost_pp --- .../dispatchkit/proxy_constructors.hpp | 70 +++++++------------ 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/include/chaiscript/dispatchkit/proxy_constructors.hpp b/include/chaiscript/dispatchkit/proxy_constructors.hpp index b555489..32bae3e 100644 --- a/include/chaiscript/dispatchkit/proxy_constructors.hpp +++ b/include/chaiscript/dispatchkit/proxy_constructors.hpp @@ -4,21 +4,36 @@ // and Jason Turner (jason@emptycrate.com) // http://www.chaiscript.com -#include -#ifndef BOOST_PP_IS_ITERATING #ifndef CHAISCRIPT_PROXY_CONSTRUCTORS_HPP_ #define CHAISCRIPT_PROXY_CONSTRUCTORS_HPP_ - - -#define BOOST_PP_ITERATION_LIMITS ( 0, 10 ) -#define BOOST_PP_FILENAME_1 -#include BOOST_PP_ITERATE() -# endif - namespace chaiscript { + namespace dispatch + { + namespace detail + { + /** + * A constructor function, used for creating a new object + * of a given type with a given set of params + */ + template + std::shared_ptr constructor_(Params ... params) + { + return std::shared_ptr(new Class(params...)); + } + + template + Proxy_Function build_constructor_(Class (*)(Params...)) + { + typedef std::shared_ptr (sig)(Params...); + return Proxy_Function(new Proxy_Function_Impl(std::function(&(constructor_)))); + } + } + } + + /// \brief Generates a constructor function for use with ChaiScript /// /// \tparam T The signature of the constructor to generate. In the form of: ClassType (ParamType1, ParamType2, ...) @@ -36,43 +51,8 @@ namespace chaiscript T *f = 0; return (dispatch::detail::build_constructor_(f)); } + } -#else -# define n BOOST_PP_ITERATION() - -namespace chaiscript -{ - namespace dispatch - { - namespace detail - { - /** - * A constructor function, used for creating a new object - * of a given type with a given set of params - */ - template - std::shared_ptr constructor_( BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) ) - { - return std::shared_ptr(new Class( BOOST_PP_ENUM_PARAMS(n, p) )); - } - - /** - * Helper function for build a constructor function - * example: - * dispatchengine.register_function(build_constructor, "MyClass"); - * \todo See if it is possible to make this not be a variadic function - */ - template - Proxy_Function build_constructor_(Class (*)(BOOST_PP_ENUM_PARAMS(n, Param))) - { - typedef std::shared_ptr (sig)(BOOST_PP_ENUM_PARAMS(n, Param)); - return Proxy_Function(new Proxy_Function_Impl(std::function(&(constructor_)))); - } - } - } -} -#undef n - #endif