Skip to content

Commit

Permalink
Merge pull request #387 from maltemoeser/deps/range-v3
Browse files Browse the repository at this point in the history
deps: upgrade range-v3 to recent version
  • Loading branch information
maltemoeser authored May 8, 2020
2 parents 1a671de + 24c8c86 commit 2e15125
Show file tree
Hide file tree
Showing 63 changed files with 291 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
url = https://github.com/mpark/variant.git
[submodule "libs/range-v3"]
path = external/range-v3
url = https://github.com/hkalodner/range-v3.git
url = https://github.com/ericniebler/range-v3.git
[submodule "Notebooks/blocksci/Blockchain-Known-Pools"]
path = blockscipy/blocksci/Blockchain-Known-Pools
url = https://github.com/blockchain/Blockchain-Known-Pools
Expand Down
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
7 changes: 4 additions & 3 deletions blockscipy/src/blocksci_type_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <range/v3/view/any_view.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/utility/optional.hpp>

struct BlockSciTypeConverter {

Expand Down Expand Up @@ -62,13 +63,13 @@ struct BlockSciTypeConverter {

template <typename T>
auto operator()(Iterator<T> &val) -> Iterator<decltype(this->operator()(*val))> {
return val | ranges::view::transform(this);
return val | ranges::views::transform(this);
}

template <typename T>
auto operator()(Range<T> &val) -> Range<decltype(this->operator()(*val))> {
return val | ranges::view::transform(this);
return val | ranges::views::transform(this);
}
};

#endif /* blocksci_type_converter_h */
#endif /* blocksci_type_converter_h */
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)};
};
}
}
1 change: 1 addition & 0 deletions blockscipy/src/generic_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "python_fwd.hpp"

#include <blocksci/scripts/scripts_fwd.hpp>
#include <range/v3/utility/optional.hpp>

#include <any>
#include <functional>
Expand Down
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/generic_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct GenericIterator {

struct GenericRange : public GenericIterator {
virtual BlocksciRangeType getGenericRange() = 0;
virtual int64_t size() const = 0;
virtual bool empty() const = 0;
virtual int64_t size() = 0;
virtual bool empty() = 0;
virtual ~GenericRange() = default;

BlocksciIteratorType getGenericIterator() override;
Expand Down
4 changes: 2 additions & 2 deletions blockscipy/src/proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ struct Proxy<ranges::optional<T>> : public OptionalProxy {
return [f = this->func](std::any &val) -> BlocksciRangeType {
auto v = f(val);
if (v) {
return BlocksciRangeType{RawRange<T>{ranges::view::single(*v)}};
return BlocksciRangeType{RawRange<T>{ranges::views::single(*v)}};
} else {
return BlocksciRangeType{RawRange<T>{ranges::view::empty<T>()}};
return BlocksciRangeType{RawRange<T>{ranges::views::empty<T>}};
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion blockscipy/src/proxy/proxy_flow_functions_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class take_while_range : public ranges::view_facade<take_while_range<T>> {
return *v;
}

bool equal(ranges::default_sentinel) const {
bool equal(ranges::default_sentinel_t) const {
return !v;
}

Expand Down
7 changes: 3 additions & 4 deletions blockscipy/src/proxy/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void setupRangesProxy(AllProxyClasses<T, BaseSimple> &cls) {
cls.sequence
.def("_where", [](SequenceProxy<T> &p, Proxy<bool> &p2) -> Proxy<RawIterator<T>> {
return liftSequence(p, [p2](auto && seq) -> RawIterator<T> {
return ranges::view::filter(std::forward<decltype(seq)>(seq), [p2](T item) {
return ranges::views::filter(std::forward<decltype(seq)>(seq), [p2](T item) {
return p2(std::move(item));
});
});
Expand Down Expand Up @@ -86,13 +86,12 @@ void setupRangesProxy(AllProxyClasses<T, BaseSimple> &cls) {
.def("__getitem__", [](Proxy<RawRange<T>> &p, pybind11::slice slice) -> Proxy<RawRange<T>> {
return lift(p, [slice](auto && range) -> RawRange<T> {
size_t start, stop, step, slicelength;
const auto &constRange = range;
auto chainSize = ranges::size(constRange);
auto chainSize = ranges::size(range);
if (!slice.compute(chainSize, &start, &stop, &step, &slicelength))
throw pybind11::error_already_set();

auto subset = range[{static_cast<ranges::range_size_type_t<RawRange<T>>>(start), static_cast<ranges::range_size_type_t<RawRange<T>>>(stop)}];
return subset | ranges::view::stride(step);
return subset | ranges::views::stride(step);
});
}, pybind11::arg("slice"))
;
Expand Down
4 changes: 2 additions & 2 deletions blockscipy/src/proxy_create.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Proxy<RawIterator<T>> makeIteratorProxy() {
return {std::function<RawIterator<T>(std::any &)>{[](std::any &t) -> RawIterator<T> {
RawIterator<BlocksciType> *rawIt = std::any_cast<RawIterator<BlocksciType>>(&t);
if (rawIt != nullptr) {
return ranges::view::transform(*rawIt, [](BlocksciType && r) -> T { return mpark::get<T>(r.var); });
return ranges::views::transform(*rawIt, [](BlocksciType && r) -> T { return mpark::get<T>(r.var); });
}
return std::any_cast<RawIterator<T>>(t);
}}, createProxyTypeInfo<RawIterator<T>>()};
Expand All @@ -61,7 +61,7 @@ Proxy<RawRange<T>> makeRangeProxy() {
return {std::function<RawRange<T>(std::any &)>{[](std::any &t) -> RawRange<T> {
RawRange<BlocksciType> *rawIt = std::any_cast<RawRange<BlocksciType>>(&t);
if (rawIt != nullptr) {
return ranges::view::transform(*rawIt, [](BlocksciType && r) -> T { return mpark::get<T>(r.var); });
return ranges::views::transform(*rawIt, [](BlocksciType && r) -> T { return mpark::get<T>(r.var); });
}
return std::any_cast<RawRange<T>>(t);
}}, createProxyTypeInfo<RawRange<T>>()};
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
1 change: 1 addition & 0 deletions blockscipy/src/proxy_type_check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define blocksci_proxy_type_check_hpp

#include "python_fwd.hpp"
#include <range/v3/utility/optional.hpp>

#include <typeinfo>

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
12 changes: 6 additions & 6 deletions blockscipy/src/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct Range : public Sequence<T>, public GenericRange {
return BlocksciRangeType{rng};
}

int64_t size() const override {
int64_t size() override {
return rng.size();
}

bool empty() const override {
bool empty() override {
return ranges::empty(rng);
}
};
Expand All @@ -54,11 +54,11 @@ struct Range<blocksci::AnyScript> : public Sequence<blocksci::AnyScript>, public
return BlocksciRangeType{rng};
}

int64_t size() const override {
int64_t size() override {
return rng.size();
}

bool empty() const override {
bool empty() override {
return ranges::empty(rng);
}
};
Expand All @@ -80,11 +80,11 @@ struct Range<blocksci::ScriptAddress<type>> : public Sequence<blocksci::ScriptAd
return BlocksciRangeType{rng};
}

int64_t size() const override {
int64_t size() override {
return rng.size();
}

bool empty() const override {
bool empty() override {
return ranges::empty(rng);
}
};
Expand Down
2 changes: 1 addition & 1 deletion external/range-v3
Submodule range-v3 updated 586 files
1 change: 1 addition & 0 deletions include/blocksci/address/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <blocksci/scripts/scripts_fwd.hpp>

#include <range/v3/view/any_view.hpp>
#include <range/v3/utility/optional.hpp>

#include <functional>
#include <unordered_set>
Expand Down
Loading

0 comments on commit 2e15125

Please sign in to comment.