From 1bdaf08e017a2987b63807eb5d4e8d1c2ec08628 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 29 Sep 2014 20:41:35 +0400 Subject: [PATCH] Polishing examples and docs --- example/tutorial3/tutorial3.cpp | 13 ++++++------- example/tutorial8/refcounting_api.hpp | 9 +++++---- example/tutorial8/tutorial8.cpp | 3 +-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/example/tutorial3/tutorial3.cpp b/example/tutorial3/tutorial3.cpp index a5f087c..e50148b 100644 --- a/example/tutorial3/tutorial3.cpp +++ b/example/tutorial3/tutorial3.cpp @@ -4,8 +4,6 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) -#include "../shared_lib_path.hpp" - //[callplugcpp_tutorial3 #include // for import_function_alias #include @@ -20,7 +18,7 @@ std::size_t search_for_symbols(const std::vector& plugi for (std::size_t i = 0; i < plugins.size(); ++i) { std::cout << "Loading plugin: " << plugins[i] << '\n'; - lib->load(plugins[i]); + lib->load(plugins[i], dll::load_mode::append_decorations); if (!lib->search_symbol("create_plugin")) { // no such symbol continue; @@ -41,11 +39,12 @@ std::size_t search_for_symbols(const std::vector& plugi //] int main(int argc, char* argv[]) { - // argv[1] contains path to our plugin library - BOOST_ASSERT(argc >= 2); + /*<-*/ BOOST_ASSERT(argc >= 2); /*->*/ + // argv[1] contains path to our plugin library std::vector plugins; - plugins.push_back(shared_lib_path(argv[1], L"my_plugin_aggregator")); - plugins.push_back(shared_lib_path(argv[1], L"my_plugin_sum")); + boost::filesystem::path base_dir = argv[1]; + plugins.push_back(base_dir / "my_plugin_aggregator"); + plugins.push_back(base_dir / "my_plugin_sum"); const std::size_t res = search_for_symbols(plugins); BOOST_ASSERT(res == 1); diff --git a/example/tutorial8/refcounting_api.hpp b/example/tutorial8/refcounting_api.hpp index 724eb1b..90878c2 100644 --- a/example/tutorial8/refcounting_api.hpp +++ b/example/tutorial8/refcounting_api.hpp @@ -50,10 +50,11 @@ inline boost::shared_ptr get_plugin( boost::filesystem::path path, boost::string_ref func_name) { typedef my_refcounting_api*(func_t)(); - boost::function f - = boost::dll::import_function_alias( - path, func_name - ); + boost::function f = boost::dll::import_function_alias( + path, + func_name, + boost::dll::load_mode::append_decorations // will be ignored for executable + ); // `f` goes out of scope here and will be destroyed. // Returned variable holds a reference to diff --git a/example/tutorial8/tutorial8.cpp b/example/tutorial8/tutorial8.cpp index 2470ec5..86dcd92 100644 --- a/example/tutorial8/tutorial8.cpp +++ b/example/tutorial8/tutorial8.cpp @@ -5,7 +5,6 @@ // or copy at http://www.boost.org/LICENSE_1_0.txt) //[callplugcpp_tutorial8 -#include "../shared_lib_path.hpp" #include #include "refcounting_api.hpp" @@ -16,7 +15,7 @@ int main(int argc, char* argv[]) { BOOST_ASSERT(argc >= 2); //-> boost::shared_ptr plugin = get_plugin( - shared_lib_path(argv[1], L"refcounting_plugin"), + boost::filesystem::path(argv[1]) / "refcounting_plugin", "create_refc_plugin" );