// 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 OBJECT_CORE_DWA2002615_HPP
# define OBJECT_CORE_DWA2002615_HPP
# define BOOST_PYTHON_OBJECT_HAS_IS_NONE // added 2010-03-15 by rwgk
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
namespace boost { namespace python {
namespace detail
{
class kwds_proxy;
class args_proxy;
}
namespace converter
{
template struct arg_to_python;
}
// Put this in an inner namespace so that the generalized operators won't take over
namespace api
{
// This file contains the definition of the object class and enough to
// construct/copy it, but not enough to do operations like
// attribute/item access or addition.
template class proxy;
struct const_attribute_policies;
struct attribute_policies;
struct const_objattribute_policies;
struct objattribute_policies;
struct const_item_policies;
struct item_policies;
struct const_slice_policies;
struct slice_policies;
class slice_nil;
typedef proxy const_object_attribute;
typedef proxy object_attribute;
typedef proxy const_object_objattribute;
typedef proxy object_objattribute;
typedef proxy const_object_item;
typedef proxy object_item;
typedef proxy const_object_slice;
typedef proxy object_slice;
//
// is_proxy -- proxy type detection
//
BOOST_PYTHON_IS_XXX_DEF(proxy, boost::python::api::proxy, 1)
template struct object_initializer;
class object;
typedef PyObject* (object::*bool_type)() const;
template
class object_operators : public def_visitor
{
protected:
typedef object const& object_cref;
public:
// function call
//
object operator()() const;
# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, ))
# include BOOST_PP_ITERATE()
detail::args_proxy operator* () const;
object operator()(detail::args_proxy const &args) const;
object operator()(detail::args_proxy const &args,
detail::kwds_proxy const &kwds) const;
// truth value testing
//
operator bool_type() const;
bool operator!() const; // needed for vc6
// Attribute access
//
const_object_attribute attr(char const*) const;
object_attribute attr(char const*);
const_object_objattribute attr(object const&) const;
object_objattribute attr(object const&);
// Wrap 'in' operator (aka. __contains__)
template
object contains(T const& key) const;
// item access
//
const_object_item operator[](object_cref) const;
object_item operator[](object_cref);
template
const_object_item
operator[](T const& key) const;
template
object_item
operator[](T const& key);
// slicing
//
const_object_slice slice(object_cref, object_cref) const;
object_slice slice(object_cref, object_cref);
const_object_slice slice(slice_nil, object_cref) const;
object_slice slice(slice_nil, object_cref);
const_object_slice slice(object_cref, slice_nil) const;
object_slice slice(object_cref, slice_nil);
const_object_slice slice(slice_nil, slice_nil) const;
object_slice slice(slice_nil, slice_nil);
template
const_object_slice
slice(T const& start, V const& end) const;
template
object_slice
slice(T const& start, V const& end);
private: // def visitation for adding callable objects as class methods
template
void visit(ClassT& cl, char const* name, python::detail::def_helper const& helper) const
{
// It's too late to specify anything other than docstrings if
// the callable object is already wrapped.
BOOST_STATIC_ASSERT(
(detail::is_same::value
|| detail::is_string_literal::value));
objects::add_to_namespace(cl, name, this->derived_visitor(), helper.doc());
}
friend class python::def_visitor_access;
private:
// there is a confirmed CWPro8 codegen bug here. We prevent the
// early destruction of a temporary by binding a named object
// instead.
# if __MWERKS__ < 0x3000 || __MWERKS__ > 0x3003
typedef object const& object_cref2;
# else
typedef object const object_cref2;
# endif
};
// VC6 and VC7 require this base class in order to generate the
// correct copy constructor for object. We can't define it there
// explicitly or it will complain of ambiguity.
struct object_base : object_operators