From bbc7a4cd1febbb14ec3474154bce6dd36cab1bef Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 16 Oct 2000 01:27:06 +0000 Subject: [PATCH] Now this whole file is automatically generated by gen_extclass.py. This was neccessary if I was every going to be able to honestly claim to provide arbitrary argument support using gen_all.py. [SVN r7954] --- extclass.h | 98 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 19 deletions(-) diff --git a/extclass.h b/extclass.h index 3a3be054..3374c0ae 100644 --- a/extclass.h +++ b/extclass.h @@ -5,6 +5,9 @@ // // The author gratefully acknowleges the support of Dragon Systems, Inc., in // producing this work. +// +// This file automatically generated for 5-argument constructors by +// gen_extclass.py #ifndef EXTENSION_CLASS_DWA052000_H_ # define EXTENSION_CLASS_DWA052000_H_ @@ -279,10 +282,12 @@ class ExtensionClass // define constructors template void def(Constructor) - { add_constructor( // the following incantation builds a Signature1, - prepend(Type::Id(), // Signature2, ... constructor. It _should_ all - prepend(Type::Id(), // get optimized away. Just another workaround - prepend(Type::Id(), // for the lack of partial specialization in MSVC + // The following incantation builds a Signature1, Signature2,... object. It + // should _all_ get optimized away. + { add_constructor( + prepend(Type::Id(), + prepend(Type::Id(), + prepend(Type::Id(), prepend(Type::Id(), prepend(Type::Id(), Signature0())))))); @@ -350,7 +355,69 @@ class ExtensionClass } }; -#include "extclass_pygen.h" +// A simple wrapper over a T which allows us to use ExtensionClass with a +// single template parameter only. See ExtensionClass, above. +template +class HeldInstance : public T +{ + // There are no member functions: we want to avoid inadvertently overriding + // any virtual functions in T. +public: + HeldInstance(PyObject* p) : T(), m_self(p) {} + template + HeldInstance(PyObject* p, const A1& a1) : T(a1), m_self(p) {} + template + HeldInstance(PyObject* p, const A1& a1, const A2& a2) : T(a1, a2), m_self(p) {} + template + HeldInstance(PyObject* p, const A1& a1, const A2& a2, const A3& a3) : T(a1, a2, a3), m_self(p) {} + template + HeldInstance(PyObject* p, const A1& a1, const A2& a2, const A3& a3, const A4& a4) : T(a1, a2, a3, a4), m_self(p) {} + template + HeldInstance(PyObject* p, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) : T(a1, a2, a3, a4, a5), m_self(p) {} +protected: + PyObject* m_self; // Not really needed; doesn't really hurt. +}; + +class InstanceHolderBase +{ +public: + virtual ~InstanceHolderBase() {} +}; + +template +class InstanceHolder : public InstanceHolderBase +{ +public: + virtual Held *target() = 0; +}; + +template +class InstanceValueHolder : public InstanceHolder +{ +public: + Held* target() { return &m_held; } + Wrapper* value_target() { return &m_held; } + + InstanceValueHolder(ExtensionInstance* p) : + m_held(p) {} + template + InstanceValueHolder(ExtensionInstance* p, const A1& a1) : + m_held(p, a1) {} + template + InstanceValueHolder(ExtensionInstance* p, const A1& a1, const A2& a2) : + m_held(p, a1, a2) {} + template + InstanceValueHolder(ExtensionInstance* p, const A1& a1, const A2& a2, const A3& a3) : + m_held(p, a1, a2, a3) {} + template + InstanceValueHolder(ExtensionInstance* p, const A1& a1, const A2& a2, const A3& a3, const A4& a4) : + m_held(p, a1, a2, a3, a4) {} + template + InstanceValueHolder(ExtensionInstance* p, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) : + m_held(p, a1, a2, a3, a4, a5) {} +private: + Wrapper m_held; +}; template class InstancePtrHolder : public InstanceHolder @@ -403,20 +470,6 @@ ExtensionClass::~ExtensionClass() ClassRegistry::unregister_class(this); } -#ifdef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // Back to the global namespace for this GCC bug -} -#endif - -// -// Static data member declaration. -// -#ifdef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // Back from the global namespace for this GCC bug -namespace py { -#endif - -template -Class* ClassRegistry::static_class_object; - template inline void ClassRegistry::register_class(Class* p) { @@ -434,6 +487,13 @@ inline void ClassRegistry::unregister_class(Class* p) static_class_object = 0; } +// +// Static data member declaration. +// +template +Class* ClassRegistry::static_class_object; + } // namespace py #endif // EXTENSION_CLASS_DWA052000_H_ +