Skip to content

Commit d0b4b21

Browse files
lukasm91havogt
authored andcommitted
Cleanup includes (#12)
- remove dependency on `boost::optional` - remove dependency on `boost::mpl` (remove `function_types`) - remove `is_there_in_sequence` - remove `copy_into_variadic`
1 parent aef4805 commit d0b4b21

14 files changed

+167
-234
lines changed

include/cpp_bindgen/common/any_moveable.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespace cpp_bindgen {
1818

1919
struct bad_any_cast : std::bad_cast {
20-
const char *what() const noexcept override { return "gridtools::bad_any_cast"; }
20+
const char *what() const noexcept override { return "cpp_bindgen::bad_any_cast"; }
2121
};
2222

2323
/**

include/cpp_bindgen/common/copy_into_variadic.hpp

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* GridTools
3+
*
4+
* Copyright (c) 2014-2019, ETH Zurich
5+
* All rights reserved.
6+
*
7+
* Please, refer to the LICENSE file in the root directory.
8+
* SPDX-License-Identifier: BSD-3-Clause
9+
*/
10+
#pragma once
11+
12+
#include <type_traits>
13+
14+
namespace cpp_bindgen {
15+
16+
template <class...>
17+
struct disjunction : std::false_type {};
18+
template <class B1>
19+
struct disjunction<B1> : B1 {};
20+
template <class B1, class... Bn>
21+
struct disjunction<B1, Bn...> : std::conditional<bool(B1::value), B1, disjunction<Bn...>>::type {};
22+
} // namespace cpp_bindgen

include/cpp_bindgen/common/for_each.hpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ namespace cpp_bindgen {
3636
};
3737
} // namespace for_each_detail
3838

39-
/** \ingroup common
40-
@{
41-
\ingroup allmeta
42-
@{
43-
\defgroup foreach For Each
44-
@{
45-
*/
4639
/// Calls fun(T{}) for each element of the type list List.
4740
template <class List, class Fun>
4841
void for_each(Fun const &fun) {
@@ -60,9 +53,5 @@ namespace cpp_bindgen {
6053
template <class List, class Fun>
6154
void for_each_type(Fun const &fun) {
6255
for_each_detail::for_each_type_impl<List>::exec(fun);
63-
};
64-
65-
/** @} */
66-
/** @} */
67-
/** @} */
56+
}
6857
} // namespace cpp_bindgen
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* GridTools
3+
*
4+
* Copyright (c) 2014-2019, ETH Zurich
5+
* All rights reserved.
6+
*
7+
* Please, refer to the LICENSE file in the root directory.
8+
* SPDX-License-Identifier: BSD-3-Clause
9+
*/
10+
#pragma once
11+
12+
#include <tuple>
13+
#include <type_traits>
14+
15+
namespace cpp_bindgen {
16+
namespace function_traits {
17+
namespace _impl {
18+
template <class>
19+
struct parameter_types_helper;
20+
21+
template <class Ret, class... Args>
22+
struct parameter_types_helper<Ret(Args...)> {
23+
using type = std::tuple<Args...>;
24+
};
25+
26+
template <class>
27+
struct result_type_helper;
28+
29+
template <class Ret, class... Args>
30+
struct result_type_helper<Ret(Args...)> {
31+
using type = Ret;
32+
};
33+
34+
template <class>
35+
struct arity_helper;
36+
37+
template <class Ret, class... Args>
38+
struct arity_helper<Ret(Args...)> {
39+
static constexpr std::size_t value = sizeof...(Args);
40+
};
41+
} // namespace _impl
42+
43+
template <class F, typename std::enable_if<std::is_function<F>::value, int>::type = 0>
44+
struct parameter_types : _impl::parameter_types_helper<typename std::remove_cv<F>::type> {};
45+
46+
template <class F, typename std::enable_if<std::is_function<F>::value, int>::type = 0>
47+
struct result_type : _impl::result_type_helper<typename std::remove_cv<F>::type> {};
48+
49+
template <class F, typename std::enable_if<std::is_function<F>::value, int>::type = 0>
50+
struct arity : _impl::arity_helper<typename std::remove_cv<F>::type> {};
51+
52+
} // namespace function_traits
53+
} // namespace cpp_bindgen

include/cpp_bindgen/common/is_there_in_sequence_if.hpp

Lines changed: 0 additions & 37 deletions
This file was deleted.

include/cpp_bindgen/export.hpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,21 @@
99
*/
1010
#pragma once
1111

12-
#include <boost/function_types/function_arity.hpp>
13-
#include <boost/function_types/parameter_types.hpp>
14-
#include <boost/function_types/result_type.hpp>
15-
#include <boost/mpl/at.hpp>
1612
#include <boost/preprocessor.hpp>
1713

14+
#include "common/function_traits.hpp"
1815
#include "function_wrapper.hpp"
1916
#include "generator.hpp"
2017

21-
#define GEN_EXPORT_BINDING_IMPL_PARAM_DECL(z, i, signature) \
22-
typename boost::mpl::at_c< \
23-
typename boost::function_types::parameter_types<::cpp_bindgen::wrapped_t<signature>>::type, \
24-
i>::type param_##i
18+
#define GEN_EXPORT_BINDING_IMPL_PARAM_DECL(z, i, signature) \
19+
typename std::tuple_element<i, \
20+
::cpp_bindgen::function_traits::parameter_types<::cpp_bindgen::wrapped_t<signature>>::type>::type param_##i
2521

26-
#define GEN_ADD_GENERATED_DEFINITION_IMPL(n, name, cppsignature, impl) \
27-
static_assert(::boost::function_types::function_arity<cppsignature>::value == n, "arity mismatch"); \
28-
extern "C" typename ::boost::function_types::result_type<::cpp_bindgen::wrapped_t<cppsignature>>::type name( \
29-
BOOST_PP_ENUM(n, GEN_EXPORT_BINDING_IMPL_PARAM_DECL, cppsignature)) { \
30-
return ::cpp_bindgen::wrap<cppsignature>(impl)(BOOST_PP_ENUM_PARAMS(n, param_)); \
22+
#define GEN_ADD_GENERATED_DEFINITION_IMPL(n, name, cppsignature, impl) \
23+
static_assert(::cpp_bindgen::function_traits::arity<cppsignature>::value == n, "arity mismatch"); \
24+
extern "C" typename ::cpp_bindgen::function_traits::result_type<::cpp_bindgen::wrapped_t<cppsignature>>::type \
25+
name(BOOST_PP_ENUM(n, GEN_EXPORT_BINDING_IMPL_PARAM_DECL, cppsignature)) { \
26+
return ::cpp_bindgen::wrap<cppsignature>(impl)(BOOST_PP_ENUM_PARAMS(n, param_)); \
3127
}
3228

3329
/**

0 commit comments

Comments
 (0)