mirror of
https://github.com/boostorg/dll.git
synced 2026-07-21 13:13:30 +00:00
Add test from bugreport, provide compile time diagnostics for such cases (#85)
Fixes https://github.com/apolukhin/Boost.DLL/issues/47
This commit is contained in:
@@ -76,7 +76,7 @@ void mangled_storage_impl::trim_typename(std::string & val)
|
||||
static constexpr char class_ [7] = "class ";
|
||||
static constexpr char struct_[8] = "struct ";
|
||||
|
||||
if (equal(begin(class_), end(class_)-1, val.begin())) //aklright, starts with 'class '
|
||||
if (equal(begin(class_), end(class_)-1, val.begin()))
|
||||
val.erase(0, 6);
|
||||
else if (val.size() >= 7)
|
||||
if (equal(begin(struct_), end(struct_)-1, val.begin()))
|
||||
@@ -98,7 +98,7 @@ namespace parser {
|
||||
parser::try_consume_prefix(s, prefix);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline void consume_ptrs(boost::core::string_view& s) {
|
||||
do {
|
||||
while (parser::try_consume_prefix(s, " ")) {}
|
||||
@@ -126,6 +126,15 @@ namespace parser {
|
||||
parser::ignore_prefix(s, "struct ");
|
||||
|
||||
const auto& mangled_name = ms.get_name<T>();
|
||||
|
||||
static_assert(
|
||||
!std::is_function<typename std::remove_pointer<T>::type>::value,
|
||||
"boost::dll::smart_library on Windows platform does not support "
|
||||
"functions that accept functions. If you wish to see such support "
|
||||
"- please provide a working PR on github with sufficient tests. "
|
||||
"Otherwise simplify the function. For example, use `void*` "
|
||||
"parameter instead of a function pointer. "
|
||||
);
|
||||
if (!parser::try_consume_prefix(s, mangled_name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ project
|
||||
[ run shared_library_concurrent_load_test.cpp /boost/thread//boost_thread : : library1 library2 my_plugin_aggregator refcounting_plugin : <link>shared ]
|
||||
[ run cpp_mangle_test.cpp : : cpp_plugin ]
|
||||
[ run cpp_mangling.cpp ]
|
||||
[ compile-fail cpp_mangling1_cf.cpp ]
|
||||
[ run cpp_load_test.cpp : : cpp_plugin ]
|
||||
[ run cpp_import_test.cpp : : cpp_plugin ]
|
||||
[ run template_method_linux_test.cpp : : cpp_plugin ]
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2024 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
#include <boost/dll/detail/demangling/msvc.hpp>
|
||||
|
||||
struct CallbackInfo;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef void(__stdcall* Callback)(CallbackInfo* pInfo);
|
||||
#else
|
||||
typedef void(*Callback)(CallbackInfo* pInfo);
|
||||
#endif
|
||||
|
||||
|
||||
int main() {
|
||||
namespace parser = boost::dll::detail::parser;
|
||||
boost::dll::detail::mangled_storage_impl ms;
|
||||
|
||||
// The following case of mangling is not supported at the moment. Make
|
||||
// sure that we detect it on compile time.
|
||||
parser::is_mem_fn_with_name<int, void(*)(Callback)>("set_callback", ms)
|
||||
("public: void __cdecl int::set_callback(void (__cdecl*)(struct CallbackInfo * __ptr64)) __ptr64")
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user