diff --git a/CMakeLists.txt b/CMakeLists.txt index 888283fb..42542d55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ target_link_libraries(boost_dll Boost::filesystem Boost::predef Boost::smart_ptr - Boost::spirit Boost::system Boost::throw_exception Boost::type_index diff --git a/build.jam b/build.jam index 19c19dd2..f5d93e2b 100644 --- a/build.jam +++ b/build.jam @@ -12,7 +12,6 @@ constant boost_dependencies : /boost/filesystem//boost_filesystem /boost/predef//boost_predef /boost/smart_ptr//boost_smart_ptr - /boost/spirit//boost_spirit /boost/system//boost_system /boost/throw_exception//boost_throw_exception /boost/type_index//boost_type_index diff --git a/include/boost/dll/detail/demangling/msvc.hpp b/include/boost/dll/detail/demangling/msvc.hpp index b520b540..61c1a11c 100644 --- a/include/boost/dll/detail/demangling/msvc.hpp +++ b/include/boost/dll/detail/demangling/msvc.hpp @@ -15,8 +15,6 @@ #include #include -#include - namespace boost { namespace dll { namespace detail { class mangled_storage_impl : public mangled_storage_base @@ -24,11 +22,6 @@ class mangled_storage_impl : public mangled_storage_base template struct dummy {}; - template - std::vector get_func_params(dummy) const - { - return {get_name()...}; - } template std::string get_return_type(dummy) const { @@ -92,22 +85,7 @@ void mangled_storage_impl::trim_typename(std::string & val) } -namespace parser -{ - namespace x3 = spirit::x3; - - inline auto ptr_rule_impl(std::integral_constant) - { - return -((-x3::space) >> "__ptr32"); - } - inline auto ptr_rule_impl(std::integral_constant) - { - return -((-x3::space) >> "__ptr64"); - } - - inline auto ptr_rule() { - return ptr_rule_impl(std::integral_constant()); - } +namespace parser { inline boost::core::string_view trim_ptrs(boost::core::string_view s) { bool retry = false; @@ -133,7 +111,6 @@ namespace parser return s; } - auto const visibility = ("public:" | x3::lit("protected:") | "private:"); inline std::string::size_type find_visibility(boost::core::string_view s) { if (s.starts_with("public:")) { return sizeof("public:") - 1; @@ -145,7 +122,6 @@ namespace parser return std::string::npos; } - auto const virtual_ = x3::space >> "virtual"; inline std::string::size_type find_virtual(boost::core::string_view s) { if (s.starts_with(" virtual")) { return sizeof(" virtual") - 1; @@ -153,7 +129,6 @@ namespace parser return std::string::npos; } - auto const static_ = x3::space >> x3::lit("static") ; inline std::string::size_type find_static(boost::core::string_view s) { if (s.starts_with(" static")) { return sizeof(" static") - 1; @@ -161,53 +136,6 @@ namespace parser return std::string::npos; } - inline auto const_rule_impl(std::true_type ) {return x3::space >> "const";}; - inline auto const_rule_impl(std::false_type) {return x3::eps;}; - template - auto const_rule() {using t = std::is_const::type>; return const_rule_impl(t());} - - inline auto volatile_rule_impl(std::true_type ) {return x3::space >> "volatile";}; - inline auto volatile_rule_impl(std::false_type) {return x3::eps;}; - template - auto volatile_rule() {using t = std::is_volatile::type>; return volatile_rule_impl(t());} - - - inline auto inv_const_rule_impl(std::true_type ) {return "const" >> x3::space ;}; - inline auto inv_const_rule_impl(std::false_type) {return x3::eps;}; - template - auto inv_const_rule() {using t = std::is_const::type>; return inv_const_rule_impl(t());} - - inline auto inv_volatile_rule_impl(std::true_type ) {return "volatile" >> x3::space;}; - inline auto inv_volatile_rule_impl(std::false_type) {return x3::eps;}; - template - auto inv_volatile_rule() {using t = std::is_volatile::type>; return inv_volatile_rule_impl(t());} - - - inline auto reference_rule_impl(std::false_type, std::false_type) {return x3::eps;} - inline auto reference_rule_impl(std::true_type, std::false_type) {return x3::space >>"&" ;} - inline auto reference_rule_impl(std::false_type, std::true_type ) {return x3::space >>"&&" ;} - - - template - auto reference_rule() {using t_l = std::is_lvalue_reference; using t_r = std::is_rvalue_reference; return reference_rule_impl(t_l(), t_r());} - - auto const class_ = ("class" | x3::lit("struct")); - - //it takes a string, because it may be overloaded. - template - auto type_rule(const std::string & type_name) - { - using namespace std; - - return -(class_ >> x3::space)>> x3::string(type_name) >> - const_rule() >> - volatile_rule() >> - reference_rule() >> - ptr_rule(); - } - template<> - inline auto type_rule(const std::string &) { return x3::string("void"); }; - template std::string::size_type find_type(const mangled_storage_impl& ms, boost::core::string_view s_orig) { if (std::is_void::value) { @@ -259,17 +187,10 @@ namespace parser } } - s = trim_ptrs(s); + s = parser::trim_ptrs(s); return s_orig.size() - s.size(); } - auto const cdecl_ = "__cdecl" >> x3::space; - auto const stdcall = "__stdcall" >> x3::space; -#if defined(_WIN64)//seems to be necessary by msvc 14-x64 - auto const thiscall = "__cdecl" >> x3::space; -#else - auto const thiscall = "__thiscall" >> x3::space; -#endif inline std::string::size_type find_thiscall(boost::core::string_view s) { if (s.starts_with(" __cdecl ")) { // Win 64bit return sizeof(" __cdecl ") - 1; @@ -279,26 +200,6 @@ namespace parser return std::string::npos; } - template - auto arg_list(const mangled_storage_impl & ms, Return (*)(Arg)) - { - return type_rule(ms.get_name()); - } - - template - auto arg_list(const mangled_storage_impl & ms, Return (*)(First, Second, Args...)) - { - using next_type = Return (*)(Second, Args...); - return type_rule(ms.get_name()) >> x3::char_(',') >> arg_list(ms, next_type()); - } - - template - auto arg_list(const mangled_storage_impl& /*ms*/, Return (*)()) - { - return x3::string("void"); - } - - template std::string::size_type find_arg_list(const mangled_storage_impl& ms, boost::core::string_view s, Return (*)(Arg)) { @@ -637,7 +538,7 @@ namespace parser template std::string mangled_storage_impl::get_variable(const std::string &name) const { - const auto found = std::find_if(storage_.begin(), storage_.end(), parser::is_variable_with_name(name)); + const auto found = std::find_if(storage_.begin(), storage_.end(), parser::is_variable_with_name(name, *this)); if (found != storage_.end()) return found->mangled; @@ -647,7 +548,7 @@ std::string mangled_storage_impl::get_variable(const std::string &name) const { template std::string mangled_storage_impl::get_function(const std::string &name) const { - const auto found = std::find_if(storage_.begin(), storage_.end(), parser::is_function_with_name(name)); + const auto found = std::find_if(storage_.begin(), storage_.end(), parser::is_function_with_name(name, *this)); if (found != storage_.end()) return found->mangled; @@ -657,7 +558,7 @@ std::string mangled_storage_impl::get_function(const std::string &name) const { template std::string mangled_storage_impl::get_mem_fn(const std::string &name) const { - const auto found = std::find_if(storage_.begin(), storage_.end(), parser::is_mem_fn_with_name(name)); + const auto found = std::find_if(storage_.begin(), storage_.end(), parser::is_mem_fn_with_name(name, *this)); if (found != storage_.end()) return found->mangled; diff --git a/test/cpp_mangling.cpp b/test/cpp_mangling.cpp index 7e49c71d..00c600d9 100644 --- a/test/cpp_mangling.cpp +++ b/test/cpp_mangling.cpp @@ -58,8 +58,8 @@ int main(int argc, char* argv[]) BOOST_TEST_EQ(parser::find_arg_list(ms, "int,int", ptr3), 7); } { - void(*ptr4)(int,short,long) = nullptr; - BOOST_TEST_EQ(parser::find_arg_list(ms, "int,short,long", ptr4), 14); + void(*ptr4)(int,int,int) = nullptr; + BOOST_TEST_EQ(parser::find_arg_list(ms, "int,int,int", ptr4), 11); }