-
Notifications
You must be signed in to change notification settings - Fork 188
feat(Sol): Remove Lua C and replace by Sol2 #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the Lua integration by replacing direct Lua C API usage with Sol2, a modern C++ binding library for Lua. The change maintains backward compatibility with Lua 5.1-5.4 and LuaJIT while providing a cleaner, more type-safe interface.
Key changes:
- Introduced
sol/config.hppto configure Sol2 with Lua version detection, safety settings, and performance optimizations - Replaced all
extern "C"Lua includes with#include <sol/sol.hpp>across the codebase - Removed the ALECompat compatibility layer (
.hand.cppfiles) as Sol2 provides built-in compatibility - Updated
lua_dumpcalls to include the strip parameter (4th argument set to 0) for Lua 5.3+ compatibility - Modified CMake files to correct include paths and add conditional linking for static vs non-static Lua builds
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/sol/config.hpp | New configuration file that sets up Sol2 with Lua version detection, safety features, performance optimizations, and compatibility settings for Lua 5.1-5.4 and LuaJIT |
| src/lualib/luajit/CMakeLists.txt | Changed LuaJIT include directory from source folder to build folder for proper header location |
| src/lualib/lua/CMakeLists.txt | Added conditional build logic to distinguish between static and non-static Lua library builds for lua_interpreter and lua_compiler executables |
| src/LuaEngine/lmarshal.h | Replaced direct Lua C includes with Sol2 header |
| src/LuaEngine/lmarshal.cpp | Updated include and fixed lua_dump call to include strip parameter |
| src/LuaEngine/LuaFunctions.cpp | Removed Lua C includes (now provided by Sol2 via other headers) |
| src/LuaEngine/LuaEngine.h | Replaced Lua C includes with Sol2 header |
| src/LuaEngine/LuaEngine.cpp | Removed Lua C includes and ALECompat.h, updated lua_dump calls with strip parameter |
| src/LuaEngine/HttpManager.cpp | Replaced Lua C includes with Sol2 header |
| src/LuaEngine/BindingMap.h | Replaced Lua C includes with Sol2 header |
| src/LuaEngine/ALETemplate.h | Replaced Lua C includes with Sol2 header and removed ALECompat.h dependency |
| src/LuaEngine/ALEIncludes.h | Added Sol2 header include |
| src/LuaEngine/ALEEventMgr.cpp | Replaced Lua C includes with Sol2 header |
| src/LuaEngine/ALECompat.h | Removed file - compatibility functions no longer needed with Sol2 |
| src/LuaEngine/ALECompat.cpp | Removed file - compatibility implementations no longer needed with Sol2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You should probably reconsider this approach. Direct C is much more performant than using an abstraction layer in most cases. The only real benefit of using a binding abstraction is for ease of maintenance, but these things rarely change and you can just write your own abstraction code if absolutely necessary (which is mostly already done). |
This PR need : azerothcore/azerothcore-wotlk#23838
Nothing has changed except for the includes; everything still works as before. This does not break anything and does not directly affect ALE. This is only the first part of the API modernization; this PR can be accepted without fear of breaking ALE.
Compilation tested:
Tested with the following script on all versions of Lua: https://github.com/iThorgrim/lua-paragon-anniversary