Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove several dependencies #8

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions AddressLibDecoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ add_project(
"src/main.cpp"
)

find_package(fmt REQUIRED CONFIG)
find_package(mmio REQUIRED CONFIG)

target_link_libraries(
"${PROJECT_NAME}"
PUBLIC
fmt::fmt
mmio::mmio
)
1 change: 0 additions & 1 deletion AddressLibDecoder/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## Build Dependencies
* [fmt](https://github.com/fmtlib/fmt)
* [mmio](https://github.com/Ryan-rsm-McKenzie/mmio)
13 changes: 5 additions & 8 deletions AddressLibDecoder/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#pragma warning(push)
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <fstream>
#include <iostream>
#include <span>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>

#include <fmt/format.h>
#include <mmio/mmio.hpp>
#pragma warning(pop)

Expand Down Expand Up @@ -45,10 +42,10 @@ int main(int a_argc, char* a_argv[])
reinterpret_cast<const Pair*>(input.data() + sizeof(std::uint64_t)),
*reinterpret_cast<const std::uint64_t*>(input.data()));
if (!data.empty()) {
const auto width = fmt::format(FMT_STRING("{}"), data.back().id);
const auto format = fmt::format(FMT_STRING("{{: >{}}}\t{{:0>7X}}\n"), width.length());
for (const auto& elem : data) {
output << fmt::format(fmt::runtime(format), elem.id, elem.offset);
const auto width = std::format("{}", data.back().id);
const auto format = std::format("{{: >{}}}\t{{:0>7X}}\n", width.length());
for (const auto& [id, offset] : data) {
output << std::vformat(format, std::make_format_args(id, offset));
}
}

Expand Down
2 changes: 0 additions & 2 deletions AddressLibGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ add_project(
"src/main.cpp"
)

find_package(robin_hood REQUIRED CONFIG)
find_package(srell MODULE REQUIRED)

target_link_libraries(
"${PROJECT_NAME}"
PRIVATE
robin_hood::robin_hood
srell::srell
)
1 change: 0 additions & 1 deletion AddressLibGen/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## Build Dependencies
* [robin-hood-hashing](https://github.com/martinus/robin-hood-hashing)
* [SRELL](https://www.akenotsuki.com/misc/srell/en/)
5 changes: 2 additions & 3 deletions AddressLibGen/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#include <sstream>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

#include <robin_hood.h>
#include <srell.hpp>
#pragma warning(pop)

Expand Down Expand Up @@ -145,8 +145,7 @@ using files_t = std::vector<std::tuple<Version, Version, std::filesystem::path>>
return results;
}

using offset_map = robin_hood::unordered_node_map<std::uint64_t, Mapping>;
//using offset_map = std::unordered_map<std::uint64_t, Mapping>;
using offset_map = std::unordered_map<std::uint64_t, Mapping>;
using version_map = std::map<Version, offset_map>;

[[nodiscard]] version_map load_mappings(const files_t& a_files)
Expand Down
3 changes: 1 addition & 2 deletions CommonLibF4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
endif()

find_package(Boost MODULE REQUIRED)
find_package(fmt REQUIRED CONFIG)
find_package(mmio REQUIRED CONFIG)
find_package(spdlog REQUIRED CONFIG)

Expand Down Expand Up @@ -73,6 +72,7 @@ if (MSVC)
/wd4625 # 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted
/wd4626 # 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted
/wd4686 # 'user-defined type' : possible change in behavior, change in UDT return calling convention
/wd4702 # unreachable code
/wd4710 # 'function' : function not inlined
/wd4711 # function 'function' selected for inline expansion
/wd4820 # 'bytes' bytes padding added after construct 'member_name'
Expand All @@ -97,7 +97,6 @@ target_link_libraries(
PUBLIC
bcrypt.lib
Boost::headers
fmt::fmt
mmio::mmio
spdlog::spdlog
Version.lib
Expand Down
1 change: 0 additions & 1 deletion CommonLibF4/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## Build Dependencies
* [Boost](https://www.boost.org/)
* Stl_interfaces
* [fmt](https://github.com/fmtlib/fmt)
* [mmio](https://github.com/Ryan-rsm-McKenzie/mmio)
* [spdlog](https://github.com/gabime/spdlog)
1 change: 0 additions & 1 deletion CommonLibF4/cmake/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
include(CMakeFindDependencyMacro)

find_dependency(Boost MODULE)
find_dependency(fmt CONFIG)
find_dependency(mmio CONFIG)
find_dependency(spdlog CONFIG)
48 changes: 22 additions & 26 deletions CommonLibF4/include/F4SE/Impl/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ static_assert(
"wrap std::time_t instead");

#pragma warning(push, 0)
#include <boost/stl_interfaces/iterator_interface.hpp>
#include <boost/stl_interfaces/sequence_container_interface.hpp>
#include <fmt/format.h>
#include <mmio/mmio.hpp>
#include <spdlog/spdlog.h>
#pragma warning(pop)
Expand Down Expand Up @@ -208,31 +206,18 @@ namespace F4SE
scope_exit(EF) -> scope_exit<EF>;

template <class F>
class counted_function_iterator :
public boost::stl_interfaces::iterator_interface<
counted_function_iterator<F>,
std::input_iterator_tag,
std::remove_reference_t<decltype(std::declval<F>()())>>
class counted_function_iterator
{
private:
using super =
boost::stl_interfaces::iterator_interface<
counted_function_iterator<F>,
std::input_iterator_tag,
std::remove_reference_t<decltype(std::declval<F>()())>>;

public:
using difference_type = typename super::difference_type;
using value_type = typename super::value_type;
using pointer = typename super::pointer;
using reference = typename super::reference;
using iterator_category = typename super::iterator_category;
using difference_type = std::ptrdiff_t;
using value_type = std::remove_const_t<std::remove_reference_t<decltype(std::declval<F>()())>>;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::input_iterator_tag;

counted_function_iterator() noexcept = default;

counted_function_iterator(
F a_fn,
std::size_t a_count) noexcept :
counted_function_iterator(F a_fn, std::size_t a_count) noexcept :
_fn(std::move(a_fn)),
_left(a_count)
{}
Expand All @@ -244,19 +229,30 @@ namespace F4SE
return (*_fn)();
}

[[nodiscard]] pointer operator->() const
{
return std::pointer_traits<pointer>::pointer_to(operator*());
}

[[nodiscard]] friend bool operator==(
const counted_function_iterator& a_lhs,
const counted_function_iterator& a_rhs) noexcept
{
return a_lhs._left == a_rhs._left;
}

using super::operator++;

void operator++() noexcept
counted_function_iterator& operator++() noexcept
{
assert(_left > 0);
_left -= 1;
return *this;
}

counted_function_iterator operator++(int) noexcept
{
counted_function_iterator tmp{ *this };
operator++();
return tmp;
}

private:
Expand Down Expand Up @@ -579,7 +575,7 @@ namespace F4SE
fileview = fileview.substr(pos + off);
}

return fmt::format(FMT_STRING("{}({}): {}"), fileview, a_loc.line(), a_msg);
return std::format("{}({}): {}", fileview, a_loc.line(), a_msg);
}();

const auto caption = []() -> std::string {
Expand Down
4 changes: 2 additions & 2 deletions CommonLibF4/include/F4SE/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
a_func() = delete; \
\
explicit a_func( \
fmt::format_string<Args...> a_fmt, \
spdlog::format_string_t<Args...> a_fmt, \
Args&&... a_args, \
std::source_location a_loc = std::source_location::current()) \
{ \
Expand All @@ -24,7 +24,7 @@
}; \
\
template <class... Args> \
a_func(fmt::format_string<Args...>, Args&&...) -> a_func<Args...>;
a_func(spdlog::format_string_t<Args...>, Args&&...) -> a_func<Args...>;

namespace F4SE::log
{
Expand Down
3 changes: 2 additions & 1 deletion CommonLibF4/include/F4SE/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace F4SE
inline constexpr REL::Version RUNTIME_1_10_162{ 1, 10, 162, 0 };
inline constexpr REL::Version RUNTIME_1_10_163{ 1, 10, 163, 0 };
inline constexpr REL::Version RUNTIME_1_10_980{ 1, 10, 980, 0 };
inline constexpr REL::Version RUNTIME_1_10_984{ 1, 10, 984, 0 };

inline constexpr auto RUNTIME_LATEST = RUNTIME_1_10_980;
inline constexpr auto RUNTIME_LATEST = RUNTIME_1_10_984;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace RE
isLatent(a_isLatent)
{
for (std::size_t i = 0; i < descTable.paramCount; ++i) {
descTable.entries[i].first = fmt::format(FMT_STRING("param{}"), i + 1);
descTable.entries[i].first = std::format("param{}", i + 1);
}
}

Expand Down
23 changes: 5 additions & 18 deletions CommonLibF4/include/RE/Bethesda/BSScriptUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ namespace RE::BSScript
if (!_proxy) {
const auto game = GameVM::GetSingleton();
const auto vm = game ? game->GetVM() : nullptr;
if (!vm ||
!vm->CreateStruct(name, _proxy) ||
!_proxy) {
F4SE::log::error(
FMT_STRING("failed to create structure of type \"{}\""),
name);
if (!vm || !vm->CreateStruct(name, _proxy) || !_proxy) {
F4SE::log::error("failed to create structure of type \"{}\"", name);
assert(false);
}
}
Expand All @@ -84,10 +80,7 @@ namespace RE::BSScript
}

if (!a_quiet) {
F4SE::log::warn(
FMT_STRING("failed to find var \"{}\" on structure \"{}\""),
a_name,
name);
F4SE::log::warn("failed to find var \"{}\" on structure \"{}\"", a_name, name);
}

return std::nullopt;
Expand All @@ -106,10 +99,7 @@ namespace RE::BSScript
}
}

F4SE::log::warn(
FMT_STRING("failed to pack var \"{}\" on structure \"{}\""),
a_name,
name);
F4SE::log::warn("failed to pack var \"{}\" on structure \"{}\"", a_name, name);
return false;
}

Expand Down Expand Up @@ -1229,10 +1219,7 @@ namespace RE::BSScript
std::move(a_func),
a_isLatent));
if (!success) {
F4SE::log::warn(
FMT_STRING("failed to register method \"{}\" on object \"{}\""),
a_function,
a_object);
F4SE::log::warn("failed to register method \"{}\" on object \"{}\"", a_function, a_object);
}

if (success && a_taskletCallable) {
Expand Down
45 changes: 26 additions & 19 deletions CommonLibF4/include/RE/Bethesda/BSTBTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,14 @@ namespace RE

private:
template <class U>
class iterator_base :
public boost::stl_interfaces::iterator_interface<
iterator_base<U>,
std::forward_iterator_tag,
U>
class iterator_base
{
private:
using super =
boost::stl_interfaces::iterator_interface<
iterator_base<U>,
std::forward_iterator_tag,
U>;

public:
using difference_type = typename super::difference_type;
using value_type = typename super::value_type;
using pointer = typename super::pointer;
using reference = typename super::reference;
using iterator_category = typename super::iterator_category;
using difference_type = std::ptrdiff_t;
using value_type = std::remove_const_t<U>;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;

iterator_base() noexcept = default;

Expand Down Expand Up @@ -116,15 +105,24 @@ namespace RE
return _cur->entries[_pos];
}

[[nodiscard]] pointer operator->() const noexcept
{
return std::pointer_traits<pointer>::pointer_to(operator*());
}

template <class V>
[[nodiscard]] bool operator==(const iterator_base<V>& a_rhs) const noexcept
{
return _cur == nullptr && a_rhs._cur == nullptr;
}

using super::operator++;
template <class V>
[[nodiscard]] bool operator!=(const iterator_base<V>& a_rhs) const noexcept
{
return !operator==(a_rhs);
}

void operator++() noexcept
iterator_base& operator++() noexcept
{
assert(_cur != nullptr);
if (++_pos >= _cur->usedEntries) {
Expand All @@ -136,6 +134,15 @@ namespace RE
push_level();
}
}

return *this;
}

iterator_base operator++(int) noexcept
{
iterator_base tmp{ *this };
operator++();
return tmp;
}

protected:
Expand Down
Loading
Loading