From 6a5771e57d5b4e429001ecb2583ab5b83d3571da Mon Sep 17 00:00:00 2001 From: Orange Date: Fri, 19 Jun 2026 02:03:17 +0300 Subject: [PATCH] removed second FixedString --- include/omath/rev_eng/internal_rev_object.hpp | 39 ++++++------------- include/omath/utility/pattern_scan.hpp | 13 +++++-- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/include/omath/rev_eng/internal_rev_object.hpp b/include/omath/rev_eng/internal_rev_object.hpp index e8c2a13..29e15f2 100644 --- a/include/omath/rev_eng/internal_rev_object.hpp +++ b/include/omath/rev_eng/internal_rev_object.hpp @@ -21,24 +21,6 @@ namespace omath::rev_eng { - template - struct FixedString final - { - char data[Length]{}; - // ReSharper disable once CppNonExplicitConvertingConstructor - constexpr FixedString(const char (&str)[Length]) noexcept // NOLINT(*-explicit-constructor) - { - std::ranges::copy_n(str, Length, data); - } - // ReSharper disable once CppNonExplicitConversionOperator - [[nodiscard("You forgot to use string")]] - constexpr operator std::string_view() const noexcept // NOLINT(*-explicit-constructor) - { - return {data, Length - 1}; - } - }; - template - FixedString(const char (&)[N]) -> FixedString; class InternalReverseEngineeredObject { @@ -78,14 +60,16 @@ namespace omath::rev_eng return reinterpret_cast(const_cast(ptr))(this, arg_list...); } - template + template ReturnType call_method(auto... arg_list) { static const auto* address = resolve_pattern(ModuleName, Pattern); return call_method(address, arg_list...); } - template + template ReturnType call_method(auto... arg_list) const { static const auto* address = resolve_pattern(ModuleName, Pattern); @@ -93,14 +77,15 @@ namespace omath::rev_eng } template - ReturnType call_method(const std::string_view& module_name,const std::string_view& pattern, auto... arg_list) + ReturnType call_method(const std::string_view& module_name, const std::string_view& pattern, auto... arg_list) { static const auto* address = resolve_pattern(module_name, pattern); return call_method(address, arg_list...); } template - ReturnType call_method(const std::string_view& module_name,const std::string_view& pattern, auto... arg_list) const + ReturnType call_method(const std::string_view& module_name, const std::string_view& pattern, + auto... arg_list) const { static const auto* address = resolve_pattern(module_name, pattern); return call_method(address, arg_list...); @@ -121,26 +106,24 @@ namespace omath::rev_eng template ReturnType call_virtual_method(auto... arg_list) { - auto sub_this = reinterpret_cast( - reinterpret_cast(this) + TableOffset); + auto sub_this = reinterpret_cast(reinterpret_cast(this) + TableOffset); const auto vtable = *reinterpret_cast(sub_this); #ifdef _MSC_VER using Fn = ReturnType(__thiscall*)(void*, decltype(arg_list)...); #else - using Fn = ReturnType(*)(void*, decltype(arg_list)...); + using Fn = ReturnType (*)(void*, decltype(arg_list)...); #endif return reinterpret_cast(vtable[Id])(sub_this, arg_list...); } template ReturnType call_virtual_method(auto... arg_list) const { - auto sub_this = reinterpret_cast( - reinterpret_cast(this) + TableOffset); + auto sub_this = reinterpret_cast(reinterpret_cast(this) + TableOffset); const auto vtable = *reinterpret_cast(sub_this); #ifdef _MSC_VER using Fn = ReturnType(__thiscall*)(const void*, decltype(arg_list)...); #else - using Fn = ReturnType(*)(const void*, decltype(arg_list)...); + using Fn = ReturnType (*)(const void*, decltype(arg_list)...); #endif return reinterpret_cast(vtable[Id])(sub_this, arg_list...); } diff --git a/include/omath/utility/pattern_scan.hpp b/include/omath/utility/pattern_scan.hpp index c912d4b..27d1607 100644 --- a/include/omath/utility/pattern_scan.hpp +++ b/include/omath/utility/pattern_scan.hpp @@ -38,17 +38,24 @@ namespace omath friend unit_test_pattern_scan_consteval_spacing_and_case_Test; public: - template + template struct ConstevalPattern final { - char value[N]{}; + char value[Length]{}; // ReSharper disable once CppNonExplicitConvertingConstructor - constexpr ConstevalPattern(const char (&text)[N]) // NOLINT(*-explicit-constructor) + constexpr ConstevalPattern(const char (&text)[Length]) // NOLINT(*-explicit-constructor) { std::ranges::copy(text, value); } + [[nodiscard("You forgot to use string")]] + constexpr operator std::string_view() const noexcept // NOLINT(*-explicit-constructor) + { + return {value, Length - 1}; + } }; + template + ConstevalPattern(const char (&)[N]) -> ConstevalPattern; [[nodiscard]] static std::span::iterator scan_for_pattern(const std::span& range,