From 0593074196e16ca18dcbf9783d42e4d8a1e530a1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 12 Oct 2002 15:37:34 +0000 Subject: [PATCH] Patches to support Synopsis [SVN r15906] --- .../boost/python/converter/pyobject_type.hpp | 1 + .../converter/rvalue_from_python_data.hpp | 3 +- include/boost/python/detail/call_object.hpp | 66 ------------------- .../boost/python/detail/exception_handler.hpp | 1 + include/boost/python/detail/make_tuple.hpp | 16 +++-- include/boost/python/detail/module_base.hpp | 46 ------------- include/boost/python/detail/scope.hpp | 2 + .../boost/python/detail/type_list_impl.hpp | 2 + .../python/detail/type_list_impl_no_pts.hpp | 2 + .../boost/python/detail/type_list_utils.hpp | 28 -------- .../boost/python/object/add_to_namespace.hpp | 1 + include/boost/python/object/construct.hpp | 24 ------- .../boost/python/object/pickle_support.hpp | 4 +- include/boost/python/object_call.hpp | 12 ++-- include/boost/python/object_protocol_core.hpp | 1 + include/boost/python/operators.hpp | 22 +++---- 16 files changed, 42 insertions(+), 189 deletions(-) delete mode 100644 include/boost/python/detail/call_object.hpp delete mode 100644 include/boost/python/detail/module_base.hpp delete mode 100644 include/boost/python/detail/type_list_utils.hpp delete mode 100644 include/boost/python/object/construct.hpp diff --git a/include/boost/python/converter/pyobject_type.hpp b/include/boost/python/converter/pyobject_type.hpp index 63127d5b..59ff7244 100644 --- a/include/boost/python/converter/pyobject_type.hpp +++ b/include/boost/python/converter/pyobject_type.hpp @@ -6,6 +6,7 @@ #ifndef PYOBJECT_TYPE_DWA2002720_HPP # define PYOBJECT_TYPE_DWA2002720_HPP +# include # include # include diff --git a/include/boost/python/converter/rvalue_from_python_data.hpp b/include/boost/python/converter/rvalue_from_python_data.hpp index 7f512830..91b5afd8 100644 --- a/include/boost/python/converter/rvalue_from_python_data.hpp +++ b/include/boost/python/converter/rvalue_from_python_data.hpp @@ -94,7 +94,8 @@ struct rvalue_from_python_data : rvalue_from_python_storage { # if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ && (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ - && (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) + && (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \ + && !defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */ // This must always be a POD struct with m_data its first member. BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage,stage1) == 0); # endif diff --git a/include/boost/python/detail/call_object.hpp b/include/boost/python/detail/call_object.hpp deleted file mode 100644 index 5595e5c0..00000000 --- a/include/boost/python/detail/call_object.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright David Abrahams 2001. 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 CALL_OBJECT_DWA20011222_HPP -# define CALL_OBJECT_DWA20011222_HPP -# include -# include -# include - -namespace boost { namespace python { - -namespace detail -{ - // A function object adaptor which turns a function returning R into - // an "equivalent" function returning void, but taking an R& in - // which the adapted function's result is stored. - template - struct return_by_reference - { - typedef void return_type; - - return_by_reference(R& result, F f) - : m_result(result) - , m_f(f) - { - } - - void operator()() const - { - m_result = m_f(); - } - - R& m_result; - F m_f; - }; - - // An object generator for the above adaptors - template - return_by_reference bind_return(R& result, F f) - { - return return_by_reference(result, f); - } - - // Given a function object f with signature - // - // R f(PyTypeObject*,PyObject*) - // - // calls f inside of handle_exception_impl, placing f's result in - // ret. Returns true iff an exception is thrown by f, leaving ret - // unmodified. - template - bool call_object(R& ret, PyObject* obj, F f) - { - return handle_exception( - detail::bind_return( - ret - , boost::bind( - f, static_cast(obj->ob_type), obj))); - } -} // namespace detail - -}} // namespace boost::python - -#endif // CALL_OBJECT_DWA20011222_HPP diff --git a/include/boost/python/detail/exception_handler.hpp b/include/boost/python/detail/exception_handler.hpp index 9a9aa4d2..3e36a7a5 100644 --- a/include/boost/python/detail/exception_handler.hpp +++ b/include/boost/python/detail/exception_handler.hpp @@ -6,6 +6,7 @@ #ifndef EXCEPTION_HANDLER_DWA2002810_HPP # define EXCEPTION_HANDLER_DWA2002810_HPP +# include # include # include diff --git a/include/boost/python/detail/make_tuple.hpp b/include/boost/python/detail/make_tuple.hpp index cb5c6fc6..399498bc 100644 --- a/include/boost/python/detail/make_tuple.hpp +++ b/include/boost/python/detail/make_tuple.hpp @@ -1,16 +1,17 @@ +# ifndef BOOST_PYTHON_SYNOPSIS # // 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. -#if !defined(BOOST_PP_IS_ITERATING) -# error Boost.Python - do not include this file! -#endif +# if !defined(BOOST_PP_IS_ITERATING) +# error Boost.Python - do not include this file! +# endif -#define N BOOST_PP_ITERATION() +# define N BOOST_PP_ITERATION() -#define BOOST_PYTHON_MAKE_TUPLE_ARG(z, N, ignored) \ +# define BOOST_PYTHON_MAKE_TUPLE_ARG(z, N, ignored) \ PyTuple_SET_ITEM( \ result.ptr() \ , N \ @@ -26,6 +27,7 @@ return result; } -#undef BOOST_PYTHON_MAKE_TUPLE_ARG +# undef BOOST_PYTHON_MAKE_TUPLE_ARG -#undef N +# undef N +# endif // BOOST_PYTHON_SYNOPSIS diff --git a/include/boost/python/detail/module_base.hpp b/include/boost/python/detail/module_base.hpp deleted file mode 100644 index 39056d63..00000000 --- a/include/boost/python/detail/module_base.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#error obsolete -// 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 MODULE_BASE_DWA2002227_HPP -# define MODULE_BASE_DWA2002227_HPP -# include -# include -# include - -namespace boost { namespace python { namespace detail { - -class BOOST_PYTHON_DECL module_base -{ - public: - // Create a module. REQUIRES: only one module is created per module. - module_base(char const* name, char const* doc = 0); - ~module_base(); - - // Add elements to the module - void add(type_handle const&); // just use the type's name - - // Return a reference to the Python module object being built - inline handle<> object() const; - - protected: - void setattr_doc(const char* name, python::object const&, char const* doc); - - private: - handle<> m_module; - static PyMethodDef initial_methods[1]; -}; - -// -// inline implementations -// -inline handle<> module_base::object() const -{ - return m_module; -} - -}}} // namespace boost::python::detail - -#endif // MODULE_BASE_DWA2002227_HPP diff --git a/include/boost/python/detail/scope.hpp b/include/boost/python/detail/scope.hpp index f8ece8f9..94528fa1 100644 --- a/include/boost/python/detail/scope.hpp +++ b/include/boost/python/detail/scope.hpp @@ -6,6 +6,8 @@ #ifndef SCOPE_DWA2002927_HPP # define SCOPE_DWA2002927_HPP +# include + namespace boost { namespace python { namespace detail { void BOOST_PYTHON_DECL scope_setattr_doc(char const* name, object const& obj, char const* doc); diff --git a/include/boost/python/detail/type_list_impl.hpp b/include/boost/python/detail/type_list_impl.hpp index 831ca5c0..50ab2446 100644 --- a/include/boost/python/detail/type_list_impl.hpp +++ b/include/boost/python/detail/type_list_impl.hpp @@ -7,6 +7,8 @@ # ifndef TYPE_LIST_IMPL_DWA2002913_HPP # define TYPE_LIST_IMPL_DWA2002913_HPP +# include + # include # include # include diff --git a/include/boost/python/detail/type_list_impl_no_pts.hpp b/include/boost/python/detail/type_list_impl_no_pts.hpp index d4d282aa..7c9d7fab 100644 --- a/include/boost/python/detail/type_list_impl_no_pts.hpp +++ b/include/boost/python/detail/type_list_impl_no_pts.hpp @@ -7,6 +7,8 @@ # ifndef TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP # define TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP +# include + # include # include # include diff --git a/include/boost/python/detail/type_list_utils.hpp b/include/boost/python/detail/type_list_utils.hpp deleted file mode 100644 index ebb5488b..00000000 --- a/include/boost/python/detail/type_list_utils.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#error obsolete -// 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 TYPE_LIST_UTILS_JDG20020826_HPP -# define TYPE_LIST_UTILS_JDG20020826_HPP - - -# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace python { namespace detail { - -template< typename T > -struct is_list_arg -{ - enum { value = true }; -}; - -template<> -struct is_list_arg -{ - enum { value = false }; -}; - -}}} -# endif -#endif // TYPE_LIST_UTILS_JDG20020826_HPP diff --git a/include/boost/python/object/add_to_namespace.hpp b/include/boost/python/object/add_to_namespace.hpp index 6a862b3d..e075bafd 100644 --- a/include/boost/python/object/add_to_namespace.hpp +++ b/include/boost/python/object/add_to_namespace.hpp @@ -6,6 +6,7 @@ #ifndef ADD_TO_NAMESPACE_DWA200286_HPP # define ADD_TO_NAMESPACE_DWA200286_HPP +# include # include namespace boost { namespace python { namespace objects { diff --git a/include/boost/python/object/construct.hpp b/include/boost/python/object/construct.hpp deleted file mode 100644 index 1eb73e4a..00000000 --- a/include/boost/python/object/construct.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright David Abrahams 2001. 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 CONSTRUCT_DWA20011215_HPP -# define CONSTRUCT_DWA20011215_HPP - -namespace boost { namespace python { namespace objects { - -template -struct construct -{ - static - template namespace boost { namespace python { diff --git a/include/boost/python/object_call.hpp b/include/boost/python/object_call.hpp index 362446b2..dd0c0dc0 100644 --- a/include/boost/python/object_call.hpp +++ b/include/boost/python/object_call.hpp @@ -1,14 +1,15 @@ +# if !defined(BOOST_PYTHON_SYNOPSIS) # // 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. -#if !defined(BOOST_PP_IS_ITERATING) -# error Boost.Python - do not include this file! -#endif +# if !defined(BOOST_PP_IS_ITERATING) +# error Boost.Python - do not include this file! +# endif -#define N BOOST_PP_ITERATION() +# define N BOOST_PP_ITERATION() template typename detail::dependent::type @@ -19,4 +20,5 @@ return call(get_managed_object(self, tag), BOOST_PP_ENUM_PARAMS_Z(1, N, a)); } -#undef N +# undef N +# endif // BOOST_PYTHON_SYNOPSIS diff --git a/include/boost/python/object_protocol_core.hpp b/include/boost/python/object_protocol_core.hpp index c5c41c6a..50d2f454 100755 --- a/include/boost/python/object_protocol_core.hpp +++ b/include/boost/python/object_protocol_core.hpp @@ -6,6 +6,7 @@ #ifndef OBJECT_PROTOCOL_CORE_DWA2002615_HPP # define OBJECT_PROTOCOL_CORE_DWA2002615_HPP +# include # include namespace boost { namespace python { diff --git a/include/boost/python/operators.hpp b/include/boost/python/operators.hpp index 7087f83a..3292efa7 100644 --- a/include/boost/python/operators.hpp +++ b/include/boost/python/operators.hpp @@ -169,16 +169,16 @@ namespace detail \ }; \ } -# define BOOST_PYTHON_BINARY_OPERATOR(id, rid, op) \ -BOOST_PYTHON_BINARY_OPERATION(id, rid, l op r) \ -namespace self_ns \ -{ \ - template \ - inline detail::operator_ \ - operator##op(L const&, R const&) \ - { \ - return detail::operator_(); \ - } \ +# define BOOST_PYTHON_BINARY_OPERATOR(id, rid, op) \ +BOOST_PYTHON_BINARY_OPERATION(id, rid, l op r) \ +namespace self_ns \ +{ \ + template \ + inline detail::operator_ \ + operator op(L const&, R const&) \ + { \ + return detail::operator_(); \ + } \ } BOOST_PYTHON_BINARY_OPERATOR(add, radd, +) @@ -262,7 +262,7 @@ namespace self_ns \ { \ template \ inline detail::operator_ \ - operator##op(self_t const&, R const&) \ + operator op(self_t const&, R const&) \ { \ return detail::operator_(); \ } \