Added boost header
This commit is contained in:
23
test/external/boost/python/object/add_to_namespace.hpp
vendored
Normal file
23
test/external/boost/python/object/add_to_namespace.hpp
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef ADD_TO_NAMESPACE_DWA200286_HPP
|
||||
# define ADD_TO_NAMESPACE_DWA200286_HPP
|
||||
|
||||
# include <boost/python/object_fwd.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
//
|
||||
// A setattr that's "smart" about function overloading (and docstrings).
|
||||
//
|
||||
BOOST_PYTHON_DECL void add_to_namespace(
|
||||
object const& name_space, char const* name, object const& attribute);
|
||||
|
||||
BOOST_PYTHON_DECL void add_to_namespace(
|
||||
object const& name_space, char const* name, object const& attribute, char const* doc);
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // ADD_TO_NAMESPACE_DWA200286_HPP
|
||||
64
test/external/boost/python/object/class.hpp
vendored
Normal file
64
test/external/boost/python/object/class.hpp
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
// 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)
|
||||
#ifndef CLASS_DWA20011214_HPP
|
||||
# define CLASS_DWA20011214_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/utility.hpp>
|
||||
# include <boost/python/object_core.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <cstddef>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace objects {
|
||||
|
||||
struct BOOST_PYTHON_DECL class_base : python::api::object
|
||||
{
|
||||
// constructor
|
||||
class_base(
|
||||
char const* name // The name of the class
|
||||
|
||||
, std::size_t num_types // A list of class_ids. The first is the type
|
||||
, type_info const*const types // this is wrapping. The rest are the types of
|
||||
// any bases.
|
||||
|
||||
, char const* doc = 0 // Docstring, if any.
|
||||
);
|
||||
|
||||
|
||||
// Implementation detail. Hiding this in the private section would
|
||||
// require use of template friend declarations.
|
||||
void enable_pickling_(bool getstate_manages_dict);
|
||||
|
||||
protected:
|
||||
void add_property(
|
||||
char const* name, object const& fget, char const* docstr);
|
||||
void add_property(char const* name,
|
||||
object const& fget, object const& fset, char const* docstr);
|
||||
|
||||
void add_static_property(char const* name, object const& fget);
|
||||
void add_static_property(char const* name, object const& fget, object const& fset);
|
||||
|
||||
// Retrieve the underlying object
|
||||
void setattr(char const* name, object const&);
|
||||
|
||||
// Set a special attribute in the class which tells Boost.Python
|
||||
// to allocate extra bytes for embedded C++ objects in Python
|
||||
// instances.
|
||||
void set_instance_size(std::size_t bytes);
|
||||
|
||||
// Set an __init__ function which throws an appropriate exception
|
||||
// for abstract classes.
|
||||
void def_no_init();
|
||||
|
||||
// Effects:
|
||||
// setattr(self, staticmethod(getattr(self, method_name)))
|
||||
void make_method_static(const char *method_name);
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // CLASS_DWA20011214_HPP
|
||||
19
test/external/boost/python/object/class_detail.hpp
vendored
Normal file
19
test/external/boost/python/object/class_detail.hpp
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef CLASS_DETAIL_DWA200295_HPP
|
||||
# define CLASS_DETAIL_DWA200295_HPP
|
||||
|
||||
# include <boost/python/handle.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
BOOST_PYTHON_DECL type_handle registered_class_object(type_info id);
|
||||
BOOST_PYTHON_DECL type_handle class_metatype();
|
||||
BOOST_PYTHON_DECL type_handle class_type();
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // CLASS_DETAIL_DWA200295_HPP
|
||||
297
test/external/boost/python/object/class_metadata.hpp
vendored
Normal file
297
test/external/boost/python/object/class_metadata.hpp
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
// Copyright David Abrahams 2004. 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)
|
||||
#ifndef CLASS_METADATA_DWA2004719_HPP
|
||||
# define CLASS_METADATA_DWA2004719_HPP
|
||||
# include <boost/python/converter/shared_ptr_from_python.hpp>
|
||||
|
||||
# include <boost/python/object/inheritance.hpp>
|
||||
# include <boost/python/object/class_wrapper.hpp>
|
||||
# include <boost/python/object/make_instance.hpp>
|
||||
# include <boost/python/object/value_holder.hpp>
|
||||
# include <boost/python/object/pointer_holder.hpp>
|
||||
# include <boost/python/object/make_ptr_instance.hpp>
|
||||
|
||||
# include <boost/python/detail/force_instantiate.hpp>
|
||||
# include <boost/python/detail/not_specified.hpp>
|
||||
|
||||
# include <boost/python/has_back_reference.hpp>
|
||||
# include <boost/python/bases.hpp>
|
||||
|
||||
# include <boost/type_traits/add_pointer.hpp>
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
# include <boost/type_traits/is_polymorphic.hpp>
|
||||
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/mpl/eval_if.hpp>
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/mpl/or.hpp>
|
||||
# include <boost/mpl/identity.hpp>
|
||||
# include <boost/mpl/for_each.hpp>
|
||||
# include <boost/mpl/placeholders.hpp>
|
||||
# include <boost/mpl/single_view.hpp>
|
||||
|
||||
# include <boost/mpl/assert.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
# include <boost/noncopyable.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
BOOST_PYTHON_DECL
|
||||
void copy_class_object(type_info const& src, type_info const& dst);
|
||||
|
||||
//
|
||||
// Support for registering base/derived relationships
|
||||
//
|
||||
template <class Derived>
|
||||
struct register_base_of
|
||||
{
|
||||
template <class Base>
|
||||
inline void operator()(Base*) const
|
||||
{
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, == 1200)
|
||||
BOOST_MPL_ASSERT_NOT((is_same<Base,Derived>));
|
||||
# else
|
||||
BOOST_STATIC_ASSERT(!(is_same<Base,Derived>::value));
|
||||
# endif
|
||||
|
||||
// Register the Base class
|
||||
register_dynamic_id<Base>();
|
||||
|
||||
// Register the up-cast
|
||||
register_conversion<Derived,Base>(false);
|
||||
|
||||
// Register the down-cast, if appropriate.
|
||||
this->register_downcast((Base*)0, is_polymorphic<Base>());
|
||||
}
|
||||
|
||||
private:
|
||||
static inline void register_downcast(void*, mpl::false_) {}
|
||||
|
||||
template <class Base>
|
||||
static inline void register_downcast(Base*, mpl::true_)
|
||||
{
|
||||
register_conversion<Base, Derived>(true);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Preamble of register_class. Also used for callback classes, which
|
||||
// need some registration of their own.
|
||||
//
|
||||
template <class T, class Bases>
|
||||
inline void register_shared_ptr_from_python_and_casts(T*, Bases)
|
||||
{
|
||||
// Constructor performs registration
|
||||
python::detail::force_instantiate(converter::shared_ptr_from_python<T>());
|
||||
|
||||
//
|
||||
// register all up/downcasts here. We're using the alternate
|
||||
// interface to mpl::for_each to avoid an MSVC 6 bug.
|
||||
//
|
||||
register_dynamic_id<T>();
|
||||
mpl::for_each(register_base_of<T>(), (Bases*)0, (add_pointer<mpl::_>*)0);
|
||||
}
|
||||
|
||||
//
|
||||
// Helper for choosing the unnamed held_type argument
|
||||
//
|
||||
template <class T, class Prev>
|
||||
struct select_held_type
|
||||
: mpl::if_<
|
||||
mpl::or_<
|
||||
python::detail::specifies_bases<T>
|
||||
, is_same<T,noncopyable>
|
||||
>
|
||||
, Prev
|
||||
, T
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template <
|
||||
class T // class being wrapped
|
||||
, class X1 // = detail::not_specified
|
||||
, class X2 // = detail::not_specified
|
||||
, class X3 // = detail::not_specified
|
||||
>
|
||||
struct class_metadata
|
||||
{
|
||||
//
|
||||
// Calculate the unnamed template arguments
|
||||
//
|
||||
|
||||
// held_type_arg -- not_specified, [a class derived from] T or a
|
||||
// smart pointer to [a class derived from] T. Preserving
|
||||
// not_specified allows us to give class_<T,T> a back-reference.
|
||||
typedef typename select_held_type<
|
||||
X1
|
||||
, typename select_held_type<
|
||||
X2
|
||||
, typename select_held_type<
|
||||
X3
|
||||
, python::detail::not_specified
|
||||
>::type
|
||||
>::type
|
||||
>::type held_type_arg;
|
||||
|
||||
// bases
|
||||
typedef typename python::detail::select_bases<
|
||||
X1
|
||||
, typename python::detail::select_bases<
|
||||
X2
|
||||
, typename python::detail::select_bases<
|
||||
X3
|
||||
, python::bases<>
|
||||
>::type
|
||||
>::type
|
||||
>::type bases;
|
||||
|
||||
typedef mpl::or_<
|
||||
is_same<X1,noncopyable>
|
||||
, is_same<X2,noncopyable>
|
||||
, is_same<X3,noncopyable>
|
||||
> is_noncopyable;
|
||||
|
||||
//
|
||||
// Holder computation.
|
||||
//
|
||||
|
||||
// Compute the actual type that will be held in the Holder.
|
||||
typedef typename mpl::if_<
|
||||
is_same<held_type_arg,python::detail::not_specified>, T, held_type_arg
|
||||
>::type held_type;
|
||||
|
||||
// Determine if the object will be held by value
|
||||
typedef is_convertible<held_type*,T*> use_value_holder;
|
||||
|
||||
// Compute the "wrapped type", that is, if held_type is a smart
|
||||
// pointer, we're talking about the pointee.
|
||||
typedef typename mpl::eval_if<
|
||||
use_value_holder
|
||||
, mpl::identity<held_type>
|
||||
, pointee<held_type>
|
||||
>::type wrapped;
|
||||
|
||||
// Determine whether to use a "back-reference holder"
|
||||
typedef mpl::or_<
|
||||
has_back_reference<T>
|
||||
, is_same<held_type_arg,T>
|
||||
, is_base_and_derived<T,wrapped>
|
||||
> use_back_reference;
|
||||
|
||||
// Select the holder.
|
||||
typedef typename mpl::eval_if<
|
||||
use_back_reference
|
||||
, mpl::if_<
|
||||
use_value_holder
|
||||
, value_holder_back_reference<T, wrapped>
|
||||
, pointer_holder_back_reference<held_type,T>
|
||||
>
|
||||
, mpl::if_<
|
||||
use_value_holder
|
||||
, value_holder<T>
|
||||
, pointer_holder<held_type,wrapped>
|
||||
>
|
||||
>::type holder;
|
||||
|
||||
inline static void register_() // Register the runtime metadata.
|
||||
{
|
||||
class_metadata::register_aux((T*)0);
|
||||
}
|
||||
|
||||
private:
|
||||
template <class T2>
|
||||
inline static void register_aux(python::wrapper<T2>*)
|
||||
{
|
||||
typedef typename mpl::not_<is_same<T2,wrapped> >::type use_callback;
|
||||
class_metadata::register_aux2((T2*)0, use_callback());
|
||||
}
|
||||
|
||||
inline static void register_aux(void*)
|
||||
{
|
||||
typedef typename is_base_and_derived<T,wrapped>::type use_callback;
|
||||
class_metadata::register_aux2((T*)0, use_callback());
|
||||
}
|
||||
|
||||
template <class T2, class Callback>
|
||||
inline static void register_aux2(T2*, Callback)
|
||||
{
|
||||
objects::register_shared_ptr_from_python_and_casts((T2*)0, bases());
|
||||
|
||||
class_metadata::maybe_register_callback_class((T2*)0, Callback());
|
||||
|
||||
class_metadata::maybe_register_class_to_python((T2*)0, is_noncopyable());
|
||||
|
||||
class_metadata::maybe_register_pointer_to_python(
|
||||
(T2*)0, (use_value_holder*)0, (use_back_reference*)0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Support for converting smart pointers to python
|
||||
//
|
||||
inline static void maybe_register_pointer_to_python(...) {}
|
||||
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
inline static void maybe_register_pointer_to_python(void*,void*,mpl::true_*)
|
||||
{
|
||||
objects::copy_class_object(python::type_id<T>(), python::type_id<back_reference<T const &> >());
|
||||
objects::copy_class_object(python::type_id<T>(), python::type_id<back_reference<T &> >());
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T2>
|
||||
inline static void maybe_register_pointer_to_python(T2*, mpl::false_*, mpl::false_*)
|
||||
{
|
||||
python::detail::force_instantiate(
|
||||
objects::class_value_wrapper<
|
||||
held_type
|
||||
, make_ptr_instance<T2, pointer_holder<held_type, T2> >
|
||||
>()
|
||||
);
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
// explicit qualification of type_id makes msvc6 happy
|
||||
objects::copy_class_object(python::type_id<T2>(), python::type_id<held_type>());
|
||||
#endif
|
||||
}
|
||||
//
|
||||
// Support for registering to-python converters
|
||||
//
|
||||
inline static void maybe_register_class_to_python(void*, mpl::true_) {}
|
||||
|
||||
|
||||
template <class T2>
|
||||
inline static void maybe_register_class_to_python(T2*, mpl::false_)
|
||||
{
|
||||
python::detail::force_instantiate(class_cref_wrapper<T2, make_instance<T2, holder> >());
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
// explicit qualification of type_id makes msvc6 happy
|
||||
objects::copy_class_object(python::type_id<T2>(), python::type_id<held_type>());
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Support for registering callback classes
|
||||
//
|
||||
inline static void maybe_register_callback_class(void*, mpl::false_) {}
|
||||
|
||||
template <class T2>
|
||||
inline static void maybe_register_callback_class(T2*, mpl::true_)
|
||||
{
|
||||
objects::register_shared_ptr_from_python_and_casts(
|
||||
(wrapped*)0, mpl::single_view<T2>());
|
||||
|
||||
// explicit qualification of type_id makes msvc6 happy
|
||||
objects::copy_class_object(python::type_id<T2>(), python::type_id<wrapped>());
|
||||
}
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // CLASS_METADATA_DWA2004719_HPP
|
||||
51
test/external/boost/python/object/class_wrapper.hpp
vendored
Normal file
51
test/external/boost/python/object/class_wrapper.hpp
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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)
|
||||
#ifndef CLASS_WRAPPER_DWA20011221_HPP
|
||||
# define CLASS_WRAPPER_DWA20011221_HPP
|
||||
|
||||
# include <boost/python/to_python_converter.hpp>
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
# include <boost/python/converter/pytype_function.hpp>
|
||||
#endif
|
||||
# include <boost/ref.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
//
|
||||
// These two classes adapt the static execute function of a class
|
||||
// MakeInstance execute() function returning a new PyObject*
|
||||
// reference. The first one is used for class copy constructors, and
|
||||
// the second one is used to handle smart pointers.
|
||||
//
|
||||
|
||||
template <class Src, class MakeInstance>
|
||||
struct class_cref_wrapper
|
||||
: to_python_converter<Src,class_cref_wrapper<Src,MakeInstance> ,true>
|
||||
{
|
||||
static PyObject* convert(Src const& x)
|
||||
{
|
||||
return MakeInstance::execute(boost::ref(x));
|
||||
}
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
static PyTypeObject const *get_pytype() { return converter::registered_pytype_direct<Src>::get_pytype(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class Src, class MakeInstance>
|
||||
struct class_value_wrapper
|
||||
: to_python_converter<Src,class_value_wrapper<Src,MakeInstance> ,true>
|
||||
{
|
||||
static PyObject* convert(Src x)
|
||||
{
|
||||
return MakeInstance::execute(x);
|
||||
}
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
static PyTypeObject const *get_pytype() { return MakeInstance::get_pytype(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // CLASS_WRAPPER_DWA20011221_HPP
|
||||
36
test/external/boost/python/object/enum_base.hpp
vendored
Normal file
36
test/external/boost/python/object/enum_base.hpp
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef ENUM_BASE_DWA200298_HPP
|
||||
# define ENUM_BASE_DWA200298_HPP
|
||||
|
||||
# include <boost/python/object_core.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/to_python_function_type.hpp>
|
||||
# include <boost/python/converter/convertible_function.hpp>
|
||||
# include <boost/python/converter/constructor_function.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
struct BOOST_PYTHON_DECL enum_base : python::api::object
|
||||
{
|
||||
protected:
|
||||
enum_base(
|
||||
char const* name
|
||||
, converter::to_python_function_t
|
||||
, converter::convertible_function
|
||||
, converter::constructor_function
|
||||
, type_info
|
||||
, const char *doc = 0
|
||||
);
|
||||
|
||||
void add_value(char const* name, long value);
|
||||
void export_values();
|
||||
|
||||
static PyObject* to_python(PyTypeObject* type, long x);
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // ENUM_BASE_DWA200298_HPP
|
||||
21
test/external/boost/python/object/find_instance.hpp
vendored
Normal file
21
test/external/boost/python/object/find_instance.hpp
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef FIND_INSTANCE_DWA2002312_HPP
|
||||
# define FIND_INSTANCE_DWA2002312_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// Given a type_id, find the instance data which corresponds to it, or
|
||||
// return 0 in case no such type is held. If null_shared_ptr_only is
|
||||
// true and the type being sought is a shared_ptr, only find an
|
||||
// instance if it turns out to be NULL. Needed for shared_ptr rvalue
|
||||
// from_python support.
|
||||
BOOST_PYTHON_DECL void* find_instance_impl(PyObject*, type_info, bool null_shared_ptr_only = false);
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // FIND_INSTANCE_DWA2002312_HPP
|
||||
194
test/external/boost/python/object/forward.hpp
vendored
Normal file
194
test/external/boost/python/object/forward.hpp
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
// 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)
|
||||
#ifndef FORWARD_DWA20011215_HPP
|
||||
# define FORWARD_DWA20011215_HPP
|
||||
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/type_traits/is_scalar.hpp>
|
||||
# include <boost/type_traits/add_const.hpp>
|
||||
# include <boost/type_traits/add_reference.hpp>
|
||||
# include <boost/ref.hpp>
|
||||
# include <boost/python/detail/value_arg.hpp>
|
||||
# include <boost/python/detail/copy_ctor_mutates_rhs.hpp>
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# include <boost/type_traits/is_enum.hpp>
|
||||
# include <boost/mpl/and.hpp>
|
||||
# include <boost/mpl/not.hpp>
|
||||
# else
|
||||
# include <boost/mpl/or.hpp>
|
||||
# endif
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// Very much like boost::reference_wrapper<T>, except that in this
|
||||
// case T can be a reference already without causing a
|
||||
// reference-to-reference error.
|
||||
template <class T>
|
||||
struct reference_to_value
|
||||
{
|
||||
typedef typename add_reference<typename add_const<T>::type>::type reference;
|
||||
|
||||
reference_to_value(reference x) : m_value(x) {}
|
||||
reference get() const { return m_value; }
|
||||
private:
|
||||
reference m_value;
|
||||
};
|
||||
|
||||
// A little metaprogram which selects the type to pass through an
|
||||
// intermediate forwarding function when the destination argument type
|
||||
// is T.
|
||||
template <class T>
|
||||
struct forward
|
||||
: mpl::if_<
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// vc6 chokes on unforwarding enums nested in classes
|
||||
mpl::and_<
|
||||
is_scalar<T>
|
||||
, mpl::not_<
|
||||
is_enum<T>
|
||||
>
|
||||
>
|
||||
# else
|
||||
mpl::or_<python::detail::copy_ctor_mutates_rhs<T>, is_scalar<T> >
|
||||
# endif
|
||||
, T
|
||||
, reference_to_value<T>
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template<typename T>
|
||||
struct unforward
|
||||
{
|
||||
typedef typename unwrap_reference<T>::type& type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct unforward<reference_to_value<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct unforward_cref
|
||||
: python::detail::value_arg<
|
||||
typename unwrap_reference<T>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct unforward_cref<reference_to_value<T> >
|
||||
: add_reference<typename add_const<T>::type>
|
||||
{
|
||||
};
|
||||
|
||||
# else // no partial specialization
|
||||
|
||||
namespace detail
|
||||
{
|
||||
typedef char (&yes_reference_to_value_t)[1];
|
||||
typedef char (&no_reference_to_value_t)[2];
|
||||
|
||||
no_reference_to_value_t is_reference_to_value_test(...);
|
||||
|
||||
template<typename T>
|
||||
yes_reference_to_value_t is_reference_to_value_test(boost::type< reference_to_value<T> >);
|
||||
|
||||
template<bool wrapped>
|
||||
struct unforwarder
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename unwrap_reference<T>::type& type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct unforwarder<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
typedef typename T::reference type;
|
||||
};
|
||||
};
|
||||
|
||||
template<bool wrapped = false>
|
||||
struct cref_unforwarder
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
: python::detail::value_arg<
|
||||
typename unwrap_reference<T>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct cref_unforwarder<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
: python::detail::value_arg<
|
||||
typename T::reference
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_reference_to_value
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = (
|
||||
sizeof(is_reference_to_value_test(boost::type<T>()))
|
||||
== sizeof(yes_reference_to_value_t)));
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct unforward
|
||||
: public detail::unforwarder<
|
||||
detail::is_reference_to_value<T>::value
|
||||
>::template apply<T>
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
struct unforward_cref
|
||||
: public detail::cref_unforwarder<
|
||||
detail::is_reference_to_value<T>::value
|
||||
>::template apply<T>
|
||||
{};
|
||||
|
||||
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class T>
|
||||
typename reference_to_value<T>::reference
|
||||
do_unforward(reference_to_value<T> const& x, int)
|
||||
{
|
||||
return x.get();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
typename reference_wrapper<T>::type&
|
||||
do_unforward(reference_wrapper<T> const& x, int)
|
||||
{
|
||||
return x.get();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T const& do_unforward(T const& x, ...)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // FORWARD_DWA20011215_HPP
|
||||
82
test/external/boost/python/object/function.hpp
vendored
Normal file
82
test/external/boost/python/object/function.hpp
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// 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)
|
||||
#ifndef FUNCTION_DWA20011214_HPP
|
||||
# define FUNCTION_DWA20011214_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/python/args_fwd.hpp>
|
||||
# include <boost/python/handle.hpp>
|
||||
# include <boost/function/function2.hpp>
|
||||
# include <boost/python/object_core.hpp>
|
||||
# include <boost/python/object/py_function.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
|
||||
struct BOOST_PYTHON_DECL function : PyObject
|
||||
{
|
||||
function(
|
||||
py_function const&
|
||||
, python::detail::keyword const* names_and_defaults
|
||||
, unsigned num_keywords);
|
||||
|
||||
~function();
|
||||
|
||||
PyObject* call(PyObject*, PyObject*) const;
|
||||
|
||||
// Add an attribute to the name_space with the given name. If it is
|
||||
// a function object (this class), and an existing function is
|
||||
// already there, add it as an overload.
|
||||
static void add_to_namespace(
|
||||
object const& name_space, char const* name, object const& attribute);
|
||||
|
||||
static void add_to_namespace(
|
||||
object const& name_space, char const* name, object const& attribute, char const* doc);
|
||||
|
||||
object const& doc() const;
|
||||
void doc(object const& x);
|
||||
|
||||
object const& name() const;
|
||||
|
||||
object const& get_namespace() const { return m_namespace; }
|
||||
|
||||
private: // helper functions
|
||||
object signature(bool show_return_type=false) const;
|
||||
object signatures(bool show_return_type=false) const;
|
||||
void argument_error(PyObject* args, PyObject* keywords) const;
|
||||
void add_overload(handle<function> const&);
|
||||
|
||||
private: // data members
|
||||
py_function m_fn;
|
||||
handle<function> m_overloads;
|
||||
object m_name;
|
||||
object m_namespace;
|
||||
object m_doc;
|
||||
object m_arg_names;
|
||||
unsigned m_nkeyword_values;
|
||||
friend class function_doc_signature_generator;
|
||||
};
|
||||
|
||||
//
|
||||
// implementations
|
||||
//
|
||||
inline object const& function::doc() const
|
||||
{
|
||||
return this->m_doc;
|
||||
}
|
||||
|
||||
inline void function::doc(object const& x)
|
||||
{
|
||||
this->m_doc = x;
|
||||
}
|
||||
|
||||
inline object const& function::name() const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // FUNCTION_DWA20011214_HPP
|
||||
36
test/external/boost/python/object/function_doc_signature.hpp
vendored
Normal file
36
test/external/boost/python/object/function_doc_signature.hpp
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright Nikolay Mladenov 2007.
|
||||
// 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)
|
||||
#ifndef FUNCTION_SIGNATURE_20070531_HPP
|
||||
# define FUNCTION_SIGNATURE_20070531_HPP
|
||||
|
||||
#include <boost/python/object/function.hpp>
|
||||
#include <boost/python/converter/registrations.hpp>
|
||||
#include <boost/python/str.hpp>
|
||||
#include <boost/python/tuple.hpp>
|
||||
|
||||
#include <boost/python/detail/signature.hpp>
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
class function_doc_signature_generator{
|
||||
static const char * py_type_str(const python::detail::signature_element &s);
|
||||
static bool arity_cmp( function const *f1, function const *f2 );
|
||||
static bool are_seq_overloads( function const *f1, function const *f2 , bool check_docs);
|
||||
static std::vector<function const*> flatten(function const *f);
|
||||
static std::vector<function const*> split_seq_overloads( const std::vector<function const *> &funcs, bool split_on_doc_change);
|
||||
static str raw_function_pretty_signature(function const *f, size_t n_overloads, bool cpp_types = false);
|
||||
static str parameter_string(py_function const &f, size_t n, object arg_names, bool cpp_types);
|
||||
static str pretty_signature(function const *f, size_t n_overloads, bool cpp_types = false);
|
||||
|
||||
public:
|
||||
static list function_doc_signatures( function const * f);
|
||||
};
|
||||
|
||||
}}}//end of namespace boost::python::objects
|
||||
|
||||
#endif //FUNCTION_SIGNATURE_20070531_HPP
|
||||
44
test/external/boost/python/object/function_handle.hpp
vendored
Normal file
44
test/external/boost/python/object/function_handle.hpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef FUNCTION_HANDLE_DWA2002725_HPP
|
||||
# define FUNCTION_HANDLE_DWA2002725_HPP
|
||||
# include <boost/python/handle.hpp>
|
||||
# include <boost/python/detail/caller.hpp>
|
||||
# include <boost/python/default_call_policies.hpp>
|
||||
# include <boost/python/object/py_function.hpp>
|
||||
# include <boost/python/signature.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
BOOST_PYTHON_DECL handle<> function_handle_impl(py_function const& f);
|
||||
|
||||
// Just like function_object, but returns a handle<> instead. Using
|
||||
// this for arg_to_python<> allows us to break a circular dependency
|
||||
// between object and arg_to_python.
|
||||
template <class F, class Signature>
|
||||
inline handle<> function_handle(F const& f, Signature)
|
||||
{
|
||||
enum { n_arguments = mpl::size<Signature>::value - 1 };
|
||||
|
||||
return objects::function_handle_impl(
|
||||
python::detail::caller<
|
||||
F,default_call_policies,Signature
|
||||
>(
|
||||
f, default_call_policies()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Just like make_function, but returns a handle<> intead. Same
|
||||
// reasoning as above.
|
||||
template <class F>
|
||||
handle<> make_function_handle(F f)
|
||||
{
|
||||
return objects::function_handle(f, python::detail::get_signature(f));
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // FUNCTION_HANDLE_DWA2002725_HPP
|
||||
40
test/external/boost/python/object/function_object.hpp
vendored
Normal file
40
test/external/boost/python/object/function_object.hpp
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef FUNCTION_OBJECT_DWA2002725_HPP
|
||||
# define FUNCTION_OBJECT_DWA2002725_HPP
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/function/function2.hpp>
|
||||
# include <boost/python/object_core.hpp>
|
||||
# include <boost/python/args_fwd.hpp>
|
||||
# include <boost/python/object/py_function.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace objects
|
||||
{
|
||||
BOOST_PYTHON_DECL api::object function_object(
|
||||
py_function const& f
|
||||
, python::detail::keyword_range const&);
|
||||
|
||||
BOOST_PYTHON_DECL api::object function_object(
|
||||
py_function const& f
|
||||
, python::detail::keyword_range const&);
|
||||
|
||||
BOOST_PYTHON_DECL api::object function_object(py_function const& f);
|
||||
|
||||
// Add an attribute to the name_space with the given name. If it is
|
||||
// a Boost.Python function object
|
||||
// (boost/python/object/function.hpp), and an existing function is
|
||||
// already there, add it as an overload.
|
||||
BOOST_PYTHON_DECL void add_to_namespace(
|
||||
object const& name_space, char const* name, object const& attribute);
|
||||
|
||||
BOOST_PYTHON_DECL void add_to_namespace(
|
||||
object const& name_space, char const* name, object const& attribute, char const* doc);
|
||||
}
|
||||
|
||||
}} // namespace boost::python::objects
|
||||
|
||||
#endif // FUNCTION_OBJECT_DWA2002725_HPP
|
||||
132
test/external/boost/python/object/inheritance.hpp
vendored
Normal file
132
test/external/boost/python/object/inheritance.hpp
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef INHERITANCE_DWA200216_HPP
|
||||
# define INHERITANCE_DWA200216_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/type_traits/is_polymorphic.hpp>
|
||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
typedef type_info class_id;
|
||||
using python::type_id;
|
||||
|
||||
// Types used to get address and id of most derived type
|
||||
typedef std::pair<void*,class_id> dynamic_id_t;
|
||||
typedef dynamic_id_t (*dynamic_id_function)(void*);
|
||||
|
||||
BOOST_PYTHON_DECL void register_dynamic_id_aux(
|
||||
class_id static_id, dynamic_id_function get_dynamic_id);
|
||||
|
||||
BOOST_PYTHON_DECL void add_cast(
|
||||
class_id src_t, class_id dst_t, void* (*cast)(void*), bool is_downcast);
|
||||
|
||||
//
|
||||
// a generator with an execute() function which, given a source type
|
||||
// and a pointer to an object of that type, returns its most-derived
|
||||
// /reachable/ type identifier and object pointer.
|
||||
//
|
||||
|
||||
// first, the case where T has virtual functions
|
||||
template <class T>
|
||||
struct polymorphic_id_generator
|
||||
{
|
||||
static dynamic_id_t execute(void* p_)
|
||||
{
|
||||
T* p = static_cast<T*>(p_);
|
||||
return std::make_pair(dynamic_cast<void*>(p), class_id(typeid(*p)));
|
||||
}
|
||||
};
|
||||
|
||||
// now, the non-polymorphic case.
|
||||
template <class T>
|
||||
struct non_polymorphic_id_generator
|
||||
{
|
||||
static dynamic_id_t execute(void* p_)
|
||||
{
|
||||
return std::make_pair(p_, python::type_id<T>());
|
||||
}
|
||||
};
|
||||
|
||||
// Now the generalized selector
|
||||
template <class T>
|
||||
struct dynamic_id_generator
|
||||
: mpl::if_<
|
||||
boost::is_polymorphic<T>
|
||||
, boost::python::objects::polymorphic_id_generator<T>
|
||||
, boost::python::objects::non_polymorphic_id_generator<T>
|
||||
>
|
||||
{};
|
||||
|
||||
// Register the dynamic id function for T with the type-conversion
|
||||
// system.
|
||||
template <class T>
|
||||
void register_dynamic_id(T* = 0)
|
||||
{
|
||||
typedef typename dynamic_id_generator<T>::type generator;
|
||||
register_dynamic_id_aux(
|
||||
python::type_id<T>(), &generator::execute);
|
||||
}
|
||||
|
||||
//
|
||||
// a generator with an execute() function which, given a void*
|
||||
// pointing to an object of type Source will attempt to convert it to
|
||||
// an object of type Target.
|
||||
//
|
||||
|
||||
template <class Source, class Target>
|
||||
struct dynamic_cast_generator
|
||||
{
|
||||
static void* execute(void* source)
|
||||
{
|
||||
return dynamic_cast<Target*>(
|
||||
static_cast<Source*>(source));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <class Source, class Target>
|
||||
struct implicit_cast_generator
|
||||
{
|
||||
static void* execute(void* source)
|
||||
{
|
||||
Target* result = static_cast<Source*>(source);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Source, class Target>
|
||||
struct cast_generator
|
||||
: mpl::if_<
|
||||
is_base_and_derived<Target,Source>
|
||||
, implicit_cast_generator<Source,Target>
|
||||
, dynamic_cast_generator<Source,Target>
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template <class Source, class Target>
|
||||
inline void register_conversion(
|
||||
bool is_downcast = ::boost::is_base_and_derived<Source,Target>::value
|
||||
// These parameters shouldn't be used; they're an MSVC bug workaround
|
||||
, Source* = 0, Target* = 0)
|
||||
{
|
||||
typedef typename cast_generator<Source,Target>::type generator;
|
||||
|
||||
add_cast(
|
||||
python::type_id<Source>()
|
||||
, python::type_id<Target>()
|
||||
, &generator::execute
|
||||
, is_downcast
|
||||
);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // INHERITANCE_DWA200216_HPP
|
||||
17
test/external/boost/python/object/inheritance_query.hpp
vendored
Normal file
17
test/external/boost/python/object/inheritance_query.hpp
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright David Abrahams 2003.
|
||||
// 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)
|
||||
#ifndef INHERITANCE_QUERY_DWA2003520_HPP
|
||||
# define INHERITANCE_QUERY_DWA2003520_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
BOOST_PYTHON_DECL void* find_static_type(void* p, type_info src, type_info dst);
|
||||
BOOST_PYTHON_DECL void* find_dynamic_type(void* p, type_info src, type_info dst);
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // INHERITANCE_QUERY_DWA2003520_HPP
|
||||
51
test/external/boost/python/object/instance.hpp
vendored
Normal file
51
test/external/boost/python/object/instance.hpp
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef INSTANCE_DWA200295_HPP
|
||||
# define INSTANCE_DWA200295_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/type_traits/alignment_traits.hpp>
|
||||
# include <cstddef>
|
||||
|
||||
namespace boost { namespace python
|
||||
{
|
||||
struct BOOST_PYTHON_DECL_FORWARD instance_holder;
|
||||
}} // namespace boost::python
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// Each extension instance will be one of these
|
||||
template <class Data = char>
|
||||
struct instance
|
||||
{
|
||||
PyObject_VAR_HEAD
|
||||
PyObject* dict;
|
||||
PyObject* weakrefs;
|
||||
instance_holder* objects;
|
||||
|
||||
typedef typename type_with_alignment<
|
||||
::boost::alignment_of<Data>::value
|
||||
>::type align_t;
|
||||
|
||||
union
|
||||
{
|
||||
align_t align;
|
||||
char bytes[sizeof(Data)];
|
||||
} storage;
|
||||
};
|
||||
|
||||
template <class Data>
|
||||
struct additional_instance_size
|
||||
{
|
||||
typedef instance<Data> instance_data;
|
||||
typedef instance<char> instance_char;
|
||||
BOOST_STATIC_CONSTANT(
|
||||
std::size_t, value = sizeof(instance_data)
|
||||
- BOOST_PYTHON_OFFSETOF(instance_char,storage));
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // INSTANCE_DWA200295_HPP
|
||||
258
test/external/boost/python/object/iterator.hpp
vendored
Normal file
258
test/external/boost/python/object/iterator.hpp
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef ITERATOR_DWA2002510_HPP
|
||||
# define ITERATOR_DWA2002510_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/python/class.hpp>
|
||||
# include <boost/python/return_value_policy.hpp>
|
||||
# include <boost/python/return_by_value.hpp>
|
||||
# include <boost/python/handle.hpp>
|
||||
# include <boost/python/make_function.hpp>
|
||||
|
||||
# include <boost/python/object/iterator_core.hpp>
|
||||
# include <boost/python/object/class_detail.hpp>
|
||||
# include <boost/python/object/function_object.hpp>
|
||||
|
||||
# include <boost/mpl/vector/vector10.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
|
||||
# include <boost/python/detail/raw_pyobject.hpp>
|
||||
|
||||
# include <boost/type.hpp>
|
||||
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# include <boost/type_traits/add_reference.hpp>
|
||||
# include <boost/type_traits/add_const.hpp>
|
||||
|
||||
# include <boost/detail/iterator.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// CallPolicies for the next() method of iterators. We don't want
|
||||
// users to have to explicitly specify that the references returned by
|
||||
// iterators are copied, so we just replace the result_converter from
|
||||
// the default_iterator_call_policies with a permissive one which
|
||||
// always copies the result.
|
||||
typedef return_value_policy<return_by_value> default_iterator_call_policies;
|
||||
|
||||
// Instantiations of these are wrapped to produce Python iterators.
|
||||
template <class NextPolicies, class Iterator>
|
||||
struct iterator_range
|
||||
{
|
||||
iterator_range(object sequence, Iterator start, Iterator finish);
|
||||
|
||||
typedef boost::detail::iterator_traits<Iterator> traits_t;
|
||||
|
||||
struct next
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_reference<
|
||||
typename traits_t::reference
|
||||
>
|
||||
, typename traits_t::reference
|
||||
, typename traits_t::value_type
|
||||
>::type result_type;
|
||||
|
||||
result_type
|
||||
operator()(iterator_range<NextPolicies,Iterator>& self)
|
||||
{
|
||||
if (self.m_start == self.m_finish)
|
||||
stop_iteration_error();
|
||||
return *self.m_start++;
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||
// CWPro8 has a codegen problem when this is an empty class
|
||||
int garbage;
|
||||
# endif
|
||||
};
|
||||
|
||||
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
// for compilers which can't deduce the value_type of pointers, we
|
||||
// have a special implementation of next. This takes advantage of
|
||||
// the fact that T* results are treated like T& results by
|
||||
// Boost.Python's function wrappers.
|
||||
struct next_ptr
|
||||
{
|
||||
typedef Iterator result_type;
|
||||
|
||||
result_type
|
||||
operator()(iterator_range<NextPolicies,Iterator>& self)
|
||||
{
|
||||
if (self.m_start == self.m_finish)
|
||||
stop_iteration_error();
|
||||
return self.m_start++;
|
||||
}
|
||||
};
|
||||
|
||||
typedef mpl::if_<
|
||||
is_same<
|
||||
boost::detail::please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<Iterator>
|
||||
, typename traits_t::value_type
|
||||
>
|
||||
, next_ptr
|
||||
, next
|
||||
>::type next_fn;
|
||||
# else
|
||||
typedef next next_fn;
|
||||
# endif
|
||||
|
||||
object m_sequence; // Keeps the sequence alive while iterating.
|
||||
Iterator m_start;
|
||||
Iterator m_finish;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Get a Python class which contains the given iterator and
|
||||
// policies, creating it if necessary. Requires: NextPolicies is
|
||||
// default-constructible.
|
||||
template <class Iterator, class NextPolicies>
|
||||
object demand_iterator_class(char const* name, Iterator* = 0, NextPolicies const& policies = NextPolicies())
|
||||
{
|
||||
typedef iterator_range<NextPolicies,Iterator> range_;
|
||||
|
||||
// Check the registry. If one is already registered, return it.
|
||||
handle<> class_obj(
|
||||
objects::registered_class_object(python::type_id<range_>()));
|
||||
|
||||
if (class_obj.get() != 0)
|
||||
return object(class_obj);
|
||||
|
||||
typedef typename range_::next_fn next_fn;
|
||||
typedef typename next_fn::result_type result_type;
|
||||
|
||||
return class_<range_>(name, no_init)
|
||||
.def("__iter__", identity_function())
|
||||
.def(
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
"__next__"
|
||||
#else
|
||||
"next"
|
||||
#endif
|
||||
, make_function(
|
||||
next_fn()
|
||||
, policies
|
||||
, mpl::vector2<result_type,range_&>()
|
||||
));
|
||||
}
|
||||
|
||||
// A function object which builds an iterator_range.
|
||||
template <
|
||||
class Target
|
||||
, class Iterator
|
||||
, class Accessor1
|
||||
, class Accessor2
|
||||
, class NextPolicies
|
||||
>
|
||||
struct py_iter_
|
||||
{
|
||||
py_iter_(Accessor1 const& get_start, Accessor2 const& get_finish)
|
||||
: m_get_start(get_start)
|
||||
, m_get_finish(get_finish)
|
||||
{}
|
||||
|
||||
// Extract an object x of the Target type from the first Python
|
||||
// argument, and invoke get_start(x)/get_finish(x) to produce
|
||||
// iterators, which are used to construct a new iterator_range<>
|
||||
// object that gets wrapped into a Python iterator.
|
||||
iterator_range<NextPolicies,Iterator>
|
||||
operator()(back_reference<Target&> x) const
|
||||
{
|
||||
// Make sure the Python class is instantiated.
|
||||
detail::demand_iterator_class("iterator", (Iterator*)0, NextPolicies());
|
||||
|
||||
return iterator_range<NextPolicies,Iterator>(
|
||||
x.source()
|
||||
, m_get_start(x.get())
|
||||
, m_get_finish(x.get())
|
||||
);
|
||||
}
|
||||
private:
|
||||
Accessor1 m_get_start;
|
||||
Accessor2 m_get_finish;
|
||||
};
|
||||
|
||||
template <class Target, class Iterator, class NextPolicies, class Accessor1, class Accessor2>
|
||||
inline object make_iterator_function(
|
||||
Accessor1 const& get_start
|
||||
, Accessor2 const& get_finish
|
||||
, NextPolicies const& /*next_policies*/
|
||||
, Iterator const& (*)()
|
||||
, boost::type<Target>*
|
||||
, int
|
||||
)
|
||||
{
|
||||
return make_function(
|
||||
py_iter_<Target,Iterator,Accessor1,Accessor2,NextPolicies>(get_start, get_finish)
|
||||
, default_call_policies()
|
||||
, mpl::vector2<iterator_range<NextPolicies,Iterator>, back_reference<Target&> >()
|
||||
);
|
||||
}
|
||||
|
||||
template <class Target, class Iterator, class NextPolicies, class Accessor1, class Accessor2>
|
||||
inline object make_iterator_function(
|
||||
Accessor1 const& get_start
|
||||
, Accessor2 const& get_finish
|
||||
, NextPolicies const& next_policies
|
||||
, Iterator& (*)()
|
||||
, boost::type<Target>*
|
||||
, ...)
|
||||
{
|
||||
return make_iterator_function(
|
||||
get_start
|
||||
, get_finish
|
||||
, next_policies
|
||||
, (Iterator const&(*)())0
|
||||
, (boost::type<Target>*)0
|
||||
, 0
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create a Python callable object which accepts a single argument
|
||||
// convertible to the C++ Target type and returns a Python
|
||||
// iterator. The Python iterator uses get_start(x) and get_finish(x)
|
||||
// (where x is an instance of Target) to produce begin and end
|
||||
// iterators for the range, and an instance of NextPolicies is used as
|
||||
// CallPolicies for the Python iterator's next() function.
|
||||
template <class Target, class NextPolicies, class Accessor1, class Accessor2>
|
||||
inline object make_iterator_function(
|
||||
Accessor1 const& get_start
|
||||
, Accessor2 const& get_finish
|
||||
, NextPolicies const& next_policies
|
||||
, boost::type<Target>* = 0
|
||||
)
|
||||
{
|
||||
typedef typename Accessor1::result_type iterator;
|
||||
typedef typename add_const<iterator>::type iterator_const;
|
||||
typedef typename add_reference<iterator_const>::type iterator_cref;
|
||||
|
||||
return detail::make_iterator_function(
|
||||
get_start
|
||||
, get_finish
|
||||
, next_policies
|
||||
, (iterator_cref(*)())0
|
||||
, (boost::type<Target>*)0
|
||||
, 0
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
template <class NextPolicies, class Iterator>
|
||||
inline iterator_range<NextPolicies,Iterator>::iterator_range(
|
||||
object sequence, Iterator start, Iterator finish)
|
||||
: m_sequence(sequence), m_start(start), m_finish(finish)
|
||||
{
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // ITERATOR_DWA2002510_HPP
|
||||
17
test/external/boost/python/object/iterator_core.hpp
vendored
Normal file
17
test/external/boost/python/object/iterator_core.hpp
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef ITERATOR_CORE_DWA2002512_HPP
|
||||
# define ITERATOR_CORE_DWA2002512_HPP
|
||||
|
||||
# include <boost/python/object_fwd.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
BOOST_PYTHON_DECL object const& identity_function();
|
||||
BOOST_PYTHON_DECL void stop_iteration_error();
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // ITERATOR_CORE_DWA2002512_HPP
|
||||
15
test/external/boost/python/object/life_support.hpp
vendored
Normal file
15
test/external/boost/python/object/life_support.hpp
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef LIFE_SUPPORT_DWA200222_HPP
|
||||
# define LIFE_SUPPORT_DWA200222_HPP
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
BOOST_PYTHON_DECL PyObject* make_nurse_and_patient(PyObject* nurse, PyObject* patient);
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // LIFE_SUPPORT_DWA200222_HPP
|
||||
109
test/external/boost/python/object/make_holder.hpp
vendored
Normal file
109
test/external/boost/python/object/make_holder.hpp
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// 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)
|
||||
|
||||
# ifndef MAKE_HOLDER_DWA20011215_HPP
|
||||
# define MAKE_HOLDER_DWA20011215_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/python/object/instance.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
|
||||
# include <boost/python/detail/python_type.hpp>
|
||||
#endif
|
||||
|
||||
# include <boost/python/object/forward.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
|
||||
# include <boost/mpl/next.hpp>
|
||||
# include <boost/mpl/begin_end.hpp>
|
||||
# include <boost/mpl/deref.hpp>
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/iteration/local.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/debug/line.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
|
||||
|
||||
# include <cstddef>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
template <int nargs> struct make_holder;
|
||||
|
||||
# define BOOST_PYTHON_DO_FORWARD_ARG(z, index, _) , f##index(a##index)
|
||||
|
||||
// specializations...
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/make_holder.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
# undef BOOST_PYTHON_DO_FORWARD_ARG
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
# endif // MAKE_HOLDER_DWA20011215_HPP
|
||||
|
||||
// For gcc 4.4 compatability, we must include the
|
||||
// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
|
||||
#else // BOOST_PP_IS_ITERATING
|
||||
#if BOOST_PP_ITERATION_DEPTH() == 1
|
||||
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
||||
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
||||
# line BOOST_PP_LINE(__LINE__, make_holder.hpp)
|
||||
# endif
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
|
||||
template <>
|
||||
struct make_holder<N>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
# if N
|
||||
// Unrolled iteration through each argument type in ArgList,
|
||||
// choosing the type that will be forwarded on to the holder's
|
||||
// templated constructor.
|
||||
typedef typename mpl::begin<ArgList>::type iter0;
|
||||
|
||||
# define BOOST_PP_LOCAL_MACRO(n) \
|
||||
typedef typename mpl::deref<iter##n>::type t##n; \
|
||||
typedef typename forward<t##n>::type f##n; \
|
||||
typedef typename mpl::next<iter##n>::type \
|
||||
BOOST_PP_CAT(iter,BOOST_PP_INC(n)); // Next iterator type
|
||||
|
||||
# define BOOST_PP_LOCAL_LIMITS (0, N-1)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
# endif
|
||||
|
||||
static void execute(
|
||||
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
|
||||
boost::python::detail::python_class<BOOST_DEDUCED_TYPENAME Holder::value_type> *p
|
||||
#else
|
||||
PyObject *p
|
||||
#endif
|
||||
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, t, a))
|
||||
{
|
||||
typedef instance<Holder> instance_t;
|
||||
|
||||
void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder));
|
||||
try {
|
||||
(new (memory) Holder(
|
||||
p BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
|
||||
}
|
||||
catch(...) {
|
||||
Holder::deallocate(p, memory);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
# undef N
|
||||
|
||||
#endif // BOOST_PP_ITERATION_DEPTH()
|
||||
#endif
|
||||
78
test/external/boost/python/object/make_instance.hpp
vendored
Normal file
78
test/external/boost/python/object/make_instance.hpp
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef MAKE_INSTANCE_DWA200296_HPP
|
||||
# define MAKE_INSTANCE_DWA200296_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
# include <boost/python/object/instance.hpp>
|
||||
# include <boost/python/converter/registered.hpp>
|
||||
# include <boost/python/detail/decref_guard.hpp>
|
||||
# include <boost/python/detail/none.hpp>
|
||||
# include <boost/mpl/assert.hpp>
|
||||
# include <boost/mpl/or.hpp>
|
||||
# include <boost/type_traits/is_union.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
template <class T, class Holder, class Derived>
|
||||
struct make_instance_impl
|
||||
{
|
||||
typedef objects::instance<Holder> instance_t;
|
||||
|
||||
template <class Arg>
|
||||
static inline PyObject* execute(Arg& x)
|
||||
{
|
||||
BOOST_MPL_ASSERT((mpl::or_<is_class<T>, is_union<T> >));
|
||||
|
||||
PyTypeObject* type = Derived::get_class_object(x);
|
||||
|
||||
if (type == 0)
|
||||
return python::detail::none();
|
||||
|
||||
PyObject* raw_result = type->tp_alloc(
|
||||
type, objects::additional_instance_size<Holder>::value);
|
||||
|
||||
if (raw_result != 0)
|
||||
{
|
||||
python::detail::decref_guard protect(raw_result);
|
||||
|
||||
instance_t* instance = (instance_t*)raw_result;
|
||||
|
||||
// construct the new C++ object and install the pointer
|
||||
// in the Python object.
|
||||
Derived::construct(&instance->storage, (PyObject*)instance, x)->install(raw_result);
|
||||
|
||||
// Note the position of the internally-stored Holder,
|
||||
// for the sake of destruction
|
||||
Py_SIZE(instance) = offsetof(instance_t, storage);
|
||||
|
||||
// Release ownership of the python object
|
||||
protect.cancel();
|
||||
}
|
||||
return raw_result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Holder>
|
||||
struct make_instance
|
||||
: make_instance_impl<T, Holder, make_instance<T,Holder> >
|
||||
{
|
||||
template <class U>
|
||||
static inline PyTypeObject* get_class_object(U&)
|
||||
{
|
||||
return converter::registered<T>::converters.get_class_object();
|
||||
}
|
||||
|
||||
static inline Holder* construct(void* storage, PyObject* instance, reference_wrapper<T const> x)
|
||||
{
|
||||
return new (storage) Holder(instance, x);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // MAKE_INSTANCE_DWA200296_HPP
|
||||
72
test/external/boost/python/object/make_ptr_instance.hpp
vendored
Normal file
72
test/external/boost/python/object/make_ptr_instance.hpp
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef MAKE_PTR_INSTANCE_DWA200296_HPP
|
||||
# define MAKE_PTR_INSTANCE_DWA200296_HPP
|
||||
|
||||
# include <boost/python/object/make_instance.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/type_traits/is_polymorphic.hpp>
|
||||
# include <boost/get_pointer.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
# include <typeinfo>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
template <class T, class Holder>
|
||||
struct make_ptr_instance
|
||||
: make_instance_impl<T, Holder, make_ptr_instance<T,Holder> >
|
||||
{
|
||||
template <class Arg>
|
||||
static inline Holder* construct(void* storage, PyObject*, Arg& x)
|
||||
{
|
||||
return new (storage) Holder(x);
|
||||
}
|
||||
|
||||
template <class Ptr>
|
||||
static inline PyTypeObject* get_class_object(Ptr const& x)
|
||||
{
|
||||
return get_class_object_impl(get_pointer(x));
|
||||
}
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
static inline PyTypeObject const* get_pytype()
|
||||
{
|
||||
return converter::registered<T>::converters.get_class_object();
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
template <class U>
|
||||
static inline PyTypeObject* get_class_object_impl(U const volatile* p)
|
||||
{
|
||||
if (p == 0)
|
||||
return 0; // means "return None".
|
||||
|
||||
PyTypeObject* derived = get_derived_class_object(
|
||||
BOOST_DEDUCED_TYPENAME is_polymorphic<U>::type(), p);
|
||||
|
||||
if (derived)
|
||||
return derived;
|
||||
return converter::registered<T>::converters.get_class_object();
|
||||
}
|
||||
|
||||
template <class U>
|
||||
static inline PyTypeObject* get_derived_class_object(mpl::true_, U const volatile* x)
|
||||
{
|
||||
converter::registration const* r = converter::registry::query(
|
||||
type_info(typeid(*get_pointer(x)))
|
||||
);
|
||||
return r ? r->m_class_object : 0;
|
||||
}
|
||||
|
||||
template <class U>
|
||||
static inline PyTypeObject* get_derived_class_object(mpl::false_, U*)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // MAKE_PTR_INSTANCE_DWA200296_HPP
|
||||
124
test/external/boost/python/object/pickle_support.hpp
vendored
Normal file
124
test/external/boost/python/object/pickle_support.hpp
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
// (C) Copyright R.W. Grosse-Kunstleve 2002.
|
||||
// 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)
|
||||
#ifndef BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP
|
||||
# define BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace api
|
||||
{
|
||||
class object;
|
||||
}
|
||||
using api::object;
|
||||
class tuple;
|
||||
|
||||
BOOST_PYTHON_DECL object const& make_instance_reduce_function();
|
||||
|
||||
struct pickle_suite;
|
||||
|
||||
namespace error_messages {
|
||||
|
||||
template <class T>
|
||||
struct missing_pickle_suite_function_or_incorrect_signature {};
|
||||
|
||||
inline void must_be_derived_from_pickle_suite(pickle_suite const&) {}
|
||||
}
|
||||
|
||||
namespace detail { struct pickle_suite_registration; }
|
||||
|
||||
struct pickle_suite
|
||||
{
|
||||
private:
|
||||
struct inaccessible {};
|
||||
friend struct detail::pickle_suite_registration;
|
||||
public:
|
||||
static inaccessible* getinitargs() { return 0; }
|
||||
static inaccessible* getstate() { return 0; }
|
||||
static inaccessible* setstate() { return 0; }
|
||||
static bool getstate_manages_dict() { return false; }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct pickle_suite_registration
|
||||
{
|
||||
typedef pickle_suite::inaccessible inaccessible;
|
||||
|
||||
template <class Class_, class Tgetinitargs>
|
||||
static
|
||||
void
|
||||
register_(
|
||||
Class_& cl,
|
||||
tuple (*getinitargs_fn)(Tgetinitargs),
|
||||
inaccessible* (* /*getstate_fn*/)(),
|
||||
inaccessible* (* /*setstate_fn*/)(),
|
||||
bool)
|
||||
{
|
||||
cl.enable_pickling_(false);
|
||||
cl.def("__getinitargs__", getinitargs_fn);
|
||||
}
|
||||
|
||||
template <class Class_,
|
||||
class Rgetstate, class Tgetstate,
|
||||
class Tsetstate, class Ttuple>
|
||||
static
|
||||
void
|
||||
register_(
|
||||
Class_& cl,
|
||||
inaccessible* (* /*getinitargs_fn*/)(),
|
||||
Rgetstate (*getstate_fn)(Tgetstate),
|
||||
void (*setstate_fn)(Tsetstate, Ttuple),
|
||||
bool getstate_manages_dict)
|
||||
{
|
||||
cl.enable_pickling_(getstate_manages_dict);
|
||||
cl.def("__getstate__", getstate_fn);
|
||||
cl.def("__setstate__", setstate_fn);
|
||||
}
|
||||
|
||||
template <class Class_,
|
||||
class Tgetinitargs,
|
||||
class Rgetstate, class Tgetstate,
|
||||
class Tsetstate, class Ttuple>
|
||||
static
|
||||
void
|
||||
register_(
|
||||
Class_& cl,
|
||||
tuple (*getinitargs_fn)(Tgetinitargs),
|
||||
Rgetstate (*getstate_fn)(Tgetstate),
|
||||
void (*setstate_fn)(Tsetstate, Ttuple),
|
||||
bool getstate_manages_dict)
|
||||
{
|
||||
cl.enable_pickling_(getstate_manages_dict);
|
||||
cl.def("__getinitargs__", getinitargs_fn);
|
||||
cl.def("__getstate__", getstate_fn);
|
||||
cl.def("__setstate__", setstate_fn);
|
||||
}
|
||||
|
||||
template <class Class_>
|
||||
static
|
||||
void
|
||||
register_(
|
||||
Class_&,
|
||||
...)
|
||||
{
|
||||
typedef typename
|
||||
error_messages::missing_pickle_suite_function_or_incorrect_signature<
|
||||
Class_>::error_type error_type;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename PickleSuiteType>
|
||||
struct pickle_suite_finalize
|
||||
: PickleSuiteType,
|
||||
pickle_suite_registration
|
||||
{};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP
|
||||
224
test/external/boost/python/object/pointer_holder.hpp
vendored
Normal file
224
test/external/boost/python/object/pointer_holder.hpp
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// 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)
|
||||
|
||||
# ifndef POINTER_HOLDER_DWA20011215_HPP
|
||||
# define POINTER_HOLDER_DWA20011215_HPP
|
||||
|
||||
# include <boost/get_pointer.hpp>
|
||||
# include <boost/type.hpp>
|
||||
|
||||
# include <boost/python/instance_holder.hpp>
|
||||
# include <boost/python/object/inheritance_query.hpp>
|
||||
# include <boost/python/object/forward.hpp>
|
||||
|
||||
# include <boost/python/pointee.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
# include <boost/python/detail/wrapper_base.hpp>
|
||||
# include <boost/python/detail/force_instantiate.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
|
||||
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/mpl/apply.hpp>
|
||||
|
||||
# include <boost/preprocessor/comma_if.hpp>
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/debug/line.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
# include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <class T> class wrapper;
|
||||
|
||||
}}
|
||||
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
# if BOOST_WORKAROUND(__GNUC__, == 2)
|
||||
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)objects::do_unforward(a##n,0)
|
||||
# else
|
||||
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) objects::do_unforward(a##n,0)
|
||||
# endif
|
||||
|
||||
template <class Pointer, class Value>
|
||||
struct pointer_holder : instance_holder
|
||||
{
|
||||
typedef Value value_type;
|
||||
|
||||
pointer_holder(Pointer);
|
||||
|
||||
// Forward construction to the held object
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/pointer_holder.hpp>, 1))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
private: // types
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info, bool null_ptr_only);
|
||||
|
||||
template <class T>
|
||||
inline void* holds_wrapped(type_info dst_t, wrapper<T>*,T* p)
|
||||
{
|
||||
return python::type_id<T>() == dst_t ? p : 0;
|
||||
}
|
||||
|
||||
inline void* holds_wrapped(type_info, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private: // data members
|
||||
Pointer m_p;
|
||||
};
|
||||
|
||||
template <class Pointer, class Value>
|
||||
struct pointer_holder_back_reference : instance_holder
|
||||
{
|
||||
private:
|
||||
typedef typename python::pointee<Pointer>::type held_type;
|
||||
public:
|
||||
typedef Value value_type;
|
||||
|
||||
// Not sure about this one -- can it work? The source object
|
||||
// undoubtedly does not carry the correct back reference pointer.
|
||||
pointer_holder_back_reference(Pointer);
|
||||
|
||||
// Forward construction to the held object
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/pointer_holder.hpp>, 2))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info, bool null_ptr_only);
|
||||
|
||||
private: // data members
|
||||
Pointer m_p;
|
||||
};
|
||||
|
||||
# undef BOOST_PYTHON_UNFORWARD_LOCAL
|
||||
|
||||
template <class Pointer, class Value>
|
||||
inline pointer_holder<Pointer,Value>::pointer_holder(Pointer p)
|
||||
: m_p(p)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
inline pointer_holder_back_reference<Pointer,Value>::pointer_holder_back_reference(Pointer p)
|
||||
: m_p(p)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
void* pointer_holder<Pointer, Value>::holds(type_info dst_t, bool null_ptr_only)
|
||||
{
|
||||
typedef typename boost::remove_const< Value >::type non_const_value;
|
||||
|
||||
if (dst_t == python::type_id<Pointer>()
|
||||
&& !(null_ptr_only && get_pointer(this->m_p))
|
||||
)
|
||||
return &this->m_p;
|
||||
|
||||
Value* p0
|
||||
# if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
||||
= static_cast<Value*>( get_pointer(this->m_p) )
|
||||
# else
|
||||
= get_pointer(this->m_p)
|
||||
# endif
|
||||
;
|
||||
non_const_value* p = const_cast<non_const_value*>( p0 );
|
||||
|
||||
if (p == 0)
|
||||
return 0;
|
||||
|
||||
if (void* wrapped = holds_wrapped(dst_t, p, p))
|
||||
return wrapped;
|
||||
|
||||
type_info src_t = python::type_id<non_const_value>();
|
||||
return src_t == dst_t ? p : find_dynamic_type(p, src_t, dst_t);
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t, bool null_ptr_only)
|
||||
{
|
||||
if (dst_t == python::type_id<Pointer>()
|
||||
&& !(null_ptr_only && get_pointer(this->m_p))
|
||||
)
|
||||
return &this->m_p;
|
||||
|
||||
if (!get_pointer(this->m_p))
|
||||
return 0;
|
||||
|
||||
Value* p = get_pointer(m_p);
|
||||
|
||||
if (dst_t == python::type_id<held_type>())
|
||||
return p;
|
||||
|
||||
type_info src_t = python::type_id<Value>();
|
||||
return src_t == dst_t ? p : find_dynamic_type(p, src_t, dst_t);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
# endif // POINTER_HOLDER_DWA20011215_HPP
|
||||
|
||||
/* --------------- pointer_holder --------------- */
|
||||
// For gcc 4.4 compatability, we must include the
|
||||
// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
|
||||
#else // BOOST_PP_IS_ITERATING
|
||||
#if BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
|
||||
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
||||
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
||||
# line BOOST_PP_LINE(__LINE__, pointer_holder.hpp)
|
||||
# endif
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
|
||||
# if (N != 0)
|
||||
template< BOOST_PP_ENUM_PARAMS_Z(1, N, class A) >
|
||||
# endif
|
||||
pointer_holder(PyObject* self BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a))
|
||||
: m_p(new Value(
|
||||
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
|
||||
))
|
||||
{
|
||||
python::detail::initialize_wrapper(self, get_pointer(this->m_p));
|
||||
}
|
||||
|
||||
# undef N
|
||||
|
||||
/* --------------- pointer_holder_back_reference --------------- */
|
||||
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2
|
||||
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
||||
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
||||
# line BOOST_PP_LINE(__LINE__, pointer_holder.hpp(pointer_holder_back_reference))
|
||||
# endif
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
|
||||
# if (N != 0)
|
||||
template < BOOST_PP_ENUM_PARAMS_Z(1, N, class A) >
|
||||
# endif
|
||||
pointer_holder_back_reference(
|
||||
PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a))
|
||||
: m_p(new held_type(
|
||||
p BOOST_PP_COMMA_IF(N) BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
|
||||
))
|
||||
{}
|
||||
|
||||
# undef N
|
||||
|
||||
#endif // BOOST_PP_ITERATION_DEPTH()
|
||||
#endif
|
||||
172
test/external/boost/python/object/py_function.hpp
vendored
Normal file
172
test/external/boost/python/object/py_function.hpp
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef PY_FUNCTION_DWA200286_HPP
|
||||
# define PY_FUNCTION_DWA200286_HPP
|
||||
|
||||
# include <boost/python/detail/signature.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
# include <boost/mpl/size.hpp>
|
||||
# include <memory>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// This type is used as a "generalized Python callback", wrapping the
|
||||
// function signature:
|
||||
//
|
||||
// PyObject* (PyObject* args, PyObject* keywords)
|
||||
|
||||
struct BOOST_PYTHON_DECL py_function_impl_base
|
||||
{
|
||||
virtual ~py_function_impl_base();
|
||||
virtual PyObject* operator()(PyObject*, PyObject*) = 0;
|
||||
virtual unsigned min_arity() const = 0;
|
||||
virtual unsigned max_arity() const;
|
||||
virtual python::detail::py_func_sig_info signature() const = 0;
|
||||
};
|
||||
|
||||
template <class Caller>
|
||||
struct caller_py_function_impl : py_function_impl_base
|
||||
{
|
||||
caller_py_function_impl(Caller const& caller)
|
||||
: m_caller(caller)
|
||||
{}
|
||||
|
||||
PyObject* operator()(PyObject* args, PyObject* kw)
|
||||
{
|
||||
return m_caller(args, kw);
|
||||
}
|
||||
|
||||
virtual unsigned min_arity() const
|
||||
{
|
||||
return m_caller.min_arity();
|
||||
}
|
||||
|
||||
virtual python::detail::py_func_sig_info signature() const
|
||||
{
|
||||
return m_caller.signature();
|
||||
}
|
||||
|
||||
private:
|
||||
Caller m_caller;
|
||||
};
|
||||
|
||||
template <class Caller, class Sig>
|
||||
struct signature_py_function_impl : py_function_impl_base
|
||||
{
|
||||
signature_py_function_impl(Caller const& caller)
|
||||
: m_caller(caller)
|
||||
{}
|
||||
|
||||
PyObject* operator()(PyObject* args, PyObject* kw)
|
||||
{
|
||||
return m_caller(args, kw);
|
||||
}
|
||||
|
||||
virtual unsigned min_arity() const
|
||||
{
|
||||
return mpl::size<Sig>::value - 1;
|
||||
}
|
||||
|
||||
virtual python::detail::py_func_sig_info signature() const
|
||||
{
|
||||
python::detail::signature_element const* sig = python::detail::signature<Sig>::elements();
|
||||
python::detail::py_func_sig_info res = {sig, sig};
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
Caller m_caller;
|
||||
};
|
||||
|
||||
template <class Caller, class Sig>
|
||||
struct full_py_function_impl : py_function_impl_base
|
||||
{
|
||||
full_py_function_impl(Caller const& caller, unsigned min_arity, unsigned max_arity)
|
||||
: m_caller(caller)
|
||||
, m_min_arity(min_arity)
|
||||
, m_max_arity(max_arity > min_arity ? max_arity : min_arity)
|
||||
{}
|
||||
|
||||
PyObject* operator()(PyObject* args, PyObject* kw)
|
||||
{
|
||||
return m_caller(args, kw);
|
||||
}
|
||||
|
||||
virtual unsigned min_arity() const
|
||||
{
|
||||
return m_min_arity;
|
||||
}
|
||||
|
||||
virtual unsigned max_arity() const
|
||||
{
|
||||
return m_max_arity;
|
||||
}
|
||||
|
||||
virtual python::detail::py_func_sig_info signature() const
|
||||
{
|
||||
python::detail::signature_element const* sig = python::detail::signature<Sig>::elements();
|
||||
python::detail::py_func_sig_info res = {sig, sig};
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
Caller m_caller;
|
||||
unsigned m_min_arity;
|
||||
unsigned m_max_arity;
|
||||
};
|
||||
|
||||
struct py_function
|
||||
{
|
||||
template <class Caller>
|
||||
py_function(Caller const& caller)
|
||||
: m_impl(new caller_py_function_impl<Caller>(caller))
|
||||
{}
|
||||
|
||||
template <class Caller, class Sig>
|
||||
py_function(Caller const& caller, Sig)
|
||||
: m_impl(new signature_py_function_impl<Caller, Sig>(caller))
|
||||
{}
|
||||
|
||||
template <class Caller, class Sig>
|
||||
py_function(Caller const& caller, Sig, int min_arity, int max_arity = 0)
|
||||
: m_impl(new full_py_function_impl<Caller, Sig>(caller, min_arity, max_arity))
|
||||
{}
|
||||
|
||||
py_function(py_function const& rhs)
|
||||
: m_impl(rhs.m_impl)
|
||||
{}
|
||||
|
||||
PyObject* operator()(PyObject* args, PyObject* kw) const
|
||||
{
|
||||
return (*m_impl)(args, kw);
|
||||
}
|
||||
|
||||
unsigned min_arity() const
|
||||
{
|
||||
return m_impl->min_arity();
|
||||
}
|
||||
|
||||
unsigned max_arity() const
|
||||
{
|
||||
return m_impl->max_arity();
|
||||
}
|
||||
|
||||
python::detail::signature_element const* signature() const
|
||||
{
|
||||
return m_impl->signature().signature;
|
||||
}
|
||||
|
||||
python::detail::signature_element const& get_return_type() const
|
||||
{
|
||||
return *m_impl->signature().ret;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::auto_ptr<py_function_impl_base> m_impl;
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // PY_FUNCTION_DWA200286_HPP
|
||||
27
test/external/boost/python/object/stl_iterator_core.hpp
vendored
Normal file
27
test/external/boost/python/object/stl_iterator_core.hpp
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright Eric Niebler 2005.
|
||||
// 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)
|
||||
#ifndef STL_ITERATOR_CORE_EAN20051028_HPP
|
||||
# define STL_ITERATOR_CORE_EAN20051028_HPP
|
||||
|
||||
# include <boost/python/object_fwd.hpp>
|
||||
# include <boost/python/handle_fwd.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
struct BOOST_PYTHON_DECL stl_input_iterator_impl
|
||||
{
|
||||
stl_input_iterator_impl();
|
||||
stl_input_iterator_impl(boost::python::object const &ob);
|
||||
void increment();
|
||||
bool equal(stl_input_iterator_impl const &that) const;
|
||||
boost::python::handle<> const ¤t() const;
|
||||
private:
|
||||
boost::python::object it_;
|
||||
boost::python::handle<> ob_;
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // STL_ITERATOR_CORE_EAN20051028_HPP
|
||||
170
test/external/boost/python/object/value_holder.hpp
vendored
Normal file
170
test/external/boost/python/object/value_holder.hpp
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// 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)
|
||||
|
||||
# ifndef VALUE_HOLDER_DWA20011215_HPP
|
||||
# define VALUE_HOLDER_DWA20011215_HPP
|
||||
|
||||
# include <boost/python/object/value_holder_fwd.hpp>
|
||||
|
||||
# include <boost/python/instance_holder.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/wrapper.hpp>
|
||||
|
||||
# include <boost/python/object/inheritance_query.hpp>
|
||||
# include <boost/python/object/forward.hpp>
|
||||
|
||||
# include <boost/python/detail/force_instantiate.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
|
||||
# include <boost/preprocessor/comma_if.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/debug/line.hpp>
|
||||
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
# include <boost/utility/addressof.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
# if BOOST_WORKAROUND(__GNUC__, == 2)
|
||||
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)objects::do_unforward(a##n,0)
|
||||
# else
|
||||
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) objects::do_unforward(a##n,0)
|
||||
# endif
|
||||
|
||||
template <class Value>
|
||||
struct value_holder : instance_holder
|
||||
{
|
||||
typedef Value held_type;
|
||||
typedef Value value_type;
|
||||
|
||||
// Forward construction to the held object
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/value_holder.hpp>, 1))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info, bool null_ptr_only);
|
||||
|
||||
template <class T>
|
||||
inline void* holds_wrapped(type_info dst_t, wrapper<T>*,T* p)
|
||||
{
|
||||
return python::type_id<T>() == dst_t ? p : 0;
|
||||
}
|
||||
|
||||
inline void* holds_wrapped(type_info, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
private: // data members
|
||||
Value m_held;
|
||||
};
|
||||
|
||||
template <class Value, class Held>
|
||||
struct value_holder_back_reference : instance_holder
|
||||
{
|
||||
typedef Held held_type;
|
||||
typedef Value value_type;
|
||||
|
||||
// Forward construction to the held object
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/value_holder.hpp>, 2))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info, bool null_ptr_only);
|
||||
|
||||
private: // data members
|
||||
Held m_held;
|
||||
};
|
||||
|
||||
# undef BOOST_PYTHON_UNFORWARD_LOCAL
|
||||
|
||||
template <class Value>
|
||||
void* value_holder<Value>::holds(type_info dst_t, bool /*null_ptr_only*/)
|
||||
{
|
||||
if (void* wrapped = holds_wrapped(dst_t, boost::addressof(m_held), boost::addressof(m_held)))
|
||||
return wrapped;
|
||||
|
||||
type_info src_t = python::type_id<Value>();
|
||||
return src_t == dst_t ? boost::addressof(m_held)
|
||||
: find_static_type(boost::addressof(m_held), src_t, dst_t);
|
||||
}
|
||||
|
||||
template <class Value, class Held>
|
||||
void* value_holder_back_reference<Value,Held>::holds(
|
||||
type_info dst_t, bool /*null_ptr_only*/)
|
||||
{
|
||||
type_info src_t = python::type_id<Value>();
|
||||
Value* x = &m_held;
|
||||
|
||||
if (dst_t == src_t)
|
||||
return x;
|
||||
else if (dst_t == python::type_id<Held>())
|
||||
return &m_held;
|
||||
else
|
||||
return find_static_type(x, src_t, dst_t);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
# endif // VALUE_HOLDER_DWA20011215_HPP
|
||||
|
||||
// --------------- value_holder ---------------
|
||||
|
||||
// For gcc 4.4 compatability, we must include the
|
||||
// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
|
||||
#else // BOOST_PP_IS_ITERATING
|
||||
#if BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
|
||||
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
||||
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
||||
# line BOOST_PP_LINE(__LINE__, value_holder.hpp(value_holder))
|
||||
# endif
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
|
||||
# if (N != 0)
|
||||
template <BOOST_PP_ENUM_PARAMS_Z(1, N, class A)>
|
||||
# endif
|
||||
value_holder(
|
||||
PyObject* self BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a))
|
||||
: m_held(
|
||||
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
|
||||
)
|
||||
{
|
||||
python::detail::initialize_wrapper(self, boost::addressof(this->m_held));
|
||||
}
|
||||
|
||||
# undef N
|
||||
|
||||
// --------------- value_holder_back_reference ---------------
|
||||
|
||||
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2
|
||||
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
||||
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
||||
# line BOOST_PP_LINE(__LINE__, value_holder.hpp(value_holder_back_reference))
|
||||
# endif
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
|
||||
# if (N != 0)
|
||||
template <BOOST_PP_ENUM_PARAMS_Z(1, N, class A)>
|
||||
# endif
|
||||
value_holder_back_reference(
|
||||
PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a))
|
||||
: m_held(
|
||||
p BOOST_PP_COMMA_IF(N)
|
||||
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
# undef N
|
||||
|
||||
#endif // BOOST_PP_ITERATION_DEPTH()
|
||||
#endif
|
||||
16
test/external/boost/python/object/value_holder_fwd.hpp
vendored
Normal file
16
test/external/boost/python/object/value_holder_fwd.hpp
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// 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)
|
||||
#ifndef VALUE_HOLDER_FWD_DWA2002311_HPP
|
||||
# define VALUE_HOLDER_FWD_DWA2002311_HPP
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
struct no_back_reference;
|
||||
|
||||
template <class CallbackType = no_back_reference> struct value_holder_generator;
|
||||
|
||||
}}} // namespace boost::python::object
|
||||
|
||||
#endif // VALUE_HOLDER_FWD_DWA2002311_HPP
|
||||
Reference in New Issue
Block a user