Skip to content

Commit 738ac6f

Browse files
[BSIP40] Generate list_#.cpp files
See bitshares#2093 (comment) Add a cmake template file for the list_#.cpp files and autogenerate them from the template rather than having 12 almost identical copies of a file
1 parent 3cd47d1 commit 738ac6f

13 files changed

+9
-474
lines changed

libraries/protocol/CMakeLists.txt

+7-13
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,18 @@ list(APPEND CUSTOM_AUTHS_FILES
3737
custom_authorities/create_predicate_fwd_1.cpp
3838
custom_authorities/create_predicate_fwd_2.cpp
3939
custom_authorities/create_predicate_fwd_3.cpp
40-
custom_authorities/restriction_predicate.cpp
41-
custom_authorities/list_1.cpp
42-
custom_authorities/list_2.cpp
43-
custom_authorities/list_3.cpp
44-
custom_authorities/list_4.cpp
45-
custom_authorities/list_5.cpp
46-
custom_authorities/list_6.cpp
47-
custom_authorities/list_7.cpp
48-
custom_authorities/list_8.cpp
49-
custom_authorities/list_9.cpp
50-
custom_authorities/list_10.cpp
51-
custom_authorities/list_11.cpp
52-
custom_authorities/list_12.cpp)
40+
custom_authorities/restriction_predicate.cpp)
41+
42+
foreach(LIST_NUM RANGE 1 12)
43+
configure_file("custom_authorities/list.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/custom_authorities/list_${LIST_NUM}.cpp")
44+
list(APPEND CUSTOM_AUTHS_FILES "${CMAKE_CURRENT_BINARY_DIR}/custom_authorities/list_${LIST_NUM}.cpp")
45+
endforeach(LIST_NUM)
5346

5447
file(GLOB CUSTOM_AUTHS_HEADERS "custom_authorities/*.hxx")
5548

5649
add_library( graphene_protocol_custom_auths ${CUSTOM_AUTHS_FILES} ${CUSTOM_AUTHS_HEADERS} )
5750
target_link_libraries( graphene_protocol_custom_auths fc )
51+
target_include_directories(graphene_protocol_custom_auths PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/custom_authorities")
5852
target_include_directories( graphene_protocol_custom_auths PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
5953

6054
if( MSVC )

libraries/protocol/custom_authorities/list_1.cpp libraries/protocol/custom_authorities/list.cpp.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
namespace graphene { namespace protocol {
2929
using result_type = object_restriction_predicate<operation>;
3030

31-
result_type get_restriction_predicate_list_1(size_t idx, vector<restriction> rs) {
32-
return typelist::runtime::dispatch(operation_list_1::list(), idx, [&rs] (auto t) -> result_type {
31+
result_type get_restriction_predicate_list_${LIST_NUM}(size_t idx, vector<restriction> rs) {
32+
return typelist::runtime::dispatch(operation_list_${LIST_NUM}::list(), idx, [&rs] (auto t) -> result_type {
3333
using Op = typename decltype(t)::type;
3434
return [p=restrictions_to_predicate<Op>(std::move(rs), true)] (const operation& op) {
3535
FC_ASSERT(op.which() == operation::tag<Op>::value,

libraries/protocol/custom_authorities/list_10.cpp

-41
This file was deleted.

libraries/protocol/custom_authorities/list_11.cpp

-41
This file was deleted.

libraries/protocol/custom_authorities/list_12.cpp

-41
This file was deleted.

libraries/protocol/custom_authorities/list_2.cpp

-42
This file was deleted.

libraries/protocol/custom_authorities/list_3.cpp

-42
This file was deleted.

libraries/protocol/custom_authorities/list_4.cpp

-42
This file was deleted.

libraries/protocol/custom_authorities/list_5.cpp

-42
This file was deleted.

libraries/protocol/custom_authorities/list_6.cpp

-42
This file was deleted.

0 commit comments

Comments
 (0)