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 |
|
---|
12 | namespace boost { namespace python
|
---|
13 | {
|
---|
14 | struct BOOST_PYTHON_DECL_FORWARD instance_holder;
|
---|
15 | }} // namespace boost::python
|
---|
16 |
|
---|
17 | namespace boost { namespace python { namespace objects {
|
---|
18 |
|
---|
19 | // Each extension instance will be one of these
|
---|
20 | template <class Data = char>
|
---|
21 | struct 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 |
|
---|
39 | template <class Data>
|
---|
40 | struct 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
|
---|