source: NonGTP/Boost/boost/python/object/instance.hpp @ 857

Revision 857, 1.3 KB checked in by igarcia, 18 years ago (diff)
Line 
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef INSTANCE_DWA200295_HPP
6# define INSTANCE_DWA200295_HPP
7
8# include <boost/python/detail/prefix.hpp>
9# include <boost/type_traits/alignment_traits.hpp>
10# include <cstddef>
11
12namespace boost { namespace python
13{
14  struct BOOST_PYTHON_DECL_FORWARD instance_holder;
15}} // namespace boost::python
16
17namespace boost { namespace python { namespace objects {
18
19// Each extension instance will be one of these
20template <class Data = char>
21struct instance
22{
23    PyObject_VAR_HEAD
24    PyObject* dict;
25    PyObject* weakrefs;
26    instance_holder* objects;
27
28    typedef typename type_with_alignment<
29        ::boost::alignment_of<Data>::value
30    >::type align_t;
31         
32    union
33    {
34        align_t align;
35        char bytes[sizeof(Data)];
36    } storage;
37};
38
39template <class Data>
40struct additional_instance_size
41{
42    typedef instance<Data> instance_data;
43    typedef instance<char> instance_char;
44    BOOST_STATIC_CONSTANT(
45        std::size_t, value = sizeof(instance_data)
46                           - BOOST_PYTHON_OFFSETOF(instance_char,storage));
47};
48
49}}} // namespace boost::python::object
50
51#endif // INSTANCE_DWA200295_HPP
Note: See TracBrowser for help on using the repository browser.