Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:46:09

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef INSTANCE_HOLDER_DWA2002517_HPP
0006 # define INSTANCE_HOLDER_DWA2002517_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 
0010 # include <boost/noncopyable.hpp>
0011 # include <boost/python/type_id.hpp>
0012 # include <cstddef>
0013 
0014 namespace boost { namespace python { 
0015 
0016 // Base class for all holders
0017 struct BOOST_PYTHON_DECL instance_holder : private noncopyable
0018 {
0019  public:
0020     instance_holder();
0021     virtual ~instance_holder();
0022     
0023     // return the next holder in a chain
0024     instance_holder* next() const;
0025 
0026     // When the derived holder actually holds by [smart] pointer and
0027     // null_ptr_only is set, only report that the type is held when
0028     // the pointer is null.  This is needed for proper shared_ptr
0029     // support, to prevent holding shared_ptrs from being found when
0030     // converting from python so that we can use the conversion method
0031     // that always holds the Python object.
0032     virtual void* holds(type_info, bool null_ptr_only) = 0;
0033 
0034     void install(PyObject* inst) throw();
0035 
0036     // These functions should probably be located elsewhere.
0037     
0038     // Allocate storage for an object of the given size at the given
0039     // offset in the Python instance<> object if bytes are available
0040     // there. Otherwise allocate size bytes of heap memory.
0041     static void* allocate(PyObject*, std::size_t offset, std::size_t size, std::size_t alignment = 1);
0042 
0043     // Deallocate storage from the heap if it was not carved out of
0044     // the given Python object by allocate(), above.
0045     static void deallocate(PyObject*, void* storage) throw();
0046  private:
0047     instance_holder* m_next;
0048 };
0049 
0050 // This macro is needed for implementation of derived holders
0051 # define BOOST_PYTHON_UNFORWARD(N,ignored) (typename unforward<A##N>::type)(a##N)
0052 
0053 //
0054 // implementation
0055 //
0056 inline instance_holder* instance_holder::next() const
0057 {
0058     return m_next;
0059 }
0060 
0061 }} // namespace boost::python
0062 
0063 #endif // INSTANCE_HOLDER_DWA2002517_HPP