<commit_before>// This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2009-2011, <NAME> (<EMAIL>)
// and <NAME> (<EMAIL>)
// http://www.chaiscript.com

#include <boost/preprocessor.hpp>

#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 <chaiscript/dispatchkit/proxy_constructors.hpp>
#include BOOST_PP_ITERATE()
# endif

namespace chaiscript
{
  /// \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, ...)
  /// 
  /// Example:
  /// \code
  ///    chaiscript::ChaiScript chai;
  ///    // Create a new function that creates a MyClass object using the (int, float) constructor
  ///    // and call that function "MyClass" so that it appears as a normal constructor to the user.
  ///    chai.add(constructor<MyClass (int, float)>(), "MyClass");
  /// \endcode
  template<typename T>
    Proxy_Function constructor()
    {
      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<typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
        std::shared_ptr<Class> constructor_( BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) )
        {
          return std::shared_ptr<Class>(new Class( BOOST_PP_ENUM_PARAMS(n, p) ));
        }

      /**
       * Helper function for build a constructor function
       * example:
       * dispatchengine.register_function(build_constructor<MyClass, int, const std::string&>, "MyClass");
       * \todo See if it is possible to make this not be a variadic function
       */
      template<typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
        Proxy_Function build_constructor_(Class (*)(BOOST_PP_ENUM_PARAMS(n, Param)))
        {
          typedef std::shared_ptr<Class> (sig)(BOOST_PP_ENUM_PARAMS(n, Param));
          return Proxy_Function(new Proxy_Function_Impl<sig>(std::function<sig>(&(constructor_<Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>))));
        }
    }
  }
}
#undef n

#endif
<commit_msg>One more file no longer using boost_pp<commit_after>// This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2009-2011, <NAME> (<EMAIL>)
// and <NAME> (<EMAIL>)
// http://www.chaiscript.com


#ifndef CHAISCRIPT_PROXY_CONSTRUCTORS_HPP_
#define CHAISCRIPT_PROXY_CONSTRUCTORS_HPP_

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<typename Class, typename ... Params>
        std::shared_ptr<Class> constructor_(Params ... params)
        {
          return std::shared_ptr<Class>(new Class(params...));
        }

      template<typename Class, typename ... Params  >
        Proxy_Function build_constructor_(Class (*)(Params...))
        {
          typedef std::shared_ptr<Class> (sig)(Params...);
          return Proxy_Function(new Proxy_Function_Impl<sig>(std::function<sig>(&(constructor_<Class, Params...>))));
        }
    }
  }


  /// \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, ...)
  /// 
  /// Example:
  /// \code
  ///    chaiscript::ChaiScript chai;
  ///    // Create a new function that creates a MyClass object using the (int, float) constructor
  ///    // and call that function "MyClass" so that it appears as a normal constructor to the user.
  ///    chai.add(constructor<MyClass (int, float)>(), "MyClass");
  /// \endcode
  template<typename T>
    Proxy_Function constructor()
    {
      T *f = 0;
      return (dispatch::detail::build_constructor_(f));
    }

}

#endif

{'fraction_non_alphanumeric': 0.11940997424490751, 'fraction_numerical': 0.006087567314446265, 'mean_word_length': 2.9813606710158433, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5558798', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1322, 'n_words': 363}