From 73a81aa6220121031f726745552ca069003ced62 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 12 Nov 2000 22:06:10 +0000 Subject: [PATCH] changed to use new conversion namespace macros [SVN r8189] --- gen_extclass.py | 11 ++++++----- pointers.html | 16 ++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/gen_extclass.py b/gen_extclass.py index f4a87c58..a0887b5a 100644 --- a/gen_extclass.py +++ b/gen_extclass.py @@ -128,9 +128,9 @@ class ClassRegistry static std::vector static_derived_class_info; }; -#ifdef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // back to global namespace for this GCC bug } -#endif + +PY_BEGIN_CONVERSION_NAMESPACE // This class' only job is to define from_python and to_python converters for T // and U. T is the class the user really intends to wrap. U is a class derived @@ -294,10 +294,11 @@ PyObject* to_python(const T& x) return py_extension_class_converters(py::Type()).to_python(x); } -#ifdef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // back from global namespace for this GCC bug +PY_END_CONVERSION_NAMESPACE + namespace py { -using ::PyExtensionClassConverters; -#endif + +PY_IMPORT_CONVERSION(PyExtensionClassConverters); template class InstanceHolder; diff --git a/pointers.html b/pointers.html index d2dc1f04..61e07e7e 100644 --- a/pointers.html +++ b/pointers.html @@ -61,15 +61,11 @@ wrapped T, you may want to provide an automatic thin wrappers. You can do this simply as follows:
-#ifndef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // work around gcc 2.95.2 bug
-namespace py {
-#endif
+PY_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
   PyObject* to_python(const Foo* p) {
      return to_python(*p); // convert const Foo* in terms of const Foo&
   }
-#ifndef PY_NO_INLINE_FRIENDS_IN_NAMESPACE
-}
-#endif
+PY_END_CONVERSION_NAMESPACE
 

If you can't (afford to) copy the referent, or the pointer is non-const

@@ -82,9 +78,7 @@ can not control the lifetime of the referent, so it may be destroyed by your C++ code before the last Python reference to it disappears:
-#ifndef PY_NO_INLINE_FRIENDS_IN_NAMESPACE // work around gcc 2.95.2 bug
-namespace py {
-#endif
+PY_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
   PyObject* to_python(Foo* p)
   {
       return py::PyExtensionClassConverters::ptr_to_python(p);
@@ -94,9 +88,7 @@ namespace py {
   {
       return to_python(const_cast(p));
   }
-#ifndef PY_NO_INLINE_FRIENDS_IN_NAMESPACE
-}
-#endif
+PY_END_CONVERSION_NAMESPACE
 
This will cause the Foo* to be treated as though it were an owning smart