Skip to content

Commit b6755e2

Browse files
committed
fix
1 parent 2287602 commit b6755e2

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

include/omath/rev_eng/internal_rev_object.hpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,28 @@ namespace omath::rev_eng
119119
template<std::size_t TableIndex, std::size_t Id, class ReturnType>
120120
ReturnType call_virtual_method(auto... arg_list)
121121
{
122-
const auto vtable = *reinterpret_cast<void***>(
122+
void* sub_this = reinterpret_cast<void*>(
123123
reinterpret_cast<std::uintptr_t>(this) + TableIndex * sizeof(std::uintptr_t));
124-
return call_method<ReturnType>(vtable[Id], arg_list...);
124+
const auto vtable = *reinterpret_cast<void***>(sub_this);
125+
#ifdef _MSC_VER
126+
using Fn = ReturnType(__thiscall*)(void*, decltype(arg_list)...);
127+
#else
128+
using Fn = ReturnType(*)(void*, decltype(arg_list)...);
129+
#endif
130+
return reinterpret_cast<Fn>(vtable[Id])(sub_this, arg_list...);
125131
}
126132
template<std::size_t TableIndex, std::size_t Id, class ReturnType>
127133
ReturnType call_virtual_method(auto... arg_list) const
128134
{
129-
const auto vtable = *reinterpret_cast<void* const* const*>(
135+
const void* sub_this = reinterpret_cast<const void*>(
130136
reinterpret_cast<std::uintptr_t>(this) + TableIndex * sizeof(std::uintptr_t));
131-
return call_method<ReturnType>(vtable[Id], arg_list...);
137+
const auto vtable = *reinterpret_cast<void* const* const*>(sub_this);
138+
#ifdef _MSC_VER
139+
using Fn = ReturnType(__thiscall*)(const void*, decltype(arg_list)...);
140+
#else
141+
using Fn = ReturnType(*)(const void*, decltype(arg_list)...);
142+
#endif
143+
return reinterpret_cast<Fn>(vtable[Id])(sub_this, arg_list...);
132144
}
133145

134146
private:

0 commit comments

Comments
 (0)