From bc59a89b319c2344c11ad34ff2feb7a8c3294e73 Mon Sep 17 00:00:00 2001 From: arc_ Date: Sat, 11 Feb 2023 17:11:01 +0100 Subject: [PATCH] Remove unused code --- VNTextProxy/CompilerSpecific/CompilerHelper.h | 174 ------------------ 1 file changed, 174 deletions(-) diff --git a/VNTextProxy/CompilerSpecific/CompilerHelper.h b/VNTextProxy/CompilerSpecific/CompilerHelper.h index 1a0b003..387b90f 100644 --- a/VNTextProxy/CompilerSpecific/CompilerHelper.h +++ b/VNTextProxy/CompilerSpecific/CompilerHelper.h @@ -10,181 +10,7 @@ class CompilerHelper static inline CompilerType CompilerType{}; - template - static TResult CallStaticMethod (TArgs... args) - { - switch (CompilerType) - { - case CompilerType::Borland: - return BorlandRegToCdeclAdapter::Call(args...); - - case CompilerType::Msvc: - return static_cast(*TFuncPtrPtr)(args...); - - default: - throw std::exception("Unsupported compiler type"); - } - } - - template - static TResult CallInstanceMethod (TArgs... args) - { - switch (CompilerType) - { - case CompilerType::Borland: - return BorlandRegToCdeclAdapter::Call(args...); - - case CompilerType::Msvc: - return ThiscallToCdeclAdapter::Call(args...); - - default: - throw std::exception("Unsupported compiler type"); - } - } - - template - static void* WrapAsStaticMethod () - { - static void* FuncPtr = TFuncPtr; - switch (CompilerType) - { - case CompilerType::Borland: - return &CdeclToBorlandRegAdapter::Call; - - case CompilerType::Msvc: - return TFuncPtr; - - default: - throw std::exception("Unsupported compiler type"); - } - } - - template typename TCallbackClass> - static void* WrapAsStaticMethod () - { - switch (CompilerType) - { - case CompilerType::Borland: - return WrapAsStaticMethod<&TCallbackClass::Call>(); - - case CompilerType::Msvc: - return WrapAsStaticMethod<&TCallbackClass::Call>(); - - default: - throw std::exception("Unsupported compiler type"); - } - } - - template - static void* WrapAsInstanceMethod () - { - static void* FuncPtr = TFuncPtr; - switch (CompilerType) - { - case CompilerType::Borland: - return &CdeclToBorlandRegAdapter::Call; - - case CompilerType::Msvc: - return &CdeclToThiscallAdapter::Call; - - default: - throw std::exception("Unsupported compiler type"); - } - } - - template typename TCallbackClass> - static void* WrapAsInstanceMethod () - { - switch (CompilerType) - { - case CompilerType::Borland: - return WrapAsInstanceMethod<&TCallbackClass::Call>(); - - case CompilerType::Msvc: - return WrapAsInstanceMethod<&TCallbackClass::Call>(); - - default: - throw std::exception("Unsupported compiler type"); - } - } - - template - static void ApplyWrappedVTable (void* pObj) - { - *(void**)pObj = WrapVTable(*(void**)pObj); - } - - template - static void* WrapVTable (void* pVTable) - { - switch (CompilerType) - { - case CompilerType::Borland: - return VTableAdapter::AdaptToBorlandReg(pVTable); - - case CompilerType::Msvc: - return pVTable; - - default: - throw std::exception("Unsupported compiler type"); - } - } - - struct SpecialVirtualFunction - { - }; - - static inline SpecialVirtualFunction NoChange{}; - static inline SpecialVirtualFunction VirtualDestructor{}; - private: - template - class VTableAdapter - { - public: - static void* AdaptToBorlandReg (void *pOrigVTable) - { - return AdaptThiscallToBorlandReg(pOrigVTable, std::make_index_sequence()); - } - - private: - template - static void* AdaptThiscallToBorlandReg (void* pOrigVTable, std::index_sequence indexes) - { - static void* origVTable[sizeof...(TFuncPtrs)]; - if (origVTable[0] == nullptr) - memcpy(origVTable, pOrigVTable, sizeof(origVTable)); - - static void* newVTable[] = { CallingConventionAdapter::AdaptThiscallToBorlandReg(TFuncPtrs)... }; - return &newVTable; - } - }; - - template - class CallingConventionAdapter - { - public: - template - static constexpr void* AdaptThiscallToBorlandReg (TResult (TClass::*pFunc)(TArgs...)) - { - return &ThiscallToBorlandRegAdapter::Call; - } - - static constexpr void* AdaptThiscallToBorlandReg (SpecialVirtualFunction* pFunc) - { - if (pFunc == &NoChange) - { - void** ppFunc = TFuncPtrPtr + TFuncPtrIndex; - return *ppFunc; - } - - if (pFunc == &VirtualDestructor) - return &ThiscallToBorlandRegAdapter::Call; - - throw std::exception("Unsupported special member function"); - } - }; - static bool HasBorlandTypeDescriptor (void** pVTable, const std::string& className, void* pModuleStart, void* pModuleEnd); static bool HasMsvcTypeDescriptor (void** pVTable, const std::string& className, void* pModuleStart, void* pModuleEnd); };