Skip to content

Commit

Permalink
🐛 [pph] Fix sml.hpp generation
Browse files Browse the repository at this point in the history
Problem:
- `sml.hpp` generation using `tools/pph.sh` is out of date with `sml.hpp`.

Solution:
- Update files in sml/ folder to fix the generated `sml.hpp`.
  • Loading branch information
krzysztof-jusiak committed May 27, 2020
1 parent 1e74038 commit 9fc46f5
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 45 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/pph-checker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pph Checker
name: PPH checker

on:
push:
Expand All @@ -8,9 +8,17 @@ on:

jobs:
build:

runs-on: ubuntu-latest

runs-on: ${{ matrix.os }}
strategy:
matrix:
name: [
ubuntu-18.04-clang-4.0
]
include:
- name: ubuntu-18.04-clang-4.0
os: ubuntu-18.04
compiler: clang
version: "4.0"
steps:
- uses: actions/checkout@v2
- name: Run pph
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build*/
/BUILD*/
/*.log
*.out
37 changes: 16 additions & 21 deletions include/boost/sml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
//
#ifndef BOOST_SML_HPP
#define BOOST_SML_HPP
#if defined(_MSC_VER) && !defined(__clang__)
#define COMPILING_WITH_MSVC
#endif
#if (__cplusplus < 201305L && _MSC_VER < 1900)
#error "[Boost].SML requires C++14 support (Clang-3.4+, GCC-5.1+, MSVC-2015+)"
#else
#define BOOST_SML_VERSION 1'1'0
#define BOOST_SML_VERSION 1'1'1
#define BOOST_SML_NAMESPACE_BEGIN \
namespace boost { \
namespace sml { \
inline namespace v1_1_0 {
inline namespace v1_1_1 {
#define BOOST_SML_NAMESPACE_END \
} \
} \
Expand Down Expand Up @@ -44,15 +41,15 @@
#define __BOOST_SML_TEMPLATE_KEYWORD template
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#elif defined(COMPILING_WITH_MSVC)
#elif defined(_MSC_VER) && !defined(__clang__)
#define __BOOST_SML_DEFINED_HAS_BUILTIN
#define __has_builtin(...) __has_builtin##__VA_ARGS__
#define __has_builtin__make_integer_seq(...) 1
#define __BOOST_SML_UNUSED
#define __BOOST_SML_VT_INIT
#define __BOOST_SML_ZERO_SIZE_ARRAY(...)
#define __BOOST_SML_ZERO_SIZE_ARRAY_CREATE(...) __VA_ARGS__ ? __VA_ARGS__ : 1
#if (defined(COMPILING_WITH_MSVC) && _MSC_VER >= 1910) // MSVC 2017
#if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1910 // MSVC 2017
#define __BOOST_SML_TEMPLATE_KEYWORD template
#else
#define __BOOST_SML_TEMPLATE_KEYWORD
Expand Down Expand Up @@ -125,7 +122,7 @@ struct is_same : false_type {};
template <class T>
struct is_same<T, T> : true_type {};
template <class T, class U>
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
struct is_base_of : integral_constant<bool, __is_base_of(T, U)> {
};
#else
Expand All @@ -136,7 +133,7 @@ decltype(T(declval<TArgs>()...), true_type{}) test_is_constructible(int);
template <class, class...>
false_type test_is_constructible(...);
template <class T, class... TArgs>
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
struct is_constructible : decltype(test_is_constructible<T, TArgs...>(0)) {
};
#else
Expand Down Expand Up @@ -341,7 +338,7 @@ struct missing_ctor_parameter {
operator U() {
return {};
}
#if !defined(COMPILING_WITH_MSVC)
#if !defined(_MSC_VER) && !defined(__clang__)
template <class TMissing, __BOOST_SML_REQUIRES(!aux::is_base_of<pool_type_base, TMissing>::value)>
operator TMissing &() const {
static_assert(missing_ctor_parameter<TMissing>::value,
Expand Down Expand Up @@ -414,7 +411,7 @@ template <template <class...> class T, class... Ts>
struct size<T<Ts...>> {
static constexpr auto value = sizeof...(Ts);
};
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
constexpr int max_impl() { return 0; }
constexpr int max_impl(int r) { return r; }
constexpr int max_impl(int r, int i) { return r > i ? r : i; }
Expand Down Expand Up @@ -461,7 +458,7 @@ auto get_type_name(const char *ptr, index_sequence<Ns...>) {
}
template <class T>
const char *get_type_name() {
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
return detail::get_type_name<T, 34>(__FUNCSIG__, make_index_sequence<sizeof(__FUNCSIG__) - 34 - 8>{});
#elif defined(__clang__)
return detail::get_type_name<T, 58>(__PRETTY_FUNCTION__, make_index_sequence<sizeof(__PRETTY_FUNCTION__) - 58 - 2>{});
Expand Down Expand Up @@ -523,7 +520,6 @@ class queue_event {
}
queue_event &operator=(queue_event &&other) {
dtor(data);

id = other.id;
dtor = other.dtor;
move = other.move;
Expand Down Expand Up @@ -1201,7 +1197,7 @@ TPolicy get_policy(aux::pair<T, TPolicy> *);
template <class SM, class... TPolicies>
struct sm_policy {
static_assert(aux::is_same<aux::remove_reference_t<SM>, SM>::value, "SM type can't have qualifiers");
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
using default_dispatch_policy = policies::jump_table;
#elif defined(__clang__)
using default_dispatch_policy = policies::jump_table;
Expand Down Expand Up @@ -1994,7 +1990,7 @@ template <template <class...> class T>
using defer_queue = back::policies::defer_queue<T>;
template <template <class...> class T>
using process_queue = back::policies::process_queue<T>;
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
template <class T, class... TPolicies, class T__ = aux::remove_reference_t<decltype(aux::declval<T>())>>
using sm = back::sm<back::sm_policy<T__, TPolicies...>>;
#else
Expand Down Expand Up @@ -2122,7 +2118,7 @@ struct state<TState(history_state)> : state_impl<state<TState(history_state)>> {
return transition<T, state>{t, *this};
}
};
#if defined(COMPILING_WITH_MSVC)
#if defined(_MSC_VER) && !defined(__clang__)
template <class T, class T__ = aux::remove_reference_t<decltype(aux::declval<T>())>, class = void>
struct state_sm {
using type = state<T>;
Expand Down Expand Up @@ -2593,7 +2589,7 @@ struct transition<state<internal>, state<S2>, front::event<E>, always, none> {
};
}
using _ = back::_;
#if !defined(COMPILING_WITH_MSVC)
#if !defined(_MSC_VER) && !defined(__clang__)
template <class TEvent>
constexpr front::event<TEvent> event{};
#else
Expand All @@ -2610,15 +2606,15 @@ template <class T>
front::event<back::exception<T>> exception __BOOST_SML_VT_INIT;
using anonymous = back::anonymous;
using initial = back::initial;
#if !defined(COMPILING_WITH_MSVC)
#if !defined(_MSC_VER) && !defined(__clang__)
template <class T>
constexpr typename front::state_sm<T>::type state{};
#else
template <class T>
typename front::state_sm<T>::type state __BOOST_SML_VT_INIT;
#endif
inline namespace literals {
#if !defined(COMPILING_WITH_MSVC)
#if !defined(_MSC_VER) && !defined(__clang__)
template <class T, T... Chrs>
constexpr auto operator""_s() {
return front::state<aux::string<T, Chrs...>>{};
Expand Down Expand Up @@ -2649,10 +2645,9 @@ BOOST_SML_NAMESPACE_END
#elif defined(__GNUC__) && defined(__BOOST_SML_DEFINED_HAS_BUILTIN)
#undef __has_builtin
#pragma GCC diagnostic pop
#elif defined(COMPILING_WITH_MSVC) && defined(__BOOST_SML_DEFINED_HAS_BUILTIN)
#elif defined(_MSC_VER) && !defined(__clang__) && defined(__BOOST_SML_DEFINED_HAS_BUILTIN)
#undef __has_builtin
#undef __has_builtin__make_integer_seq
#endif
#undef COMPILING_WITH_MSVC
#endif
#endif
4 changes: 2 additions & 2 deletions include/boost/sml/aux_/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ template <class T>
struct is_same<T, T> : true_type {};

template <class T, class U>
#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
struct is_base_of : integral_constant<bool, __is_base_of(T, U)> {
};
#else // __pph__
Expand All @@ -95,7 +95,7 @@ decltype(T(declval<TArgs>()...), true_type{}) test_is_constructible(int);
template <class, class...>
false_type test_is_constructible(...);
template <class T, class... TArgs>
#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
struct is_constructible : decltype(test_is_constructible<T, TArgs...>(0)) {
};
#else // __pph__
Expand Down
6 changes: 3 additions & 3 deletions include/boost/sml/aux_/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct missing_ctor_parameter {
return {};
}

#if !defined(_MSC_VER) // __pph__
#if !defined(_MSC_VER) && !defined(__clang__) // __pph__
template <class TMissing, __BOOST_SML_REQUIRES(!aux::is_base_of<pool_type_base, TMissing>::value)>
operator TMissing &() const {
static_assert(missing_ctor_parameter<TMissing>::value,
Expand Down Expand Up @@ -253,7 +253,7 @@ struct size<T<Ts...>> {
static constexpr auto value = sizeof...(Ts);
};

#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
constexpr int max_impl() { return 0; }
constexpr int max_impl(int r) { return r; }
constexpr int max_impl(int r, int i) { return r > i ? r : i; }
Expand Down Expand Up @@ -306,7 +306,7 @@ auto get_type_name(const char *ptr, index_sequence<Ns...>) {

template <class T>
const char *get_type_name() {
#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
return detail::get_type_name<T, 34>(__FUNCSIG__, make_index_sequence<sizeof(__FUNCSIG__) - 34 - 8>{});
#elif defined(__clang__) // __pph__
return detail::get_type_name<T, 58>(__PRETTY_FUNCTION__, make_index_sequence<sizeof(__PRETTY_FUNCTION__) - 58 - 2>{});
Expand Down
2 changes: 1 addition & 1 deletion include/boost/sml/back/policies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ template <class SM, class... TPolicies>
struct sm_policy {
static_assert(aux::is_same<aux::remove_reference_t<SM>, SM>::value, "SM type can't have qualifiers");

#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
using default_dispatch_policy = policies::jump_table;
#elif defined(__clang__) // __pph__
using default_dispatch_policy = policies::jump_table;
Expand Down
6 changes: 3 additions & 3 deletions include/boost/sml/back/state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ struct sm_impl : aux::conditional_t<aux::is_empty<typename TSM::sm>::value, aux:
__BOOST_SML_REQUIRES(aux::is_base_of<get_generic_t<TEvent>, events_ids_t>::value)>
bool process_internal_generic_event(const TEvent &event, TDeps &deps, TSubs &subs, state_t &current_state) {
policies::log_process_event<sm_t>(aux::type<logger_t>{}, deps, event);
#if BOOST_SML_DISABLE_EXCEPTIONS
#if BOOST_SML_DISABLE_EXCEPTIONS // __pph__
return process_event_impl<get_event_mapping_t<get_generic_t<TEvent>, mappings>>(event, deps, subs, states_t{},
current_state);
#else
#else // __pph__
return process_event_noexcept<get_event_mapping_t<get_generic_t<TEvent>, mappings>>(event, deps, subs, current_state,
has_exceptions{});
#endif
#endif // __pph__
}

template <class TEvent, class TDeps, class TSubs,
Expand Down
2 changes: 1 addition & 1 deletion include/boost/sml/front/actions/process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct process {
explicit process_impl(const TEvent& event) : event(event) {}

template <class T, class TSM, class TDeps, class TSubs>
void operator()(const T&, TSM&, TDeps&, TSubs&) {
void operator()(const T&, TSM&, TDeps&, TSubs& subs) {
aux::get<get_root_sm_t<TSubs>>(subs).process_.push(event);
}

Expand Down
2 changes: 1 addition & 1 deletion include/boost/sml/front/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct state<TState(history_state)> : state_impl<state<TState(history_state)>> {
}
};

#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
template <class T, class T__ = aux::remove_reference_t<decltype(aux::declval<T>())>, class = void>
struct state_sm {
using type = state<T>;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/sml/state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using process_queue = back::policies::process_queue<T>;

/// state machine

#if defined(_MSC_VER) // __pph__
#if defined(_MSC_VER) && !defined(__clang__) // __pph__
template <class T, class... TPolicies, class T__ = aux::remove_reference_t<decltype(aux::declval<T>())>>
using sm = back::sm<back::sm_policy<T__, TPolicies...>>;
#else // __pph__
Expand Down
6 changes: 3 additions & 3 deletions include/boost/sml/transition_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using _ = back::_;

/// events

#if !defined(_MSC_VER) // __pph__
#if !defined(_MSC_VER) && !defined(__clang__) // __pph__
template <class TEvent>
constexpr front::event<TEvent> event{};
#else // __pph__
Expand All @@ -46,7 +46,7 @@ using initial = back::initial;

/// states

#if !defined(_MSC_VER) // __pph__
#if !defined(_MSC_VER) && !defined(__clang__) // __pph__
template <class T>
constexpr typename front::state_sm<T>::type state{};
#else // __pph__
Expand All @@ -55,7 +55,7 @@ typename front::state_sm<T>::type state __BOOST_SML_VT_INIT;
#endif // __pph__

inline namespace literals {
#if !defined(_MSC_VER) // __pph__
#if !defined(_MSC_VER) && !defined(__clang__) // __pph__
template <class T, T... Chrs>
constexpr auto operator""_s() {
return front::state<aux::string<T, Chrs...>>{};
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ endif()

add_subdirectory(ft)
add_subdirectory(ut)

10 changes: 6 additions & 4 deletions tools/pph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pph() {
echo "#pragma clang diagnostic ignored \"-Wzero-length-array\""
echo "#elif defined(__GNUC__)"
echo "#if !defined(__has_builtin)"
echo "#define __BOOST_SML_DEFINED_HAS_BUILTIN"
echo "#define __has_builtin(...) 0"
echo "#endif"
echo "#define __BOOST_SML_UNUSED __attribute__((unused))"
Expand All @@ -41,14 +42,15 @@ pph() {
echo "#define __BOOST_SML_TEMPLATE_KEYWORD template"
echo "#pragma GCC diagnostic push"
echo "#pragma GCC diagnostic ignored \"-Wpedantic\""
echo "#elif defined(_MSC_VER)"
echo "#elif defined(_MSC_VER) && !defined(__clang__)"
echo "#define __BOOST_SML_DEFINED_HAS_BUILTIN"
echo "#define __has_builtin(...) __has_builtin##__VA_ARGS__"
echo "#define __has_builtin__make_integer_seq(...) 1"
echo "#define __BOOST_SML_UNUSED"
echo "#define __BOOST_SML_VT_INIT"
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY(...)"
echo "#define __BOOST_SML_ZERO_SIZE_ARRAY_CREATE(...) __VA_ARGS__ ? __VA_ARGS__ : 1"
echo "#if (_MSC_VER >= 1910) // MSVC 2017"
echo "#if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1910 // MSVC 2017"
echo "#define __BOOST_SML_TEMPLATE_KEYWORD template "
echo "#else"
echo "#define __BOOST_SML_TEMPLATE_KEYWORD"
Expand Down Expand Up @@ -78,10 +80,10 @@ pph() {
echo "#undef __BOOST_SML_TEMPLATE_KEYWORD"
echo "#if defined(__clang__)"
echo "#pragma clang diagnostic pop"
echo "#elif defined(__GNUC__)"
echo "#elif defined(__GNUC__) && defined(__BOOST_SML_DEFINED_HAS_BUILTIN)"
echo "#undef __has_builtin"
echo "#pragma GCC diagnostic pop"
echo "#elif defined(_MSC_VER)"
echo "#elif defined(_MSC_VER) && !defined(__clang__) && defined(__BOOST_SML_DEFINED_HAS_BUILTIN)"
echo "#undef __has_builtin"
echo "#undef __has_builtin__make_integer_seq"
echo "#endif"
Expand Down

0 comments on commit 9fc46f5

Please sign in to comment.