Boost logo

Boost Testing :

From: Jim Douglas (jim_at_[hidden])
Date: 2005-10-31 05:28:10


David Abrahams wrote:
>>>I'm not 100% sure, but I have managed to run the tests using Dinkum
>>>locally. I will check my patched version for compatability with GNU on
>>>the next run and let you know the results.
>>
>>OK.
>
> FWIW, I'm waiting to hear from you before I consider making any
> changes.

I have attached the patched type_id.cpp file used on the last sucessful
run. As you can see I took the coward's route and removed all the
existing conditional stuff :-) This hack works for both the Dinkum and
GNU libraries. The QNX GNU library does have a cxxabi.h file but in this
context it proves to be redundant. (Do you need to include it at all?)

So, one test for

#if defined(__QNXNTO__)

will serve for both libraries for now. (NB there are two underscores)

The embedded test requires a change in boost/tools/build/v1/python.jam.
On or after line 81 you need to add a test:

...
else if $(OS) = QNXNTO
{
        PYTHON_EMBEDDED_LIBRARY = python(PYTHON_VERSION) ;
}
...

(This is the same as for OSF)

Thanks
Jim


// Copyright David Abrahams 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/python/type_id.hpp>
#include <boost/python/detail/decorated_type_id.hpp>
#include <utility>
#include <vector>
#include <algorithm>
#include <memory>
#include <cstdlib>
#include <cstring>

// ********** My hack starts here **********
#include <ostream>

namespace boost { namespace python {

#ifdef BOOST_PYTHON_HAVE_GCC_CP_DEMANGLE

namespace cxxabi {
extern "C" char* __cxa_demangle(char const*, char*, std::size_t*, int*);
}

// ********** My hack ends here **********

namespace
{
  struct compare_first_cstring
  {
      template <class T>
      bool operator()(T const& x, T const& y)
      {
          return std::strcmp(x.first,y.first) < 0;
      }
  };
  
  struct free_mem
  {
      free_mem(char*p)
          : p(p) {}
    
      ~free_mem()
      {
          std::free(p);
      }
      char* p;
  };
}

namespace detail
{
  BOOST_PYTHON_DECL char const* gcc_demangle(char const* mangled)
  {
      typedef std::vector<
          std::pair<char const*, char const*>
> mangling_map;
      
      static mangling_map demangler;
      mangling_map::iterator p
          = std::lower_bound(
              demangler.begin(), demangler.end()
            , std::make_pair(mangled, (char const*)0)
            , compare_first_cstring());
      
      if (p == demangler.end() || strcmp(p->first, mangled))
      {
          int status;
          free_mem keeper(
              cxxabi::__cxa_demangle(mangled, 0, 0, &status)
              );
    
          assert(status != -3); // invalid argument error
    
          if (status == -1)
          {
              throw std::bad_alloc();
          }
          else
          {
              char const* demangled
                = status == -2
                  // Invalid mangled name. Best we can do is to
                  // return it intact.
                  ? mangled
                  : keeper.p;

              p = demangler.insert(p, std::make_pair(mangled, demangled));
              keeper.p = 0;
          }
      }
      
      return p->second;
  }
}
# endif

BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream& os, type_info const& x)
{
    return os << x.name();
}

namespace detail
{
  BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream& os, detail::decorated_type_info const& x)
  {
      os << x.m_base_type;
      if (x.m_decoration & decorated_type_info::const_)
          os << " const";
      if (x.m_decoration & decorated_type_info::volatile_)
          os << " volatile";
      if (x.m_decoration & decorated_type_info::reference)
          os << "&";
      return os;
  }
}
}} // namespace boost::python::converter


Boost-testing list run by mbergal at meta-comm.com