// This file is distributed under the BSD License. // See "license.txt" for details. // Copyright 2009, Jonathan Turner (jturner@minnow-lang.org) // and Jason Turner (lefticus@gmail.com) // http://www.chaiscript.com #include #ifndef BOOST_PP_IS_ITERATING #ifndef __proxy_constructors_hpp__ #define __proxy_constructors_hpp__ #include #include #include #define BOOST_PP_ITERATION_LIMITS ( 0, 10 ) #define BOOST_PP_FILENAME_1 #include BOOST_PP_ITERATE() # endif #else # define n BOOST_PP_ITERATION() namespace dispatchkit { /** * A constructor function, used for creating a new object * of a given type with a given set of params */ template boost::shared_ptr constructor( BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) ) { return boost::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 boost::function (BOOST_PP_ENUM_PARAMS(n, Param))> build_constructor() { typedef boost::shared_ptr (*func)(BOOST_PP_ENUM_PARAMS(n, Param)); return boost::function (BOOST_PP_ENUM_PARAMS(n, Param))>(func(&(constructor))); } } #endif