From caae49861fd7acbf0ce6458ee23cd04acee54ad4 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 21 Nov 2000 15:00:54 +0000 Subject: [PATCH] detail-ified the gen_*.py scripts changed defaults to handle up to 10 arguments [SVN r8274] --- callback.h | 473 +++++++++++++++++++++++++- caller.h | 774 ++++++++++++++++++++++++++++++++++++++++++- extclass.h | 41 ++- gen_all.py | 2 +- gen_caller.py | 2 +- gen_extclass.py | 336 ++++++++----------- gen_init_function.py | 3 +- gen_signatures.py | 14 +- gen_singleton.py | 4 +- init_function.h | 220 ++++++++++++ signatures.h | 87 ++++- singleton.h | 15 + 12 files changed, 1753 insertions(+), 218 deletions(-) diff --git a/callback.h b/callback.h index cb0ba6c1..292dac14 100644 --- a/callback.h +++ b/callback.h @@ -6,7 +6,7 @@ // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. // -// This file was generated for 5-argument python callbacks by gen_callback.py +// This file was generated for 10-argument python callbacks by gen_callback.py #ifndef CALLBACK_DWA_052100_H_ # define CALLBACK_DWA_052100_H_ @@ -187,6 +187,251 @@ struct Callback detail::callback_adjust_refcount(result.get(), Type()); return from_python(result.get(), Type()); } + + template + static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr p10(to_python(a10)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get(), + p10.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } + + template + static R call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr p10(to_python(a10)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get(), + p10.get())); + detail::callback_adjust_refcount(result.get(), Type()); + return from_python(result.get(), Type()); + } }; // This specialization wouldn't be needed, but MSVC6 doesn't correctly allow the following: @@ -331,6 +576,231 @@ struct Callback p4.get(), p5.get())); } + + template + static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get())); + } + + template + static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get())); + } + + template + static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get())); + } + + template + static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get())); + } + + template + static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get())); + } + + template + static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get())); + } + + template + static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get())); + } + + template + static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get())); + } + + template + static void call_method(PyObject* self, const char* name, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr p10(to_python(a10)); + Ptr result(PyEval_CallMethod(self, const_cast(name), + const_cast("(OOOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get(), + p10.get())); + } + + template + static void call(PyObject* self, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) + { + Ptr p1(to_python(a1)); + Ptr p2(to_python(a2)); + Ptr p3(to_python(a3)); + Ptr p4(to_python(a4)); + Ptr p5(to_python(a5)); + Ptr p6(to_python(a6)); + Ptr p7(to_python(a7)); + Ptr p8(to_python(a8)); + Ptr p9(to_python(a9)); + Ptr p10(to_python(a10)); + Ptr result(PyEval_CallFunction(self, const_cast("(OOOOOOOOOO)"), + p1.get(), + p2.get(), + p3.get(), + p4.get(), + p5.get(), + p6.get(), + p7.get(), + p8.get(), + p9.get(), + p10.get())); + } }; // Make it a compile-time error to try to return a const char* from a virtual @@ -357,4 +827,3 @@ struct Callback } // namespace py #endif // CALLBACK_DWA_052100_H_ - diff --git a/caller.h b/caller.h index 71100e26..7dd2a590 100644 --- a/caller.h +++ b/caller.h @@ -6,7 +6,7 @@ // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. // -// This file generated for 5-argument member functions and 5-argument free +// This file generated for 10-argument member functions and 11-argument free // functions by gen_caller.py #ifndef CALLER_DWA05090_H_ @@ -103,6 +103,126 @@ struct Caller from_python(a5, Type()))); } + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + PyObject* a9; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + 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("OOOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type()))); + } + template static PyObject* call(R (T::*pmf)() const, PyObject* args, PyObject* /* keywords */ ) { @@ -183,6 +303,126 @@ struct Caller from_python(a5, Type()))); } + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + PyObject* a9; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()))); + } + + template + static PyObject* call(R (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + 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("OOOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)) + return 0; + T& target = from_python(self, Type()); + return to_python((target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type()))); + } + // Free functions static PyObject* call(R (*f)(), PyObject* args, PyObject* /* keywords */ ) { if (!PyArg_ParseTuple(args, const_cast(""))) @@ -250,6 +490,144 @@ struct Caller from_python(a5, Type()))); } + template + static PyObject* call(R (*f)(A1, A2, A3, A4, A5, A6), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + return to_python(f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()))); + } + + template + static PyObject* call(R (*f)(A1, A2, A3, A4, A5, A6, A7), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + return to_python(f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()))); + } + + template + static PyObject* call(R (*f)(A1, A2, A3, A4, A5, A6, A7, A8), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + return to_python(f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()))); + } + + template + static PyObject* call(R (*f)(A1, A2, A3, A4, A5, A6, A7, A8, A9), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + return to_python(f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()))); + } + + template + static PyObject* call(R (*f)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + return to_python(f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type()))); + } + + template + static PyObject* call(R (*f)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11), PyObject* args, PyObject* /* keywords */ ) { + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + PyObject* a9; + PyObject* a10; + PyObject* a11; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10, &a11)) + return 0; + return to_python(f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type()), + from_python(a11, Type()))); + } + }; template <> @@ -340,6 +718,131 @@ struct Caller return detail::none(); } + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + PyObject* a9; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + 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("OOOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type())); + return detail::none(); + } + template static PyObject* call(void (T::*pmf)() const, PyObject* args, PyObject* /* keywords */ ) { @@ -426,6 +929,131 @@ struct Caller return detail::none(); } + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + PyObject* a9; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type())); + return detail::none(); + } + + template + static PyObject* call(void (T::*pmf)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const, PyObject* args, PyObject* /* keywords */ ) { + PyObject* self; + 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("OOOOOOOOOOO"), &self, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)) + return 0; + T& target = from_python(self, Type()); + (target.*pmf)(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type())); + return detail::none(); + } + // Free functions static PyObject* call(void (*f)(), PyObject* args, PyObject* /* keywords */ ) { @@ -500,6 +1128,150 @@ struct Caller return detail::none(); } + template + static PyObject* call(void (*f)(A1, A2, A3, A4, A5, A6), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type())); + return detail::none(); + } + + template + static PyObject* call(void (*f)(A1, A2, A3, A4, A5, A6, A7), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type())); + return detail::none(); + } + + template + static PyObject* call(void (*f)(A1, A2, A3, A4, A5, A6, A7, A8), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type())); + return detail::none(); + } + + template + static PyObject* call(void (*f)(A1, A2, A3, A4, A5, A6, A7, A8, A9), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type())); + return detail::none(); + } + + template + static PyObject* call(void (*f)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), PyObject* args, PyObject* /* keywords */ ) { + 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)) + return 0; + f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type())); + return detail::none(); + } + + template + static PyObject* call(void (*f)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11), PyObject* args, PyObject* /* keywords */ ) { + PyObject* a1; + PyObject* a2; + PyObject* a3; + PyObject* a4; + PyObject* a5; + PyObject* a6; + PyObject* a7; + PyObject* a8; + PyObject* a9; + PyObject* a10; + PyObject* a11; + if (!PyArg_ParseTuple(args, const_cast("OOOOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10, &a11)) + return 0; + f(from_python(a1, Type()), + from_python(a2, Type()), + from_python(a3, Type()), + from_python(a4, Type()), + from_python(a5, Type()), + from_python(a6, Type()), + from_python(a7, Type()), + from_python(a8, Type()), + from_python(a9, Type()), + from_python(a10, Type()), + from_python(a11, Type())); + return detail::none(); + } + }; } diff --git a/extclass.h b/extclass.h index d0a09bf6..dd46ca08 100644 --- a/extclass.h +++ b/extclass.h @@ -6,7 +6,7 @@ // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. // -// This file automatically generated for 5-argument constructors by +// This file automatically generated for 10-argument constructors by // gen_extclass.py #ifndef EXTENSION_CLASS_DWA052000_H_ @@ -363,8 +363,8 @@ class ExtensionClass ~ExtensionClass(); // define constructors - template - inline void def(Constructor) + template + inline void def(Constructor) // The following incantation builds a Signature1, Signature2,... object. It // should _all_ get optimized away. { add_constructor( @@ -373,9 +373,15 @@ class ExtensionClass prepend(Type::Id(), prepend(Type::Id(), prepend(Type::Id(), - Signature0())))))); + prepend(Type::Id(), + prepend(Type::Id(), + prepend(Type::Id(), + prepend(Type::Id(), + prepend(Type::Id(), + Signature0()))))))))))); } + // export homogeneous operators (type of both lhs and rhs is 'operator') // usage: foo_class.def(py::operators<(py::op_add | py::op_sub), Foo>()); @@ -603,7 +609,6 @@ class ExtensionClass { this->add_constructor_object(InitFunction::create(sig)); } - }; // A simple wrapper over a T which allows us to use ExtensionClass with a @@ -625,6 +630,16 @@ public: HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4) : T(a1, a2, a3, a4) {} template HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) : T(a1, a2, a3, a4, a5) {} + template + HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) : T(a1, a2, a3, a4, a5, a6) {} + template + HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) : T(a1, a2, a3, a4, a5, a6, a7) {} + template + HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) : T(a1, a2, a3, a4, a5, a6, a7, a8) {} + template + HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) : T(a1, a2, a3, a4, a5, a6, a7, a8, a9) {} + template + HeldInstance(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) : T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {} }; // Abstract base class for all instance holders. Base for template class @@ -676,6 +691,21 @@ public: template InstanceValueHolder(ExtensionInstance* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) : m_held(p, a1, a2, a3, a4, a5) {} + template + InstanceValueHolder(ExtensionInstance* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) : + m_held(p, a1, a2, a3, a4, a5, a6) {} + template + InstanceValueHolder(ExtensionInstance* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) : + m_held(p, a1, a2, a3, a4, a5, a6, a7) {} + template + InstanceValueHolder(ExtensionInstance* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) : + m_held(p, a1, a2, a3, a4, a5, a6, a7, a8) {} + template + InstanceValueHolder(ExtensionInstance* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) : + m_held(p, a1, a2, a3, a4, a5, a6, a7, a8, a9) {} + template + InstanceValueHolder(ExtensionInstance* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) : + m_held(p, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {} public: // implementation of InstanceHolderBase required interface bool held_by_value() { return true; } @@ -831,4 +861,3 @@ std::vector ClassRegistry::static_derived_class_info; }} // namespace py::detail #endif // EXTENSION_CLASS_DWA052000_H_ - diff --git a/gen_all.py b/gen_all.py index 31eab966..c6c00c1f 100644 --- a/gen_all.py +++ b/gen_all.py @@ -17,7 +17,7 @@ if __name__ == '__main__': import sys if len(sys.argv) == 1: - args = 5 + args = 10 else: args = int(sys.argv[1]) diff --git a/gen_caller.py b/gen_caller.py index ae1a0de7..c8b8ca00 100644 --- a/gen_caller.py +++ b/gen_caller.py @@ -92,7 +92,7 @@ def gen_caller(member_function_args, free_function_args = None): free_function_args = member_function_args + 1 return_none = '''; - return none();''' + return detail::none();''' return (header % (member_function_args, free_function_args) + body_sections[0] diff --git a/gen_extclass.py b/gen_extclass.py index 2a7b6be2..2eab3ecf 100644 --- a/gen_extclass.py +++ b/gen_extclass.py @@ -30,12 +30,26 @@ def gen_extclass(args): namespace py { +// forward declarations +template struct operators; +template struct left_operand; +template struct right_operand; + +enum WithoutDowncast { without_downcast }; + +namespace detail { + // forward declarations class ExtensionInstance; class ExtensionClassBase; template class InstanceHolder; template class InstanceValueHolder; template class InstancePtrHolder; +template struct operand_select; + template struct choose_op; + template struct choose_rop; + template struct choose_unary_op; + template struct define_operator; MetaClass* extension_meta_class(); ExtensionInstance* get_extension_instance(PyObject* p); @@ -54,23 +68,21 @@ T* check_non_null(T* p) template class HeldInstance; -namespace detail { - typedef void* (*ConversionFunction)(void*); +typedef void* (*ConversionFunction)(void*); - struct BaseClassInfo - { - BaseClassInfo(ExtensionClassBase* t, ConversionFunction f) - :class_object(t), convert(f) - {} +struct BaseClassInfo +{ + BaseClassInfo(ExtensionClassBase* t, ConversionFunction f) + :class_object(t), convert(f) + {} - ExtensionClassBase* class_object; - ConversionFunction convert; - }; + ExtensionClassBase* class_object; + ConversionFunction convert; +}; - typedef BaseClassInfo DerivedClassInfo; +typedef BaseClassInfo DerivedClassInfo; - struct add_operator_base; -} +struct add_operator_base; class ExtensionClassBase : public Class { @@ -89,11 +101,11 @@ class ExtensionClassBase : public Class private: virtual void* extract_object_from_holder(InstanceHolderBase* v) const = 0; - virtual std::vector const& base_classes() const = 0; - virtual std::vector const& derived_classes() const = 0; + virtual std::vector const& base_classes() const = 0; + virtual std::vector const& derived_classes() const = 0; protected: - friend struct detail::add_operator_base; + friend struct add_operator_base; void add_method(PyPtr method, const char* name); void add_method(Function* method, const char* name); @@ -114,19 +126,19 @@ class ClassRegistry static void unregister_class(ExtensionClassBase*); // Establish C++ inheritance relationships - static void register_base_class(py::detail::BaseClassInfo const&); - static void register_derived_class(py::detail::DerivedClassInfo const&); + static void register_base_class(BaseClassInfo const&); + static void register_derived_class(DerivedClassInfo const&); // Query the C++ inheritance relationships - static std::vector const& base_classes(); - static std::vector const& derived_classes(); + static std::vector const& base_classes(); + static std::vector const& derived_classes(); private: static ExtensionClassBase* static_class_object; - static std::vector static_base_class_info; - static std::vector static_derived_class_info; + static std::vector static_base_class_info; + static std::vector static_derived_class_info; }; -} +}} // namespace py::detail PY_BEGIN_CONVERSION_NAMESPACE @@ -134,7 +146,7 @@ PY_BEGIN_CONVERSION_NAMESPACE // and U. T is the class the user really intends to wrap. U is a class derived // from T with some virtual function overriding boilerplate, or if there are no // virtual functions, U = HeldInstance. -template > +template > class PyExtensionClassConverters { public: @@ -165,10 +177,10 @@ class PyExtensionClassConverters // writes code which causes us to try to copy a T. PyObject* to_python(const T& x) const { - py::PyPtr result(create_instance()); + py::PyPtr result(create_instance()); result->add_implementation( - std::auto_ptr( - new py::InstanceValueHolder(result.get(), x))); + std::auto_ptr( + new py::detail::InstanceValueHolder(result.get(), x))); return result.release(); } @@ -176,21 +188,21 @@ class PyExtensionClassConverters friend T* from_python(PyObject* obj, py::Type) { // Downcast to an ExtensionInstance, then find the actual T - py::ExtensionInstance* self = py::get_extension_instance(obj); - typedef std::vector::const_iterator Iterator; + py::detail::ExtensionInstance* self = py::detail::get_extension_instance(obj); + typedef std::vector::const_iterator Iterator; for (Iterator p = self->wrapped_objects().begin(); p != self->wrapped_objects().end(); ++p) { - py::InstanceHolder* held = dynamic_cast*>(*p); + py::detail::InstanceHolder* held = dynamic_cast*>(*p); if (held != 0) return held->target(); // see extclass.cpp for an explanation of try_class_conversions() - void* target = py::ClassRegistry::class_object()->try_class_conversions(*p); + void* target = py::detail::ClassRegistry::class_object()->try_class_conversions(*p); if(target) return static_cast(target); } - py::report_missing_instance_data(self, py::ClassRegistry::class_object(), typeid(T)); + py::detail::report_missing_instance_data(self, py::detail::ClassRegistry::class_object(), typeid(T)); throw py::ArgumentError(); } @@ -199,38 +211,38 @@ class PyExtensionClassConverters static PtrType& ptr_from_python(PyObject* obj, py::Type) { // Downcast to an ExtensionInstance, then find the actual T - py::ExtensionInstance* self = py::get_extension_instance(obj); - typedef std::vector::const_iterator Iterator; + py::detail::ExtensionInstance* self = py::detail::get_extension_instance(obj); + typedef std::vector::const_iterator Iterator; for (Iterator p = self->wrapped_objects().begin(); p != self->wrapped_objects().end(); ++p) { - py::InstancePtrHolder* held = - dynamic_cast*>(*p); + py::detail::InstancePtrHolder* held = + dynamic_cast*>(*p); if (held != 0) return held->ptr(); } - py::report_missing_ptr_data(self, py::ClassRegistry::class_object(), typeid(T)); + py::detail::report_missing_ptr_data(self, py::detail::ClassRegistry::class_object(), typeid(T)); throw py::ArgumentError(); } template static PyObject* ptr_to_python(PtrType x) { - py::PyPtr result(create_instance()); + py::PyPtr result(create_instance()); result->add_implementation( - std::auto_ptr( - new py::InstancePtrHolder(x))); + std::auto_ptr( + new py::detail::InstancePtrHolder(x))); return result.release(); } - static py::PyPtr create_instance() + static py::PyPtr create_instance() { - PyTypeObject* class_object = py::ClassRegistry::class_object(); + PyTypeObject* class_object = py::detail::ClassRegistry::class_object(); if (class_object == 0) - py::report_missing_class_object(typeid(T)); + py::detail::report_missing_class_object(typeid(T)); - return py::PyPtr( - new py::ExtensionInstance(class_object)); + return py::PyPtr( + new py::detail::ExtensionInstance(class_object)); } // Convert to const T* @@ -247,7 +259,7 @@ class PyExtensionClassConverters // Convert to T& friend T& from_python(PyObject* p, py::Type) - { return *py::check_non_null(from_python(p, py::Type())); } + { return *py::detail::check_non_null(from_python(p, py::Type())); } // Convert to const T& friend const T& from_python(PyObject* p, py::Type) @@ -298,6 +310,8 @@ namespace py { PY_IMPORT_CONVERSION(PyExtensionClassConverters); +namespace detail { + template class InstanceHolder; class ReadOnlySetattrFunction : public Function @@ -310,72 +324,6 @@ class ReadOnlySetattrFunction : public Function String m_name; }; -enum operator_id -{ - op_add = 0x1, - op_sub = 0x2, - op_mul = 0x4, - op_div = 0x8, - op_mod = 0x10, - op_divmod =0x20, - op_pow = 0x40, - op_lshift = 0x80, - op_rshift = 0x100, - op_and = 0x200, - op_xor = 0x400, - op_or = 0x800, - op_neg = 0x1000, - op_pos = 0x2000, - op_abs = 0x4000, - op_invert = 0x8000, - op_int = 0x10000, - op_long = 0x20000, - op_float = 0x40000, - op_str = 0x80000, - op_cmp = 0x100000 -}; - -namespace detail -{ - struct auto_operand {}; - - template - struct operand_select - { - template - struct wrapped - { - typedef Specified type; - }; - }; - - template <> - struct operand_select - { - template - struct wrapped - { - typedef const WrappedType& type; - }; - }; - - template struct define_operator; - template struct choose_op; - template struct choose_rop; - template struct choose_unary_op; -} - -template -struct operators {}; - -template -struct left_operand {}; - -template -struct right_operand {}; - -namespace detail -{ template struct DefineConversion { @@ -389,9 +337,6 @@ namespace detail return dynamic_cast(static_cast(v)); } }; -} - -enum WithoutDowncast { without_downcast }; // An easy way to make an extension base class which wraps T. Note that Python // subclasses of this class will simply be Class objects. @@ -445,7 +390,7 @@ class ExtensionClass template inline void def(operators) { - typedef typename detail::operand_select::template wrapped::type true_operand; + typedef typename operand_select::template wrapped::type true_operand; def_operators(operators()); } @@ -459,7 +404,7 @@ class ExtensionClass template inline void def(operators, right_operand r) { - typedef typename detail::operand_select::template wrapped::type true_left; + typedef typename operand_select::template wrapped::type true_left; def_operators(operators(), r); } @@ -475,7 +420,7 @@ class ExtensionClass template inline void def(operators, left_operand l) { - typedef typename detail::operand_select::template wrapped::type true_right; + typedef typename operand_select::template wrapped::type true_right; def_operators(operators(), l); } @@ -488,7 +433,7 @@ class ExtensionClass template inline void def_raw(Fn fn, const char* name) { - this->add_method(py::detail::new_raw_arguments_function(fn), name); + this->add_method(new_raw_arguments_function(fn), name); } // define member functions. In fact this works for free functions, too - @@ -507,7 +452,7 @@ class ExtensionClass template inline void def(Fn fn, const char* name, DefaultFn default_fn) { - this->add_method(py::detail::new_virtual_function(Type(), fn, default_fn), name); + this->add_method(new_virtual_function(Type(), fn, default_fn), name); } // Provide a function which implements x., reading from the given @@ -541,10 +486,10 @@ class ExtensionClass this->def_getter(pm, name); this->def_setter(pm, name); } - + // define the standard coercion needed for operator overloading void def_standard_coerce(); - + // declare the given class a base class of this one and register // up and down conversion functions template @@ -552,13 +497,13 @@ class ExtensionClass { // see extclass.cpp for an explanation of why we need to register // conversion functions - detail::BaseClassInfo baseInfo(base, - &detail::DefineConversion::downcast_ptr); + BaseClassInfo baseInfo(base, + &DefineConversion::downcast_ptr); ClassRegistry::register_base_class(baseInfo); add_base(Ptr(as_object(base), Ptr::new_ref)); - detail::DerivedClassInfo derivedInfo(this, - &detail::DefineConversion::upcast_ptr); + DerivedClassInfo derivedInfo(this, + &DefineConversion::upcast_ptr); ClassRegistry::register_derived_class(derivedInfo); } @@ -569,12 +514,12 @@ class ExtensionClass { // see extclass.cpp for an explanation of why we need to register // conversion functions - detail::BaseClassInfo baseInfo(base, 0); + BaseClassInfo baseInfo(base, 0); ClassRegistry::register_base_class(baseInfo); add_base(Ptr(as_object(base), Ptr::new_ref)); - detail::DerivedClassInfo derivedInfo(this, - &detail::DefineConversion::upcast_ptr); + DerivedClassInfo derivedInfo(this, + &DefineConversion::upcast_ptr); ClassRegistry::register_derived_class(derivedInfo); } @@ -582,8 +527,8 @@ class ExtensionClass typedef InstanceValueHolder Holder; private: // ExtensionClassBase virtual function implementations - std::vector const& base_classes() const; - std::vector const& derived_classes() const; + std::vector const& base_classes() const; + std::vector const& derived_classes() const; void* extract_object_from_holder(InstanceHolderBase* v) const; private: // Utility functions @@ -591,28 +536,32 @@ class ExtensionClass inline void def_operators(operators) { def_standard_coerce(); - - detail::choose_op<(which & op_add)>::template args::add(this); - detail::choose_op<(which & op_sub)>::template args::add(this); - detail::choose_op<(which & op_mul)>::template args::add(this); - detail::choose_op<(which & op_div)>::template args::add(this); - detail::choose_op<(which & op_mod)>::template args::add(this); - detail::choose_op<(which & op_divmod)>::template args::add(this); - detail::choose_op<(which & op_pow)>::template args::add(this); - detail::choose_op<(which & op_lshift)>::template args::add(this); - detail::choose_op<(which & op_rshift)>::template args::add(this); - detail::choose_op<(which & op_and)>::template args::add(this); - detail::choose_op<(which & op_xor)>::template args::add(this); - detail::choose_op<(which & op_or)>::template args::add(this); - detail::choose_unary_op<(which & op_neg)>::template args::add(this); - detail::choose_unary_op<(which & op_pos)>::template args::add(this); - detail::choose_unary_op<(which & op_abs)>::template args::add(this); - detail::choose_unary_op<(which & op_invert)>::template args::add(this); - detail::choose_unary_op<(which & op_int)>::template args::add(this); - detail::choose_unary_op<(which & op_long)>::template args::add(this); - detail::choose_unary_op<(which & op_float)>::template args::add(this); - detail::choose_op<(which & op_cmp)>::template args::add(this); - detail::choose_unary_op<(which & op_str)>::template args::add(this); + + // for some strange reason, this prevents MSVC from having an + // "unrecoverable block scoping error"! + typedef choose_op<(which & op_add)> choose_add; + + choose_op<(which & op_add)>::template args::add(this); + choose_op<(which & op_sub)>::template args::add(this); + choose_op<(which & op_mul)>::template args::add(this); + choose_op<(which & op_div)>::template args::add(this); + choose_op<(which & op_mod)>::template args::add(this); + choose_op<(which & op_divmod)>::template args::add(this); + choose_op<(which & op_pow)>::template args::add(this); + choose_op<(which & op_lshift)>::template args::add(this); + choose_op<(which & op_rshift)>::template args::add(this); + choose_op<(which & op_and)>::template args::add(this); + choose_op<(which & op_xor)>::template args::add(this); + choose_op<(which & op_or)>::template args::add(this); + choose_unary_op<(which & op_neg)>::template args::add(this); + choose_unary_op<(which & op_pos)>::template args::add(this); + choose_unary_op<(which & op_abs)>::template args::add(this); + choose_unary_op<(which & op_invert)>::template args::add(this); + choose_unary_op<(which & op_int)>::template args::add(this); + choose_unary_op<(which & op_long)>::template args::add(this); + choose_unary_op<(which & op_float)>::template args::add(this); + choose_op<(which & op_cmp)>::template args::add(this); + choose_unary_op<(which & op_str)>::template args::add(this); } template @@ -620,19 +569,19 @@ class ExtensionClass { def_standard_coerce(); - detail::choose_op<(which & op_add)>::template args::add(this); - detail::choose_op<(which & op_sub)>::template args::add(this); - detail::choose_op<(which & op_mul)>::template args::add(this); - detail::choose_op<(which & op_div)>::template args::add(this); - detail::choose_op<(which & op_mod)>::template args::add(this); - detail::choose_op<(which & op_divmod)>::template args::add(this); - detail::choose_op<(which & op_pow)>::template args::add(this); - detail::choose_op<(which & op_lshift)>::template args::add(this); - detail::choose_op<(which & op_rshift)>::template args::add(this); - detail::choose_op<(which & op_and)>::template args::add(this); - detail::choose_op<(which & op_xor)>::template args::add(this); - detail::choose_op<(which & op_or)>::template args::add(this); - detail::choose_op<(which & op_cmp)>::template args::add(this); + choose_op<(which & op_add)>::template args::add(this); + choose_op<(which & op_sub)>::template args::add(this); + choose_op<(which & op_mul)>::template args::add(this); + choose_op<(which & op_div)>::template args::add(this); + choose_op<(which & op_mod)>::template args::add(this); + choose_op<(which & op_divmod)>::template args::add(this); + choose_op<(which & op_pow)>::template args::add(this); + choose_op<(which & op_lshift)>::template args::add(this); + choose_op<(which & op_rshift)>::template args::add(this); + choose_op<(which & op_and)>::template args::add(this); + choose_op<(which & op_xor)>::template args::add(this); + choose_op<(which & op_or)>::template args::add(this); + choose_op<(which & op_cmp)>::template args::add(this); } template @@ -640,19 +589,19 @@ class ExtensionClass { def_standard_coerce(); - detail::choose_rop<(which & op_add)>::template args::add(this); - detail::choose_rop<(which & op_sub)>::template args::add(this); - detail::choose_rop<(which & op_mul)>::template args::add(this); - detail::choose_rop<(which & op_div)>::template args::add(this); - detail::choose_rop<(which & op_mod)>::template args::add(this); - detail::choose_rop<(which & op_divmod)>::template args::add(this); - detail::choose_rop<(which & op_pow)>::template args::add(this); - detail::choose_rop<(which & op_lshift)>::template args::add(this); - detail::choose_rop<(which & op_rshift)>::template args::add(this); - detail::choose_rop<(which & op_and)>::template args::add(this); - detail::choose_rop<(which & op_xor)>::template args::add(this); - detail::choose_rop<(which & op_or)>::template args::add(this); - detail::choose_rop<(which & op_cmp)>::template args::add(this); + choose_rop<(which & op_add)>::template args::add(this); + choose_rop<(which & op_sub)>::template args::add(this); + choose_rop<(which & op_mul)>::template args::add(this); + choose_rop<(which & op_div)>::template args::add(this); + choose_rop<(which & op_mod)>::template args::add(this); + choose_rop<(which & op_divmod)>::template args::add(this); + choose_rop<(which & op_pow)>::template args::add(this); + choose_rop<(which & op_lshift)>::template args::add(this); + choose_rop<(which & op_rshift)>::template args::add(this); + choose_rop<(which & op_and)>::template args::add(this); + choose_rop<(which & op_xor)>::template args::add(this); + choose_rop<(which & op_or)>::template args::add(this); + choose_rop<(which & op_cmp)>::template args::add(this); } template @@ -758,10 +707,7 @@ class ExtensionInstance : public Instance // Template function implementations // -namespace detail -{ - Tuple extension_class_coerce(Ptr l, Ptr r); -} +Tuple extension_class_coerce(Ptr l, Ptr r); template ExtensionClass::ExtensionClass() @@ -778,17 +724,17 @@ ExtensionClass::ExtensionClass(const char* name) } template -void ExtensionClass::register_coerce() +void ExtensionClass::def_standard_coerce() { Ptr coerce_fct = dict().get_item(String("__coerce__")); if(coerce_fct.get() == 0) // not yet defined - this->def(&py::detail::extension_class_coerce, "__coerce__"); + this->def(&extension_class_coerce, "__coerce__"); } template inline -std::vector const& +std::vector const& ExtensionClass::base_classes() const { return ClassRegistry::base_classes(); @@ -796,7 +742,7 @@ ExtensionClass::base_classes() const template inline -std::vector const& +std::vector const& ExtensionClass::derived_classes() const { return ClassRegistry::derived_classes(); @@ -805,7 +751,7 @@ ExtensionClass::derived_classes() const template void* ExtensionClass::extract_object_from_holder(InstanceHolderBase* v) const { - py::InstanceHolder* held = dynamic_cast*>(v); + InstanceHolder* held = dynamic_cast*>(v); if(held) return held->target(); return 0; @@ -835,25 +781,25 @@ inline void ClassRegistry::unregister_class(ExtensionClassBase* p) } template -void ClassRegistry::register_base_class(py::detail::BaseClassInfo const& i) +void ClassRegistry::register_base_class(BaseClassInfo const& i) { static_base_class_info.push_back(i); } template -void ClassRegistry::register_derived_class(py::detail::DerivedClassInfo const& i) +void ClassRegistry::register_derived_class(DerivedClassInfo const& i) { static_derived_class_info.push_back(i); } template -std::vector const& ClassRegistry::base_classes() +std::vector const& ClassRegistry::base_classes() { return static_base_class_info; } template -std::vector const& ClassRegistry::derived_classes() +std::vector const& ClassRegistry::derived_classes() { return static_derived_class_info; } @@ -864,11 +810,11 @@ std::vector const& ClassRegistry::derived_class template ExtensionClassBase* ClassRegistry::static_class_object; template -std::vector ClassRegistry::static_base_class_info; +std::vector ClassRegistry::static_base_class_info; template -std::vector ClassRegistry::static_derived_class_info; +std::vector ClassRegistry::static_derived_class_info; -} // namespace py +}} // namespace py::detail #endif // EXTENSION_CLASS_DWA052000_H_ """) diff --git a/gen_init_function.py b/gen_init_function.py index 1a5fc2ca..a96a7b68 100644 --- a/gen_init_function.py +++ b/gen_init_function.py @@ -105,7 +105,6 @@ namespace detail { private: const_reference value; }; -} class ExtensionInstance; class InstanceHolderBase; @@ -150,7 +149,7 @@ struct Init%x : Init { return typeid(void (*)(T&%(, A%n%%))).name(); } };""", args) + """ -} +}} // namespace py::detail #endif // INIT_FUNCTION_DWA052000_H_ """) diff --git a/gen_signatures.py b/gen_signatures.py index d9395171..8d19ffe6 100644 --- a/gen_signatures.py +++ b/gen_signatures.py @@ -58,9 +58,11 @@ def gen_signatures(args): namespace py { +namespace detail { // A stand-in for the built-in void. This one can be passed to functions and // (under MSVC, which has a bug, be used as a default template type parameter). struct Void {}; +} // An envelope in which type information can be delivered for the purposes // of selecting an overloaded from_python() function. This is needed to work @@ -79,11 +81,12 @@ struct Type }; template <> -struct Type +struct Type { - typedef Void Id; + typedef py::detail::Void Id; }; +namespace detail { // These basically encapsulate a chain of types, , used to make the syntax of // add(Constructor()) work. We need to produce a unique type for each number // of non-default parameters to Constructor<>. Q: why not use a recursive @@ -97,14 +100,17 @@ struct Type // This one terminates the chain. Prepending Void to the head of a Void // signature results in a Void signature again. inline Signature0 prepend(Void, Signature0) { return Signature0(); } + +} // namespace detail """ + gen_function(""" -template <%(class A%n% = Void%:, %)> +template <%(class A%n% = detail::Void%:, %)> struct Constructor { }; """, args) + """ +namespace detail { // Return value extraction: // This is just another little envelope for carrying a typedef (see Type, @@ -135,7 +141,7 @@ ReturnValue return_value(R (T::*)(%(A%n%:, %)) const) { return ReturnValue """, args) + """ -} +}} // namespace py::detail #endif """) diff --git a/gen_singleton.py b/gen_singleton.py index ed2e97d6..36422966 100644 --- a/gen_singleton.py +++ b/gen_singleton.py @@ -16,7 +16,7 @@ def gen_singleton(args): # include "pyconfig.h" -namespace py { +namespace py { namespace detail { struct Empty {}; template @@ -42,7 +42,7 @@ Derived* Singleton::singleton() return &x; } -} +}} // namespace py::detail #endif """) diff --git a/init_function.h b/init_function.h index 6facbe68..70709d9c 100644 --- a/init_function.h +++ b/init_function.h @@ -110,6 +110,11 @@ 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 @@ -157,6 +162,71 @@ struct InitFunction 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 @@ -282,6 +352,156 @@ struct Init5 : Init { 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_ diff --git a/signatures.h b/signatures.h index ccf5fcd5..1d12b9c3 100644 --- a/signatures.h +++ b/signatures.h @@ -6,13 +6,13 @@ // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. // -// This file automatically generated by gen_signatures.py for 5 arguments. +// This file automatically generated by gen_signatures.py for 10 arguments. #ifndef SIGNATURES_DWA050900_H_ # define SIGNATURES_DWA050900_H_ # include "pyconfig.h" -namespace py { +namespace py { namespace detail { // A stand-in for the built-in void. This one can be passed to functions and @@ -50,9 +50,44 @@ namespace detail { // that involve recursive template nesting. // // Signature chaining +template +struct Signature10 {}; + +template +struct Signature9 {}; + +template +inline Signature10 prepend(Type, Signature9) + { return Signature10(); } + +template +struct Signature8 {}; + +template +inline Signature9 prepend(Type, Signature8) + { return Signature9(); } + +template +struct Signature7 {}; + +template +inline Signature8 prepend(Type, Signature7) + { return Signature8(); } + +template +struct Signature6 {}; + +template +inline Signature7 prepend(Type, Signature6) + { return Signature7(); } + template struct Signature5 {}; +template +inline Signature6 prepend(Type, Signature5) + { return Signature6(); } + template struct Signature4 {}; @@ -94,13 +129,12 @@ inline Signature0 prepend(Void, Signature0) { return Signature0(); } } // namespace detail -template +template struct Constructor { }; namespace detail { - // Return value extraction: // This is just another little envelope for carrying a typedef (see Type, @@ -128,6 +162,21 @@ ReturnValue return_value(R (*)(A1, A2, A3, A4)) { return ReturnValue(); } template ReturnValue return_value(R (*)(A1, A2, A3, A4, A5)) { return ReturnValue(); } +template +ReturnValue return_value(R (*)(A1, A2, A3, A4, A5, A6)) { return ReturnValue(); } + +template +ReturnValue return_value(R (*)(A1, A2, A3, A4, A5, A6, A7)) { return ReturnValue(); } + +template +ReturnValue return_value(R (*)(A1, A2, A3, A4, A5, A6, A7, A8)) { return ReturnValue(); } + +template +ReturnValue return_value(R (*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { return ReturnValue(); } + +template +ReturnValue return_value(R (*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { return ReturnValue(); } + // TODO(?): handle 'const void' // member functions @@ -149,6 +198,21 @@ ReturnValue return_value(R (T::*)(A1, A2, A3, A4)) { return ReturnValue(); template ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5)) { return ReturnValue(); } +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6)) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7)) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7, A8)) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { return ReturnValue(); } + template ReturnValue return_value(R (T::*)() const) { return ReturnValue(); } @@ -167,6 +231,21 @@ ReturnValue return_value(R (T::*)(A1, A2, A3, A4) const) { return ReturnValue template ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5) const) { return ReturnValue(); } +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6) const) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7) const) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7, A8) const) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const) { return ReturnValue(); } + +template +ReturnValue return_value(R (T::*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const) { return ReturnValue(); } + }} // namespace py::detail #endif diff --git a/singleton.h b/singleton.h index d6786ada..2dc8051d 100644 --- a/singleton.h +++ b/singleton.h @@ -39,6 +39,21 @@ struct Singleton : Base template Singleton(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) : Base(a1, a2, a3, a4, a5) {} + template + Singleton(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) : Base(a1, a2, a3, a4, a5, a6) {} + + template + Singleton(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) : Base(a1, a2, a3, a4, a5, a6, a7) {} + + template + Singleton(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) : Base(a1, a2, a3, a4, a5, a6, a7, a8) {} + + template + Singleton(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) : Base(a1, a2, a3, a4, a5, a6, a7, a8, a9) {} + + template + Singleton(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) : Base(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {} + }; template