Skip to content

Commit

Permalink
Merge pull request #11 from karel-burda/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
karel-burda authored Oct 1, 2018
2 parents 52d6297 + 2634cbf commit 3f4b92a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(function-loader VERSION 1.0.0 LANGUAGES CXX)
project(function-loader VERSION 1.1.0 LANGUAGES CXX)

include("cmake-helpers/cmake-helpers/messages.cmake")
include("cmake-helpers/cmake-helpers/standard-settings.cmake")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Version](https://img.shields.io/badge/version-1.0.0-green.svg)
![Version](https://img.shields.io/badge/version-1.1.0-green.svg)
[![License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat)](LICENSE)
[![Build Status](https://travis-ci.org/karel-burda/function-loader.svg?branch=master)](https://travis-ci.org/karel-burda/function-loader)
[![Coverage Status](https://coveralls.io/repos/github/karel-burda/function-loader/badge.svg?branch=master)](https://coveralls.io/github/karel-burda/function-loader?branch=master)
Expand Down Expand Up @@ -47,8 +47,8 @@ try

// get procedures at runtime from the shared library
// see "demo-library.hpp" and "demo-library.cpp" in the "demo-library" directory
const auto func_simple = loader.get_procedure<void()>("function_with_no_params");
const auto func_more_complex = loader.get_procedure<int(float, const char *)>
const auto func_simple = loader.get_function<void()>("function_with_no_params");
const auto func_more_complex = loader.get_function<int(float, const char *)>
("function_with_return_value_and_params");

// don't have to check for call-ability, otherwise the "function_does_not_exist" would be thrown
Expand Down
4 changes: 2 additions & 2 deletions example/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ static int show_usage()

// get procedures at runtime from the shared library
// see "demo-library.hpp" and "demo-library.cpp" in the "demo-library" directory
const auto func_void_no_params = loader.get_procedure<void()>("function_with_no_params");
const auto func_with_return_value_and_params = loader.get_procedure<int(float, const char *)>("function_with_return_value_and_params");
const auto func_void_no_params = loader.get_function<void()>("function_with_no_params");
const auto func_with_return_value_and_params = loader.get_function<int(float, const char *)>("function_with_return_value_and_params");

// don't have to check for call-ability, otherwise the "function_does_not_exist" would be thrown
func_void_no_params();
Expand Down
2 changes: 1 addition & 1 deletion include/function_loader/function_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class function_loader : public detail::function_loader_base
/// @returns std::function that binds to the found function in a shared library
/// @throws function_does_not_exist
template<typename function_type>
std::function<function_type> get_procedure(const std::string & procedure_name)
std::function<function_type> get_function(const std::string & procedure_name)
{
void * procedure_address = get_function_address(library.get_handle(), procedure_name.c_str());

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/src/function_loader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ TEST(function_loader, default_values)
EXPECT_NE(&loader.library, nullptr);
}

TEST(function_loader, get_procedure)
TEST(function_loader, get_function)
{
function_loader loader{ testing::get_demo_library_file_path() };

{
const auto func_void_no_params = loader.get_procedure<void()>("function_with_no_params");
const auto func_void_no_params = loader.get_function<void()>("function_with_no_params");

EXPECT_NO_THROW(func_void_no_params());
}

{
const auto func_with_return_value_and_params = loader.get_procedure<int(float, const char *)>("function_with_return_value_and_params");
const auto func_with_return_value_and_params = loader.get_function<int(float, const char *)>("function_with_return_value_and_params");
int returnedValue = 0;
EXPECT_NO_THROW(returnedValue = func_with_return_value_and_params(2.3f, "foo-bar-baz"));
EXPECT_EQ(returnedValue, 999);
}

{
EXPECT_THROW(loader.get_procedure<int(float, const char *)>("function_that_does_not_exists"), exceptions::function_does_not_exist);
EXPECT_THROW(loader.get_function<int(float, const char *)>("function_that_does_not_exists"), exceptions::function_does_not_exist);
}
}

Expand All @@ -64,7 +64,7 @@ TEST(function_loader, exceptions)
try
{
function_loader loader{ testing::get_demo_library_file_path() };
loader.get_procedure<void()>("foo-bar-baz");
loader.get_function<void()>("foo-bar-baz");
}
catch (const exceptions::function_does_not_exist & error)
{
Expand Down

0 comments on commit 3f4b92a

Please sign in to comment.