| 1 | // Copyright 2019 Lichao Xia |
| 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 | #include <boost/config.hpp> |
| 10 | |
| 11 | #if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) |
| 12 | #include "../example/b2_workarounds.hpp" |
| 13 | |
| 14 | #include <boost/core/lightweight_test.hpp> |
| 15 | #include <boost/dll/smart_library.hpp> |
| 16 | #include <boost/filesystem.hpp> |
| 17 | |
| 18 | #include <iostream> |
| 19 | #include <string> |
| 20 | |
| 21 | class alias; |
| 22 | |
| 23 | namespace space { |
| 24 | template<typename... T> |
| 25 | class test_template_class |
| 26 | {}; |
| 27 | |
| 28 | template<typename T1, |
| 29 | typename T2 = char, |
| 30 | typename T3 = test_template_class<int>> |
| 31 | class test_template_class_have_default_args |
| 32 | {}; |
| 33 | } // namespace space |
| 34 | |
| 35 | int |
| 36 | main(int argc, char* argv[]) |
| 37 | { |
| 38 | using mangled_storage = boost::dll::detail::mangled_storage_impl; |
| 39 | using library = boost::dll::experimental::smart_library; |
| 40 | |
| 41 | boost::dll::fs::path pt = b2_workarounds::first_lib_from_argv(argc, argv); |
| 42 | |
| 43 | std::cout << "Library: " << pt << std::endl; |
| 44 | // boost::dll::library_info lib{pt}; |
| 45 | |
| 46 | library lib(pt); |
| 47 | mangled_storage ms = lib.symbol_storage(); |
| 48 | // mangled_storage ms(lib); |
| 49 | |
| 50 | std::cout << "Symbols: " << std::endl; |
| 51 | |
| 52 | for (auto& s : ms.get_storage()) { |
| 53 | std::cout << s.demangled << std::endl; |
| 54 | std::cout << s.mangled << std::endl; |
| 55 | std::cout << std::endl; |
| 56 | } |
| 57 | |
| 58 | std::string v; |
| 59 | |
| 60 | ms.add_alias<alias>(name: "space::cpp_plugin_type_pasrser" ); |
| 61 | |
| 62 | auto ctor1 = ms.get_constructor<alias()>(); |
| 63 | BOOST_TEST(!ctor1.empty()); |
| 64 | |
| 65 | auto ctor2 = ms.get_constructor<alias(int*)>(); |
| 66 | BOOST_TEST(!ctor2.empty()); |
| 67 | |
| 68 | auto ctor3 = ms.get_constructor<alias(const int*)>(); |
| 69 | BOOST_TEST(!ctor3.empty()); |
| 70 | |
| 71 | auto ctor4 = ms.get_constructor<alias(const volatile int*)>(); |
| 72 | BOOST_TEST(!ctor4.empty()); |
| 73 | |
| 74 | auto ctor5 = ms.get_constructor<alias(const std::string&)>(); |
| 75 | BOOST_TEST(!ctor5.empty()); |
| 76 | |
| 77 | auto ctor6 = ms.get_constructor<alias(const volatile std::string*)>(); |
| 78 | BOOST_TEST(!ctor6.empty()); |
| 79 | |
| 80 | v = ms.get_mem_fn<alias, void(int*)>(name: "type_test" ); |
| 81 | BOOST_TEST(!v.empty()); |
| 82 | |
| 83 | v = ms.get_mem_fn<alias, void(const int*)>(name: "type_test" ); |
| 84 | BOOST_TEST(!v.empty()); |
| 85 | |
| 86 | v = ms.get_mem_fn<alias, void(const volatile int*)>(name: "type_test" ); |
| 87 | BOOST_TEST(!v.empty()); |
| 88 | |
| 89 | v = ms.get_mem_fn<alias, void(std::string*)>(name: "type_test" ); |
| 90 | BOOST_TEST(!v.empty()); |
| 91 | |
| 92 | v = ms.get_mem_fn<alias, void(const std::string*)>(name: "type_test" ); |
| 93 | BOOST_TEST(!v.empty()); |
| 94 | |
| 95 | v = ms.get_mem_fn<alias, void(const volatile std::string*)>(name: "type_test" ); |
| 96 | BOOST_TEST(!v.empty()); |
| 97 | |
| 98 | v = ms.get_mem_fn<alias, void(const std::string&)>(name: "type_test" ); |
| 99 | BOOST_TEST(!v.empty()); |
| 100 | |
| 101 | v = ms.get_mem_fn<alias, void(void (*)(const char* volatile))>(name: "type_test" ); |
| 102 | BOOST_TEST(!v.empty()); |
| 103 | |
| 104 | v = ms.get_mem_fn<alias, void(const volatile char* const* volatile*&&)>( |
| 105 | name: "type_test" ); |
| 106 | BOOST_TEST(!v.empty()); |
| 107 | |
| 108 | v = ms.get_mem_fn<const alias, void(const char*)>(name: "type_test" ); |
| 109 | BOOST_TEST(!v.empty()); |
| 110 | |
| 111 | v = ms.get_mem_fn<volatile alias, void(const char*)>(name: "type_test" ); |
| 112 | BOOST_TEST(!v.empty()); |
| 113 | |
| 114 | v = ms.get_mem_fn<const volatile alias, void(const char*)>(name: "type_test" ); |
| 115 | BOOST_TEST(!v.empty()); |
| 116 | |
| 117 | v = ms.get_mem_fn<alias, void(const space::test_template_class<>&)>( |
| 118 | name: "type_test" ); |
| 119 | BOOST_TEST(!v.empty()); |
| 120 | |
| 121 | v = ms.get_mem_fn<alias, void(const space::test_template_class<void(int)>&)>( |
| 122 | name: "type_test" ); |
| 123 | BOOST_TEST(!v.empty()); |
| 124 | |
| 125 | v = ms.get_mem_fn<alias, void(const space::test_template_class<int>&)>( |
| 126 | name: "type_test" ); |
| 127 | BOOST_TEST(!v.empty()); |
| 128 | |
| 129 | v = |
| 130 | ms.get_mem_fn<alias, void(const space::test_template_class<std::string>&)>( |
| 131 | name: "type_test" ); |
| 132 | BOOST_TEST(!v.empty()); |
| 133 | |
| 134 | v = |
| 135 | ms.get_mem_fn<alias, |
| 136 | void( |
| 137 | const space::test_template_class<char, int, std::string>&)>( |
| 138 | name: "type_test" ); |
| 139 | BOOST_TEST(!v.empty()); |
| 140 | |
| 141 | v = |
| 142 | ms.get_mem_fn<alias, |
| 143 | void( |
| 144 | const space::test_template_class_have_default_args<int>&)>( |
| 145 | name: "type_test" ); |
| 146 | BOOST_TEST(!v.empty()); |
| 147 | |
| 148 | v = ms.get_mem_fn< |
| 149 | alias, |
| 150 | void(const space::test_template_class_have_default_args<int, double>&)>( |
| 151 | name: "type_test" ); |
| 152 | BOOST_TEST(!v.empty()); |
| 153 | |
| 154 | v = ms.get_mem_fn< |
| 155 | alias, |
| 156 | void(const space:: |
| 157 | test_template_class_have_default_args<int, double, std::string>&)>( |
| 158 | name: "type_test" ); |
| 159 | BOOST_TEST(!v.empty()); |
| 160 | |
| 161 | auto dtor = ms.get_destructor<alias>(); |
| 162 | |
| 163 | BOOST_TEST(!dtor.empty()); |
| 164 | |
| 165 | return boost::report_errors(); |
| 166 | } |
| 167 | |
| 168 | #else |
| 169 | int |
| 170 | main() |
| 171 | { |
| 172 | return 0; |
| 173 | } |
| 174 | #endif |
| 175 | |