Skip to content

Commit

Permalink
Merge pull request #10 from qudix/dev
Browse files Browse the repository at this point in the history
refactor: remove more dependencies
  • Loading branch information
shad0wshayd3 authored May 15, 2024
2 parents 30d456f + dac94d3 commit 5926408
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 128 deletions.
20 changes: 14 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/.idea
/.vscode
/cmake-build*
/build*
# dot folders
.idea*/
.vs*/
.vscode/
.xmake/

# folders
build*/
cmake-build*/
out*/
vs*/

# files
*.zip
CMakeUserPresets.json
/out*
/.vs*
8 changes: 0 additions & 8 deletions AddressLibGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ add_project(
GROUPED_FILES
"src/main.cpp"
)

find_package(srell MODULE REQUIRED)

target_link_libraries(
"${PROJECT_NAME}"
PRIVATE
srell::srell
)
2 changes: 1 addition & 1 deletion AddressLibGen/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Build Dependencies
* [SRELL](https://www.akenotsuki.com/misc/srell/en/)
* None
8 changes: 4 additions & 4 deletions AddressLibGen/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <map>
#include <memory>
#include <optional>
#include <regex>
#include <set>
#include <sstream>
#include <string>
Expand All @@ -20,7 +21,6 @@
#include <utility>
#include <vector>

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

using namespace std::literals;
Expand Down Expand Up @@ -117,12 +117,12 @@ using files_t = std::vector<std::tuple<Version, Version, std::filesystem::path>>
[[nodiscard]] files_t get_files(const std::filesystem::path& a_root)
{
files_t results;
srell::wregex regex(L"(\\d+)\\.(\\d+)\\.(\\d+)_(\\d+)\\.(\\d+)\\.(\\d+)\\.txt"s, srell::regex::ECMAScript);
std::wregex regex(L"(\\d+)\\.(\\d+)\\.(\\d+)_(\\d+)\\.(\\d+)\\.(\\d+)\\.txt"s, std::regex::ECMAScript);
for (const auto& entry : std::filesystem::directory_iterator(a_root)) {
if (entry.is_regular_file()) {
const auto filename = entry.path().filename();
srell::wsmatch matches;
if (srell::regex_match(filename.native(), matches, regex) && matches.size() == 7) {
std::wsmatch matches;
if (std::regex_match(filename.native(), matches, regex) && matches.size() == 7) {
results.emplace_back();
auto& [lversion, rversion, path] = results.back();

Expand Down
8 changes: 0 additions & 8 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@
},
{
"cacheVariables": {
"Boost_USE_STATIC_LIBS": {
"type": "BOOL",
"value": "ON"
},
"Boost_USE_STATIC_RUNTIME": {
"type": "BOOL",
"value": "OFF"
},
"CMAKE_EXE_LINKER_FLAGS_RELEASE": {
"type": "STRING",
"value": "/DEBUG:FASTLINK"
Expand Down
3 changes: 0 additions & 3 deletions CommonLibF4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "in-source builds are not allowed")
endif()

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

Expand All @@ -37,7 +36,6 @@ add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}")
target_compile_definitions(
"${PROJECT_NAME}"
PUBLIC
BOOST_STL_INTERFACES_DISABLE_CONCEPTS
WINVER=0x0601 # windows 7, minimum supported version by fallout 4
_WIN32_WINNT=0x0601
"$<$<BOOL:${F4SE_SUPPORT_XBYAK}>:F4SE_SUPPORT_XBYAK=1>"
Expand Down Expand Up @@ -96,7 +94,6 @@ target_link_libraries(
"${PROJECT_NAME}"
PUBLIC
bcrypt.lib
Boost::headers
mmio::mmio
spdlog::spdlog
Version.lib
Expand Down
2 changes: 0 additions & 2 deletions CommonLibF4/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## Build Dependencies
* [Boost](https://www.boost.org/)
* Stl_interfaces
* [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
@@ -1,6 +1,5 @@
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
include(CMakeFindDependencyMacro)

find_dependency(Boost MODULE)
find_dependency(mmio CONFIG)
find_dependency(spdlog CONFIG)
1 change: 0 additions & 1 deletion CommonLibF4/include/F4SE/Impl/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static_assert(
"wrap std::time_t instead");

#pragma warning(push, 0)
#include <boost/stl_interfaces/sequence_container_interface.hpp>
#include <mmio/mmio.hpp>
#include <spdlog/spdlog.h>
#pragma warning(pop)
Expand Down
148 changes: 110 additions & 38 deletions CommonLibF4/include/RE/Bethesda/BSTArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,8 @@ namespace RE
template <
class T,
class Allocator = BSTArrayHeapAllocator>
class BSTArray :
public boost::stl_interfaces::sequence_container_interface<
BSTArray<T, Allocator>,
boost::stl_interfaces::element_layout::contiguous>
class BSTArray
{
private:
using super =
boost::stl_interfaces::sequence_container_interface<
BSTArray<T, Allocator>,
boost::stl_interfaces::element_layout::contiguous>;

public:
using value_type = T;
using allocator_type = Allocator;
Expand All @@ -248,29 +239,6 @@ namespace RE
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

using super::operator=;
using super::operator[];

using super::assign;
using super::at;
using super::back;
using super::begin;
using super::cbegin;
using super::cend;
using super::clear;
using super::crbegin;
using super::crend;
using super::data;
using super::empty;
using super::end;
using super::erase;
using super::front;
using super::insert;
using super::push_back;
using super::rbegin;
using super::rend;
using super::size;

// 1)
BSTArray() noexcept = default;

Expand Down Expand Up @@ -358,10 +326,54 @@ namespace RE

F4_HEAP_REDEFINE_NEW(BSTArray<T, Allocator>);

[[nodiscard]] iterator begin() noexcept { return static_cast<pointer>(_allocator.data()); }
[[nodiscard]] iterator end() noexcept { return begin() + _size; }
constexpr reference at(size_type a_pos)
{
if (size() <= a_pos)
throw std::out_of_range("bounds check failed in BSTArray::at()");

return begin()[a_pos];
}

constexpr reference at(size_type a_pos) const
{
if (size() <= a_pos)
throw std::out_of_range("bounds check failed in BSTArray::at()");

return begin()[a_pos];
}

[[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept { return begin()[a_pos]; }
[[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept { return begin()[a_pos]; }

[[nodiscard]] constexpr reference front() noexcept { return operator[](0); }
[[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); }

[[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); }
[[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); }

[[nodiscard]] size_type max_size() const noexcept { return std::numeric_limits<size_type>::max(); }
[[nodiscard]] constexpr pointer data() noexcept { return static_cast<pointer>(_allocator.data()); }
[[nodiscard]] constexpr const_pointer data() const noexcept { return static_cast<const_pointer>(_allocator.data()); }

[[nodiscard]] constexpr iterator begin() noexcept { return data(); }
[[nodiscard]] constexpr const_iterator begin() const noexcept { return data(); }
[[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }

[[nodiscard]] constexpr iterator end() noexcept { return begin() + size(); }
[[nodiscard]] constexpr const_iterator end() const noexcept { return begin() + size(); }
[[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }

[[nodiscard]] constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
[[nodiscard]] constexpr const_reverse_iterator rbegin() const noexcept { return rbegin(); }
[[nodiscard]] constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }

[[nodiscard]] constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
[[nodiscard]] constexpr const_reverse_iterator rend() const noexcept { return rend(); }
[[nodiscard]] constexpr const_reverse_iterator crend() const noexcept { return rend(); }

[[nodiscard]] constexpr size_type size() const noexcept { return _size; }
[[nodiscard]] constexpr size_type max_size() const noexcept { return std::numeric_limits<size_type>::max(); }

[[nodiscard]] constexpr bool empty() const noexcept { size() == 0; }

void reserve(size_type a_capacity)
{
Expand All @@ -370,10 +382,29 @@ namespace RE
}
}

[[nodiscard]] size_type capacity() const noexcept { return _allocator.capacity(); }
[[nodiscard]] constexpr size_type capacity() const noexcept { return _allocator.capacity(); }

void shrink_to_fit() { reserve_exact(size()); }

template<class ForwardIt>
void assign(ForwardIt a_first, ForwardIt a_last)
{
auto out = begin();
auto const out_last = end();
for (; out != out_last && a_first != a_last; ++a_first, ++out) {
*out = *a_first;
}
if (out != out_last)
erase(out, out_last);
if (a_first != a_last)
insert(end(), a_first, a_last);
}

void assign(std::initializer_list<value_type> a_init)
{
assign(a_init.begin(), a_init.end());
}

template <class ForwardIt>
iterator insert(const_iterator a_pos, ForwardIt a_first, ForwardIt a_last) //
requires(std::derived_from<typename std::iterator_traits<ForwardIt>::iterator_category, std::forward_iterator_tag>)
Expand All @@ -391,6 +422,21 @@ namespace RE
return iter;
}

iterator insert(const_iterator a_pos, value_type const& a_value)
{
return emplace(a_pos, a_value);
}

iterator insert(const_iterator a_pos, value_type&& a_value)
{
return emplace(a_pos, std::move(a_value));
}

iterator insert(const_iterator a_pos, std::initializer_list<value_type> a_init)
{
return insert(a_pos, a_init.begin(), a_init.end());
}

template <class... Args>
iterator emplace(const_iterator a_pos, Args&&... a_args) //
requires(std::constructible_from<value_type, Args&&...>)
Expand Down Expand Up @@ -424,13 +470,33 @@ namespace RE
return end();
}

iterator erase(const_iterator a_pos)
{
return erase(a_pos, std::next(a_pos));
}

void clear()
{
erase(begin(), end());
}

template <class... Args>
reference emplace_back(Args&&... a_args) //
reference emplace_back(Args&&... a_args)
requires(std::constructible_from<value_type, Args&&...>)
{
return *emplace(end(), std::forward<Args>(a_args)...);
}

void push_back(value_type const& a_value)
{
emplace_back(a_value);
}

void push_back(value_type&& a_value)
{
emplace_back(std::move(a_value));
}

void pop_back() { erase(std::prev(end())); }

void resize(size_type a_count) { resize_impl(a_count, nullptr); }
Expand All @@ -443,6 +509,12 @@ namespace RE
a_rhs = std::move(tmp);
}

auto operator=(std::initializer_list<value_type> a_init)
{
assign(a_init.begin(), a_init.end());
return *this;
}

private:
[[nodiscard]] iterator decay_iterator(const_iterator a_iter) noexcept
{
Expand Down
1 change: 0 additions & 1 deletion CommonLibF4/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"license": "MIT",
"supports": "windows & x64",
"dependencies": [
"boost-stl-interfaces",
"rsm-mmio",
"spdlog"
]
Expand Down
2 changes: 0 additions & 2 deletions RTTIDump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ if(NOT TARGET CommonLibF4)
endif()

find_package(spdlog REQUIRED CONFIG)
find_package(srell MODULE REQUIRED)

target_link_libraries(
"${PROJECT_NAME}"
PUBLIC
CommonLibF4::CommonLibF4
Dbghelp.lib
spdlog::spdlog
srell::srell
)

copy_files(
Expand Down
4 changes: 3 additions & 1 deletion RTTIDump/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Build Dependencies
* [CommonLibF4](https://github.com/Ryan-rsm-McKenzie/CommonLibF4)
* [spdlog](https://github.com/gabime/spdlog)
* [SRELL](https://www.akenotsuki.com/misc/srell/en/)

## Note
Build with Release mode otherwise the dump will take ages
10 changes: 3 additions & 7 deletions RTTIDump/src/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@
#include <fstream>
#include <functional>
#include <memory>
#include <regex>
#include <span>
#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>

#include <srell.hpp>

#ifdef NDEBUG
# include <spdlog/sinks/basic_file_sink.h>
#else
# include <spdlog/sinks/msvc_sink.h>
#endif
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/msvc_sink.h>

#define DLLEXPORT extern "C" [[maybe_unused]] __declspec(dllexport)

Expand Down
Loading

0 comments on commit 5926408

Please sign in to comment.