GeezerVison is showing github.com — reference<> => handle<> · mborgerding/python@366ee6d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Jamfile +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ dll bpl | 23 | 23 | src/object/life_support.cpp | 24 | 24 | src/errors.cpp | 25 | 25 | src/module.cpp | 26 | | - src/objects.cpp | | 26 | + src/objects2.cpp | 27 | 27 | src/converter/builtin_converters.cpp | 28 | 28 | src/converter/callback.cpp | 29 | 29 | src/object/iterator.cpp | |
Collapse file Copy file name to clipboardExpand all lines: include/boost/python/back_reference.hpp +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | #ifndef BACK_REFERENCE_DWA2002510_HPP | 7 | 7 | # define BACK_REFERENCE_DWA2002510_HPP | 8 | 8 |
| 9 | | -# include <boost/python/reference.hpp> | | 9 | +# include <boost/python/handle.hpp> | 10 | 10 |
| 11 | 11 | namespace boost { namespace python { | 12 | 12 |
| @@ -17,10 +17,10 @@ struct back_reference | 17 | 17 | typedef T type; | 18 | 18 |
| 19 | 19 | back_reference(PyObject*, T); | 20 | | - ref reference() const; | | 20 | + handle<> reference() const; | 21 | 21 | T get() const; | 22 | 22 | private: | 23 | | - ref m_reference; | | 23 | + handle<> m_reference; | 24 | 24 | T m_value; | 25 | 25 | }; | 26 | 26 |
| @@ -75,13 +75,13 @@ class is_back_reference | 75 | 75 | // | 76 | 76 | template <class T> | 77 | 77 | back_reference<T>::back_reference(PyObject* p, T x) | 78 | | - : m_reference(p, ref::increment_count) | | 78 | + : m_reference(python::borrow(p)) | 79 | 79 | , m_value(x) | 80 | 80 | { | 81 | 81 | } | 82 | 82 |
| 83 | 83 | template <class T> | 84 | | -ref back_reference<T>::reference() const | | 84 | +handle<> back_reference<T>::reference() const | 85 | 85 | { | 86 | 86 | return m_reference; | 87 | 87 | } | |
Collapse file Copy file name to clipboard +96Lines changed: 96 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Copyright David Abrahams 2002. Permission to copy, use, | | 2 | +// modify, sell and distribute this software is granted provided this | | 3 | +// copyright notice appears in all copies. This software is provided | | 4 | +// "as is" without express or implied warranty, and with no claim as | | 5 | +// to its suitability for any purpose. | | 6 | +#ifndef CAST_DWA200269_HPP | | 7 | +# define CAST_DWA200269_HPP | | 8 | + | | 9 | +# include <boost/python/detail/wrap_python.hpp> | | 10 | +# include <boost/type_traits/same_traits.hpp> | | 11 | +# include <boost/type.hpp> | | 12 | + | | 13 | +namespace boost { namespace python { | | 14 | + | | 15 | +template <class T> struct base_type_traits; | | 16 | + | | 17 | +template <> | | 18 | +struct base_type_traits<PyObject> | | 19 | +{ | | 20 | + typedef PyObject type; | | 21 | +}; | | 22 | + | | 23 | +template <> | | 24 | +struct base_type_traits<PyTypeObject> | | 25 | +{ | | 26 | + typedef PyObject type; | | 27 | +}; | | 28 | + | | 29 | +namespace detail | | 30 | +{ | | 31 | + typedef char* yes_convertible; | | 32 | + typedef int* no_convertible; | | 33 | + | | 34 | + typedef char* yes_python_object; | | 35 | + typedef int* no_python_object; | | 36 | + | | 37 | + template <class Target> | | 38 | + struct convertible | | 39 | + { | | 40 | + static inline yes_convertible check(Target) { return 0; } | | 41 | + static inline no_convertible check(...) { return 0; } | | 42 | + }; | | 43 | + | | 44 | + template <class Target> | | 45 | + inline Target* upcast(Target* p, yes_convertible) | | 46 | + { | | 47 | + return p; | | 48 | + } | | 49 | + | | 50 | + template <class Target, class Source> | | 51 | + inline Target* upcast(Source* p, no_convertible, boost::type<Target>* = 0) | | 52 | + { | | 53 | + typedef typename base_type_traits<Source>::type base; | | 54 | + return detail::upcast<Target>((base*)p, convertible<Target*>::check((base*)0)); | | 55 | + } | | 56 | + | | 57 | + | | 58 | + template <class Target, class Source> | | 59 | + inline Target* downcast(Source* p, yes_convertible) | | 60 | + { | | 61 | + return static_cast<Target*>(p); | | 62 | + } | | 63 | + | | 64 | + template <class Target, class Source> | | 65 | + inline Target* downcast(Source* p, no_convertible, boost::type<Target>* = 0) | | 66 | + { | | 67 | + typedef typename base_type_traits<Source>::type base; | | 68 | + return (Target*)detail::downcast<base>(p, convertible<Source*>::check((base*)0)); | | 69 | + } | | 70 | + | | 71 | + template <class T> | | 72 | + inline void assert_castable(boost::type<T>* = 0) | | 73 | + { | | 74 | + typedef char must_be_a_complete_type[sizeof(T)]; | | 75 | + } | | 76 | +} | | 77 | + | | 78 | +template <class Target, class Source> | | 79 | +inline Target* upcast(Source* x, Target* = 0) | | 80 | +{ | | 81 | + detail::assert_castable<Source>(); | | 82 | + detail::assert_castable<Target>(); | | 83 | + return detail::upcast<Target>(x, detail::convertible<Target*>::check(x)); | | 84 | +} | | 85 | + | | 86 | +template <class Target, class Source> | | 87 | +inline Target* downcast(Source* x, Target* = 0) | | 88 | +{ | | 89 | + detail::assert_castable<Source>(); | | 90 | + detail::assert_castable<Target>(); | | 91 | + return detail::downcast<Target>(x, detail::convertible<Source*>::check((Target*)0)); | | 92 | +} | | 93 | + | | 94 | +}} // namespace boost::python | | 95 | + | | 96 | +#endif // CAST_DWA200269_HPP |
Collapse file Copy file name to clipboardExpand all lines: include/boost/python/class.hpp +14-14Lines changed: 14 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | # include <boost/python/class_fwd.hpp> | 10 | 10 | # include <boost/python/bases.hpp> | 11 | 11 | # include <boost/python/args.hpp> | 12 | | -# include <boost/python/reference.hpp> | | 12 | +# include <boost/python/handle.hpp> | 13 | 13 | # include <boost/python/object/class.hpp> | 14 | 14 | # include <boost/python/type_id.hpp> | 15 | 15 | # include <boost/python/detail/wrap_function.hpp> | @@ -46,14 +46,14 @@ namespace detail | 46 | 46 | // to the type of holder that must be created. The 3rd argument is a | 47 | 47 | // reference to the Python type object to be created. | 48 | 48 | template <class T, class Holder> | 49 | | - static inline void register_copy_constructor(mpl::bool_t<true> const&, Holder*, ref const& obj, T* = 0) | | 49 | + static inline void register_copy_constructor(mpl::bool_t<true> const&, Holder*, handle<> const& obj, T* = 0) | 50 | 50 | { | 51 | 51 | objects::class_wrapper<T,Holder> x(obj); | 52 | 52 | } | 53 | 53 |
| 54 | 54 | // Tag dispatched to have no effect. | 55 | 55 | template <class T, class Holder> | 56 | | - static inline void register_copy_constructor(mpl::bool_t<false> const&, Holder*, ref const&, T* = 0) | | 56 | + static inline void register_copy_constructor(mpl::bool_t<false> const&, Holder*, handle<> const&, T* = 0) | 57 | 57 | { | 58 | 58 | } | 59 | 59 | } | @@ -104,7 +104,7 @@ class class_ : public objects::class_base | 104 | 104 | // appropriate. | 105 | 105 | objects::function::add_to_namespace( | 106 | 106 | this->object(), name, | 107 | | - ref(detail::wrap_function( | | 107 | + handle<>(detail::wrap_function( | 108 | 108 | // This bit of nastiness casts F to a member function of T if possible. | 109 | 109 | detail::member_function_cast<T,F>::stage1(f).stage2((T*)0).stage3(f) | 110 | 110 | ))); | @@ -132,7 +132,7 @@ class class_ : public objects::class_base | 132 | 132 | // appropriate. | 133 | 133 | objects::function::add_to_namespace( | 134 | 134 | this->object(), op.name(), | 135 | | - ref(detail::wrap_function(&op_t::template apply<T>::execute))); | | 135 | + handle<>(detail::wrap_function(&op_t::template apply<T>::execute))); | 136 | 136 | return *this; | 137 | 137 | } | 138 | 138 |
| @@ -176,24 +176,24 @@ class class_ : public objects::class_base | 176 | 176 | template <class D> | 177 | 177 | self& def_readonly(char const* name, D T::*pm) | 178 | 178 | { | 179 | | - ref fget(make_getter(pm)); | | 179 | + handle<> fget(make_getter(pm)); | 180 | 180 | this->add_property(name, fget); | 181 | 181 | return *this; | 182 | 182 | } | 183 | 183 |
| 184 | 184 | template <class D> | 185 | 185 | self& def_readwrite(char const* name, D T::*pm) | 186 | 186 | { | 187 | | - ref fget(make_getter(pm)); | 188 | | - ref fset(make_setter(pm)); | | 187 | + handle<> fget(make_getter(pm)); | | 188 | + handle<> fset(make_setter(pm)); | 189 | 189 | return this->add_property(name, fget, fset); | 190 | 190 | } | 191 | 191 |
| 192 | 192 | // Property creation | 193 | | - self& add_property(char const* name, ref const& fget); | 194 | | - self& add_property(char const* name, ref const& fget, ref const& fset); | | 193 | + self& add_property(char const* name, handle<> const& fget); | | 194 | + self& add_property(char const* name, handle<> const& fget, handle<> const& fset); | 195 | 195 |
| 196 | | - self& setattr(char const* name, ref const&); | | 196 | + self& setattr(char const* name, handle<> const&); | 197 | 197 |
| 198 | 198 | private: // types | 199 | 199 | typedef objects::class_id class_id; | @@ -258,21 +258,21 @@ inline class_<T,X1,X2,X3>::class_(char const* name) | 258 | 258 |
| 259 | 259 |
| 260 | 260 | template <class T, class X1, class X2, class X3> | 261 | | -inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, ref const& fget) | | 261 | +inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, handle<> const& fget) | 262 | 262 | { | 263 | 263 | base::add_property(name, fget); | 264 | 264 | return *this; | 265 | 265 | } | 266 | 266 |
| 267 | 267 | template <class T, class X1, class X2, class X3> | 268 | | -inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, ref const& fget, ref const& fset) | | 268 | +inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, handle<> const& fget, handle<> const& fset) | 269 | 269 | { | 270 | 270 | base::add_property(name, fget, fset); | 271 | 271 | return *this; | 272 | 272 | } | 273 | 273 |
| 274 | 274 | template <class T, class X1, class X2, class X3> | 275 | | -inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::setattr(char const* name, ref const& x) | | 275 | +inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::setattr(char const* name, handle<> const& x) | 276 | 276 | { | 277 | 277 | base::setattr(name, x); | 278 | 278 | return *this; | |
Collapse file Copy file name to clipboardExpand all lines: include/boost/python/converter/arg_to_python.hpp +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | # include <boost/python/converter/pointee_to_python_function.hpp> | 12 | 12 | # include <boost/python/converter/arg_to_python_base.hpp> | 13 | 13 | # include <boost/python/to_python_indirect.hpp> | | 14 | +// Bring in specializations | | 15 | +# include <boost/python/converter/builtin_converters.hpp> | 14 | 16 |
| 15 | 17 | namespace boost { namespace python { namespace converter { | 16 | 18 |
| @@ -19,7 +21,7 @@ namespace detail | 19 | 21 | BOOST_PYTHON_DECL void throw_no_class_registered(); | 20 | 22 |
| 21 | 23 | template <class T> | 22 | | - struct reference_arg_to_python : arg_to_python_holder | | 24 | + struct reference_arg_to_python : handle<> | 23 | 25 | { | 24 | 26 | reference_arg_to_python(T& x); | 25 | 27 | private: | @@ -41,7 +43,7 @@ namespace detail | 41 | 43 | }; | 42 | 44 |
| 43 | 45 | template <class Ptr> | 44 | | - struct pointer_shallow_arg_to_python : arg_to_python_holder | | 46 | + struct pointer_shallow_arg_to_python : handle<> | 45 | 47 | { | 46 | 48 | // Throw an exception if the conversion can't succeed | 47 | 49 | pointer_shallow_arg_to_python(Ptr); | @@ -129,13 +131,13 @@ namespace detail | 129 | 131 |
| 130 | 132 | template <class T> | 131 | 133 | inline reference_arg_to_python<T>::reference_arg_to_python(T& x) | 132 | | - : arg_to_python_holder(get_object(x)) | | 134 | + : handle<>(get_object(x)) | 133 | 135 | { | 134 | 136 | } | 135 | 137 |
| 136 | 138 | template <class Ptr> | 137 | 139 | inline pointer_shallow_arg_to_python<Ptr>::pointer_shallow_arg_to_python(Ptr x) | 138 | | - : arg_to_python_holder(get_object(x)) | | 140 | + : handle<>(get_object(x)) | 139 | 141 | {} | 140 | 142 |
| 141 | 143 | template <class Ptr> | |
Collapse file Copy file name to clipboardExpand all lines: include/boost/python/converter/arg_to_python_base.hpp +2-31Lines changed: 2 additions & 31 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | # define ARG_TO_PYTHON_BASE_DWA200237_HPP | 8 | 8 | # include <boost/python/converter/to_python_function_type.hpp> | 9 | 9 | # include <boost/python/detail/wrap_python.hpp> | 10 | | -# include <boost/python/reference.hpp> | | 10 | +# include <boost/python/handle.hpp> | 11 | 11 |
| 12 | 12 | namespace boost { namespace python { namespace converter { | 13 | 13 |
| 14 | 14 | namespace detail | 15 | 15 | { | 16 | | - struct arg_to_python_holder | 17 | | - { | 18 | | - arg_to_python_holder(PyObject* obj); | 19 | | - PyObject* get() const; | 20 | | - PyObject* get_incref() const; | 21 | | - private: | 22 | | - ref m_held; | 23 | | - }; | 24 | | - | 25 | | - struct BOOST_PYTHON_DECL arg_to_python_base : arg_to_python_holder | | 16 | + struct BOOST_PYTHON_DECL arg_to_python_base : handle<> | 26 | 17 | { | 27 | 18 | arg_to_python_base(void const volatile* source, to_python_function_t); | 28 | 19 | }; | 29 | | - | 30 | | - // | 31 | | - // implmentation | 32 | | - // | 33 | | - inline arg_to_python_holder::arg_to_python_holder(PyObject* obj) | 34 | | - : m_held(obj) | 35 | | - { | 36 | | - } | 37 | | - | 38 | | - inline PyObject* arg_to_python_holder::get() const | 39 | | - { | 40 | | - return m_held.get(); | 41 | | - } | 42 | | - | 43 | | - inline PyObject* arg_to_python_holder::get_incref() const | 44 | | - { | 45 | | - PyObject* result = m_held.get(); | 46 | | - Py_XINCREF(result); | 47 | | - return result; | 48 | | - } | 49 | 20 | } | 50 | 21 |
| 51 | 22 | }}} // namespace boost::python::converter | |
Collapse file Copy file name to clipboardExpand all lines: include/boost/python/converter/builtin_converters.hpp +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | # define BUILTIN_CONVERTERS_DWA2002124_HPP | 8 | 8 | # include <boost/python/detail/wrap_python.hpp> | 9 | 9 | # include <boost/python/detail/none.hpp> | 10 | | -# include <boost/python/reference.hpp> | 11 | | -# include <boost/python/converter/arg_to_python_base.hpp> | | 10 | +# include <boost/python/handle.hpp> | 12 | 11 | # include <string> | 13 | 12 | # include <complex> | 14 | 13 |
| @@ -65,10 +64,10 @@ namespace detail | 65 | 64 | namespace converter \ | 66 | 65 | { \ | 67 | 66 | template <> struct arg_to_python< T > \ | 68 | | - : detail::arg_to_python_holder \ | | 67 | + : handle<> \ | 69 | 68 | { \ | 70 | 69 | arg_to_python(T const& x) \ | 71 | | - : detail::arg_to_python_holder(expr) {} \ | | 70 | + : python::handle<>(expr) {} \ | 72 | 71 | }; \ | 73 | 72 | } | 74 | 73 |
| |
|