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