Skip to content

Commit

Permalink
maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 authored and github-actions[bot] committed May 17, 2024
1 parent 303e2dd commit 9e0ccf9
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions CommonLibF4/include/REL/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,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 @@ -279,58 +278,49 @@ namespace REL
return stl::unrestricted_cast<value_type>(_impl);
}


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 F4SE::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 F4SE::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 F4SE::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 F4SE::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(std::size_t a_idx, std::uintptr_t a_newFunc)
requires(std::same_as<U, std::uintptr_t>)
std::uintptr_t write_vfunc(std::size_t a_idx, 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 @@ -339,8 +329,7 @@ namespace REL
}

template <class F>
std::uintptr_t write_vfunc(std::size_t a_idx, F a_newFunc)
requires(std::same_as<value_type, std::uintptr_t>)
std::uintptr_t write_vfunc(std::size_t a_idx, 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

0 comments on commit 9e0ccf9

Please sign in to comment.