]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/dll/include/boost/dll/detail/type_info.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / dll / include / boost / dll / detail / type_info.hpp
1 // Copyright 2016 Klemens Morgenstern, Antony Polukhin
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 // For more information, see http://www.boost.org
8
9 #ifndef BOOST_DLL_DETAIL_TYPE_INFO_HPP_
10 #define BOOST_DLL_DETAIL_TYPE_INFO_HPP_
11
12 #include <typeinfo>
13 #include <cstring>
14
15 namespace boost { namespace dll { namespace detail {
16
17 #if defined(BOOST_MSVC) || defined(BOOST_MSVC_VER)
18
19 #if defined ( _WIN64 )
20
21 template<typename Class, typename Lib, typename Storage>
22 const std::type_info& load_type_info(Lib & lib, Storage & storage)
23 {
24 struct RTTICompleteObjectLocator
25 {
26 boost::detail::winapi::DWORD_ signature; //always zero ?
27 boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
28 boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
29 boost::detail::winapi::DWORD_ pTypeDescriptorOffset; //TypeDescriptor of the complete class
30 boost::detail::winapi::DWORD_ pClassDescriptorOffset; //describes inheritance hierarchy (ignored)
31 };
32
33 RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
34
35 vtable_p--;
36 auto vtable = *vtable_p;
37
38 auto nat = reinterpret_cast<const char*>(lib.native());
39
40 nat += vtable->pTypeDescriptorOffset;
41
42 return *reinterpret_cast<const std::type_info*>(nat);
43
44 }
45
46 #else
47
48 template<typename Class, typename Lib, typename Storage>
49 const std::type_info& load_type_info(Lib & lib, Storage & storage)
50 {
51 struct RTTICompleteObjectLocator
52 {
53 boost::detail::winapi::DWORD_ signature; //always zero ?
54 boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
55 boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
56 const std::type_info* pTypeDescriptor; //TypeDescriptor of the complete class
57 void* pClassDescriptor; //describes inheritance hierarchy (ignored)
58 };
59
60 RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
61
62 vtable_p--;
63 auto vtable = *vtable_p;
64 return *vtable->pTypeDescriptor;
65
66 }
67
68 #endif //_WIN64
69
70 #else
71
72 template<typename Class, typename Lib, typename Storage>
73 const std::type_info& load_type_info(Lib & lib, Storage & storage)
74 {
75 return lib.template get<const std::type_info>(storage.template get_type_info<Class>());
76
77 }
78
79 #endif
80
81
82 }}}
83 #endif /* BOOST_DLL_DETAIL_TYPE_INFO_HPP_ */