os/ossrv/ossrv_pub/boost_apis/boost/python/instance_holder.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/instance_holder.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,63 @@
     1.4 +// Copyright David Abrahams 2002.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See
     1.6 +// accompanying file LICENSE_1_0.txt or copy at
     1.7 +// http://www.boost.org/LICENSE_1_0.txt)
     1.8 +#ifndef INSTANCE_HOLDER_DWA2002517_HPP
     1.9 +# define INSTANCE_HOLDER_DWA2002517_HPP
    1.10 +
    1.11 +# include <boost/python/detail/prefix.hpp>
    1.12 +
    1.13 +# include <boost/utility.hpp>
    1.14 +# include <boost/python/type_id.hpp>
    1.15 +# include <cstddef>
    1.16 +
    1.17 +namespace boost { namespace python { 
    1.18 +
    1.19 +// Base class for all holders
    1.20 +struct BOOST_PYTHON_DECL instance_holder : private noncopyable
    1.21 +{
    1.22 + public:
    1.23 +    instance_holder();
    1.24 +    virtual ~instance_holder();
    1.25 +    
    1.26 +    // return the next holder in a chain
    1.27 +    instance_holder* next() const;
    1.28 +
    1.29 +    // When the derived holder actually holds by [smart] pointer and
    1.30 +    // null_ptr_only is set, only report that the type is held when
    1.31 +    // the pointer is null.  This is needed for proper shared_ptr
    1.32 +    // support, to prevent holding shared_ptrs from being found when
    1.33 +    // converting from python so that we can use the conversion method
    1.34 +    // that always holds the Python object.
    1.35 +    virtual void* holds(type_info, bool null_ptr_only) = 0;
    1.36 +
    1.37 +    void install(PyObject* inst) throw();
    1.38 +
    1.39 +    // These functions should probably be located elsewhere.
    1.40 +    
    1.41 +    // Allocate storage for an object of the given size at the given
    1.42 +    // offset in the Python instance<> object if bytes are available
    1.43 +    // there. Otherwise allocate size bytes of heap memory.
    1.44 +    static void* allocate(PyObject*, std::size_t offset, std::size_t size);
    1.45 +
    1.46 +    // Deallocate storage from the heap if it was not carved out of
    1.47 +    // the given Python object by allocate(), above.
    1.48 +    static void deallocate(PyObject*, void* storage) throw();
    1.49 + private:
    1.50 +    instance_holder* m_next;
    1.51 +};
    1.52 +
    1.53 +// This macro is needed for implementation of derived holders
    1.54 +# define BOOST_PYTHON_UNFORWARD(N,ignored) (typename unforward<A##N>::type)(a##N)
    1.55 +
    1.56 +//
    1.57 +// implementation
    1.58 +//
    1.59 +inline instance_holder* instance_holder::next() const
    1.60 +{
    1.61 +    return m_next;
    1.62 +}
    1.63 +
    1.64 +}} // namespace boost::python
    1.65 +
    1.66 +#endif // INSTANCE_HOLDER_DWA2002517_HPP