mirror of
https://github.com/boostorg/python.git
synced 2026-01-28 19:32:14 +00:00
This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15564]
This commit is contained in:
41
include/boost/python/args_fwd.hpp
Normal file
41
include/boost/python/args_fwd.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
#ifndef ARGS_FWD_DWA2002927_HPP
|
||||
# define ARGS_FWD_DWA2002927_HPP
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <cstddef>
|
||||
# include <utility>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct keyword;
|
||||
template <std::size_t nkeywords = 0> struct keywords;
|
||||
|
||||
typedef std::pair<keyword const*, keyword const*> keyword_range;
|
||||
|
||||
template <>
|
||||
struct keywords<0>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, size = 0);
|
||||
static keyword_range range() { return keyword_range(); }
|
||||
};
|
||||
|
||||
namespace error
|
||||
{
|
||||
template <int keywords, int function_args>
|
||||
struct more_keywords_than_function_arguments
|
||||
{
|
||||
typedef char too_many_keywords[keywords > function_args ? -1 : 1];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // ARGS_FWD_DWA2002927_HPP
|
||||
45
include/boost/python/detail/make_keyword_range_fn.hpp
Normal file
45
include/boost/python/detail/make_keyword_range_fn.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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.
|
||||
#ifndef MAKE_KEYWORD_RANGE_FN_DWA2002927_HPP
|
||||
# define MAKE_KEYWORD_RANGE_FN_DWA2002927_HPP
|
||||
|
||||
# include <boost/python/args_fwd.hpp>
|
||||
# include <boost/python/detail/caller.hpp>
|
||||
# include <boost/python/object/function_object.hpp>
|
||||
# include <boost/python/object/make_holder.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
template <class F, class Policies>
|
||||
object make_keyword_range_function(F f, Policies const& policies, keyword_range const& kw)
|
||||
{
|
||||
enum { n_arguments = detail::arg_tuple_size<F>::value };
|
||||
return objects::function_object(
|
||||
::boost::bind<PyObject*>(detail::caller(), f, _1, _2, policies)
|
||||
, n_arguments
|
||||
, kw);
|
||||
}
|
||||
|
||||
template <class ArgList, class HolderGenerator, class Policies>
|
||||
object make_keyword_range_constructor(
|
||||
Policies const& policies
|
||||
, detail::keyword_range const& kw
|
||||
, HolderGenerator* = 0
|
||||
, ArgList* = 0)
|
||||
{
|
||||
enum { nargs = mpl::size<ArgList>::value };
|
||||
|
||||
return objects::function_object(
|
||||
::boost::bind<PyObject*>(detail::caller(),
|
||||
objects::make_holder<nargs>
|
||||
::template apply<HolderGenerator,ArgList>::execute
|
||||
, _1, _2, policies)
|
||||
, nargs + 1, kw);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // MAKE_KEYWORD_RANGE_FN_DWA2002927_HPP
|
||||
15
include/boost/python/detail/scope.hpp
Normal file
15
include/boost/python/detail/scope.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
#ifndef SCOPE_DWA2002927_HPP
|
||||
# define SCOPE_DWA2002927_HPP
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
void BOOST_PYTHON_DECL scope_setattr_doc(char const* name, object const& obj, char const* doc);
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // SCOPE_DWA2002927_HPP
|
||||
231
include/boost/python/numeric.hpp
Normal file
231
include/boost/python/numeric.hpp
Normal file
@@ -0,0 +1,231 @@
|
||||
// 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.
|
||||
#ifndef NUMARRAY_DWA2002922_HPP
|
||||
# define NUMARRAY_DWA2002922_HPP
|
||||
|
||||
# include <boost/python/tuple.hpp>
|
||||
# include <boost/python/str.hpp>
|
||||
# include <boost/preprocessor/iteration/local.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/repetition/enum.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace numeric {
|
||||
|
||||
namespace aux
|
||||
{
|
||||
struct BOOST_PYTHON_DECL array_base : object
|
||||
{
|
||||
# define BOOST_PP_LOCAL_MACRO(n) \
|
||||
array_base(BOOST_PP_ENUM_PARAMS_Z(1, n, object const& x));
|
||||
# define BOOST_PP_LOCAL_LIMITS (1, 7)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
object argmax(long axis=-1);
|
||||
object argmin(long axis=-1);
|
||||
object argsort(long axis=-1);
|
||||
object astype(object const& type = object());
|
||||
void byteswap();
|
||||
object copy() const;
|
||||
object diagonal(long offset = 0, long axis1 = 0, long axis2 = 1) const;
|
||||
void info() const;
|
||||
bool is_c_array() const;
|
||||
bool isbyteswapped() const;
|
||||
object new_(object type) const;
|
||||
void sort();
|
||||
object trace(long offset = 0, long axis1 = 0, long axis2 = 1) const;
|
||||
object type() const;
|
||||
char typecode() const;
|
||||
|
||||
object factory(object const& buffer=object()
|
||||
, object const& type=object()
|
||||
, object const& shape=object()
|
||||
, bool copy = true
|
||||
, bool savespace = false
|
||||
, object typecode = object());
|
||||
|
||||
object getflat() const;
|
||||
long getrank() const;
|
||||
object getshape() const;
|
||||
bool isaligned() const;
|
||||
bool iscontiguous() const;
|
||||
long itemsize() const;
|
||||
long nelements() const;
|
||||
object nonzero() const;
|
||||
|
||||
void put(object const& indices, object const& values);
|
||||
|
||||
void ravel();
|
||||
|
||||
object repeat(object const& repeats, long axis=0);
|
||||
|
||||
void resize(object const& shape);
|
||||
|
||||
void setflat(object const& flat);
|
||||
void setshape(object const& shape);
|
||||
|
||||
void swapaxes(long axis1, long axis2);
|
||||
|
||||
object take(object const& sequence, long axis = 0) const;
|
||||
|
||||
void tofile(object const& file) const;
|
||||
|
||||
str tostring() const;
|
||||
|
||||
void transpose(object const& axes = object());
|
||||
|
||||
object view() const;
|
||||
|
||||
public: // implementation detail - do not touch.
|
||||
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(array_base, object);
|
||||
};
|
||||
|
||||
struct BOOST_PYTHON_DECL array_object_manager_traits
|
||||
{
|
||||
static bool check(PyObject* obj);
|
||||
static detail::new_non_null_reference adopt(PyObject* obj);
|
||||
};
|
||||
} // namespace aux
|
||||
|
||||
class array : public aux::array_base
|
||||
{
|
||||
typedef aux::array_base base;
|
||||
public:
|
||||
|
||||
object astype() { return base::astype(); }
|
||||
|
||||
template <class Type>
|
||||
object astype(Type const& type_)
|
||||
{
|
||||
return base::astype(object(type_));
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
object new_(Type const& type_) const
|
||||
{
|
||||
return base::new_(object(type_));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void resize(Sequence const& x)
|
||||
{
|
||||
base::resize(object(x));
|
||||
}
|
||||
|
||||
# define BOOST_PP_LOCAL_MACRO(n) \
|
||||
void resize(BOOST_PP_ENUM_PARAMS_Z(1, n, long x)) \
|
||||
{ \
|
||||
resize(make_tuple(BOOST_PP_ENUM_PARAMS_Z(1, n, x))); \
|
||||
}
|
||||
# define BOOST_PP_LOCAL_LIMITS (1, BOOST_PYTHON_MAX_ARITY)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
template <class Sequence>
|
||||
void setshape(Sequence const& x)
|
||||
{
|
||||
base::setshape(object(x));
|
||||
}
|
||||
|
||||
# define BOOST_PP_LOCAL_MACRO(n) \
|
||||
void setshape(BOOST_PP_ENUM_PARAMS_Z(1, n, long x)) \
|
||||
{ \
|
||||
setshape(make_tuple(BOOST_PP_ENUM_PARAMS_Z(1, n, x))); \
|
||||
}
|
||||
# define BOOST_PP_LOCAL_LIMITS (1, BOOST_PYTHON_MAX_ARITY)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
template <class Indices, class Values>
|
||||
void put(Indices const& indices, Values const& values)
|
||||
{
|
||||
base::put(object(indices), object(values));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
object take(Sequence const& sequence, long axis = 0)
|
||||
{
|
||||
return base::take(object(sequence), axis);
|
||||
}
|
||||
|
||||
template <class File>
|
||||
void tofile(File const& f) const
|
||||
{
|
||||
base::tofile(object(f));
|
||||
}
|
||||
|
||||
object factory()
|
||||
{
|
||||
return base::factory();
|
||||
}
|
||||
|
||||
template <class Buffer>
|
||||
object factory(Buffer const& buffer)
|
||||
{
|
||||
return base::factory(object(buffer));
|
||||
}
|
||||
|
||||
template <class Buffer, class Type>
|
||||
object factory(
|
||||
Buffer const& buffer
|
||||
, Type const& type_)
|
||||
{
|
||||
return base::factory(object(buffer), object(type_));
|
||||
}
|
||||
|
||||
template <class Buffer, class Type, class Shape>
|
||||
object factory(
|
||||
Buffer const& buffer
|
||||
, Type const& type_
|
||||
, Shape const& shape
|
||||
, bool copy = true
|
||||
, bool savespace = false)
|
||||
{
|
||||
return base::factory(object(buffer), object(type_), object(shape), copy, savespace);
|
||||
}
|
||||
|
||||
template <class Buffer, class Type, class Shape>
|
||||
object factory(
|
||||
Buffer const& buffer
|
||||
, Type const& type_
|
||||
, Shape const& shape
|
||||
, bool copy
|
||||
, bool savespace
|
||||
, char typecode)
|
||||
{
|
||||
return base::factory(object(buffer), object(type_), object(shape), copy, savespace, object(typecode));
|
||||
}
|
||||
|
||||
# define BOOST_PYTHON_ENUM_AS_OBJECT(z, n, x) object(BOOST_PP_CAT(x,n))
|
||||
# define BOOST_PP_LOCAL_MACRO(n) \
|
||||
template <BOOST_PP_ENUM_PARAMS_Z(1, n, class T)> \
|
||||
explicit array(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, n, T, const& x)) \
|
||||
: base(BOOST_PP_ENUM_1(n, BOOST_PYTHON_ENUM_AS_OBJECT, x)) \
|
||||
{}
|
||||
# define BOOST_PP_LOCAL_LIMITS (1, 7)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
# undef BOOST_PYTHON_AS_OBJECT
|
||||
|
||||
static BOOST_PYTHON_DECL void set_module_and_type(char const* package_name = 0, char const* type_attribute_name = 0);
|
||||
|
||||
public: // implementation detail -- for internal use only
|
||||
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(array, base);
|
||||
};
|
||||
|
||||
} // namespace boost::python::numeric
|
||||
|
||||
namespace converter
|
||||
{
|
||||
template <>
|
||||
struct object_manager_traits< numeric::array >
|
||||
: numeric::aux::array_object_manager_traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
};
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // NUMARRAY_DWA2002922_HPP
|
||||
Reference in New Issue
Block a user