2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 06:02:14 +00:00

Get Cygwin linking again

User-readable type name printing for GCC


[SVN r19236]
This commit is contained in:
Dave Abrahams
2003-07-21 02:14:58 +00:00
parent 25bfd3c50f
commit 817dcd37e0
7 changed files with 148 additions and 27 deletions

View File

@@ -71,7 +71,7 @@
# define BOOST_PYTHON_NO_TEMPLATE_EXPORT
#endif
#if defined(BOOST_PYTHON_DYNAMIC_LIB) && defined(_WIN32)
#if defined(BOOST_PYTHON_DYNAMIC_LIB) && defined(_WIN32) || defined(__CYGWIN__)
# if defined(BOOST_PYTHON_SOURCE)
# define BOOST_PYTHON_DECL __declspec(dllexport)
# define BOOST_PYTHON_BUILD_DLL

View File

@@ -13,8 +13,15 @@
namespace boost { namespace python {
class BOOST_PYTHON_DECL scope
: public object
namespace detail
{
// Making this a namespace-scope variable to avoid Cygwin issues.
// Use a PyObject* to avoid problems with static destruction after Py_Finalize
extern BOOST_PYTHON_DECL PyObject* current_scope;
}
class scope
: public object
{
public:
inline scope(scope const&);
@@ -27,32 +34,27 @@ class BOOST_PYTHON_DECL scope
private: // unimplemented functions
void operator=(scope const&);
private: // static members
// Use a PyObject* to avoid problems with static destruction after Py_Finalize
static PyObject* current_scope;
};
inline scope::scope(object const& new_scope)
: object(new_scope)
, m_previous_scope(current_scope)
, m_previous_scope(detail::current_scope)
{
current_scope = python::incref(new_scope.ptr());
detail::current_scope = python::incref(new_scope.ptr());
}
inline scope::scope()
: object(detail::borrowed_reference(
current_scope ? current_scope : Py_None
detail::current_scope ? detail::current_scope : Py_None
))
, m_previous_scope(python::xincref(current_scope))
, m_previous_scope(python::xincref(detail::current_scope))
{
}
inline scope::~scope()
{
python::xdecref(current_scope);
current_scope = m_previous_scope;
python::xdecref(detail::current_scope);
detail::current_scope = m_previous_scope;
}
namespace converter
@@ -67,9 +69,9 @@ namespace converter
// Placing this after the specialization above suppresses a CWPro8.3 bug
inline scope::scope(scope const& new_scope)
: object(new_scope)
, m_previous_scope(current_scope)
, m_previous_scope(detail::current_scope)
{
current_scope = python::incref(new_scope.ptr());
detail::current_scope = python::incref(new_scope.ptr());
}
}} // namespace boost::python

View File

@@ -15,6 +15,13 @@
# include <boost/static_assert.hpp>
# include <boost/type_traits/same_traits.hpp>
# ifndef BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE
# if defined(__GNUC__) \
&& ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
# define BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE
# endif
# endif
namespace boost { namespace python {
// for this compiler at least, cross-shared-library type_info
@@ -87,7 +94,7 @@ BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(long long)
# undef BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID
# endif
//
inline type_info::type_info(std::type_info const& id)
: m_base_type(
# ifdef BOOST_PYTHON_TYPE_ID_NAME
@@ -117,12 +124,26 @@ inline bool type_info::operator==(type_info const& rhs) const
# endif
}
# ifdef BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE
namespace detail
{
BOOST_PYTHON_DECL char const* gcc_demangle(char const*);
}
# endif
inline char const* type_info::name() const
{
# ifdef BOOST_PYTHON_TYPE_ID_NAME
return m_base_type;
char const* raw_name
= m_base_type
# ifndef BOOST_PYTHON_TYPE_ID_NAME
->name()
# endif
;
# ifdef BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE
return detail::gcc_demangle(raw_name);
# else
return m_base_type->name();
return raw_name;
# endif
}