Skip to content

Commit 66efce9

Browse files
authored
Remove MPL and dependencies (#19)
* Remove MPL usage * Remove BOOST_WORKAROUND * Remove comment * Remove MPL deps * Add test case * Refine test
1 parent 2b3b872 commit 66efce9

8 files changed

Lines changed: 115 additions & 29 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,9 @@ jobs:
204204
libs/assert \
205205
libs/config \
206206
libs/core \
207-
libs/io \
208-
libs/mpl \
209-
libs/predef \
210207
libs/preprocessor \
211208
libs/static_assert \
212-
libs/throw_exception \
213-
libs/type_traits \
214-
libs/utility
209+
libs/throw_exception
215210
216211
- name: Build upstream Boost libraries (Ubuntu)
217212
if: matrix.os.name == 'ubuntu' && steps.cache-boost.outputs.cache-hit != 'true'

‎CMakeLists.txt‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ list(APPEND iris_x4_boost_deps config)
128128
list(APPEND iris_x4_boost_deps static_assert)
129129
list(APPEND iris_x4_boost_deps throw_exception)
130130

131-
# Everything required by `mpl`
132-
list(APPEND iris_x4_boost_deps mpl)
133-
list(APPEND iris_x4_boost_deps io)
134-
list(APPEND iris_x4_boost_deps predef)
135-
list(APPEND iris_x4_boost_deps type_traits)
136-
list(APPEND iris_x4_boost_deps utility)
137-
138131
# ---------------------------------------------
139132
list(REMOVE_DUPLICATES iris_x4_boost_deps)
140133

‎README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ Note: Boost dependency is going to be removed entirely in the near future.
4646
```console
4747
git submodule update --init --depth 1 --recursive -- \
4848
tools/build tools/boost_install libs/assert libs/config \
49-
libs/core libs/io libs/mpl libs/predef libs/preprocessor \
50-
libs/static_assert libs/throw_exception libs/type_traits libs/utility
49+
libs/core libs/preprocessor libs/static_assert libs/throw_exception
5150

5251
# Linux
5352
./bootstrap.sh

‎include/iris/x4/numeric/utils/extract_int.hpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ template<
261261
>
262262
struct extract_int
263263
{
264-
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
264+
#ifdef _MSC_VER
265265
# pragma warning(push)
266266
# pragma warning(disable: 4127) // conditional expression is constant
267267
# pragma warning(disable: 4459) // declaration hides global declaration
@@ -300,7 +300,7 @@ struct extract_int
300300
}
301301
return false;
302302
}
303-
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
303+
#ifdef _MSC_VER
304304
# pragma warning(pop)
305305
#endif
306306

@@ -343,7 +343,7 @@ struct extract_int
343343
template<class T, unsigned Radix, class Accumulator, bool Accumulate>
344344
struct extract_int<T, Radix, 1, -1, Accumulator, Accumulate>
345345
{
346-
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
346+
#ifdef _MSC_VER
347347
# pragma warning(push)
348348
# pragma warning(disable: 4127) // conditional expression is constant
349349
# pragma warning(disable: 4459) // declaration hides global declaration
@@ -397,7 +397,7 @@ struct extract_int<T, Radix, 1, -1, Accumulator, Accumulate>
397397
first = it;
398398
return true;
399399
}
400-
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
400+
#ifdef _MSC_VER
401401
# pragma warning(pop)
402402
#endif
403403

‎include/iris/x4/numeric/utils/extract_real.hpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
#include <cassert>
2525
#include <cmath>
2626

27-
// TODO: fix this
28-
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
27+
#ifdef _MSC_VER
2928
# pragma warning(push)
3029
# pragma warning(disable: 4100) // 'p': unreferenced formal parameter
3130
#endif
@@ -253,7 +252,7 @@ struct extract_real
253252
}
254253
};
255254

256-
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
255+
#ifdef _MSC_VER
257256
# pragma warning(pop)
258257
#endif
259258

‎include/iris/x4/traits/substitution.hpp‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
#include <iris/alloy/traits.hpp>
1818

19-
#include <boost/mpl/placeholders.hpp>
20-
#include <boost/mpl/equal.hpp>
21-
#include <boost/mpl/filter_view.hpp>
22-
2319
#include <optional>
2420
#include <type_traits>
2521

@@ -38,10 +34,22 @@ constexpr bool is_substitute_v = is_substitute<T, Attr>::value;
3834
template<class Variant, X4Attribute Attr>
3935
struct variant_has_substitute;
4036

41-
// TODO: reduce MPL usage
42-
4337
namespace detail {
4438

39+
template<class TTuple, class UTuple, class IndexSeq = std::make_index_sequence<alloy::tuple_size_v<TTuple>>>
40+
struct is_all_substitute_for_tuple_impl {};
41+
42+
template<class TTuple, class UTuple, std::size_t... Is>
43+
struct is_all_substitute_for_tuple_impl<TTuple, UTuple, std::index_sequence<Is...>>
44+
: std::conjunction<is_substitute<alloy::tuple_element_t<Is, TTuple>, alloy::tuple_element_t<Is, UTuple>>...> {};
45+
46+
template<class TTuple, class UTuple>
47+
struct is_all_substitute_for_tuple : std::false_type {};
48+
49+
template<class TTuple, class UTuple>
50+
requires is_same_size_sequence_v<TTuple, UTuple>
51+
struct is_all_substitute_for_tuple<TTuple, UTuple> : is_all_substitute_for_tuple_impl<TTuple, UTuple> {};
52+
4553
template<class T, X4Attribute Attr>
4654
struct value_type_is_substitute
4755
: is_substitute<container_value_t<T>, container_value_t<Attr>>
@@ -56,7 +64,7 @@ template<class T, X4Attribute Attr>
5664
alloy::is_tuple_like<Attr>
5765
>
5866
struct is_substitute_impl<T, Attr>
59-
: boost::mpl::equal<T, Attr, is_substitute<boost::mpl::_1, boost::mpl::_2>>
67+
: is_all_substitute_for_tuple<T, Attr>
6068
{};
6169

6270
template<class T, X4Attribute Attr>

‎test/x4/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ x4_define_tests(
9191
with
9292
with_local
9393
x3_rule_problem
94+
alloy_wrong_substitute_test_case
9495
)
9596

9697
x4_define_test(rule_separate_tu rule_separate_tu.cpp rule_separate_tu_grammar.cpp)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#include "iris_x4_test.hpp"
2+
3+
#include <iris/x4/auxiliary/eps.hpp>
4+
#include <iris/x4/operator/alternative.hpp>
5+
#include <iris/x4/rule.hpp>
6+
7+
#include <iris/alloy/adapt.hpp>
8+
#include <iris/alloy/tuple.hpp>
9+
10+
#include <iris/rvariant.hpp>
11+
12+
namespace alloy_wrong_substitute_test_case {
13+
14+
struct A
15+
{
16+
int foo;
17+
int bar;
18+
};
19+
20+
struct B
21+
{
22+
int hoge;
23+
std::string fuga;
24+
};
25+
26+
} // alloy_wrong_substitute_test_case
27+
28+
namespace iris::alloy {
29+
30+
// If enabled, `B` can be wrongly treated as substitutable to `A`
31+
template<>
32+
struct adaptor<alloy_wrong_substitute_test_case::A>
33+
{
34+
using getters_list = make_getters_list<
35+
&alloy_wrong_substitute_test_case::A::foo,
36+
&alloy_wrong_substitute_test_case::A::bar
37+
>;
38+
};
39+
40+
template<>
41+
struct adaptor<alloy_wrong_substitute_test_case::B>
42+
{
43+
using getters_list = make_getters_list<
44+
&alloy_wrong_substitute_test_case::B::hoge,
45+
&alloy_wrong_substitute_test_case::B::fuga
46+
>;
47+
};
48+
49+
} // iris::alloy
50+
51+
namespace ast {
52+
53+
using A = alloy_wrong_substitute_test_case::A;
54+
using B = alloy_wrong_substitute_test_case::B;
55+
using AorB = iris::rvariant<
56+
alloy_wrong_substitute_test_case::A,
57+
alloy_wrong_substitute_test_case::B
58+
>;
59+
60+
} // ast
61+
62+
using ARule = x4::rule<struct a_tag, ast::A>;
63+
using BRule = x4::rule<struct b_tag, ast::B>;
64+
using AorBRule = x4::rule<struct a_or_b_tag, ast::AorB>;
65+
66+
constexpr ARule a;
67+
constexpr BRule b;
68+
constexpr AorBRule a_or_b;
69+
70+
IRIS_X4_DECLARE(ARule);
71+
IRIS_X4_DECLARE(BRule);
72+
IRIS_X4_DECLARE(AorBRule);
73+
74+
constexpr auto a_def = x4::eps;
75+
76+
constexpr auto b_def = x4::eps;
77+
78+
constexpr auto a_or_b_def = a | b;
79+
80+
IRIS_X4_DEFINE(a);
81+
IRIS_X4_DEFINE(b);
82+
IRIS_X4_DEFINE(a_or_b);
83+
84+
IRIS_X4_INSTANTIATE(AorBRule, const char*, x4::unused_type);
85+
86+
TEST_CASE("alloy_wrong_substitute_test_case")
87+
{
88+
const char* ptr = nullptr;
89+
ast::AorB result;
90+
(void)a_or_b.parse(ptr, nullptr, x4::unused, result);
91+
}

0 commit comments

Comments
 (0)