Skip to content

Commit

Permalink
refactor: use ##__VA_ARGS__ in favour of __VA_ARGS__
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Aug 31, 2024
1 parent 37a3127 commit e56ecbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ endstone
| Build System | CMake | CMake |
| Generator | Ninja | Ninja |
| C/C++ Compiler **(Recommended)** | MSVC 193 (Visual Studio 2022) | Clang 15 |
| C/C++ Compiler (Minimum) | MSVC 191 (Visual Studio 2017) | Clang 5 |
| C/C++ Compiler (Minimum) | MSVC 191 (Visual Studio 2017) | Clang 9 |
| Standard Library | MSVC STL | libc++ |

## 🌟 Plugins [🔝](#-table-of-contents)
Expand Down
2 changes: 1 addition & 1 deletion include/bedrock/world/level/block/block_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class BlockLegacy : public BlockComponentStorage {
#ifdef __linux__ //
std::shared_timed_mutex mutex_;
#else //
std::int64_t unknown5_; // +832
std::shared_mutex mutex_; // +832
#endif //
std::unordered_map<void *, void *> unknown6_; // +840
std::unique_ptr<void *> block_state_group_; // +904 void* = BlockStateGroup
Expand Down
10 changes: 5 additions & 5 deletions include/endstone/detail/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ Return (Class::*get_original(Return (Class::*fp)(Arg...) const,
}

} // namespace endstone::detail::hook
#define ENDSTONE_HOOK_CALL_ORIGINAL(fp, ...) std::invoke(endstone::detail::hook::get_original(fp), __VA_ARGS__)
#define ENDSTONE_HOOK_CALL_ORIGINAL(fp, ...) std::invoke(endstone::detail::hook::get_original(fp), ##__VA_ARGS__)
#define ENDSTONE_HOOK_CALL_ORIGINAL_NAME(fp, name, ...) \
std::invoke(endstone::detail::hook::get_original(fp, name), __VA_ARGS__)
std::invoke(endstone::detail::hook::get_original(fp, name), ##__VA_ARGS__)

namespace endstone::detail::hook {
#ifdef _WIN32
Expand All @@ -93,7 +93,7 @@ void (*get_ctor(std::unique_ptr<Class> (*)(Args...), const std::string &name))(C
#endif
} // namespace endstone::detail::hook

#define ENDSTONE_FACTORY_DECLARE(type, ...) static std::unique_ptr<type> create(__VA_ARGS__);
#define ENDSTONE_FACTORY_DECLARE(type, ...) static std::unique_ptr<type> create(##__VA_ARGS__);
#ifdef _WIN32
#define ENDSTONE_FACTORY_PREFIX_TARGET(type) ENDSTONE_TOSTRING(type) "@@@std@@@std@"
#define ENDSTONE_FACTORY_PREFIX_REPLACEMENT(type) "??0" ENDSTONE_TOSTRING(type) "@@QEAA"
Expand All @@ -103,7 +103,7 @@ void (*get_ctor(std::unique_ptr<Class> (*)(Args...), const std::string &name))(C
"_ZN" + std::to_string(std::strlen(ENDSTONE_TOSTRING(type))) + ENDSTONE_TOSTRING(type) "C2"
#endif

#define ENDSTONE_FACTORY_IMPLEMENT(type, ...) ENDSTONE_FACTORY_IMPLEMENT_OVERLOAD(type, &type::create, __VA_ARGS__)
#define ENDSTONE_FACTORY_IMPLEMENT(type, ...) ENDSTONE_FACTORY_IMPLEMENT_OVERLOAD(type, &type::create, ##__VA_ARGS__)

#define ENDSTONE_FACTORY_IMPLEMENT_OVERLOAD(type, fp, ...) \
{ \
Expand All @@ -113,6 +113,6 @@ void (*get_ctor(std::unique_ptr<Class> (*)(Args...), const std::string &name))(C
func_decorated_name.substr(func_decorated_name.find(ENDSTONE_FACTORY_PREFIX_TARGET(type)) + \
std::strlen(ENDSTONE_FACTORY_PREFIX_TARGET(type))); \
auto *obj = reinterpret_cast<type *>(new char[sizeof(type)]); \
endstone::detail::hook::get_ctor(fp, __name)(obj, __VA_ARGS__); \
endstone::detail::hook::get_ctor(fp, __name)(obj, ##__VA_ARGS__); \
return std::unique_ptr<type>(obj); \
}

0 comments on commit e56ecbd

Please sign in to comment.