Skip to content

Commit

Permalink
Drop dependency on Boost.Move
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Dec 15, 2024
1 parent 4775838 commit 52e4837
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 80 deletions.
1 change: 0 additions & 1 deletion build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ constant boost_dependencies :
/boost/core//boost_core
/boost/filesystem//boost_filesystem
/boost/function//boost_function
/boost/move//boost_move
/boost/predef//boost_predef
/boost/smart_ptr//boost_smart_ptr
/boost/spirit//boost_spirit
Expand Down
22 changes: 9 additions & 13 deletions include/boost/dll/detail/posix/shared_library_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <boost/dll/detail/posix/path_from_handle.hpp>
#include <boost/dll/detail/posix/program_location_impl.hpp>

#include <boost/move/utility.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/predef/os.h>

Expand All @@ -33,27 +32,24 @@
namespace boost { namespace dll { namespace detail {

class shared_library_impl {

BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_library_impl)

public:
typedef void* native_handle_t;

shared_library_impl() BOOST_NOEXCEPT
shared_library_impl() noexcept
: handle_(NULL)
{}

~shared_library_impl() BOOST_NOEXCEPT {
~shared_library_impl() noexcept {
unload();
}

shared_library_impl(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT
shared_library_impl(shared_library_impl&& sl) noexcept
: handle_(sl.handle_)
{
sl.handle_ = NULL;
}

shared_library_impl & operator=(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT {
shared_library_impl & operator=(shared_library_impl&& sl) noexcept {
swap(sl);
return *this;
}
Expand Down Expand Up @@ -163,11 +159,11 @@ class shared_library_impl {
}
}

bool is_loaded() const BOOST_NOEXCEPT {
bool is_loaded() const noexcept {
return (handle_ != 0);
}

void unload() BOOST_NOEXCEPT {
void unload() noexcept {
if (!is_loaded()) {
return;
}
Expand All @@ -176,7 +172,7 @@ class shared_library_impl {
handle_ = 0;
}

void swap(shared_library_impl& rhs) BOOST_NOEXCEPT {
void swap(shared_library_impl& rhs) noexcept {
boost::core::invoke_swap(handle_, rhs.handle_);
}

Expand All @@ -193,7 +189,7 @@ class shared_library_impl {
#endif
}

void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const BOOST_NOEXCEPT {
void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const noexcept {
// dlsym - obtain the address of a symbol from a dlopen object
void* const symbol = dlsym(handle_, sb);
if (symbol == NULL) {
Expand All @@ -210,7 +206,7 @@ class shared_library_impl {
return symbol;
}

native_handle_t native() const BOOST_NOEXCEPT {
native_handle_t native() const noexcept {
return handle_;
}

Expand Down
23 changes: 10 additions & 13 deletions include/boost/dll/detail/windows/shared_library_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <boost/dll/detail/system_error.hpp>
#include <boost/dll/detail/windows/path_from_handle.hpp>

#include <boost/move/utility.hpp>
#include <boost/core/invoke_swap.hpp>

#include <boost/winapi/dll.hpp>
Expand All @@ -26,26 +25,24 @@
namespace boost { namespace dll { namespace detail {

class shared_library_impl {
BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_library_impl)

public:
typedef boost::winapi::HMODULE_ native_handle_t;

shared_library_impl() BOOST_NOEXCEPT
shared_library_impl() noexcept
: handle_(NULL)
{}

~shared_library_impl() BOOST_NOEXCEPT {
~shared_library_impl() noexcept {
unload();
}

shared_library_impl(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT
shared_library_impl(shared_library_impl&& sl) noexcept
: handle_(sl.handle_)
{
sl.handle_ = NULL;
}

shared_library_impl & operator=(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT {
shared_library_impl & operator=(shared_library_impl&& sl) noexcept {
swap(sl);
return *this;
}
Expand Down Expand Up @@ -111,18 +108,18 @@ class shared_library_impl {
}
}

bool is_loaded() const BOOST_NOEXCEPT {
bool is_loaded() const noexcept {
return (handle_ != 0);
}

void unload() BOOST_NOEXCEPT {
void unload() noexcept {
if (handle_) {
boost::winapi::FreeLibrary(handle_);
handle_ = 0;
}
}

void swap(shared_library_impl& rhs) BOOST_NOEXCEPT {
void swap(shared_library_impl& rhs) noexcept {
boost::core::invoke_swap(handle_, rhs.handle_);
}

Expand All @@ -134,7 +131,7 @@ class shared_library_impl {
return L".dll";
}

void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const BOOST_NOEXCEPT {
void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const noexcept {
if (is_resource()) {
// `GetProcAddress` could not be called for libraries loaded with
// `LOAD_LIBRARY_AS_DATAFILE`, `LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE`
Expand All @@ -159,7 +156,7 @@ class shared_library_impl {
return symbol;
}

native_handle_t native() const BOOST_NOEXCEPT {
native_handle_t native() const noexcept {
return handle_;
}

Expand All @@ -181,7 +178,7 @@ class shared_library_impl {
return false;
}

bool is_resource() const BOOST_NOEXCEPT {
bool is_resource() const noexcept {
return false; /*!!(
reinterpret_cast<boost::winapi::ULONG_PTR_>(handle_) & static_cast<boost::winapi::ULONG_PTR_>(3)
);*/
Expand Down
21 changes: 10 additions & 11 deletions include/boost/dll/import.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <boost/type_traits/is_object.hpp>
#include <boost/make_shared.hpp>
#include <boost/dll/shared_library.hpp>
#include <boost/move/move.hpp>

#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
# include <boost/function.hpp>
Expand All @@ -40,12 +39,12 @@ namespace detail {
boost::shared_ptr<T> f_;

public:
inline library_function(const boost::shared_ptr<shared_library>& lib, T* func_ptr) BOOST_NOEXCEPT
inline library_function(const boost::shared_ptr<shared_library>& lib, T* func_ptr) noexcept
: f_(lib, func_ptr)
{}

#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
operator T*() const BOOST_NOEXCEPT {
operator T*() const noexcept {
return f_.get();
}
#else
Expand Down Expand Up @@ -163,19 +162,19 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const shared_library& lib, const std:

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(BOOST_RV_REF(shared_library) lib, const char* name) {
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(
boost::move(lib)
std::move(lib)
);
return type(p, boost::addressof(p->get<T>(name)));
}

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(BOOST_RV_REF(shared_library) lib, const std::string& name) {
return dll::import_symbol<T>(boost::move(lib), name.c_str());
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::string& name) {
return dll::import_symbol<T>(std::move(lib), name.c_str());
}


Expand Down Expand Up @@ -253,19 +252,19 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const std::

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(BOOST_RV_REF(shared_library) lib, const char* name) {
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(
boost::move(lib)
std::move(lib)
);
return type(p, p->get<T*>(name));
}

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(BOOST_RV_REF(shared_library) lib, const std::string& name) {
return dll::import_alias<T>(boost::move(lib), name.c_str());
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const std::string& name) {
return dll::import_alias<T>(std::move(lib), name.c_str());
}

#undef BOOST_DLL_IMPORT_RESULT_TYPE
Expand Down
19 changes: 9 additions & 10 deletions include/boost/dll/import_mangled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#endif

#include <boost/make_shared.hpp>
#include <boost/move/move.hpp>
#include <boost/dll/smart_library.hpp>
#include <boost/dll/detail/import_mangled_helpers.hpp>
#include <boost/core/addressof.hpp>
Expand All @@ -43,7 +42,7 @@ class mangled_library_function {
boost::shared_ptr<shared_library> lib_;
function_tuple<Ts...> f_;
public:
constexpr mangled_library_function(const boost::shared_ptr<shared_library>& lib, Ts*... func_ptr) BOOST_NOEXCEPT
constexpr mangled_library_function(const boost::shared_ptr<shared_library>& lib, Ts*... func_ptr) noexcept
: lib_(lib)
, f_(func_ptr...)
{}
Expand Down Expand Up @@ -77,7 +76,7 @@ class mangled_library_mem_fn<Class, sequence<Ts...>> {
call_tuple_t f_;

public:
constexpr mangled_library_mem_fn(const boost::shared_ptr<shared_library>& lib, typename Ts::mem_fn... func_ptr) BOOST_NOEXCEPT
constexpr mangled_library_mem_fn(const boost::shared_ptr<shared_library>& lib, typename Ts::mem_fn... func_ptr) noexcept
: lib_(lib)
, f_(func_ptr...)
{}
Expand Down Expand Up @@ -264,16 +263,16 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, co

//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library) lib, const char* name) {
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(smart_library&& lib, const char* name) {
typedef typename boost::dll::experimental::detail::mangled_import_type<detail::sequence<Args...>> type;

return type::make(lib, name);
}

//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library) lib, const std::string& name) {
return import_mangled<Args...>(boost::move(lib), name.c_str());
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(smart_library&& lib, const std::string& name) {
return import_mangled<Args...>(std::move(lib), name.c_str());
}

//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
Expand All @@ -293,18 +292,18 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, c

//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library) lib, const char* name) {
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(shared_library&& lib, const char* name) {
typedef typename boost::dll::experimental::detail::mangled_import_type<detail::sequence<Args...>> type;

boost::dll::experimental::smart_library p(boost::move(lib));
boost::dll::experimental::smart_library p(std::move(lib));

return type::make(p, name);
}

//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library) lib, const std::string& name) {
return import_mangled<Args...>(boost::move(lib), name.c_str());
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(shared_library&& lib, const std::string& name) {
return import_mangled<Args...>(std::move(lib), name.c_str());
}

#undef BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE
Expand Down
Loading

0 comments on commit 52e4837

Please sign in to comment.