mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
add range-v3 library
Adds the range-v3 library which supports features that otherwise wouldn't be available until C++23 or C++26. I caught a couple of uses that suit it but this will allow us to use more in future. Test Plan: - CI
This commit is contained in:
parent
393f8aab42
commit
25426127bb
@ -95,6 +95,15 @@ FetchContent_Declare(
|
|||||||
)
|
)
|
||||||
FetchContent_Populate(folly)
|
FetchContent_Populate(folly)
|
||||||
|
|
||||||
|
### range-v3
|
||||||
|
FetchContent_Declare(
|
||||||
|
range-v3
|
||||||
|
GIT_REPOSITORY https://github.com/ericniebler/range-v3.git
|
||||||
|
GIT_TAG a81477931a8aa2ad025c6bda0609f38e09e4d7ec # 0.12.0
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(range-v3)
|
||||||
|
|
||||||
set_project_warnings()
|
set_project_warnings()
|
||||||
|
|
||||||
if (ASAN)
|
if (ASAN)
|
||||||
@ -291,6 +300,7 @@ target_link_libraries(oicore
|
|||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
Boost::headers
|
Boost::headers
|
||||||
glog::glog
|
glog::glog
|
||||||
|
range-v3
|
||||||
resources
|
resources
|
||||||
)
|
)
|
||||||
if (FORCE_LLVM_STATIC)
|
if (FORCE_LLVM_STATIC)
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <range/v3/algorithm/find_if.hpp>
|
||||||
|
#include <range/v3/algorithm/starts_with.hpp>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <span>
|
#include <span>
|
||||||
@ -204,18 +206,8 @@ std::optional<std::vector<uintptr_t>> OICompiler::locateOpcodes(
|
|||||||
|
|
||||||
std::vector<uintptr_t> locs;
|
std::vector<uintptr_t> locs;
|
||||||
while (auto inst = DG()) {
|
while (auto inst = DG()) {
|
||||||
auto it = std::find_if(
|
auto it = ranges::find_if(needles, [&](const auto& needle) {
|
||||||
std::begin(needles), std::end(needles), [&](const auto& needle) {
|
return ranges::starts_with(inst->opcodes, needle);
|
||||||
// std::ranges::starts_with(inst->opcodes, needle)
|
|
||||||
if (std::ranges::size(needle) > std::ranges::size(inst->opcodes))
|
|
||||||
return false;
|
|
||||||
auto it1 = std::ranges::begin(inst->opcodes);
|
|
||||||
auto it2 = std::ranges::begin(needle);
|
|
||||||
for (; it2 != std::ranges::end(needle); ++it1, ++it2) {
|
|
||||||
if (*it1 != *it2)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (it != std::end(needles)) {
|
if (it != std::end(needles)) {
|
||||||
|
@ -66,8 +66,7 @@ void KeyCapture::visit(Class& c) {
|
|||||||
continue;
|
continue;
|
||||||
if (!keyToCapture.member.has_value())
|
if (!keyToCapture.member.has_value())
|
||||||
continue;
|
continue;
|
||||||
for (size_t i = 0; i < c.members.size(); i++) {
|
for (auto& member : c.members) {
|
||||||
auto& member = c.members[i];
|
|
||||||
if (member.name != *keyToCapture.member)
|
if (member.name != *keyToCapture.member)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user