mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 16:52:15 +00:00
Boost.Python. The major change is that, instead of being
boost::function2<PyObject*,PyObject*,PyObject*>, py_function is now a
runtime-polymorphic wrapper for compile-time polymorphic
behavior (just like function) of our own which carries more
information/behaviors. In particular, you can retrieve an array of
c-strings describing the types in the function signature.
Additionally, the minimum and maximum arity are stored in the
py_function object instead of in the 'function' object which wraps it.
* data_members.hpp -
Adjustments for the new py_function. Workarounds for CodeWarrior
Pro 8.3 bugs in function template argument deduction with
pointers-to-members.
* has_back_reference.hpp, test/back_reference.cpp,
test/select_holder.cpp -
Updated to follow the metafunction protocol
* init.hpp, detail/defaults_gen.hpp -
Make Keywords a more-specific type in function signatures to
prevent string literals that show up as char[N] from binding to
the wrong argument (at least Intel 7.1 for Windows does this).
* make_function.hpp -
Adjustments for the new py_function. Arities are now computed
by caller<>.
* opaque_pointer_converter.hpp, type_id.hpp -
Use BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS facilities;
generate specializations that all compilers can handle.
* raw_function.hpp -
Adjustments for the new py_function.
* caller.hpp -
Added arity and signature type name reporting.
* detail/config.hpp
Enable __declspec(dllexport) for Cygwin, thereby fixing the
recent horrible Cygwin linking problems.
* detail/msvc_typeinfo.hpp -
Always pass boost::type<T>* explicitly, thereby working around
incompatible notions of how to specialize function templates with
default arguments on various compilers.
* object/function.hpp
, object/function_handle.hpp
, object/function_object.hpp
, object/function_object.cpp
Adjustments for the new py_function. Arities are carried by
py_function.
* object/iterator.hpp, object/iterator.cpp
Adjustments for the new py_function; we have to compute a
signature of types to construct it with.
* object/py_function.hpp
Removed dependency on boost::function; see the comment at the
top of this entry for more details.
* object/select_holder.hpp
Clean up to more closely follow MPL idioms.
* test/Jamfile -
Adjust the embedding test for the new Cygwin use of declspec.
Update bases and pointee tests with missing properties.
* test/input_iterator.cpp -
Updates for the new iterator adaptors.
* test/opaque.py -
Add Python encoding comment to suppress PendinDeprecationWarning
with recent Python builds.
* test/str.cpp
Pass a Python long instead of a float to string.expandtabs,
suppressing a PendinDeprecationWarning with recent Python builds.
* libs/utility/counting_iterator_example.cpp
Borland workaround
* libs/utility/indirect_iterator_example.cpp
const-correctness fix.
*
[SVN r19247]
87 lines
2.4 KiB
C++
87 lines
2.4 KiB
C++
// Copyright David Abrahams 2002. Permission to copy, use,
|
|
// modify, sell and distribute this software is granted provided this
|
|
// copyright notice appears in all copies. This software is provided
|
|
// "as is" without express or implied warranty, and with no claim as
|
|
// to its suitability for any purpose.
|
|
#include <boost/python/object/select_holder.hpp>
|
|
#include <boost/python/has_back_reference.hpp>
|
|
#include <boost/python/detail/not_specified.hpp>
|
|
#include <boost/static_assert.hpp>
|
|
#include <boost/type_traits/same_traits.hpp>
|
|
#include <boost/function/function0.hpp>
|
|
#include <boost/mpl/bool.hpp>
|
|
#include <memory>
|
|
|
|
#define BOOST_INCLUDE_MAIN
|
|
#include <boost/test/test_tools.hpp>
|
|
|
|
struct BR {};
|
|
|
|
struct Base {};
|
|
struct Derived : Base {};
|
|
|
|
namespace boost { namespace python
|
|
{
|
|
// specialization
|
|
template <>
|
|
struct has_back_reference<BR>
|
|
: mpl::true_
|
|
{
|
|
};
|
|
}} // namespace boost::python
|
|
|
|
template <class T, class U>
|
|
void assert_same(U* = 0, T* = 0)
|
|
{
|
|
BOOST_TEST((boost::is_same<T,U>::value));
|
|
BOOST_STATIC_ASSERT((boost::is_same<T,U>::value));
|
|
|
|
}
|
|
|
|
template <class T, class Held, class Holder>
|
|
void assert_holder(T* = 0, Held* = 0, Holder* = 0)
|
|
{
|
|
assert_same<Holder>(
|
|
#if BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
|
boost::python::objects::select_holder<T,Held>::execute((Held*)0).get()
|
|
#else
|
|
boost::python::objects::select_holder<T,Held>::type::get()
|
|
#endif
|
|
);
|
|
}
|
|
|
|
int test_main(int, char * [])
|
|
{
|
|
using namespace boost::python::detail;
|
|
using namespace boost::python::objects;
|
|
|
|
assert_holder<Base,not_specified,value_holder<Base> >();
|
|
|
|
assert_holder<BR,not_specified,value_holder_back_reference<BR,BR> >();
|
|
assert_holder<Base,Base,value_holder<Base> >();
|
|
assert_holder<BR,BR,value_holder_back_reference<BR,BR> >();
|
|
|
|
assert_holder<Base,Derived
|
|
,value_holder_back_reference<Base,Derived> >();
|
|
|
|
assert_holder<Base,std::auto_ptr<Base>
|
|
,pointer_holder<std::auto_ptr<Base>,Base> >();
|
|
|
|
assert_holder<Base,std::auto_ptr<Derived>
|
|
,pointer_holder_back_reference<std::auto_ptr<Derived>,Base> >();
|
|
|
|
assert_holder<BR,std::auto_ptr<BR>
|
|
,pointer_holder_back_reference<std::auto_ptr<BR>,BR> > ();
|
|
|
|
return 0;
|
|
}
|
|
|
|
#if !defined(_WIN32) || defined(__GNUC__)
|
|
// This definition is needed for MinGW 2.95.2 and KCC on OSF for some
|
|
// reason, but will break other Win32 compilers.
|
|
namespace boost { namespace python
|
|
{
|
|
bool handle_exception_impl(boost::function0<void>) { return false; }
|
|
}}
|
|
#endif
|