// (C) Copyright David Abrahams 2000. Permission to copy, use, modify, sell and // distribute this software is granted provided this copyright notice appears // in all copies. This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. // // This file was generated for %d-argument constructors by gen_init_function.py #ifndef INIT_FUNCTION_DWA052000_H_ # define INIT_FUNCTION_DWA052000_H_ # include "pyconfig.h" # include "functions.h" # include "signatures.h" # include namespace py { namespace detail { // parameter_traits - so far, this is a way to pass a const T& when we can be // sure T is not a reference type, and a raw T otherwise. This should be // rolled into boost::call_traits. Ordinarily, parameter_traits would be // written: // // template struct parameter_traits // { // typedef const T& const_reference; // }; // // template struct parameter_traits // { // typedef T& const_reference; // }; // // template <> struct parameter_traits // { // typedef void const_reference; // }; // // ...but since we can't partially specialize on reference types, we need this // long-winded but equivalent incantation. // const_ref_selector -- an implementation detail of parameter_traits (below). This uses // the usual "poor man's partial specialization" hack for MSVC. template struct const_ref_selector { template struct const_ref { typedef const T& type; }; }; template <> struct const_ref_selector { template struct const_ref { typedef T type; }; }; # ifdef BOOST_MSVC # pragma warning(push) # pragma warning(disable: 4181) # endif // BOOST_MSVC template struct parameter_traits { private: typedef const_ref_selector::value> selector; public: typedef typename selector::template const_ref::type const_reference; }; # ifdef BOOST_MSVC # pragma warning(pop) # endif // BOOST_MSVC // Full spcialization for void template <> struct parameter_traits { typedef void const_reference; }; template class reference_parameter { typedef typename parameter_traits::const_reference const_reference; public: reference_parameter(const_reference value) : value(value) {} operator const_reference() { return value; } private: const_reference value; }; class ExtensionInstance; class InstanceHolderBase; class Init; template struct Init0; template struct Init1; template struct Init2; template struct Init3; template struct Init4; template struct Init5; template struct Init6; template struct Init7; template struct Init8; template struct Init9; template struct Init10; template struct InitFunction { static Init* create(Signature0) { return new Init0; } template static Init* create(Signature1) { return new Init1::const_reference>; } template static Init* create(Signature2) { return new Init2::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature3) { return new Init3::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature4) { return new Init4::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature5) { return new Init5::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature6) { return new Init6::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature7) { return new Init7::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature8) { return new Init8::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature9) { return new Init9::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } template static Init* create(Signature10) { return new Init10::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference, detail::parameter_traits::const_reference>; } }; class Init : public Function { private: // override Function hook PyObject* do_call(PyObject* args, PyObject* keywords) const; private: virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* tail_args, PyObject* keywords) const = 0; }; template struct Init0 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { if (!PyArg_ParseTuple(args, const_cast(""))) throw ArgumentError(); return new T(self ); } const char* description() const { return typeid(void (*)(T&)).name(); } }; template struct Init1 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; if (!PyArg_ParseTuple(args, const_cast("O"), &a1)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1)).name(); } }; template struct Init2 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; if (!PyArg_ParseTuple(args, const_cast("OO"), &a1, &a2)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2)).name(); } }; template struct Init3 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; if (!PyArg_ParseTuple(args, const_cast("OOO"), &a1, &a2, &a3)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3)).name(); } }; template struct Init4 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; if (!PyArg_ParseTuple(args, const_cast("OOOO"), &a1, &a2, &a3, &a4)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4)).name(); } }; template struct Init5 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; PyObject* a5; if (!PyArg_ParseTuple(args, const_cast("OOOOO"), &a1, &a2, &a3, &a4, &a5)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())), py::detail::reference_parameter(from_python(a5, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4, A5)).name(); } }; template struct Init6 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; PyObject* a5; PyObject* a6; if (!PyArg_ParseTuple(args, const_cast("OOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())), py::detail::reference_parameter(from_python(a5, Type())), py::detail::reference_parameter(from_python(a6, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6)).name(); } }; template struct Init7 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; PyObject* a5; PyObject* a6; PyObject* a7; if (!PyArg_ParseTuple(args, const_cast("OOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())), py::detail::reference_parameter(from_python(a5, Type())), py::detail::reference_parameter(from_python(a6, Type())), py::detail::reference_parameter(from_python(a7, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7)).name(); } }; template struct Init8 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; PyObject* a5; PyObject* a6; PyObject* a7; PyObject* a8; if (!PyArg_ParseTuple(args, const_cast("OOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())), py::detail::reference_parameter(from_python(a5, Type())), py::detail::reference_parameter(from_python(a6, Type())), py::detail::reference_parameter(from_python(a7, Type())), py::detail::reference_parameter(from_python(a8, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7, A8)).name(); } }; template struct Init9 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; PyObject* a5; PyObject* a6; PyObject* a7; PyObject* a8; PyObject* a9; if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())), py::detail::reference_parameter(from_python(a5, Type())), py::detail::reference_parameter(from_python(a6, Type())), py::detail::reference_parameter(from_python(a7, Type())), py::detail::reference_parameter(from_python(a8, Type())), py::detail::reference_parameter(from_python(a9, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7, A8, A9)).name(); } }; template struct Init10 : Init { virtual InstanceHolderBase* create_holder(ExtensionInstance* self, PyObject* args, PyObject* /*keywords*/) const { PyObject* a1; PyObject* a2; PyObject* a3; PyObject* a4; PyObject* a5; PyObject* a6; PyObject* a7; PyObject* a8; PyObject* a9; PyObject* a10; if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)) throw ArgumentError(); return new T(self, py::detail::reference_parameter(from_python(a1, Type())), py::detail::reference_parameter(from_python(a2, Type())), py::detail::reference_parameter(from_python(a3, Type())), py::detail::reference_parameter(from_python(a4, Type())), py::detail::reference_parameter(from_python(a5, Type())), py::detail::reference_parameter(from_python(a6, Type())), py::detail::reference_parameter(from_python(a7, Type())), py::detail::reference_parameter(from_python(a8, Type())), py::detail::reference_parameter(from_python(a9, Type())), py::detail::reference_parameter(from_python(a10, Type())) ); } const char* description() const { return typeid(void (*)(T&, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)).name(); } }; }} // namespace py::detail #endif // INIT_FUNCTION_DWA052000_H_