Skip to content

Commit

Permalink
fix: replace range::view with range::views
Browse files Browse the repository at this point in the history
  • Loading branch information
maltemoeser committed Apr 15, 2020
1 parent 5459a83 commit aa37423
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions blockscipy/src/blocksci_iterator_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ pybind11::object BlocksciIteratorType::toObject() const {

RawIterator<BlocksciType> BlocksciIteratorType::toGeneric() {
return mpark::visit([&](auto &r) -> RawIterator<BlocksciType> {
return r | ranges::view::transform([](auto && v) -> BlocksciType {
return r | ranges::views::transform([](auto && v) -> BlocksciType {
return BlocksciType{std::forward<decltype(v)>(v)};
});
}, var);
}

RawIterator<std::any> BlocksciIteratorType::toAnySequence() {
return mpark::visit([&](auto &r) -> RawIterator<std::any> {
return r | ranges::view::transform([](auto && v) -> std::any {
return r | ranges::views::transform([](auto && v) -> std::any {
return std::forward<decltype(v)>(v);
});
}, var);
Expand Down
4 changes: 2 additions & 2 deletions blockscipy/src/blocksci_range_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ BlocksciIteratorType BlocksciRangeType::toIterator() {

RawRange<BlocksciType> BlocksciRangeType::toGeneric() {
return mpark::visit([&](auto &r) -> RawRange<BlocksciType> {
return r | ranges::view::transform([](auto && v) -> BlocksciType {
return r | ranges::views::transform([](auto && v) -> BlocksciType {
return BlocksciType{std::forward<decltype(v)>(v)};
});
}, var);
}

RawRange<std::any> BlocksciRangeType::toAnySequence() {
return mpark::visit([&](auto &r) -> RawRange<std::any> {
return r | ranges::view::transform([](auto && v) -> std::any {
return r | ranges::views::transform([](auto && v) -> std::any {
return std::forward<decltype(v)>(v);
});
}, var);
Expand Down
2 changes: 1 addition & 1 deletion blockscipy/src/chain/blockchain_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
struct PythonScriptRangeFunctor {
static PythonScriptRangeVariant f(blocksci::DataAccess &access) {
auto scriptCount = getScriptCount(type, access);
return PythonScriptRange<type>{ranges::view::ints(uint32_t{1}, scriptCount + 1) | ranges::view::transform([&](uint32_t scriptNum) {
return PythonScriptRange<type>{ranges::views::ints(uint32_t{1}, scriptCount + 1) | ranges::views::transform([&](uint32_t scriptNum) {
return ScriptAddress<type>(scriptNum, access);
})};
}
Expand Down
2 changes: 1 addition & 1 deletion blockscipy/src/cluster/cluster/cluster_proxy_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct AddClusterMethods {
return cluster.getInputs();
}, "Returns an iterator over all inputs spent from this cluster");
func(property_tag, "addresses", +[](const Cluster &cluster) -> RawIterator<AnyScript> {
return ranges::any_view<AnyScript>{ranges::view::transform(cluster.getAddresses(), [](Address && address) -> AnyScript {
return ranges::any_view<AnyScript>{ranges::views::transform(cluster.getAddresses(), [](Address && address) -> AnyScript {
return address.getScript();
})};
}, "Get a iterable over all the addresses in the cluster");
Expand Down
4 changes: 2 additions & 2 deletions blockscipy/src/generic_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::function<ranges::optional<BlocksciType>(std::any &)> SimpleProxy::getGeneri
std::function<BlocksciRangeType(std::any &)> SimpleProxy::getGenericRange() const {
return [generic = getGenericSimple()](std::any &v) -> BlocksciRangeType {
return mpark::visit([](auto && val) -> BlocksciRangeType {
return BlocksciRangeType{RawRange<std::decay_t<decltype(val)>>{ranges::view::single(std::forward<decltype(val)>(val))}};
return BlocksciRangeType{RawRange<std::decay_t<decltype(val)>>{ranges::views::single(std::forward<decltype(val)>(val))}};
}, generic(v).var);
};
}
Expand All @@ -59,4 +59,4 @@ std::function<BlocksciType(std::any &)> ProxyAddress::getGenericSimple() const {
return [generic = getGenericScript()](std::any &val) -> BlocksciType {
return BlocksciType{generic(val)};
};
}
}
4 changes: 2 additions & 2 deletions blockscipy/src/generic_proxy/range_map_optional_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ namespace {

template <typename T>
RawIterator<typename ranges::range_value_t<T>::value_type> flattenOptional(T && t) {
return ranges::view::transform(ranges::view::filter(std::forward<T>(t), isOptional), derefOptional);
return ranges::views::transform(ranges::views::filter(std::forward<T>(t), isOptional), derefOptional);
}
}

template<typename R>
Proxy<RawIterator<R>> mapOptional(IteratorProxy &p, Proxy<ranges::optional<R>> &p2) {
return liftGeneric(p, [p2](auto && seq) -> RawIterator<R> {
return flattenOptional(ranges::view::transform(std::forward<decltype(seq)>(seq).toAnySequence(), p2));
return flattenOptional(ranges::views::transform(std::forward<decltype(seq)>(seq).toAnySequence(), p2));
});
}

Expand Down
2 changes: 1 addition & 1 deletion blockscipy/src/generic_proxy/range_map_sequence_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
template<typename R>
Proxy<RawIterator<R>> mapSequence(IteratorProxy &p, Proxy<RawIterator<R>> &p2) {
return liftGeneric(p, [p2](auto && seq) -> RawIterator<R> {
return ranges::view::join(ranges::view::transform(std::forward<decltype(seq)>(seq).toAnySequence(), p2));
return ranges::views::join(ranges::views::transform(std::forward<decltype(seq)>(seq).toAnySequence(), p2));
});
}

Expand Down
2 changes: 1 addition & 1 deletion blockscipy/src/generic_proxy/range_map_simple_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
template<ranges::category range_cat, typename R>
Proxy<ranges::any_view<R, range_cat>> mapSimple(proxy_sequence<range_cat> &p, Proxy<R> &p2) {
return liftGeneric(p, [p2](auto && seq) -> ranges::any_view<R, range_cat> {
return ranges::view::transform(std::forward<decltype(seq)>(seq).toAnySequence(), p2);
return ranges::views::transform(std::forward<decltype(seq)>(seq).toAnySequence(), p2);
});
}

Expand Down
4 changes: 2 additions & 2 deletions blockscipy/src/generic_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

RawIterator<std::any> GenericIterator::getAllIterator() {
return mpark::visit([](auto && seq) -> RawIterator<std::any> {
return ranges::view::transform(std::forward<decltype(seq)>(seq), [](auto && item) -> std::any {
return ranges::views::transform(std::forward<decltype(seq)>(seq), [](auto && item) -> std::any {
return std::forward<decltype(item)>(item);
});
}, getGenericIterator().var);
Expand All @@ -20,7 +20,7 @@ RawIterator<std::any> GenericIterator::getAllIterator() {

RawRange<std::any> GenericRange::getAllRange() {
return mpark::visit([](auto && seq) -> RawRange<std::any> {
return ranges::view::transform(std::forward<decltype(seq)>(seq), [](auto && item) -> std::any {
return ranges::views::transform(std::forward<decltype(seq)>(seq), [](auto && item) -> std::any {
return std::forward<decltype(item)>(item);
});
}, getGenericRange().var);
Expand Down
4 changes: 2 additions & 2 deletions blockscipy/src/proxy_py_create.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ AllProxyClasses<T, SimpleBase> createProxyClasses(pybind11::module &m) {
return {std::function<RawRange<T>(std::any &)>{[p](std::any & v) -> RawRange<T> {
auto val = p(v);
if (val) {
return ranges::view::single(*val);
return ranges::views::single(*val);
} else {
return ranges::view::empty<T>();
return ranges::views::empty<T>;
}
}}, p.sourceType};
}))
Expand Down
8 changes: 4 additions & 4 deletions blockscipy/src/python_range_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct NumpyConverter {
template <typename T>
pybind11::array_t<decltype(NumpyConverter{}(std::declval<ranges::range_value_type_t<T>>()))>
convertRandomSizedNumpy(T && t) {
auto numpy_converted = ranges::view::transform(std::move(t), NumpyConverter{});
auto numpy_converted = ranges::views::transform(std::move(t), NumpyConverter{});
auto rangeSize = static_cast<size_t>(ranges::size(numpy_converted));
pybind11::array_t<ranges::range_value_type_t<decltype(numpy_converted)>> ret{rangeSize};
auto retPtr = ret.mutable_data();
Expand All @@ -70,7 +70,7 @@ convertRandomSizedNumpy(T && t) {
template <typename T>
pybind11::array_t<decltype(NumpyConverter{}(std::declval<ranges::range_value_type_t<T>>()))>
convertInputNumpy(T && t) {
auto ret = ranges::to_vector(ranges::view::transform(std::move(t), NumpyConverter{}));
auto ret = ranges::to_vector(ranges::views::transform(std::move(t), NumpyConverter{}));
return pybind11::array_t<typename decltype(ret)::value_type>{ret.size(), ret.data()};
}

Expand Down Expand Up @@ -98,13 +98,13 @@ py::list convertInputPy(T && t) {
template <typename T>
Iterator<decltype(BlockSciTypeConverter{}(std::declval<ranges::range_value_type_t<T>>()))>
convertInputBlockSci(T && t) {
return ranges::any_view<decltype(BlockSciTypeConverter{}(std::declval<ranges::range_value_type_t<T>>()))>{ranges::view::transform(std::forward<T>(t), BlockSciTypeConverter{})};
return ranges::any_view<decltype(BlockSciTypeConverter{}(std::declval<ranges::range_value_type_t<T>>()))>{ranges::views::transform(std::forward<T>(t), BlockSciTypeConverter{})};
}

template <typename T>
Range<decltype(BlockSciTypeConverter{}(std::declval<ranges::range_value_type_t<T>>()))>
convertRandomSizedBlockSci(T && t) {
return ranges::any_view<decltype(BlockSciTypeConverter{}(std::declval<ranges::range_value_type_t<T>>())), random_access_sized>{ranges::view::transform(std::forward<T>(t), BlockSciTypeConverter{})};
return ranges::any_view<decltype(BlockSciTypeConverter{}(std::declval<ranges::range_value_type_t<T>>())), random_access_sized>{ranges::views::transform(std::forward<T>(t), BlockSciTypeConverter{})};
}


Expand Down
14 changes: 7 additions & 7 deletions blockscipy/src/scripts/equiv_address/equiv_address_proxy_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ struct AddEquivAddressMethods {
func(property_tag, "is_script_equiv", &EquivAddress::isScriptEquiv, "Returns whether this equiv address is script equivalent or not");
func(method_tag, "balance", &EquivAddress::calculateBalance, "Calculates the balance held by these equivalent addresses at the height (Defaults to the full chain)", py::arg("height") = -1);
func(property_tag, "addresses", +[](const EquivAddress &address) -> RawIterator<AnyScript> {
return ranges::view::ints(0, 1) | ranges::view::transform([address](int) {
return address | ranges::view::transform([](const Address &address) {
return ranges::views::ints(0, 1) | ranges::views::transform([address](int) {
return address | ranges::views::transform([](const Address &address) {
return address.getScript();
});
}) | ranges::view::join;
}) | ranges::views::join;
}, "Calculate balance");
func(property_tag, "outs", +[](const EquivAddress &address) -> RawIterator<Output> {
return ranges::view::ints(0, 1) | ranges::view::transform([address](int) {
return ranges::views::ints(0, 1) | ranges::views::transform([address](int) {
return address.getOutputs();
}) | ranges::view::join;
}) | ranges::views::join;
}, "Returns an iterator over all outputs sent to these equivalent addresses");
func(property_tag, "ins", +[](EquivAddress &address) -> RawIterator<Input> {
return ranges::view::ints(0, 1) | ranges::view::transform([address](int) {
return ranges::views::ints(0, 1) | ranges::views::transform([address](int) {
return address.getInputs();
}) | ranges::view::join;
}) | ranges::views::join;
}, "Returns an iterator over all inputs spent from these equivalent addresses");
func(method_tag, "out_txes_count", +[](EquivAddress &address) -> int64_t {
return address.getOutputTransactions().size();
Expand Down
2 changes: 1 addition & 1 deletion blockscipy/src/scripts/pubkey/pubkey_proxy_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct AddPubkeyBaseMethods {
void operator()(FuncApplication func) {
using namespace blocksci;
func(method_tag, "find_multisigs", +[](const T &script) -> RawIterator<script::Multisig> {
return script.getIncludingMultisigs() | ranges::view::transform([](Address && address) -> script::Multisig {
return script.getIncludingMultisigs() | ranges::views::transform([](Address && address) -> script::Multisig {
return mpark::get<script::Multisig>(address.getScript().wrapped);
});
}, "List of multisigs which include this public key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct AddWitnessUnknownMethods {
if (stack) {
py::list list;
RANGES_FOR(auto && item, *stack) {
auto charVector = item | ranges::view::transform([](auto && c) -> char { return c; } ) | ranges::to_vector;
auto charVector = item | ranges::views::transform([](auto && c) -> char { return c; } ) | ranges::to_vector;
list.append(py::bytes(std::string{charVector.begin(), charVector.end()}));
}
return list;
Expand Down

0 comments on commit aa37423

Please sign in to comment.