This commit is contained in:
2026-03-22 16:32:00 +03:00
parent 2287602fa2
commit b6755e21f9

View File

@@ -119,16 +119,28 @@ namespace omath::rev_eng
template<std::size_t TableIndex, std::size_t Id, class ReturnType>
ReturnType call_virtual_method(auto... arg_list)
{
const auto vtable = *reinterpret_cast<void***>(
void* sub_this = reinterpret_cast<void*>(
reinterpret_cast<std::uintptr_t>(this) + TableIndex * sizeof(std::uintptr_t));
return call_method<ReturnType>(vtable[Id], arg_list...);
const auto vtable = *reinterpret_cast<void***>(sub_this);
#ifdef _MSC_VER
using Fn = ReturnType(__thiscall*)(void*, decltype(arg_list)...);
#else
using Fn = ReturnType(*)(void*, decltype(arg_list)...);
#endif
return reinterpret_cast<Fn>(vtable[Id])(sub_this, arg_list...);
}
template<std::size_t TableIndex, std::size_t Id, class ReturnType>
ReturnType call_virtual_method(auto... arg_list) const
{
const auto vtable = *reinterpret_cast<void* const* const*>(
const void* sub_this = reinterpret_cast<const void*>(
reinterpret_cast<std::uintptr_t>(this) + TableIndex * sizeof(std::uintptr_t));
return call_method<ReturnType>(vtable[Id], arg_list...);
const auto vtable = *reinterpret_cast<void* const* const*>(sub_this);
#ifdef _MSC_VER
using Fn = ReturnType(__thiscall*)(const void*, decltype(arg_list)...);
#else
using Fn = ReturnType(*)(const void*, decltype(arg_list)...);
#endif
return reinterpret_cast<Fn>(vtable[Id])(sub_this, arg_list...);
}
private: