Skip to content

Commit

Permalink
maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 authored and github-actions[bot] committed Mar 4, 2024
1 parent 6f144cc commit 9190333
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
32 changes: 11 additions & 21 deletions include/REL/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ namespace REL

template <class... Args>
std::invoke_result_t<const value_type&, Args...> operator()(Args&&... a_args) const
noexcept(std::is_nothrow_invocable_v<const value_type&, Args...>)
requires(std::invocable<const value_type&, Args...>)
noexcept(std::is_nothrow_invocable_v<const value_type&, Args...>) requires(std::invocable<const value_type&, Args...>)
{
return REL::invoke(get(), std::forward<Args>(a_args)...);
}
Expand All @@ -284,56 +283,48 @@ namespace REL
}

template <std::integral U>
void write(const U& a_data)
requires(std::same_as<value_type, std::uintptr_t>)
void write(const U& a_data) requires(std::same_as<value_type, std::uintptr_t>)
{
safe_write(address(), std::addressof(a_data), sizeof(T));
}

template <class U>
void write(const std::span<U> a_data)
requires(std::same_as<value_type, std::uintptr_t>)
void write(const std::span<U> a_data) requires(std::same_as<value_type, std::uintptr_t>)
{
safe_write(address(), a_data.data(), a_data.size_bytes());
}

template <std::size_t N>
std::uintptr_t write_branch(const std::uintptr_t a_dst)
requires(std::same_as<value_type, std::uintptr_t>)
std::uintptr_t write_branch(const std::uintptr_t a_dst) requires(std::same_as<value_type, std::uintptr_t>)
{
return SKSE::GetTrampoline().write_branch<N>(address(), a_dst);
}

template <std::size_t N, class F>
std::uintptr_t write_branch(const F a_dst)
requires(std::same_as<value_type, std::uintptr_t>)
std::uintptr_t write_branch(const F a_dst) requires(std::same_as<value_type, std::uintptr_t>)
{
return SKSE::GetTrampoline().write_branch<N>(address(), stl::unrestricted_cast<std::uintptr_t>(a_dst));
}

template <std::size_t N>
std::uintptr_t write_call(const std::uintptr_t a_dst)
requires(std::same_as<value_type, std::uintptr_t>)
std::uintptr_t write_call(const std::uintptr_t a_dst) requires(std::same_as<value_type, std::uintptr_t>)
{
return SKSE::GetTrampoline().write_call<N>(address(), a_dst);
}

template <std::size_t N, class F>
std::uintptr_t write_call(const F a_dst)
requires(std::same_as<value_type, std::uintptr_t>)
std::uintptr_t write_call(const F a_dst) requires(std::same_as<value_type, std::uintptr_t>)
{
return SKSE::GetTrampoline().write_call<N>(address(), stl::unrestricted_cast<std::uintptr_t>(a_dst));
}

void write_fill(const std::uint8_t a_value, const std::size_t a_count)
requires(std::same_as<value_type, std::uintptr_t>)
void write_fill(const std::uint8_t a_value, const std::size_t a_count) requires(std::same_as<value_type, std::uintptr_t>)
{
safe_fill(address(), a_value, a_count);
}

template <class U = value_type>
std::uintptr_t write_vfunc(const std::size_t a_idx, const std::uintptr_t a_newFunc)
requires(std::same_as<U, std::uintptr_t>)
std::uintptr_t write_vfunc(const std::size_t a_idx, const std::uintptr_t a_newFunc) requires(std::same_as<U, std::uintptr_t>)
{
const auto addr = address() + (sizeof(void*) * a_idx);
const auto result = *reinterpret_cast<std::uintptr_t*>(addr);
Expand All @@ -342,8 +333,7 @@ namespace REL
}

template <class F>
std::uintptr_t write_vfunc(const std::size_t a_idx, const F a_newFunc)
requires(std::same_as<value_type, std::uintptr_t>)
std::uintptr_t write_vfunc(const std::size_t a_idx, const F a_newFunc) requires(std::same_as<value_type, std::uintptr_t>)
{
return write_vfunc(a_idx, stl::unrestricted_cast<std::uintptr_t>(a_newFunc));
}
Expand Down
2 changes: 1 addition & 1 deletion include/REL/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace REL
return result;
}

[[nodiscard]] static constexpr Version unpack(std::uint32_t a_packedVersion) noexcept
[[nodiscard]] static constexpr Version unpack(std::uint32_t a_packedVersion) noexcept
{
return REL::Version{
static_cast<value_type>((a_packedVersion >> 24) & 0x0FF),
Expand Down
2 changes: 1 addition & 1 deletion src/SKSE/Trampoline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# undef max
# undef MEM_COMMIT
# undef MEM_FREE
# undef MEM_RELEASE
# undef MEM_RELEASE
# undef MEM_RESERVE
# undef PAGE_EXECUTE_READWRITE
#endif
Expand Down

0 comments on commit 9190333

Please sign in to comment.